From a4fc5bab5cf366c381d2fa61763d7c43f9c4629a Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 21 Jun 2016 20:35:18 +0200 Subject: [PATCH] Added box controller for list of articles --- com.woltlab.wcf/objectType.xml | 7 +- com.woltlab.wcf/templates/boxArticleList.tpl | 1 + .../templates/boxArticleListSidebar.tpl | 28 ++++++++ .../files/lib/acp/form/BoxAddForm.class.php | 2 +- .../files/lib/acp/form/BoxEditForm.class.php | 2 +- .../install/files/lib/data/box/Box.class.php | 2 +- .../box/ArticleListBoxController.class.php | 67 +++++++++++++++++++ wcfsetup/install/files/style/ui/article.scss | 8 +-- 8 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 com.woltlab.wcf/templates/boxArticleList.tpl create mode 100644 com.woltlab.wcf/templates/boxArticleListSidebar.tpl create mode 100644 wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 645096dc6a..1ab32cde25 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -987,7 +987,7 @@ com.woltlab.wcf.userList com.woltlab.wcf.boxController - wcf\system\box\userListBoxController + wcf\system\box\UserListBoxController com.woltlab.wcf.userOnlineList @@ -1024,6 +1024,11 @@ com.woltlab.wcf.boxController wcf\system\box\ArticleCategoriesBoxController + + com.woltlab.wcf.articleList + com.woltlab.wcf.boxController + wcf\system\box\ArticleListBoxController + diff --git a/com.woltlab.wcf/templates/boxArticleList.tpl b/com.woltlab.wcf/templates/boxArticleList.tpl new file mode 100644 index 0000000000..57ea3b6afb --- /dev/null +++ b/com.woltlab.wcf/templates/boxArticleList.tpl @@ -0,0 +1 @@ +{include file='articleListItems' objects=$boxArticleList} diff --git a/com.woltlab.wcf/templates/boxArticleListSidebar.tpl b/com.woltlab.wcf/templates/boxArticleListSidebar.tpl new file mode 100644 index 0000000000..fff2b84640 --- /dev/null +++ b/com.woltlab.wcf/templates/boxArticleListSidebar.tpl @@ -0,0 +1,28 @@ + diff --git a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php index a614e16109..98008c2b8e 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php @@ -371,7 +371,7 @@ class BoxAddForm extends AbstractForm { parent::save(); $content = []; - if ($this->isMultilingual) { + if ($this->boxType == 'system' || $this->isMultilingual) { foreach (LanguageFactory::getInstance()->getLanguages() as $language) { $content[$language->languageID] = [ 'title' => (!empty($this->title[$language->languageID]) ? $this->title[$language->languageID] : ''), diff --git a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php index acf63a5846..3d25f1cbb5 100644 --- a/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php @@ -77,7 +77,7 @@ class BoxEditForm extends BoxAddForm { AbstractForm::save(); $content = []; - if ($this->isMultilingual) { + if ($this->boxType == 'system' || $this->isMultilingual) { foreach (LanguageFactory::getInstance()->getLanguages() as $language) { $content[$language->languageID] = [ 'title' => (!empty($_POST['title'][$language->languageID]) ? $_POST['title'][$language->languageID] : ''), diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 9c2a927fa8..9b936b9092 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -187,7 +187,7 @@ class Box extends DatabaseObject { */ public function getBoxContentTitle() { $boxContent = $this->getBoxContent(); - if ($this->isMultilingual) { + if ($this->isMultilingual || $this->boxType == 'system') { if (isset($boxContent[WCF::getLanguage()->languageID])) { return $boxContent[WCF::getLanguage()->languageID]['title']; } diff --git a/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php new file mode 100644 index 0000000000..6a41ed6958 --- /dev/null +++ b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php @@ -0,0 +1,67 @@ + + * @package WoltLabSuite\Core\System\Box + * @since 3.0 + */ +class ArticleListBoxController extends AbstractDatabaseObjectListBoxController { + /** + * @inheritDoc + */ + protected $supportedPositions = ['sidebarLeft', 'sidebarRight', 'contentTop', 'contentBottom', 'top', 'bottom']; + + /** + * @inheritDoc + */ + protected $sortFieldLanguageItemPrefix = 'wcf.article'; + + /** + * @inheritDoc + */ + public $validSortFields = [ + 'time', + 'comments', + 'views' + ]; + + /** + * @inheritDoc + */ + public function __construct() { + if (!empty($this->validSortFields) && MODULE_LIKE) { + $this->validSortFields[] = 'cumulativeLikes'; + } + + parent::__construct(); + } + + /** + * @inheritDoc + */ + protected function getObjectList() { + return new AccessibleArticleList(); + } + + /** + * @inheritDoc + */ + protected function getTemplate() { + $templateName = 'boxArticleList'; + if ($this->box->position === 'sidebarLeft' || $this->box->position === 'sidebarRight') { + $templateName = 'boxArticleListSidebar'; + } + + return WCF::getTPL()->fetch($templateName, 'wcf', [ + 'boxArticleList' => $this->objectList, + 'boxSortField' => $this->sortField + ]); + } +} diff --git a/wcfsetup/install/files/style/ui/article.scss b/wcfsetup/install/files/style/ui/article.scss index 2651f9ff27..83c2db4850 100644 --- a/wcfsetup/install/files/style/ui/article.scss +++ b/wcfsetup/install/files/style/ui/article.scss @@ -210,9 +210,7 @@ transition: .2s ease opacity; } - &:not(.rowColGap) { - > li:not(:first-child) { - margin-top: 30px; - } + > li:not(:first-child) { + margin-top: 30px; } -} \ No newline at end of file +} -- 2.20.1