* @category Community Framework
*/
class ViewableCategory extends DatabaseObjectDecorator {
+ /**
+ * list of all parent category generations of this category
+ * @var array<wcf\data\category\ViewableCategory>
+ */
+ protected $parentCategories = null;
+
+ /**
+ * parent category of this category
+ * @var wcf\data\category\ViewableCategory
+ */
+ protected $parentCategory = null;
+
/**
* @see wcf\data\DatabaseObjectDecorator::$baseClass
*/
}
}
+ /**
+ * @see wcf\data\category\Category::getParentCategories()
+ */
+ public function getParentCategories() {
+ if ($this->parentCategories === null) {
+ $this->parentCategories = array();
+ $className = get_class($this);
+
+ foreach ($this->getDecoratedObject()->getParentCategories() as $category) {
+ $this->parentCategories[$category->categoryID] = new $className($category);
+ }
+ }
+
+ return $this->parentCategories;
+ }
+
+ /**
+ * @see wcf\data\category\Category::getParentCategory()
+ */
+ public function getParentCategory() {
+ if ($this->parentCategoryID && $this->parentCategory === null) {
+ $className = get_class($this);
+
+ $this->parentCategory = new $className($this->getDecoratedObject()->getParentCategory());
+ }
+
+ return $this->parentCategory;
+ }
+
/**
* Returns the acl permission value of the given permission for the active
* user and of this category.
<?php
namespace wcf\data\category;
+use wcf\data\DatabaseObject;
/**
* Represents a viewable category node.
- *
+ *
* @author Matthias Schmidt
* @copyright 2001-2012 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @category Community Framework
*/
class ViewableCategoryNode extends CategoryNode {
+ /**
+ * @see wcf\data\DatabaseObjectDecorator::$baseClass
+ */
+ protected static $baseClass = 'wcf\data\category\ViewableCategory';
+
/**
* @see wcf\data\DatabaseObjectDecorator::__construct()
*/
public function __construct(DatabaseObject $object, $includeDisabledCategories = false, array $excludedCategoryIDs = array()) {
- parent::__construct(new ViewableCategory($object), $includeDisabledCategories, $excludedCategoryIDs);
+ if (!($object instanceof static::$baseClass)) {
+ $object = new static::$baseClass($object);
+ }
+
+ parent::__construct($object, $includeDisabledCategories, $excludedCategoryIDs);
}
}
* @subpackage data.category
* @category Community Framework
*/
-class ViewableCategoryNodeList extends CategoryNodeList {
- /**
- * @see wcf\data\category\CategoryNodeList::$nodeClassName
- */
- protected $nodeClassName = 'wcf\data\category\ViewableCategoryNode';
-}
+class ViewableCategoryNodeList extends CategoryNodeList { }