From 2dbac9ade8074f95d4dc7a74f69f006ddad66119 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 22 Jun 2016 12:40:22 +0200 Subject: [PATCH] Improved article list box --- com.woltlab.wcf/templates/boxArticleList.tpl | 58 +++++++++++++- .../templates/boxArticleListSidebar.tpl | 28 ------- .../box/ArticleListBoxController.class.php | 33 +++++--- wcfsetup/install/files/style/ui/article.scss | 76 ++++++++++++++++++- 4 files changed, 156 insertions(+), 39 deletions(-) delete mode 100644 com.woltlab.wcf/templates/boxArticleListSidebar.tpl diff --git a/com.woltlab.wcf/templates/boxArticleList.tpl b/com.woltlab.wcf/templates/boxArticleList.tpl index 57ea3b6afb..68559df214 100644 --- a/com.woltlab.wcf/templates/boxArticleList.tpl +++ b/com.woltlab.wcf/templates/boxArticleList.tpl @@ -1 +1,57 @@ -{include file='articleListItems' objects=$boxArticleList} +{if $boxPosition == 'sidebarLeft' || $boxPosition == 'sidebarRight'} + +{elseif $boxPosition == 'footerBoxes'} + +{else} + {include file='articleListItems' objects=$boxArticleList} +{/if} diff --git a/com.woltlab.wcf/templates/boxArticleListSidebar.tpl b/com.woltlab.wcf/templates/boxArticleListSidebar.tpl deleted file mode 100644 index fff2b84640..0000000000 --- a/com.woltlab.wcf/templates/boxArticleListSidebar.tpl +++ /dev/null @@ -1,28 +0,0 @@ - diff --git a/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php index 6a41ed6958..b9fdf18761 100644 --- a/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php @@ -16,13 +16,18 @@ class ArticleListBoxController extends AbstractDatabaseObjectListBoxController { /** * @inheritDoc */ - protected $supportedPositions = ['sidebarLeft', 'sidebarRight', 'contentTop', 'contentBottom', 'top', 'bottom']; + protected $supportedPositions = ['sidebarLeft', 'sidebarRight', 'contentTop', 'contentBottom', 'top', 'bottom', 'footerBoxes']; /** * @inheritDoc */ protected $sortFieldLanguageItemPrefix = 'wcf.article'; + /** + * @inheritDoc + */ + public $defaultLimit = 3; + /** * @inheritDoc */ @@ -47,21 +52,31 @@ class ArticleListBoxController extends AbstractDatabaseObjectListBoxController { * @inheritDoc */ protected function getObjectList() { - return new AccessibleArticleList(); + $objectList = new AccessibleArticleList(); + + switch ($this->sortField) { + case 'comments': + $objectList->getConditionBuilder()->add('article.comments > ?', [0]); + break; + case 'views': + $objectList->getConditionBuilder()->add('article.views > ?', [0]); + break; + case 'cumulativeLikes': + $objectList->getConditionBuilder()->add('article.cumulativeLikes > ?', [0]); + break; + } + + return $objectList; } /** * @inheritDoc */ protected function getTemplate() { - $templateName = 'boxArticleList'; - if ($this->box->position === 'sidebarLeft' || $this->box->position === 'sidebarRight') { - $templateName = 'boxArticleListSidebar'; - } - - return WCF::getTPL()->fetch($templateName, 'wcf', [ + return WCF::getTPL()->fetch('boxArticleList', 'wcf', [ 'boxArticleList' => $this->objectList, - 'boxSortField' => $this->sortField + 'boxSortField' => $this->sortField, + 'boxPosition' => $this->box->position ]); } } diff --git a/wcfsetup/install/files/style/ui/article.scss b/wcfsetup/install/files/style/ui/article.scss index e13ebe4dee..aa29601fe6 100644 --- a/wcfsetup/install/files/style/ui/article.scss +++ b/wcfsetup/install/files/style/ui/article.scss @@ -2,7 +2,7 @@ .articleImageWrapper { align-items: center; display: flex; - height: 300px; + max-height: 300px; overflow: hidden; img { @@ -215,4 +215,78 @@ > li:not(:first-child) { margin-top: 30px; } + + @include screen-xs { + .box128 > .articleListImage { + margin-right: 10px; + } + + .articleListImage > img { + height: 64px !important; + width: 64px !important; + } + } +} + +.boxesFooterBoxes { + .articleList { + display: flex; + flex-wrap: wrap; + margin: 0 -5px -20px -5px; + + > li { + margin: 0 5px 20px 5px; + } + + .articleListImage > img { + height: auto !important; + max-width: 280px; + width: 100% !important; + } + + .articleListImage + .articleListTitle { + margin-top: 5px; + } + + .articleListMetaData { + display: none; + } + } + + @include screen-lg { + .articleList { + > li { + flex: 0 0 calc(100%/3 - 10px); + max-width: calc(100%/3 - 10px); + } + } + + .boxFullWidth { + .articleList { + > li { + flex: 0 0 calc(100%/6 - 10px); + max-width: calc(100%/6 - 10px); + } + } + } + } + + @include screen-sm-up { + .articleList { + > li { + flex: 0 0 calc(100%/3 - 10px); + max-width: calc(100%/3 - 10px); + } + } + } + + @include screen-xs { + .articleList { + justify-content: center; + + > li { + width: 280px; + } + } + } } -- 2.20.1