Created
April 8, 2021 19:04
-
-
Save MatzeKitt/82802520545d91edff36d87873e57ce0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace wcf\system\box; | |
use wcf\system\cache\builder\VisitorCacheBuilder; | |
use wcf\system\WCF; | |
use function array_merge; | |
use function count; | |
use function ucfirst; | |
/** | |
* Implementation of IBoxController for visits. | |
* | |
* @author Matthias Kittsteiner | |
* @copyright 2021 KittMedia | |
* @license Free <https://shop.kittmedia.com/core/licenses/#licenseFree> | |
* @package com.kittmedia.wcf.visitstatistics | |
* @since 1.2.0 | |
*/ | |
class VisitStatisticsVisitsBoxController extends AbstractDatabaseObjectListBoxController { | |
/** | |
* @inheritDoc | |
*/ | |
protected $conditionDefinition = 'com.kittmedia.wcf.visitstatistics.box.visits.condition'; | |
/** | |
* @inheritDoc | |
*/ | |
protected function loadContent() { | |
$this->content = $this->getTemplate(); | |
} | |
/** | |
* @inheritDoc | |
*/ | |
protected function getObjectList() {} | |
/** | |
* @inheritDoc | |
*/ | |
protected function getTemplate() { | |
$conditions = $this->getBox()->getConditions(); | |
$templateData = array_merge( | |
VisitorCacheBuilder::getInstance()->getData(), | |
[ | |
'hideToday' => false, | |
'hideYesterday' => false, | |
'hideThisWeek' => false, | |
'hideLastWeek' => false, | |
'hideThisMonth' => false, | |
'hideLastMonth' => false, | |
'hideAverage' => false, | |
'hideTotal' => false, | |
'position' => $this->getBox()->position | |
] | |
); | |
if (count($conditions)) { | |
$conditionData = reset($conditions)->conditionData; | |
if (!empty($conditionData['types'])) { | |
foreach ($conditionData['types'] as $condition => $value) { | |
$templateData['hide' . ucfirst($condition)] = $value; | |
} | |
} | |
} | |
return WCF::getTPL()->fetch( | |
'boxVisitStatisticsVisits', | |
'wcf', | |
$templateData, | |
true | |
); | |
} | |
/** | |
* @inheritDoc | |
*/ | |
public function hasContent() { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment