Added box controller for list of articles
authorMarcel Werk <burntime@woltlab.com>
Tue, 21 Jun 2016 18:35:18 +0000 (20:35 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 21 Jun 2016 18:35:24 +0000 (20:35 +0200)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/boxArticleList.tpl [new file with mode: 0644]
com.woltlab.wcf/templates/boxArticleListSidebar.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php
wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php
wcfsetup/install/files/lib/data/box/Box.class.php
wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php [new file with mode: 0644]
wcfsetup/install/files/style/ui/article.scss

index 645096dc6ac774fffcadfa9f679fad1402f4ff48..1ab32cde25f55a4081bdfb87e5ed6c6fae97395b 100644 (file)
                <type>
                        <name>com.woltlab.wcf.userList</name>
                        <definitionname>com.woltlab.wcf.boxController</definitionname>
-                       <classname>wcf\system\box\userListBoxController</classname>
+                       <classname>wcf\system\box\UserListBoxController</classname>
                </type>
                <type>
                        <name>com.woltlab.wcf.userOnlineList</name>
                        <definitionname>com.woltlab.wcf.boxController</definitionname>
                        <classname>wcf\system\box\ArticleCategoriesBoxController</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.articleList</name>
+                       <definitionname>com.woltlab.wcf.boxController</definitionname>
+                       <classname>wcf\system\box\ArticleListBoxController</classname>
+               </type>
                <!-- /box controllers -->
                
                <!-- deprecated -->
diff --git a/com.woltlab.wcf/templates/boxArticleList.tpl b/com.woltlab.wcf/templates/boxArticleList.tpl
new file mode 100644 (file)
index 0000000..57ea3b6
--- /dev/null
@@ -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 (file)
index 0000000..fff2b84
--- /dev/null
@@ -0,0 +1,28 @@
+<ul class="sidebarBoxList">
+       {foreach from=$boxArticleList item=boxArticle}
+               <li>
+                       <a href="{$boxArticle->getLink()}" class="box48">
+                               <span>{if $boxArticle->getImage()}{@$boxArticle->getImage()->getElementTag(48)}{/if}</span>
+                               
+                               <div>
+                                       <h3>{$boxArticle->getTitle()}</h3>
+                                       <small>
+                                               {if $boxSortField == 'time'}
+                                                       {@$boxArticle->time|time}
+                                               {elseif $boxSortField == 'views'}
+                                                       {lang article=$boxArticle}wcf.article.articleViews{/lang}
+                                               {elseif $boxSortField == 'comments'}
+                                                       {lang article=$boxArticle}wcf.article.articleComments{/lang}
+                                               {elseif $boxSortField == 'cumulativeLikes'}
+                                                       {if MODULE_LIKE && $__wcf->getSession()->getPermission('user.like.canViewLike') && ($boxArticle->likes || $boxArticle->dislikes)}
+                                                               <span class="wcfLikeCounter{if $boxArticle->cumulativeLikes > 0} likeCounterLiked{elseif $boxArticle->cumulativeLikes < 0}likeCounterDisliked{/if}">
+                                                                       <span class="icon icon16 fa-thumbs-o-{if $boxArticle->cumulativeLikes < 0}down{else}up{/if} jsTooltip" title="{lang likes=$boxArticle->likes dislikes=$boxArticle->dislikes}wcf.like.tooltip{/lang}"></span>{if $boxArticle->cumulativeLikes > 0}+{elseif $boxArticle->cumulativeLikes == 0}&plusmn;{/if}{#$boxArticle->cumulativeLikes}
+                                                               </span>
+                                                       {/if}
+                                               {/if}
+                                       </small>
+                               </div>
+                       </a>
+               </li>
+       {/foreach}
+</ul>
index a614e16109fed61d8e8fb19edc4f9ed1104cdf1a..98008c2b8ea30941ba27ccf954ebf8f4cef4d09b 100644 (file)
@@ -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] : ''),
index acf63a58461007357a634e0d34c5c4e85738d2ef..3d25f1cbb5a4daa31838d395844862d3baef60e9 100644 (file)
@@ -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] : ''),
index 9c2a927fa85abd7490e32598edb521e3c5a27340..9b936b9092449ce9adf50e26c7335471e6c817f3 100644 (file)
@@ -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 (file)
index 0000000..6a41ed6
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+namespace wcf\system\box;
+use wcf\data\article\AccessibleArticleList;
+use wcf\system\WCF;
+
+/**
+ * Box controller for a list of articles.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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
+               ]);
+       }
+}
index 2651f9ff275733d11a2b294072280d5b99a14d6f..83c2db48509e80a1b89bb1464d29f62f0ae6a92d 100644 (file)
                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
+}