RandomBannersAjax.php 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php

class RandomBannersAjax {

	protected $bannerRepository;

	protected $persistanceManager;

	protected $objectManager;

	public function __construct() {
12
13
		$this->bannerRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Randombanners_Domain_Repository_BannerRepository');
		$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
14
15
16
17
18
19
20
21
22
23
		$this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_Manager');
	}

	public function increaseClickNumber($uid) {
		$banner = $this->bannerRepository->findByUid($uid);
		$banner->setClickedThisMonth($banner->getClickedThisMonth() + 1);
		$this->persistanceManager->persistAll();
	}
}

24
$function = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('function');
25
26
27

switch ($function) {
	case 'clickBanner':
28
		if ($uid = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('banner'))) {
29
30
31
32
33
34
35
36
37
38
39
40
			$output = new RandomBannersAjax();
			$output->increaseClickNumber($uid);
		}
		break;
	default:
		$returnValue = 'This function is not implemented!';
		break;
}

echo json_encode($returnValue);

?>