Added acp search providers for pages, boxes and articles
authorMarcel Werk <burntime@woltlab.com>
Thu, 23 Jun 2016 14:36:04 +0000 (16:36 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 23 Jun 2016 14:36:09 +0000 (16:36 +0200)
com.woltlab.wcf/acpSearchProvider.xml
wcfsetup/install/files/lib/system/search/acp/ArticleACPSearchResultProvider.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/search/acp/BoxACPSearchResultProvider.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/search/acp/PageACPSearchResultProvider.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 1777735c4a032950f3bfab8e6dcce05e1832ef9f..bee7453efe7567c68da7083484f2f2b0eef70880 100644 (file)
                        <classname><![CDATA[wcf\system\search\acp\PackageACPSearchResultProvider]]></classname>
                        <showorder>5</showorder>
                </acpsearchprovider>
+               <acpsearchprovider name="com.woltlab.wcf.page">
+                       <classname><![CDATA[wcf\system\search\acp\PageACPSearchResultProvider]]></classname>
+                       <showorder>6</showorder>
+               </acpsearchprovider>
+               <acpsearchprovider name="com.woltlab.wcf.box">
+                       <classname><![CDATA[wcf\system\search\acp\BoxACPSearchResultProvider]]></classname>
+                       <showorder>7</showorder>
+               </acpsearchprovider>
+               <acpsearchprovider name="com.woltlab.wcf.article">
+                       <classname><![CDATA[wcf\system\search\acp\ArticleACPSearchResultProvider]]></classname>
+                       <showorder>8</showorder>
+               </acpsearchprovider>
        </import>
 </data>
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 (file)
index 0000000..7aef52b
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace wcf\system\search\acp;
+use wcf\data\article\content\ArticleContentList;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+
+/**
+ * ACP search result provider implementation for cms 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\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 (file)
index 0000000..da525df
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace wcf\system\search\acp;
+use wcf\data\box\BoxList;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+
+/**
+ * ACP search result provider implementation for cms boxes.
+ * 
+ * @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\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 (file)
index 0000000..040408f
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace wcf\system\search\acp;
+use wcf\data\page\PageList;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+
+/**
+ * ACP search result provider implementation for cms pages.
+ * 
+ * @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\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;
+       }
+}
index 177d18e0c596cb50ab2783a765a8a0d246d5dcfa..6351850ccf3586a7dc0143e2de26e1c4f22450f1 100644 (file)
@@ -1324,11 +1324,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
        
        <category name="wcf.acp.search">
                <item name="wcf.acp.search.noResults"><![CDATA[Keine Treffer]]></item>
-               <item name="wcf.acp.search.provider.com.woltlab.wcf.menuItem"><![CDATA[Seiten]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.menuItem"><![CDATA[Administrationsmenü]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.option"><![CDATA[Optionen]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.package"><![CDATA[Pakete]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.user"><![CDATA[Benutzer]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.userGroupOption"><![CDATA[Berechtigungen]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.page"><![CDATA[Seiten]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.article"><![CDATA[Artikel]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.box"><![CDATA[Boxen]]></item>
                <item name="wcf.acp.search.result.subtitle"><![CDATA[{implode from=$pieces item=piece glue=' » '}{$piece|language}{/implode}]]></item>
        </category>
        
index c5a5994e5739acde9912ff82d887973411a48d04..31756f0704f199aceff5e40cd674e9c5278a24eb 100644 (file)
@@ -1336,6 +1336,9 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.package"><![CDATA[Packages]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.user"><![CDATA[Users]]></item>
                <item name="wcf.acp.search.provider.com.woltlab.wcf.userGroupOption"><![CDATA[Permissions]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.page"><![CDATA[Pages]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.article"><![CDATA[Articles]]></item>
+               <item name="wcf.acp.search.provider.com.woltlab.wcf.box"><![CDATA[Boxes]]></item>
                <item name="wcf.acp.search.result.subtitle"><![CDATA[{implode from=$pieces item=piece glue=' » '}{$piece|language}{/implode}]]></item>
        </category>