Add application filter to TemplateListPage
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 1 Jun 2013 17:22:08 +0000 (19:22 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 1 Jun 2013 17:23:18 +0000 (19:23 +0200)
Closes #1314

wcfsetup/install/files/acp/templates/templateList.tpl
wcfsetup/install/files/lib/acp/page/TemplateListPage.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 88048c4453c37bcb9475c540aab57b1c54ea7d36..a5dfec5eb4f977d61b18bfacea067c499ebe92a3 100644 (file)
                                </dd>
                        </dl>
                        
+                       <dl>
+                               <dt><label for="application">{lang}wcf.acp.template.application{/lang}</label></dt>
+                               <dd>
+                                       <select name="application" id="templateGroupID">
+                                               <option value="">{lang}wcf.acp.template.application.all{/lang}</option>
+                                               {foreach from=$availableApplications key=abbreviation item=availableApplication}
+                                                       <option value="{$abbreviation}"{if $abbreviation == $application} selected="selected"{/if}>{$availableApplication}</option>
+                                               {/foreach}
+                                       </select>
+                               </dd>
+                       </dl>
+                       
                        <dl>
                                <dt><label for="searchTemplateName">{lang}wcf.global.name{/lang}</label></dt>
                                <dd>
index f99d46f1628c92602e26b75c6af29bffbaa165d4..484fa6e4b1597d8a3ff08689a174d324eb89a3ff 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 namespace wcf\acp\page;
+use wcf\data\package\PackageCache;
 use wcf\data\template\group\TemplateGroupList;
 use wcf\page\SortablePage;
+use wcf\system\application\ApplicationHandler;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
@@ -58,12 +60,24 @@ class TemplateListPage extends SortablePage {
         */
        public $searchTemplateName = '';
        
+       /**
+        * application
+        * @var string
+        */
+       public $application = '';
+       
        /**
         * available template groups
         * @var array
         */
        public $availableTemplateGroups = array();
        
+       /**
+        * available applications
+        * @var array
+        */
+       public $availableApplications = array();
+       
        /**
         * @see wcf\page\IPage::readParameters()
         */
@@ -72,6 +86,7 @@ class TemplateListPage extends SortablePage {
        
                if (isset($_REQUEST['templateGroupID'])) $this->templateGroupID = intval($_REQUEST['templateGroupID']);
                if (isset($_REQUEST['searchTemplateName'])) $this->searchTemplateName = StringUtil::trim($_REQUEST['searchTemplateName']);
+               if (isset($_REQUEST['application'])) $this->application = StringUtil::trim($_REQUEST['application']);
        }
        
        /**
@@ -84,6 +99,7 @@ class TemplateListPage extends SortablePage {
                else $this->objectList->getConditionBuilder()->add('template.templateGroupID IS NULL');
                
                if ($this->searchTemplateName) $this->objectList->getConditionBuilder()->add('templateName LIKE ?', array($this->searchTemplateName.'%'));
+               if ($this->application) $this->objectList->getConditionBuilder()->add('application = ?', array($this->application));
        }
        
        /**
@@ -96,6 +112,13 @@ class TemplateListPage extends SortablePage {
                $templateGroupList = new TemplateGroupList();
                $templateGroupList->readObjects();
                $this->availableTemplateGroups = $templateGroupList->getObjects();
+               
+               // get applications
+               $applications = ApplicationHandler::getInstance()->getApplications();
+               foreach ($applications as $application) {
+                       $package = PackageCache::getInstance()->getPackage($application->packageID);
+                       $this->availableApplications[ApplicationHandler::getInstance()->getAbbreviation($package->packageID)] = $package;
+               }
        }
        
        /**
@@ -107,7 +130,9 @@ class TemplateListPage extends SortablePage {
                WCF::getTPL()->assign(array(
                        'templateGroupID' => $this->templateGroupID,
                        'searchTemplateName' => $this->searchTemplateName,
-                       'availableTemplateGroups' => $this->availableTemplateGroups
+                       'application' => $this->application,
+                       'availableTemplateGroups' => $this->availableTemplateGroups,
+                       'availableApplications' => $this->availableApplications
                ));
        }
 }
index 03aa3baca99bb62ad8adc239f16fee25035137e5..7448ac5ca0c51ca099f45b21ccf01449185994a0 100644 (file)
                <item name="wcf.acp.template.list"><![CDATA[Templates]]></item>
                <item name="wcf.acp.template.group"><![CDATA[Templategruppe]]></item>
                <item name="wcf.acp.template.group.default"><![CDATA[Standardtemplates]]></item>
+               <item name="wcf.acp.template.application"><![CDATA[Anwendung]]></item>
+               <item name="wcf.acp.template.application.all"><![CDATA[Keine Filterung]]></item>
                <item name="wcf.acp.template.add"><![CDATA[Template hinzufügen]]></item>
                <item name="wcf.acp.template.edit"><![CDATA[Template bearbeiten]]></item>
                <item name="wcf.acp.template.copy"><![CDATA[Template kopieren]]></item>
index 2b7640e92de6fd1c2919b0047f00ad2575c70c38..c2d37a52306b5ebaa325e2dacabd630ed91e37ef 100644 (file)
@@ -1063,6 +1063,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.template.list"><![CDATA[Templates]]></item>
                <item name="wcf.acp.template.group"><![CDATA[Template Group]]></item>
                <item name="wcf.acp.template.group.default"><![CDATA[Default Templates]]></item>
+               <item name="wcf.acp.template.application"><![CDATA[Application]]></item>
+               <item name="wcf.acp.template.application.all"><![CDATA[TODO: Keine Filterung]]></item>
                <item name="wcf.acp.template.add"><![CDATA[Add Template]]></item>
                <item name="wcf.acp.template.edit"><![CDATA[Edit Template]]></item>
                <item name="wcf.acp.template.copy"><![CDATA[Copy Template]]></item>