From 39ceaa620510589c41deea1eb0c73dd5dc279d04 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 23 Jun 2016 16:36:04 +0200 Subject: [PATCH] Added acp search providers for pages, boxes and articles --- com.woltlab.wcf/acpSearchProvider.xml | 12 ++++++ .../ArticleACPSearchResultProvider.class.php | 39 +++++++++++++++++++ .../acp/BoxACPSearchResultProvider.class.php | 39 +++++++++++++++++++ .../acp/PageACPSearchResultProvider.class.php | 39 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 5 ++- wcfsetup/install/lang/en.xml | 3 ++ 6 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/lib/system/search/acp/ArticleACPSearchResultProvider.class.php create mode 100644 wcfsetup/install/files/lib/system/search/acp/BoxACPSearchResultProvider.class.php create mode 100644 wcfsetup/install/files/lib/system/search/acp/PageACPSearchResultProvider.class.php diff --git a/com.woltlab.wcf/acpSearchProvider.xml b/com.woltlab.wcf/acpSearchProvider.xml index 1777735c4a..bee7453efe 100644 --- a/com.woltlab.wcf/acpSearchProvider.xml +++ b/com.woltlab.wcf/acpSearchProvider.xml @@ -21,5 +21,17 @@ 5 + + + 6 + + + + 7 + + + + 8 + diff --git a/wcfsetup/install/files/lib/system/search/acp/ArticleACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/ArticleACPSearchResultProvider.class.php new file mode 100644 index 0000000000..7aef52b5bd --- /dev/null +++ b/wcfsetup/install/files/lib/system/search/acp/ArticleACPSearchResultProvider.class.php @@ -0,0 +1,39 @@ + + * @package WoltLabSuite\Core\System\Search\Acp + */ +class ArticleACPSearchResultProvider implements IACPSearchResultProvider { + /** + * @inheritDoc + */ + public function search($query) { + if (!WCF::getSession()->getPermission('admin.content.article.canManageArticle')) { + return []; + } + + $results = []; + + $contentList = new ArticleContentList(); + $contentList->getConditionBuilder()->add('article_content.title LIKE ?', ['%'.$query.'%']); + $contentList->sqlLimit = 10; + $contentList->sqlOrderBy = 'article_content.title'; + $contentList->readObjects(); + foreach ($contentList as $content) { + $results[] = new ACPSearchResult($content->title, LinkHandler::getInstance()->getLink('ArticleEdit', [ + 'id' => $content->articleID, + ])); + } + + return $results; + } +} diff --git a/wcfsetup/install/files/lib/system/search/acp/BoxACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/BoxACPSearchResultProvider.class.php new file mode 100644 index 0000000000..da525df0fc --- /dev/null +++ b/wcfsetup/install/files/lib/system/search/acp/BoxACPSearchResultProvider.class.php @@ -0,0 +1,39 @@ + + * @package WoltLabSuite\Core\System\Search\Acp + */ +class BoxACPSearchResultProvider implements IACPSearchResultProvider { + /** + * @inheritDoc + */ + public function search($query) { + if (!WCF::getSession()->getPermission('admin.content.cms.canManageBox')) { + return []; + } + + $results = []; + + $boxList = new BoxList(); + $boxList->getConditionBuilder()->add('box.name LIKE ?', ['%'.$query.'%']); + $boxList->sqlLimit = 10; + $boxList->sqlOrderBy = 'box.name'; + $boxList->readObjects(); + foreach ($boxList as $box) { + $results[] = new ACPSearchResult($box->name, LinkHandler::getInstance()->getLink('BoxEdit', [ + 'id' => $box->boxID, + ])); + } + + return $results; + } +} diff --git a/wcfsetup/install/files/lib/system/search/acp/PageACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/PageACPSearchResultProvider.class.php new file mode 100644 index 0000000000..040408f711 --- /dev/null +++ b/wcfsetup/install/files/lib/system/search/acp/PageACPSearchResultProvider.class.php @@ -0,0 +1,39 @@ + + * @package WoltLabSuite\Core\System\Search\Acp + */ +class PageACPSearchResultProvider implements IACPSearchResultProvider { + /** + * @inheritDoc + */ + public function search($query) { + if (!WCF::getSession()->getPermission('admin.content.cms.canManagePage')) { + return []; + } + + $results = []; + + $pageList = new PageList(); + $pageList->getConditionBuilder()->add('page.name LIKE ?', ['%'.$query.'%']); + $pageList->sqlLimit = 10; + $pageList->sqlOrderBy = 'page.name'; + $pageList->readObjects(); + foreach ($pageList as $page) { + $results[] = new ACPSearchResult($page->name, LinkHandler::getInstance()->getLink('PageEdit', [ + 'id' => $page->pageID, + ])); + } + + return $results; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 177d18e0c5..6351850ccf 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1324,11 +1324,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> - + + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index c5a5994e57..31756f0704 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1336,6 +1336,9 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + + + -- 2.20.1