From: Marcel Werk Date: Wed, 15 Jun 2016 13:54:06 +0000 (+0200) Subject: Added box for article categories X-Git-Tag: 3.0.0_Beta_1~1434 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5eae5e4186de561cacdc6a8e7925a4dbd36ca9da;p=GitHub%2FWoltLab%2FWCF.git Added box for article categories --- diff --git a/com.woltlab.wcf/box.xml b/com.woltlab.wcf/box.xml index 0536699c42..0762f43ecf 100644 --- a/com.woltlab.wcf/box.xml +++ b/com.woltlab.wcf/box.xml @@ -299,5 +299,27 @@ Comments + + + Kategorien (Artikel) + Categories (Articles) + system + com.woltlab.wcf.articleCategories + sidebarRight + 1 + 0 + + com.woltlab.wcf.ArticleList + com.woltlab.wcf.CategoryArticleList + com.woltlab.wcf.Article + + + + Kategorien + + + Categories + + diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 15679a9145..645096dc6a 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1019,6 +1019,11 @@ com.woltlab.wcf.boxController wcf\system\box\PageCommentListBoxController + + com.woltlab.wcf.articleCategories + com.woltlab.wcf.boxController + wcf\system\box\ArticleCategoriesBoxController + diff --git a/com.woltlab.wcf/templates/boxArticleCategories.tpl b/com.woltlab.wcf/templates/boxArticleCategories.tpl new file mode 100644 index 0000000000..5c06add19e --- /dev/null +++ b/com.woltlab.wcf/templates/boxArticleCategories.tpl @@ -0,0 +1,27 @@ +
    + {foreach from=$categoryList item=categoryItem} + categoryID == $categoryItem->categoryID} class="active"{/if} data-category-id="{@$categoryItem->categoryID}"> + {$categoryItem->getTitle()} + + {if $activeCategory && ($activeCategory->categoryID == $categoryItem->categoryID || $activeCategory->isParentCategory($categoryItem->getDecoratedObject())) && $categoryItem->hasChildren()} +
      + {foreach from=$categoryItem item=subCategoryItem} + categoryID == $subCategoryItem->categoryID} class="active"{/if} data-category-id="{@$subCategoryItem->categoryID}"> + {$subCategoryItem->getTitle()} + + {if $activeCategory && ($activeCategory->categoryID == $subCategoryItem->categoryID || $activeCategory->parentCategoryID == $subCategoryItem->categoryID) && $subCategoryItem->hasChildren()} +
        + {foreach from=$subCategoryItem item=subSubCategoryItem} + categoryID == $subSubCategoryItem->categoryID} class="active"{/if} data-category-id="{@$subSubCategoryItem->categoryID}"> + {$subSubCategoryItem->getTitle()} + + {/foreach} +
      + {/if} + + {/foreach} +
    + {/if} + + {/foreach} +
diff --git a/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNode.class.php b/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNode.class.php new file mode 100644 index 0000000000..b3c1242546 --- /dev/null +++ b/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNode.class.php @@ -0,0 +1,22 @@ + + * @package WoltLabSuite\Core\Data\Article\Category + * @since 3.0 + * + * @method ArticleCategory getDecoratedObject() + * @mixin ArticleCategory + */ +class ArticleCategoryNode extends CategoryNode { + /** + * @inheritDoc + */ + protected static $baseClass = ArticleCategory::class; +} diff --git a/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNodeTree.class.php b/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNodeTree.class.php new file mode 100644 index 0000000000..c8be7ac1b9 --- /dev/null +++ b/wcfsetup/install/files/lib/data/article/category/ArticleCategoryNodeTree.class.php @@ -0,0 +1,30 @@ + + * @package WoltLabSuite\Core\Data\Article\Category + * @since 3.0 + */ +class ArticleCategoryNodeTree extends CategoryNodeTree { + /** + * name of the category node class + * @var string + */ + protected $nodeClassName = ArticleCategoryNode::class; + + /** + * @inheritDoc + */ + public function isIncluded(CategoryNode $categoryNode) { + /** @var ArticleCategoryNode $categoryNode */ + + return parent::isIncluded($categoryNode) && $categoryNode->isAccessible(); + } +} diff --git a/wcfsetup/install/files/lib/page/ArticlePage.class.php b/wcfsetup/install/files/lib/page/ArticlePage.class.php index 6feec1495d..414f34f05c 100644 --- a/wcfsetup/install/files/lib/page/ArticlePage.class.php +++ b/wcfsetup/install/files/lib/page/ArticlePage.class.php @@ -1,5 +1,6 @@ article = ViewableArticle::getArticle($this->articleContent->articleID); $this->canonicalURL = $this->articleContent->getLink(); + $this->category = $this->article->getCategory(); } /** diff --git a/wcfsetup/install/files/lib/system/box/ArticleCategoriesBoxController.class.php b/wcfsetup/install/files/lib/system/box/ArticleCategoriesBoxController.class.php new file mode 100644 index 0000000000..12dfda5ac7 --- /dev/null +++ b/wcfsetup/install/files/lib/system/box/ArticleCategoriesBoxController.class.php @@ -0,0 +1,45 @@ + + * @package WoltLabSuite\Core\System\Box + * @since 3.0 + */ +class ArticleCategoriesBoxController extends AbstractBoxController { + /** + * @inheritDoc + */ + protected $supportedPositions = ['footerBoxes', 'sidebarLeft', 'sidebarRight', 'contentTop', 'contentBottom', 'footer']; + + /** + * @inheritDoc + */ + protected function loadContent() { + // get categories + $categoryTree = new ArticleCategoryNodeTree('com.woltlab.wcf.article.category'); + $categoryList = $categoryTree->getIterator(); + $categoryList->setMaxDepth(0); + + if (iterator_count($categoryList)) { + // get active category + $activeCategory = null; + if (RequestHandler::getInstance()->getActiveRequest()->getRequestObject() instanceof CategoryArticleListPage || RequestHandler::getInstance()->getActiveRequest()->getRequestObject() instanceof ArticlePage) { + if (RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->category !== null) { + $activeCategory = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->category; + } + } + + $this->content = WCF::getTPL()->fetch('boxArticleCategories', 'wcf', ['categoryList' => $categoryList, 'activeCategory' => $activeCategory]); + } + } +} diff --git a/wcfsetup/setup/template/stepConfigureDirectories.tpl b/wcfsetup/setup/template/stepConfigureDirectories.tpl index 4972405fda..d3c6bc09b6 100644 --- a/wcfsetup/setup/template/stepConfigureDirectories.tpl +++ b/wcfsetup/setup/template/stepConfigureDirectories.tpl @@ -14,7 +14,7 @@ {foreach from=$showOrder item=$application}
- +