Properly handle AbstractSelectCondition without options
authorMatthias Schmidt <gravatronics@live.com>
Wed, 4 May 2016 18:07:34 +0000 (20:07 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 4 May 2016 18:07:34 +0000 (20:07 +0200)
wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php
wcfsetup/install/files/lib/system/condition/AbstractSelectCondition.class.php

index 75ed722c08d3e960031e058f84dc33ae4a0b5d5d..9566019205873c249b39a2aa597fad0bf92f2773 100644 (file)
@@ -8,7 +8,7 @@ use wcf\util\ArrayUtil;
  * Abstract implementation of a condition with multi select options.
  * 
  * @author     Matthias Schmidt
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.condition
@@ -70,7 +70,7 @@ abstract class AbstractMultiSelectCondition extends AbstractSelectCondition {
         * @inheritDoc
         */
        public function reset() {
-               $this->fieldValue = array();
+               $this->fieldValue = [];
        }
        
        /**
index 86632ea2a517d005deaf74e2f7f0817e53926e55..ee312209215bc1b972a72b8fbd64e02f9bdba606 100644 (file)
@@ -8,7 +8,7 @@ use wcf\system\WCF;
  * Abstract implementation of a condition with select options.
  * 
  * @author     Matthias Schmidt
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.condition
@@ -34,20 +34,18 @@ abstract class AbstractSelectCondition extends AbstractSingleFieldCondition {
        const NO_SELECTION_VALUE = -1;
        
        /**
-        * @see \wcf\system\condition\ICondition::getData()
+        * @inheritDoc
         */
        public function getData() {
                if ($this->fieldValue != self::NO_SELECTION_VALUE) {
-                       return array(
-                               $this->fieldName => $this->fieldValue
-                       );
+                       return [$this->fieldName => $this->fieldValue];
                }
                
                return null;
        }
        
        /**
-        * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+        * @inheritDoc
         */
        protected function getFieldElement() {
                $options = $this->getOptions();
@@ -66,6 +64,15 @@ abstract class AbstractSelectCondition extends AbstractSingleFieldCondition {
                return $fieldElement;
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function getHTML() {
+               if (empty($this->getOptions())) return '';
+               
+               return parent::getHTML();
+       }
+       
        /**
         * Returns the html code for an opt group.
         * 
@@ -100,28 +107,28 @@ abstract class AbstractSelectCondition extends AbstractSingleFieldCondition {
        abstract protected function getOptions();
        
        /**
-        * @see \wcf\system\condition\ICondition::readFormParameters()
+        * @inheritDoc
         */
        public function readFormParameters() {
                if (isset($_POST[$this->fieldName])) $this->fieldValue = intval($_POST[$this->fieldName]);
        }
        
        /**
-        * @see \wcf\system\condition\ICondition::reset()
+        * @inheritDoc
         */
        public function reset() {
                $this->fieldValue = self::NO_SELECTION_VALUE;
        }
        
        /**
-        * @see \wcf\system\condition\ICondition::setData()
+        * @inheritDoc
         */
        public function setData(Condition $condition) {
                $this->fieldValue = $condition->conditionData[$this->fieldName];
        }
        
        /**
-        * @see \wcf\system\condition\ICondition::validate()
+        * @inheritDoc
         */
        public function validate() {
                if ($this->fieldValue != self::NO_SELECTION_VALUE) {