Added default tag cloud box controller
authorMarcel Werk <burntime@woltlab.com>
Fri, 15 Apr 2016 13:11:59 +0000 (15:11 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 15 Apr 2016 13:12:06 +0000 (15:12 +0200)
wcfsetup/install/files/lib/system/box/TagCloudBoxController.class.php [new file with mode: 0644]

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 (file)
index 0000000..7067889
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+namespace wcf\system\box;
+use wcf\system\language\LanguageFactory;
+use wcf\system\tagging\TagCloud;
+use wcf\system\tagging\TypedTagCloud;
+use wcf\system\WCF;
+
+/**
+ * Box for the tag cloud.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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');
+                       }
+               }
+       }
+}