2 namespace wcf\acp\page
;
3 use wcf\data\article\Article
;
4 use wcf\data\article\ArticleList
;
5 use wcf\data\article\ViewableArticleList
;
6 use wcf\data\category\CategoryNodeTree
;
7 use wcf\data\user\User
;
8 use wcf\page\SortablePage
;
9 use wcf\system\clipboard\ClipboardHandler
;
10 use wcf\system\language\LanguageFactory
;
12 use wcf\util\StringUtil
;
15 * Shows a list of cms articles.
18 * @copyright 2001-2018 WoltLab GmbH
19 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
20 * @package WoltLabSuite\Core\Acp\Page
23 * @property ArticleList $objectList
25 class ArticleListPage
extends SortablePage
{
29 public $activeMenuItem = 'wcf.acp.menu.link.article.list';
34 public $objectListClassName = ViewableArticleList
::class;
39 public $neededModules = ['MODULE_ARTICLE'];
44 public $neededPermissions = ['admin.content.article.canManageArticle', 'admin.content.article.canContributeArticle'];
49 public $defaultSortField = 'time';
54 public $defaultSortOrder = 'DESC';
59 public $validSortFields = ['articleID', 'title', 'time', 'views', 'comments'];
64 public $itemsPerPage = 50;
70 public $categoryID = 0;
76 public $username = '';
91 * display 'Add Article' dialog on load
94 public $showArticleAddDialog = 0;
97 * publication status filter
100 public $publicationStatus = -1;
105 public $isDeleted = -1;
110 public function readParameters() {
111 parent
::readParameters();
113 if (isset($_REQUEST['categoryID'])) $this->categoryID
= intval($_REQUEST['categoryID']);
114 if (!empty($_REQUEST['username'])) $this->username
= StringUtil
::trim($_REQUEST['username']);
115 if (!empty($_REQUEST['title'])) $this->title
= StringUtil
::trim($_REQUEST['title']);
116 if (!empty($_REQUEST['content'])) $this->content
= StringUtil
::trim($_REQUEST['content']);
117 if (!empty($_REQUEST['showArticleAddDialog'])) $this->showArticleAddDialog
= 1;
118 if (isset($_REQUEST['publicationStatus'])) $this->publicationStatus
= intval($_REQUEST['publicationStatus']);
119 if (!empty($_REQUEST['isDeleted'])) $this->isDeleted
= intval($_REQUEST['isDeleted']);
125 protected function initObjectList() {
126 parent
::initObjectList();
128 if ($this->categoryID
) {
129 $this->objectList
->getConditionBuilder()->add('article.categoryID = ?', [$this->categoryID
]);
131 if (!empty($this->username
)) {
132 $user = User
::getUserByUsername($this->username
);
133 if ($user->userID
) $this->objectList
->getConditionBuilder()->add('article.userID = ?', [$user->userID
]);
134 else $this->objectList
->getConditionBuilder()->add('1=0');
136 if (!empty($this->title
)) {
137 $this->objectList
->getConditionBuilder()->add('article.articleID IN (SELECT articleID FROM wcf'.WCF_N
.'_article_content WHERE title LIKE ?)', ['%'.$this->title
.'%']);
139 if (!empty($this->content
)) {
140 $this->objectList
->getConditionBuilder()->add('article.articleID IN (SELECT articleID FROM wcf'.WCF_N
.'_article_content WHERE content LIKE ?)', ['%'.$this->content
.'%']);
142 if (!WCF
::getSession()->getPermission('admin.content.article.canManageArticle')) {
143 // only show own articles
144 $this->objectList
->getConditionBuilder()->add('article.userID = ?', [WCF
::getUser()->userID
]);
146 if (!WCF
::getSession()->getPermission('admin.content.article.canManageOwnArticles')) {
147 // only show unpublished articles
148 $this->objectList
->getConditionBuilder()->add('article.publicationStatus = ?', [Article
::UNPUBLISHED
]);
152 $this->objectList
->sqlSelects
= "(SELECT title FROM wcf".WCF_N
."_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = ".WCF
::getLanguage()->languageID
.") LIMIT 1) AS title";
154 if ($this->publicationStatus
!= -1) {
155 $this->objectList
->getConditionBuilder()->add('article.publicationStatus = ?', [$this->publicationStatus
]);
158 if ($this->isDeleted
!== -1) {
159 $this->objectList
->getConditionBuilder()->add('article.isDeleted = ?', [$this->isDeleted
]);
166 public function assignVariables() {
167 parent
::assignVariables();
169 WCF
::getTPL()->assign([
170 'categoryID' => $this->categoryID
,
171 'username' => $this->username
,
172 'title' => $this->title
,
173 'content' => $this->content
,
174 'showArticleAddDialog' => $this->showArticleAddDialog
,
175 'availableLanguages' => LanguageFactory
::getInstance()->getLanguages(),
176 'categoryNodeList' => (new CategoryNodeTree('com.woltlab.wcf.article.category'))->getIterator(),
177 'publicationStatus' => $this->publicationStatus
,
178 'hasMarkedItems' => ClipboardHandler
::getInstance()->hasMarkedItems(ClipboardHandler
::getInstance()->getObjectTypeID('com.woltlab.wcf.article')),
179 'isDeleted' => $this->isDeleted
,