From b78ec74e522150c80c2d96493b7c106ae89dac57 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 15 Apr 2016 15:11:59 +0200 Subject: [PATCH] Added default tag cloud box controller --- .../box/TagCloudBoxController.class.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/box/TagCloudBoxController.class.php diff --git a/wcfsetup/install/files/lib/system/box/TagCloudBoxController.class.php b/wcfsetup/install/files/lib/system/box/TagCloudBoxController.class.php new file mode 100644 index 0000000000..7067889547 --- /dev/null +++ b/wcfsetup/install/files/lib/system/box/TagCloudBoxController.class.php @@ -0,0 +1,71 @@ + + * @package com.woltlab.wcf + * @subpackage system.box + * @category Community Framework + */ +class TagCloudBoxController extends AbstractBoxController { + /** + * @inheritDoc + */ + protected $supportedPositions = ['footerBoxes', 'sidebarLeft', 'sidebarRight']; + + /** + * taggable object type + * @var string + */ + protected $objectType = ''; + + /** + * needed permission to view this box + * @var string + */ + protected $neededPermission = ''; + + /** + * @inheritDoc + */ + public function getTitle() { + return WCF::getLanguage()->get('wcf.tagging.tags'); + } + + /** + * @inheritDoc + */ + protected function loadContent() { + if (MODULE_TAGGING && WCF::getSession()->getPermission('user.tag.canViewTag') && (!$this->neededPermission || WCF::getSession()->getPermission($this->neededPermission))) { + $languageIDs = []; + if (LanguageFactory::getInstance()->multilingualismEnabled()) { + $languageIDs = WCF::getUser()->getLanguageIDs(); + } + + if ($this->objectType) { + $tagCloud = new TypedTagCloud($this->objectType, $languageIDs); + } + else { + $tagCloud = new TagCloud($languageIDs); + } + $tags = $tagCloud->getTags(); + + if (!empty($tags)) { + WCF::getTPL()->assign([ + 'tags' => $tags, + 'taggableObjectType' => $this->objectType + ]); + + $this->content = WCF::getTPL()->fetch('tagCloudBox'); + } + } + } +} -- 2.20.1