From: Joshua Rüsweg Date: Wed, 29 Aug 2018 19:12:26 +0000 (+0200) Subject: Add unread article page feature X-Git-Tag: 5.2.0_Alpha_1~364^2~47 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4e975b2aecefc1e10dcadb113bfb5fdc7f0da7dd;p=GitHub%2FWoltLab%2FWCF.git Add unread article page feature See #2623 --- diff --git a/com.woltlab.wcf/menuItem.xml b/com.woltlab.wcf/menuItem.xml index 8b46b4c481..736c2e3e12 100644 --- a/com.woltlab.wcf/menuItem.xml +++ b/com.woltlab.wcf/menuItem.xml @@ -13,6 +13,12 @@ Articles com.woltlab.wcf.ArticleList + + com.woltlab.wcf.ArticleList + Ungelesene Artikel + Unread Articles + com.woltlab.wcf.UnreadArticleList + com.woltlab.wcf.ArticleList Abonnierte Artikel diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index a8b1cf596a..959bcabe38 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -518,6 +518,22 @@ Artikel + + system + wcf\page\UnreadArticleListPage + wcf\system\page\handler\UnreadArticleListPageHandler + Ungelesene Artikel + Unread Articles + module_article + com.woltlab.wcf.ArticleList + + + Unread Articles + + + Ungelesene Artikel + + system wcf\page\WatchedArticleListPage diff --git a/com.woltlab.wcf/templates/unreadArticleList.tpl b/com.woltlab.wcf/templates/unreadArticleList.tpl new file mode 100644 index 0000000000..9b446fe609 --- /dev/null +++ b/com.woltlab.wcf/templates/unreadArticleList.tpl @@ -0,0 +1,117 @@ +{capture assign='headContent'} + {if $pageNo < $pages} + + {/if} + {if $pageNo > 1} + + {/if} +{/capture} + +{capture assign='headerNavigation'} + {if ARTICLE_ENABLE_VISIT_TRACKING} +
  • + {/if} +{/capture} + +{capture assign='sidebarRight'} + {if !$labelGroups|empty} +
    +
    +

    {lang}wcf.label.label{/lang}

    + +
    +
    + {foreach from=$labelGroups item=labelGroup} + {if $labelGroup|count} +
    {$labelGroup->getTitle()}
    +
    +
      + +
    + +
    + {/if} + {/foreach} +
    +
    + +
    +
    +
    +
    + + + {/if} +{/capture} + +{include file='header'} + +{hascontent} +
    + {content} + {pages print=true assign='pagesLinks' controller='UnreadArticleList' link="pageNo=%d"} + {/content} +
    +{/hascontent} + +{if $objects|count} +
    + {include file='articleListItems'} +
    +{else} +

    {lang}wcf.global.noItems{/lang}

    +{/if} + +
    + {hascontent} +
    + {content}{@$pagesLinks}{/content} +
    + {/hascontent} + + {hascontent} + + {/hascontent} +
    + +{if ARTICLE_ENABLE_VISIT_TRACKING} + +{/if} + +{include file='footer'} diff --git a/wcfsetup/install/files/lib/page/UnreadArticleListPage.class.php b/wcfsetup/install/files/lib/page/UnreadArticleListPage.class.php new file mode 100644 index 0000000000..89efac7fe4 --- /dev/null +++ b/wcfsetup/install/files/lib/page/UnreadArticleListPage.class.php @@ -0,0 +1,54 @@ + + * @package WoltLabSuite\Core\Page + * @since 3.2 + */ +class UnreadArticleListPage extends ArticleListPage { + /** + * @inheritDoc + */ + public $loginRequired = true; + + /** + * @inheritDoc + */ + public $neededModules = ['ARTICLE_ENABLE_VISIT_TRACKING', 'MODULE_ARTICLE']; + + /** + * @inheritDoc + */ + public $controllerName = 'UnreadArticleList'; + + /** + * @inheritDoc + */ + public function readParameters() { + parent::readParameters(); + + $this->canonicalURL = LinkHandler::getInstance()->getLink('UnreadArticleList', $this->controllerParameters, ($this->pageNo > 1 ? 'pageNo=' . $this->pageNo : '')); + } + + /** + * @inheritDoc + */ + public function initObjectList() { + parent::initObjectList(); + + $this->objectList->getConditionBuilder()->add('article.time > ?', [VisitTracker::getInstance()->getVisitTime('com.woltlab.wcf.article')]); + + if (WCF::getUser()->userID) { + $this->objectList->sqlConditionJoins = "LEFT JOIN wcf".WCF_N."_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = ".VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wcf.article')." AND tracked_visit.objectID = article.articleID AND tracked_visit.userID = ".WCF::getUser()->userID.")"; + $this->objectList->getConditionBuilder()->add("(article.time > tracked_visit.visitTime OR tracked_visit.visitTime IS NULL)"); + } + } +} diff --git a/wcfsetup/install/files/lib/system/page/handler/UnreadArticleListPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/UnreadArticleListPageHandler.class.php new file mode 100644 index 0000000000..ac4849e194 --- /dev/null +++ b/wcfsetup/install/files/lib/system/page/handler/UnreadArticleListPageHandler.class.php @@ -0,0 +1,30 @@ + + * @package WoltLabSuite\Core\System\Page\Handler + * @since 3.2 + */ +class UnreadArticleListPageHandler extends AbstractMenuPageHandler { + /** @noinspection PhpMissingParentCallCommonInspection */ + /** + * @inheritDoc + */ + public function getOutstandingItemCount(/** @noinspection PhpUnusedParameterInspection */$objectID = null) { + return ViewableArticle::getUnreadArticles(); + } + + /** @noinspection PhpMissingParentCallCommonInspection */ + /** + * @inheritDoc + */ + public function isVisible(/** @noinspection PhpUnusedParameterInspection */$objectID = null) { + return ARTICLE_ENABLE_VISIT_TRACKING && !empty(ViewableArticle::getUnreadArticles()); + } +}