[TASK] PSR-2 and PHP 5.5 refactoring
authorAlex Kellner <alexander.kellner@in2code.de>
Thu, 3 Dec 2015 16:51:06 +0000 (17:51 +0100)
committerAlex Kellner <alexander.kellner@in2code.de>
Thu, 3 Dec 2015 16:51:06 +0000 (17:51 +0100)
16 files changed:
Classes/Controller/ConditionController.php
Classes/Domain/Comparator/Comparison.php
Classes/Domain/Model/Condition.php
Classes/Domain/Model/ConditionContainer.php
Classes/Domain/Model/Rule.php
Classes/Domain/Repository/ConditionContainerRepository.php
Classes/Domain/Validator/ConditionAwareValidator.php
Classes/UserFunc/GetPowermailFields.php
Classes/UserFunc/GetPowermailFormsWithoutConditionRelation.php
Classes/Utility/ArrayUtility.php
Configuration/TCA/tx_powermailcond_domain_model_condition.php
Configuration/TCA/tx_powermailcond_domain_model_conditioncontainer.php
Configuration/TCA/tx_powermailcond_domain_model_rule.php
ext_emconf.php
ext_localconf.php
ext_tables.php

index 750da1c..5f80bb0 100644 (file)
@@ -38,67 +38,69 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
  *
  * @package powermail_cond
  * @license http://www.gnu.org/licenses/lgpl.html
- *                     GNU Lesser General Public License, version 3 or later
+ *            GNU Lesser General Public License, version 3 or later
  */
-class ConditionController extends ActionController {
+class ConditionController extends ActionController
+{
 
-       /**
-        * @var \In2code\Powermail\Domain\Repository\FormRepository
-        * @inject
-        */
-       protected $formRepository;
+    /**
+     * @var \In2code\Powermail\Domain\Repository\FormRepository
+     * @inject
+     */
+    protected $formRepository;
 
-       /**
-        * @var \In2code\PowermailCond\Domain\Repository\ConditionContainerRepository
-        * @inject
-        */
-       protected $conditionContainerRepository;
+    /**
+     * @var \In2code\PowermailCond\Domain\Repository\ConditionContainerRepository
+     * @inject
+     */
+    protected $conditionContainerRepository;
 
-       /**
-        * Build Condition for AJAX call
-        *
-        * @return string
-        */
-       public function buildConditionAction() {
-               $arguments = GeneralUtility::_GP('tx_powermail_pi1');
-               unset($arguments['__referrer']);
-               unset($arguments['__trustedProperties']);
-               /** @var Form $form */
-               $form = $this->formRepository->findByIdentifier($arguments['mail']['form']);
-               if ($form !== NULL) {
-                       /** @var Page $page */
-                       foreach ($form->getPages() as $page) {
-                               /** @var Field $field */
-                               foreach ($page->getFields() as $field) {
-                                       foreach ($arguments['field'] as $fieldName => $fieldValue) {
-                                               if ($field->getMarker() === $fieldName) {
-                                                       $field->setText($fieldValue);
-                                               }
-                                       }
-                               }
-                       }
-               }
+    /**
+     * Build Condition for AJAX call
+     *
+     * @return string
+     */
+    public function buildConditionAction()
+    {
+        $arguments = GeneralUtility::_GP('tx_powermail_pi1');
+        unset($arguments['__referrer']);
+        unset($arguments['__trustedProperties']);
+        /** @var Form $form */
+        $form = $this->formRepository->findByIdentifier($arguments['mail']['form']);
+        if ($form !== null) {
+            /** @var Page $page */
+            foreach ($form->getPages() as $page) {
+                /** @var Field $field */
+                foreach ($page->getFields() as $field) {
+                    foreach ($arguments['field'] as $fieldName => $fieldValue) {
+                        if ($field->getMarker() === $fieldName) {
+                            $field->setText($fieldValue);
+                        }
+                    }
+                }
+            }
+        }
 
-               /** @var ConditionContainer $conditionContainer */
-               $conditionContainer = $this->conditionContainerRepository->findOneByForm($form);
-               if ($conditionContainer !== NULL) {
-                       $arguments = $conditionContainer->applyConditions($form, $arguments);
+        /** @var ConditionContainer $conditionContainer */
+        $conditionContainer = $this->conditionContainerRepository->findOneByForm($form);
+        if ($conditionContainer !== null) {
+            $arguments = $conditionContainer->applyConditions($form, $arguments);
 
-                       /** @var TypoScriptFrontendController $feUser */
-                       $feUser = GeneralUtility::makeInstance(
-                               'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
-                               $GLOBALS['TYPO3_CONF_VARS'],
-                               0,
-                               0
-                       );
-                       $feUser->initFEuser();
-                       $feUser->fe_user->setAndSaveSessionData('tx_powermail_cond', $arguments);
+            /** @var TypoScriptFrontendController $feUser */
+            $feUser = GeneralUtility::makeInstance(
+                'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
+                $GLOBALS['TYPO3_CONF_VARS'],
+                0,
+                0
+            );
+            $feUser->initFEuser();
+            $feUser->fe_user->setAndSaveSessionData('tx_powermail_cond', $arguments);
 
-                       unset($arguments['backup']);
-                       unset($arguments['field']);
+            unset($arguments['backup']);
+            unset($arguments['field']);
 
-                       return json_encode($arguments);
-               }
-               return NULL;
-       }
+            return json_encode($arguments);
+        }
+        return null;
+    }
 }
index 7a299f2..1dc7463 100644 (file)
@@ -8,104 +8,109 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * Class Comparison
  */
-class Comparison {
+class Comparison
+{
 
-       /**
-        * @var int
-        */
-       protected $operation = 0;
+    /**
+     * @var int
+     */
+    protected $operation = 0;
 
-       /**
-        * @param int $operation
-        */
-       public function __construct($operation) {
-               $this->operation = $operation;
-       }
+    /**
+     * @param int $operation
+     */
+    public function __construct($operation)
+    {
+        $this->operation = $operation;
+    }
 
-       /**
-        * @param Field $leftField
-        * @param string $valueToMatch
-        * @param Field $rightField
-        * @return bool
-        */
-       public function evaluate(Field $leftField, $valueToMatch = '', Field $rightField = NULL) {
-               $result = FALSE;
-               switch ($this->operation) {
-                       case Rule::OPERATOR_IS_SET:
-                               $result = $this->operationIsNotEmpty($leftField->getText());
-                               break;
-                       case Rule::OPERATOR_NOT_IS_SET:
-                               $result = !$this->operationIsNotEmpty($leftField->getText());
-                               break;
-                       case Rule::OPERATOR_CONTAINS_VALUE:
-                               $result = $this->operationContains($leftField->getText(), $valueToMatch);
-                               break;
-                       case Rule::OPERATOR_NOT_CONTAINS_VALUE:
-                               $result = !$this->operationContains($leftField->getText(), $valueToMatch);
-                               break;
-                       case Rule::OPERATOR_IS:
-                               $result = ($leftField->getText() === $valueToMatch);
-                               break;
-                       case Rule::OPERATOR_NOT_IS:
-                               $result = ($leftField->getText() !== $valueToMatch);
-                               break;
-                       case Rule::OPERATOR_GREATER_THAN:
-                               if ($valueToMatch !== '') {
-                                       $result = (((int) $leftField->getText()) > ((int) $valueToMatch));
-                               }
-                               break;
-                       case Rule::OPERATOR_LESS_THAN:
-                               if ($valueToMatch !== '') {
-                                       $result = (((int) $leftField->getText()) < ((int) $valueToMatch));
-                               }
-                               break;
-                       case Rule::OPERATOR_CONTAINS_VALUE_FROM_FIELD:
-                               if ($rightField instanceof Field) {
-                                       $result = $this->operationContains($rightField->getText(), $leftField->getText());
-                               }
-                               break;
-                       case Rule::OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD:
-                               if ($rightField instanceof Field) {
-                                       $result = !$this->operationContains($rightField->getText(), $leftField->getText());
-                               }
-                               break;
-               }
-               return $result;
-       }
+    /**
+     * @param Field $leftField
+     * @param string $valueToMatch
+     * @param Field $rightField
+     * @return bool
+     */
+    public function evaluate(Field $leftField, $valueToMatch = '', Field $rightField = null)
+    {
+        $result = false;
+        switch ($this->operation) {
+            case Rule::OPERATOR_IS_SET:
+                $result = $this->operationIsNotEmpty($leftField->getText());
+                break;
+            case Rule::OPERATOR_NOT_IS_SET:
+                $result = !$this->operationIsNotEmpty($leftField->getText());
+                break;
+            case Rule::OPERATOR_CONTAINS_VALUE:
+                $result = $this->operationContains($leftField->getText(), $valueToMatch);
+                break;
+            case Rule::OPERATOR_NOT_CONTAINS_VALUE:
+                $result = !$this->operationContains($leftField->getText(), $valueToMatch);
+                break;
+            case Rule::OPERATOR_IS:
+                $result = ($leftField->getText() === $valueToMatch);
+                break;
+            case Rule::OPERATOR_NOT_IS:
+                $result = ($leftField->getText() !== $valueToMatch);
+                break;
+            case Rule::OPERATOR_GREATER_THAN:
+                if ($valueToMatch !== '') {
+                    $result = (((int) $leftField->getText()) > ((int) $valueToMatch));
+                }
+                break;
+            case Rule::OPERATOR_LESS_THAN:
+                if ($valueToMatch !== '') {
+                    $result = (((int) $leftField->getText()) < ((int) $valueToMatch));
+                }
+                break;
+            case Rule::OPERATOR_CONTAINS_VALUE_FROM_FIELD:
+                if ($rightField instanceof Field) {
+                    $result = $this->operationContains($rightField->getText(), $leftField->getText());
+                }
+                break;
+            case Rule::OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD:
+                if ($rightField instanceof Field) {
+                    $result = !$this->operationContains($rightField->getText(), $leftField->getText());
+                }
+                break;
+        }
+        return $result;
+    }
 
-       /**
-        * @param $value
-        * @return bool
-        */
-       protected function operationIsNotEmpty($value) {
-               return !empty($value);
-       }
+    /**
+     * @param $value
+     * @return bool
+     */
+    protected function operationIsNotEmpty($value)
+    {
+        return !empty($value);
+    }
 
-       /**
-        * @param string|array $haystack
-        * @param string|array $needle If array, all elements must be contained in $haystack (OR)
-        * @return bool
-        */
-       protected function operationContains($haystack, $needle) {
-               if (!$this->operationIsNotEmpty($needle) || !$this->operationIsNotEmpty($haystack)) {
-                       return FALSE;
-               }
-               if (strpos($needle, PHP_EOL)) {
-                       $needle = GeneralUtility::trimExplode(PHP_EOL, $needle);
-               }
-               if (is_array($needle)) {
-                       foreach ($needle as $needleString) {
-                               if ($this->operationIsNotEmpty($needleString)) {
-                                       if (strpos($haystack, $needleString) !== FALSE) {
-                                               return TRUE;
-                                       }
-                               }
-                       }
-                       return FALSE;
-               }
-               if (is_array($haystack)) {
-                       return in_array($needle, $haystack);
-               }
-               return (strpos($haystack, $needle) !== FALSE);
-       }
+    /**
+     * @param string|array $haystack
+     * @param string|array $needle If array, all elements must be contained in $haystack (OR)
+     * @return bool
+     */
+    protected function operationContains($haystack, $needle)
+    {
+        if (!$this->operationIsNotEmpty($needle) || !$this->operationIsNotEmpty($haystack)) {
+            return false;
+        }
+        if (strpos($needle, PHP_EOL)) {
+            $needle = GeneralUtility::trimExplode(PHP_EOL, $needle);
+        }
+        if (is_array($needle)) {
+            foreach ($needle as $needleString) {
+                if ($this->operationIsNotEmpty($needleString)) {
+                    if (strpos($haystack, $needleString) !== false) {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        if (is_array($haystack)) {
+            return in_array($needle, $haystack);
+        }
+        return (strpos($haystack, $needle) !== false);
+    }
 }
index ff53e7a..2195156 100644 (file)
@@ -39,347 +39,377 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
  * @license http://www.gnu.org/licenses/lgpl.html
  *            GNU Lesser General Public License, version 3 or later
  */
-class Condition extends AbstractEntity {
-
-       const CONJUNCTION_OR = 'OR';
-       const CONJUNCTION_AND = 'AND';
-       const ACTION_HIDE = 0;
-       const ACTION_UN_HIDE = 1;
-       const ACTION_HIDE_STRING = 'hide';
-       const ACTION_UN_HIDE_STRING = 'un_hide';
-       const INDEX_TODO = 'todo';
-       const INDEX_ACTION = '#action';
-       const INDEX_BACKUP = 'backup';
-       const INDEX_MATCHING_CONDITION = 'matching_condition';
-
-       /**
-        * @var \In2code\Powermail\Domain\Repository\FieldRepository
-        * @inject
-        */
-       protected $fieldRepository;
-
-       /**
-        * @var \In2code\Powermail\Domain\Repository\PageRepository
-        * @inject
-        */
-       protected $pageRepository;
-
-       /**
-        * @var string
-        */
-       protected $title = '';
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\In2code\PowermailCond\Domain\Model\Rule>
-        */
-       protected $rules = NULL;
-
-       /**
-        * @var string
-        */
-       protected $targetField = '';
-
-       /**
-        * 0 hide
-        * 1 unhide
-        *
-        * @var int
-        */
-       protected $actions = 0;
-
-       /**
-        * @var string
-        */
-       protected $filterSelectField = '';
-
-       /**
-        * "OR"
-        * "AND"
-        *
-        * @var string
-        */
-       protected $conjunction = '';
-
-       /**
-        * @var \In2code\Powermail\Domain\Model\Form
-        */
-       protected $form = '';
-
-       /**
-        * @return string
-        */
-       public function getTitle() {
-               return $this->title;
-       }
-
-       /**
-        * @param string $title
-        * @return Condition
-        */
-       public function setTitle($title) {
-               $this->title = $title;
-               return $this;
-       }
-
-       /**
-        * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
-        */
-       public function getRules() {
-               return $this->rules;
-       }
-
-       /**
-        * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $rules
-        * @return Condition
-        */
-       public function setRules($rules) {
-               $this->rules = $rules;
-               return $this;
-       }
-
-       /**
-        * @return Field|Page|NULL
-        */
-       public function getTargetField() {
-               $targetField = $this->targetField;
-               if (is_numeric($targetField)) {
-                       return $this->fieldRepository->findByUid((int) $targetField);
-               }
-               if (stristr($targetField, 'fieldset:')) {
-                       return $this->pageRepository->findByUid((int) trim($targetField, 'fieldset:'));
-               }
-               return NULL;
-       }
-
-       /**
-        * @param string $targetField
-        * @return Condition
-        */
-       public function setTargetField($targetField) {
-               $this->targetField = $targetField;
-               return $this;
-       }
-
-       /**
-        * @return int
-        */
-       public function getActions() {
-               return $this->actions;
-       }
-
-       /**
-        * @param int $actions
-        * @return Condition
-        */
-       public function setActions($actions) {
-               $this->actions = $actions;
-               return $this;
-       }
-
-       /**
-        * @return string
-        */
-       public function getFilterSelectField() {
-               return $this->filterSelectField;
-       }
-
-       /**
-        * @param string $filterSelectField
-        * @return Condition
-        */
-       public function setFilterSelectField($filterSelectField) {
-               $this->filterSelectField = $filterSelectField;
-               return $this;
-       }
-
-       /**
-        * @return string
-        */
-       public function getConjunction() {
-               return $this->conjunction;
-       }
-
-       /**
-        * @param string $conjunction
-        * @return Condition
-        */
-       public function setConjunction($conjunction) {
-               $this->conjunction = $conjunction;
-               return $this;
-       }
-
-       /**
-        * @return Form
-        */
-       public function getForm() {
-               return $this->form;
-       }
-
-       /**
-        * @param Form $form
-        * @return Condition
-        */
-       public function setForm($form) {
-               $this->form = $form;
-               return $this;
-       }
-
-       /**
-        * @param Form $form
-        * @return bool
-        */
-       public function applies(Form $form) {
-               // If conjunction is or set $isOr to TRUE
-               $isOr = ($this->conjunction === self::CONJUNCTION_OR);
-
-               /** @var Rule $rule */
-               foreach ($this->rules as $rule) {
-                       if ($rule->applies($form)) {
-                               if ($isOr === TRUE) {
-
-                                       // if it is the first matching rule in an OR conjunction return TRUE
-                                       return TRUE;
-                               }
-                       } elseif ($isOr === FALSE) {
-
-                               // if it is the first NOT matching rule in an AND conjunction return FALSE
-                               return FALSE;
-                       }
-               }
-               // if OR and no field matched: return TRUE
-               // if AND and no field matched NOT: return FALSE
-               return ($isOr !== TRUE);
-       }
-
-       /**
-        * @param Form $form
-        * @param array $arguments
-        * @return array
-        */
-       public function apply(Form $form, array $arguments) {
-               if ($this->actions === self::ACTION_HIDE) {
-                       $action = self::ACTION_HIDE_STRING;
-               } elseif ($this->actions === self::ACTION_UN_HIDE) {
-                       $action = self::ACTION_UN_HIDE_STRING;
-               } else {
-                       return $arguments;
-               }
-               return $this->process($form, $arguments, $action);
-       }
-
-       /**
-        * @param Form $form
-        * @param array $arguments
-        * @return array
-        */
-       public function negate(Form $form, array $arguments) {
-               if ($this->actions === self::ACTION_HIDE) {
-                       $action = self::ACTION_UN_HIDE_STRING;
-               } elseif ($this->actions === self::ACTION_UN_HIDE) {
-                       $action = self::ACTION_HIDE_STRING;
-               } else {
-                       return $arguments;
-               }
-               return $this->process($form, $arguments, $action);
-       }
-
-       /**
-        * @param Form $form
-        * @param array $arguments
-        * @param string $action
-        * @return array
-        */
-       protected function process(Form $form, array $arguments, $action) {
-               if (strpos($this->targetField, 'fieldset') !== FALSE) {
-                       $targetPageUid = (int) substr($this->targetField, 9);
-               } else {
-                       $this->targetField = (int) $this->targetField;
-                       $targetPageUid = FALSE;
-               }
-
-               $formUid = $form->getUid();
-               /** @var Page $page */
-               foreach ($form->getPages() as $page) {
-                       $pageUid = $page->getUid();
-                       if ($targetPageUid && $pageUid === $targetPageUid) {
-                               return $this->applyOnPage($formUid, $page, $arguments, $action);
-                       } else {
-                               /** @var Field $field */
-                               foreach ($page->getFields() as $field) {
-                                       if ($field->getUid() === $this->targetField) {
-                                               return $this->applyOnField($formUid, $pageUid, $field, $arguments, $action);
-                                       }
-                               }
-                       }
-               }
-               return $arguments;
-       }
-
-       /**
-        * Show/Hide the Field if the Page is not hidden
-        *
-        * @param int $formUid
-        * @param int $pageUid
-        * @param Field $field
-        * @param array $arguments
-        * @param string $action
-        * @param bool $weakRule A weak rule can not overrule a strong rule
-        *        (e.g. a page get's shown [=weak] but another rule hides the field [=strong])
-        * @return array
-        */
-       protected function applyOnField($formUid, $pageUid, Field $field, array $arguments, $action, $weakRule = FALSE) {
-               // IF there's an action set for the containing page
-               if (!empty($arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION])) {
-                       $pageAction = $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION];
-                       if ($pageAction === self::ACTION_HIDE_STRING) {
-                               // IF the condition tries to show a field on a hidden page prevent it
-                               if ($action === self::ACTION_UN_HIDE) {
-                                       return $arguments;
-                               }
-                       }
-               }
-               $fieldMarker = $field->getMarker();
-               $conditionUid = $this->getUid();
-               if (!empty($arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION])) {
-                       if ($weakRule && $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION] !== $action) {
-                               return $arguments;
-                       }
-               }
-               $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION] = $action;
-               $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_MATCHING_CONDITION][$conditionUid] =
-                       $conditionUid;
-
-               // Backup field value if field gets hidden
-               if ($action === self::ACTION_HIDE_STRING) {
-                       $arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker] = $field->getText();
-                       $field->setText('');
-               } else {
-                       // fill field with backup'd value if field gets enabled again
-                       if ($action === self::ACTION_UN_HIDE_STRING) {
-                               if (isset($arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker])) {
-                                       $field->setText($arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker]);
-                               }
-                       }
-               }
-               return $arguments;
-       }
-
-       /**
-        * @param int $formUid
-        * @param Page $page
-        * @param array $arguments
-        * @param string $action
-        * @return array
-        */
-       protected function applyOnPage($formUid, Page $page, array $arguments, $action) {
-               $pageUid = $page->getUid();
-               foreach ($page->getFields() as $field) {
-                       $arguments =
-                               $this->applyOnField($formUid, $pageUid, $field, $arguments, $action, ($action === self::ACTION_UN_HIDE_STRING));
-               }
-               $conditionUid = $this->getUid();
-               $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION] = $action;
-               $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_MATCHING_CONDITION][$conditionUid] = $conditionUid;
-               return $arguments;
-       }
+class Condition extends AbstractEntity
+{
+
+    const CONJUNCTION_OR = 'OR';
+    const CONJUNCTION_AND = 'AND';
+    const ACTION_HIDE = 0;
+    const ACTION_UN_HIDE = 1;
+    const ACTION_HIDE_STRING = 'hide';
+    const ACTION_UN_HIDE_STRING = 'un_hide';
+    const INDEX_TODO = 'todo';
+    const INDEX_ACTION = '#action';
+    const INDEX_BACKUP = 'backup';
+    const INDEX_MATCHING_CONDITION = 'matching_condition';
+
+    /**
+     * @var \In2code\Powermail\Domain\Repository\FieldRepository
+     * @inject
+     */
+    protected $fieldRepository;
+
+    /**
+     * @var \In2code\Powermail\Domain\Repository\PageRepository
+     * @inject
+     */
+    protected $pageRepository;
+
+    /**
+     * @var string
+     */
+    protected $title = '';
+
+    /**
+     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\In2code\PowermailCond\Domain\Model\Rule>
+     */
+    protected $rules = null;
+
+    /**
+     * @var string
+     */
+    protected $targetField = '';
+
+    /**
+     * 0 hide
+     * 1 unhide
+     *
+     * @var int
+     */
+    protected $actions = 0;
+
+    /**
+     * @var string
+     */
+    protected $filterSelectField = '';
+
+    /**
+     * "OR"
+     * "AND"
+     *
+     * @var string
+     */
+    protected $conjunction = '';
+
+    /**
+     * @var \In2code\Powermail\Domain\Model\Form
+     */
+    protected $form = '';
+
+    /**
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * @param string $title
+     * @return Condition
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+        return $this;
+    }
+
+    /**
+     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
+     */
+    public function getRules()
+    {
+        return $this->rules;
+    }
+
+    /**
+     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $rules
+     * @return Condition
+     */
+    public function setRules($rules)
+    {
+        $this->rules = $rules;
+        return $this;
+    }
+
+    /**
+     * @return Field|Page|NULL
+     */
+    public function getTargetField()
+    {
+        $targetField = $this->targetField;
+        if (is_numeric($targetField)) {
+            return $this->fieldRepository->findByUid((int) $targetField);
+        }
+        if (stristr($targetField, 'fieldset:')) {
+            return $this->pageRepository->findByUid((int) trim($targetField, 'fieldset:'));
+        }
+        return null;
+    }
+
+    /**
+     * @param string $targetField
+     * @return Condition
+     */
+    public function setTargetField($targetField)
+    {
+        $this->targetField = $targetField;
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getActions()
+    {
+        return $this->actions;
+    }
+
+    /**
+     * @param int $actions
+     * @return Condition
+     */
+    public function setActions($actions)
+    {
+        $this->actions = $actions;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getFilterSelectField()
+    {
+        return $this->filterSelectField;
+    }
+
+    /**
+     * @param string $filterSelectField
+     * @return Condition
+     */
+    public function setFilterSelectField($filterSelectField)
+    {
+        $this->filterSelectField = $filterSelectField;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getConjunction()
+    {
+        return $this->conjunction;
+    }
+
+    /**
+     * @param string $conjunction
+     * @return Condition
+     */
+    public function setConjunction($conjunction)
+    {
+        $this->conjunction = $conjunction;
+        return $this;
+    }
+
+    /**
+     * @return Form
+     */
+    public function getForm()
+    {
+        return $this->form;
+    }
+
+    /**
+     * @param Form $form
+     * @return Condition
+     */
+    public function setForm($form)
+    {
+        $this->form = $form;
+        return $this;
+    }
+
+    /**
+     * @param Form $form
+     * @return bool
+     */
+    public function applies(Form $form)
+    {
+        // If conjunction is or set $isOr to TRUE
+        $isOr = ($this->conjunction === self::CONJUNCTION_OR);
+
+        /** @var Rule $rule */
+        foreach ($this->rules as $rule) {
+            if ($rule->applies($form)) {
+                if ($isOr === true) {
+
+                    // if it is the first matching rule in an OR conjunction return TRUE
+                    return true;
+                }
+            } elseif ($isOr === false) {
+
+                // if it is the first NOT matching rule in an AND conjunction return FALSE
+                return false;
+            }
+        }
+        // if OR and no field matched: return TRUE
+        // if AND and no field matched NOT: return FALSE
+        return ($isOr !== true);
+    }
+
+    /**
+     * @param Form $form
+     * @param array $arguments
+     * @return array
+     */
+    public function apply(Form $form, array $arguments)
+    {
+        if ($this->actions === self::ACTION_HIDE) {
+            $action = self::ACTION_HIDE_STRING;
+        } elseif ($this->actions === self::ACTION_UN_HIDE) {
+            $action = self::ACTION_UN_HIDE_STRING;
+        } else {
+            return $arguments;
+        }
+        return $this->process($form, $arguments, $action);
+    }
+
+    /**
+     * @param Form $form
+     * @param array $arguments
+     * @return array
+     */
+    public function negate(Form $form, array $arguments)
+    {
+        if ($this->actions === self::ACTION_HIDE) {
+            $action = self::ACTION_UN_HIDE_STRING;
+        } elseif ($this->actions === self::ACTION_UN_HIDE) {
+            $action = self::ACTION_HIDE_STRING;
+        } else {
+            return $arguments;
+        }
+        return $this->process($form, $arguments, $action);
+    }
+
+    /**
+     * @param Form $form
+     * @param array $arguments
+     * @param string $action
+     * @return array
+     */
+    protected function process(Form $form, array $arguments, $action)
+    {
+        if (strpos($this->targetField, 'fieldset') !== false) {
+            $targetPageUid = (int) substr($this->targetField, 9);
+        } else {
+            $this->targetField = (int) $this->targetField;
+            $targetPageUid = false;
+        }
+
+        $formUid = $form->getUid();
+        /** @var Page $page */
+        foreach ($form->getPages() as $page) {
+            $pageUid = $page->getUid();
+            if ($targetPageUid && $pageUid === $targetPageUid) {
+                return $this->applyOnPage($formUid, $page, $arguments, $action);
+            } else {
+                /** @var Field $field */
+                foreach ($page->getFields() as $field) {
+                    if ($field->getUid() === $this->targetField) {
+                        return $this->applyOnField($formUid, $pageUid, $field, $arguments, $action);
+                    }
+                }
+            }
+        }
+        return $arguments;
+    }
+
+    /**
+     * Show/Hide the Field if the Page is not hidden
+     *
+     * @param int $formUid
+     * @param int $pageUid
+     * @param Field $field
+     * @param array $arguments
+     * @param string $action
+     * @param bool $weakRule A weak rule can not overrule a strong rule
+     *        (e.g. a page get's shown [=weak] but another rule hides the field [=strong])
+     * @return array
+     */
+    protected function applyOnField($formUid, $pageUid, Field $field, array $arguments, $action, $weakRule = false)
+    {
+        // IF there's an action set for the containing page
+        if (!empty($arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION])) {
+            $pageAction = $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION];
+            if ($pageAction === self::ACTION_HIDE_STRING) {
+                // IF the condition tries to show a field on a hidden page prevent it
+                if ($action === self::ACTION_UN_HIDE) {
+                    return $arguments;
+                }
+            }
+        }
+        $fieldMarker = $field->getMarker();
+        $conditionUid = $this->getUid();
+        if (!empty($arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION])) {
+            if (
+                $weakRule
+                && $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION] !== $action
+            ) {
+                return $arguments;
+            }
+        }
+        $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_ACTION] = $action;
+        $arguments[self::INDEX_TODO][$formUid][$pageUid][$fieldMarker][self::INDEX_MATCHING_CONDITION][$conditionUid] =
+            $conditionUid;
+
+        // Backup field value if field gets hidden
+        if ($action === self::ACTION_HIDE_STRING) {
+            $arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker] = $field->getText();
+            $field->setText('');
+        } else {
+            // fill field with backup'd value if field gets enabled again
+            if ($action === self::ACTION_UN_HIDE_STRING) {
+                if (isset($arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker])) {
+                    $field->setText($arguments[self::INDEX_BACKUP][$formUid][$pageUid][$fieldMarker]);
+                }
+            }
+        }
+        return $arguments;
+    }
+
+    /**
+     * @param int $formUid
+     * @param Page $page
+     * @param array $arguments
+     * @param string $action
+     * @return array
+     */
+    protected function applyOnPage($formUid, Page $page, array $arguments, $action)
+    {
+        $pageUid = $page->getUid();
+        foreach ($page->getFields() as $field) {
+            $arguments = $this->applyOnField(
+                $formUid,
+                $pageUid,
+                $field,
+                $arguments,
+                $action,
+                ($action === self::ACTION_UN_HIDE_STRING)
+            );
+        }
+        $conditionUid = $this->getUid();
+        $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_ACTION] = $action;
+        $arguments[self::INDEX_TODO][$formUid][$pageUid][self::INDEX_MATCHING_CONDITION][$conditionUid] = $conditionUid;
+        return $arguments;
+    }
 }
index 1321cf4..f823a8c 100644 (file)
@@ -35,65 +35,67 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
  *
  * @package powermail_cond
  * @license http://www.gnu.org/licenses/lgpl.html
- *                     GNU Lesser General Public License, version 3 or later
+ *            GNU Lesser General Public License, version 3 or later
  */
-class ConditionContainer extends AbstractEntity {
-
-       /**
-        * @var int
-        */
-       protected $loopCount = 0;
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\In2code\PowermailCond\Domain\Model\Condition>
-        */
-       protected $conditions = NULL;
-
-       /**
-        * @var bool
-        */
-       protected $somethingChanged = TRUE;
-
-       /**
-        * @param Form $form
-        * @param array $arguments
-        * @return Form
-        */
-       public function applyConditions(Form $form, array $arguments) {
-
-               // run this loop if any condition changed something
-               // but stop after 100 rounds to prevent infinite loops (built by editors)
-               while ($this->somethingChanged && $this->loopCount < 100) {
-
-                       $this->somethingChanged = FALSE;
-                       $this->loopCount++;
-
-                       // go through each condition
-                       foreach ($this->conditions as $condition) {
-
-                               // if the rules match on the form
-                               if ($condition->applies($form)) {
-
-                                       // then apply the changes the condition would make
-                                       $newArguments = $condition->apply($form, $arguments);
-                               } else {
-
-                                       // else "revert" the changes (un-hides previously hidden fields and vice versa)
-                                       $newArguments = $condition->negate($form, $arguments);
-                               }
-
-                               // If there were changes in the arguments (e.g. a field is now hidden)
-                               if ($newArguments !== $arguments) {
-                                       $this->somethingChanged = TRUE;
-                               }
-
-                               // set the arguments for the next iteration
-                               $arguments = $newArguments;
-                       }
-               }
-
-               // return the arguments with instructions for the JS in the frontend
-               $arguments['loops'] = $this->loopCount;
-               return $arguments;
-       }
+class ConditionContainer extends AbstractEntity
+{
+
+    /**
+     * @var int
+     */
+    protected $loopCount = 0;
+
+    /**
+     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\In2code\PowermailCond\Domain\Model\Condition>
+     */
+    protected $conditions = null;
+
+    /**
+     * @var bool
+     */
+    protected $somethingChanged = true;
+
+    /**
+     * @param Form $form
+     * @param array $arguments
+     * @return Form
+     */
+    public function applyConditions(Form $form, array $arguments)
+    {
+
+        // run this loop if any condition changed something
+        // but stop after 100 rounds to prevent infinite loops (built by editors)
+        while ($this->somethingChanged && $this->loopCount < 100) {
+
+            $this->somethingChanged = false;
+            $this->loopCount++;
+
+            // go through each condition
+            foreach ($this->conditions as $condition) {
+
+                // if the rules match on the form
+                if ($condition->applies($form)) {
+
+                    // then apply the changes the condition would make
+                    $newArguments = $condition->apply($form, $arguments);
+                } else {
+
+                    // else "revert" the changes (un-hides previously hidden fields and vice versa)
+                    $newArguments = $condition->negate($form, $arguments);
+                }
+
+                // If there were changes in the arguments (e.g. a field is now hidden)
+                if ($newArguments !== $arguments) {
+                    $this->somethingChanged = true;
+                }
+
+                // set the arguments for the next iteration
+                $arguments = $newArguments;
+            }
+        }
+
+        // return the arguments with instructions for the JS in the frontend
+        $arguments['loops'] = $this->loopCount;
+        return $arguments;
+    }
 }
index cda5453..f3bef68 100644 (file)
@@ -39,174 +39,186 @@ use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
  *
  * @package powermail_cond
  * @license http://www.gnu.org/licenses/lgpl.html
- *                     GNU Lesser General Public License, version 3 or later
+ *            GNU Lesser General Public License, version 3 or later
  */
-class Rule extends AbstractEntity {
-
-       const OPERATOR_IS_SET = 0;
-       const OPERATOR_NOT_IS_SET = 1;
-       const OPERATOR_CONTAINS_VALUE = 2;
-       const OPERATOR_NOT_CONTAINS_VALUE = 3;
-       const OPERATOR_IS = 4;
-       const OPERATOR_NOT_IS = 5;
-       const OPERATOR_GREATER_THAN = 6;
-       const OPERATOR_LESS_THAN = 7;
-       const OPERATOR_CONTAINS_VALUE_FROM_FIELD = 8;
-       const OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD = 9;
-
-       /**
-        * Internal title
-        *
-        * @var string
-        */
-       protected $title = '';
-
-       /**
-        * relation to start field
-        *
-        * @var \In2code\Powermail\Domain\Model\Field
-        */
-       protected $startField = '';
-
-       /**
-        * 0 is set
-        * 1 is not set
-        * 2 contains
-        * 3 contains not
-        * 4 is
-        * 5 is not
-        * 6 greater than
-        * 7 less than
-        * 8 contains value from field
-        * 9 contains not value from field
-        *
-        * @var int
-        */
-       protected $ops = 0;
-
-       /**
-        * @var string
-        */
-       protected $condString = '';
-
-       /**
-        * @var string
-        */
-       protected $equalField = '';
-
-       /**
-        * @return string
-        */
-       public function getTitle() {
-               return $this->title;
-       }
-
-       /**
-        * @param string $title
-        * @return Condition
-        */
-       public function setTitle($title) {
-               $this->title = $title;
-               return $this;
-       }
-
-       /**
-        * @return Field
-        */
-       public function getStartField() {
-               return $this->startField;
-       }
-
-       /**
-        * @param Field $startField
-        * @return Rule
-        */
-       public function setStartField($startField) {
-               $this->startField = $startField;
-               return $this;
-       }
-
-       /**
-        * @return int
-        */
-       public function getOps() {
-               return $this->ops;
-       }
-
-       /**
-        * @param int $ops
-        * @return Rule
-        */
-       public function setOps($ops) {
-               $this->ops = $ops;
-               return $this;
-       }
-
-       /**
-        * @return string
-        */
-       public function getCondString() {
-               return $this->condString;
-       }
-
-       /**
-        * @param string $condString
-        * @return Rule
-        */
-       public function setCondString($condString) {
-               $this->condString = $condString;
-               return $this;
-       }
-
-       /**
-        * @return string
-        */
-       public function getEqualField() {
-               return $this->equalField;
-       }
-
-       /**
-        * @param string $equalField
-        * @return Rule
-        */
-       public function setEqualField($equalField) {
-               $this->equalField = $equalField;
-               return $this;
-       }
-
-       /**
-        * @param Form $form
-        * @return bool
-        */
-       public function applies(Form $form) {
-               $equalField = NULL;
-               /** @var Page $page */
-               if (((int)$this->equalField) > 0 ) {
-                       foreach ($form->getPages() as $page) {
-                               /** @var Field $field */
-                               foreach ($page->getFields() as $field) {
-                                       if ($field->getUid() === (int) $this->equalField) {
-                                               $equalField = $field;
-                                               break;
-                                       }
-                               }
-                               if ($equalField !== NULL) {
-                                       break;
-                               }
-                       }
-               }
-               /** @var Page $page */
-               foreach ($form->getPages() as $page) {
-                       /** @var Field $field */
-                       foreach ($page->getFields() as $field) {
-                               if ($field === $this->startField) {
-                                       $comparison = new Comparison($this->ops);
-                                       if ($comparison->evaluate($field, $this->condString, $equalField)) {
-                                               return TRUE;
-                                       }
-                               }
-                       }
-               }
-               return FALSE;
-       }
+class Rule extends AbstractEntity
+{
+
+    const OPERATOR_IS_SET = 0;
+    const OPERATOR_NOT_IS_SET = 1;
+    const OPERATOR_CONTAINS_VALUE = 2;
+    const OPERATOR_NOT_CONTAINS_VALUE = 3;
+    const OPERATOR_IS = 4;
+    const OPERATOR_NOT_IS = 5;
+    const OPERATOR_GREATER_THAN = 6;
+    const OPERATOR_LESS_THAN = 7;
+    const OPERATOR_CONTAINS_VALUE_FROM_FIELD = 8;
+    const OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD = 9;
+
+    /**
+     * Internal title
+     *
+     * @var string
+     */
+    protected $title = '';
+
+    /**
+     * relation to start field
+     *
+     * @var \In2code\Powermail\Domain\Model\Field
+     */
+    protected $startField = '';
+
+    /**
+     * 0 is set
+     * 1 is not set
+     * 2 contains
+     * 3 contains not
+     * 4 is
+     * 5 is not
+     * 6 greater than
+     * 7 less than
+     * 8 contains value from field
+     * 9 contains not value from field
+     *
+     * @var int
+     */
+    protected $ops = 0;
+
+    /**
+     * @var string
+     */
+    protected $condString = '';
+
+    /**
+     * @var string
+     */
+    protected $equalField = '';
+
+    /**
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * @param string $title
+     * @return Condition
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+        return $this;
+    }
+
+    /**
+     * @return Field
+     */
+    public function getStartField()
+    {
+        return $this->startField;
+    }
+
+    /**
+     * @param Field $startField
+     * @return Rule
+     */
+    public function setStartField($startField)
+    {
+        $this->startField = $startField;
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getOps()
+    {
+        return $this->ops;
+    }
+
+    /**
+     * @param int $ops
+     * @return Rule
+     */
+    public function setOps($ops)
+    {
+        $this->ops = $ops;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getCondString()
+    {
+        return $this->condString;
+    }
+
+    /**
+     * @param string $condString
+     * @return Rule
+     */
+    public function setCondString($condString)
+    {
+        $this->condString = $condString;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getEqualField()
+    {
+        return $this->equalField;
+    }
+
+    /**
+     * @param string $equalField
+     * @return Rule
+     */
+    public function setEqualField($equalField)
+    {
+        $this->equalField = $equalField;
+        return $this;
+    }
+
+    /**
+     * @param Form $form
+     * @return bool
+     */
+    public function applies(Form $form)
+    {
+        $equalField = null;
+        /** @var Page $page */
+        if (((int) $this->equalField) > 0) {
+            foreach ($form->getPages() as $page) {
+                /** @var Field $field */
+                foreach ($page->getFields() as $field) {
+                    if ($field->getUid() === (int) $this->equalField) {
+                        $equalField = $field;
+                        break;
+                    }
+                }
+                if ($equalField !== null) {
+                    break;
+                }
+            }
+        }
+        /** @var Page $page */
+        foreach ($form->getPages() as $page) {
+            /** @var Field $field */
+            foreach ($page->getFields() as $field) {
+                if ($field === $this->startField) {
+                    $comparison = new Comparison($this->ops);
+                    if ($comparison->evaluate($field, $this->condString, $equalField)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
 }
index c4c1273..710483f 100644 (file)
@@ -37,18 +37,20 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
  * @license http://www.gnu.org/licenses/lgpl.html
  *            GNU Lesser General Public License, version 3 or later
  */
-class ConditionContainerRepository extends Repository {
+class ConditionContainerRepository extends Repository
+{
 
-       /**
-        * General settings
-        *
-        * @return void
-        */
-       public function initializeObject() {
-               /** @var Typo3QuerySettings $querySettings */
-               $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
-               $querySettings->setRespectStoragePage(FALSE);
-               $querySettings->setRespectSysLanguage(FALSE);
-               $this->setDefaultQuerySettings($querySettings);
-       }
+    /**
+     * General settings
+     *
+     * @return void
+     */
+    public function initializeObject()
+    {
+        /** @var Typo3QuerySettings $querySettings */
+        $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
+        $querySettings->setRespectStoragePage(false);
+        $querySettings->setRespectSysLanguage(false);
+        $this->setDefaultQuerySettings($querySettings);
+    }
 }
index 14d660a..4f2759a 100644 (file)
@@ -38,49 +38,55 @@ use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
 /**
  * Class ConditionAwareValidator
  */
-class ConditionAwareValidator extends InputValidator {
+class ConditionAwareValidator extends InputValidator
+{
 
-       /**
-        * Validate a single field
-        *
-        * @param Field $field
-        * @param mixed $value
-        * @return void
-        */
-       protected function isValidField(Field $field, $value) {
+    /**
+     * Validate a single field
+     *
+     * @param Field $field
+     * @param mixed $value
+     * @return void
+     */
+    protected function isValidField(Field $field, $value)
+    {
 
-               /** @var FrontendUserAuthentication $feUser */
-               $feUser = $GLOBALS['TSFE']->fe_user;
-               $arguments = $feUser->getSessionData('tx_powermail_cond');
-               $fieldMarker = $field->getMarker();
+        /** @var FrontendUserAuthentication $feUser */
+        $feUser = $GLOBALS['TSFE']->fe_user;
+        $arguments = $feUser->getSessionData('tx_powermail_cond');
+        $fieldMarker = $field->getMarker();
 
 
-               if (ConfigurationUtility::isReplaceIrreWithElementBrowserActive()) {
-                       $pages = $field->getPages();
-                       /** @var Form $form */
-                       foreach ($pages->getForms() as $form) {
-                               /** @var Page $page */
-                               foreach ($form->getPages() as $page) {
-                                       /** @var Field $field */
-                                       foreach ($page->getFields() as $field) {
-                                               if (!empty($arguments[$form->getUid()][$page->getUid()][$fieldMarker][Condition::INDEX_ACTION])) {
-                                                       if ($arguments[$form->getUid()][$page->getUid()][$fieldMarker][Condition::INDEX_ACTION] === Condition::ACTION_HIDE_STRING) {
-                                                               return;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               } else {
-                       $page = $field->getPages();
-                       $form = $page->getForms()->getUid();
-                       $page = $page->getUid();
-                       if (!empty($arguments[Condition::INDEX_TODO][$form][$page][$fieldMarker][Condition::INDEX_ACTION])) {
-                               if ($arguments[Condition::INDEX_TODO][$form][$page][$fieldMarker][Condition::INDEX_ACTION] === Condition::ACTION_HIDE_STRING) {
-                                       return;
-                               }
-                       }
-               }
-               parent::isValidField($field, $value);
-       }
+        if (ConfigurationUtility::isReplaceIrreWithElementBrowserActive()) {
+            $pages = $field->getPages();
+            /** @var Form $form */
+            foreach ($pages->getForms() as $form) {
+                /** @var Page $page */
+                foreach ($form->getPages() as $page) {
+                    /** @var Field $field */
+                    foreach ($page->getFields() as $field) {
+                        if (
+                            !empty($arguments[$form->getUid()][$page->getUid()][$fieldMarker][Condition::INDEX_ACTION])
+                        ) {
+                            if ($arguments[$form->getUid()][$page->getUid()][$fieldMarker][Condition::INDEX_ACTION] ===
+                                Condition::ACTION_HIDE_STRING) {
+                                return;
+                            }
+                        }
+                    }
+                }
+            }
+        } else {
+            $page = $field->getPages();
+            $form = $page->getForms()->getUid();
+            $page = $page->getUid();
+            if (!empty($arguments[Condition::INDEX_TODO][$form][$page][$fieldMarker][Condition::INDEX_ACTION])) {
+                if ($arguments[Condition::INDEX_TODO][$form][$page][$fieldMarker][Condition::INDEX_ACTION] ===
+                    Condition::ACTION_HIDE_STRING) {
+                    return;
+                }
+            }
+        }
+        parent::isValidField($field, $value);
+    }
 }
index 0ac4bbf..26b280e 100644 (file)
@@ -37,243 +37,260 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
  *
  * @package powermail_cond
  * @license http://www.gnu.org/licenses/lgpl.html
- *                     GNU Lesser General Public License, version 3 or later
+ *            GNU Lesser General Public License, version 3 or later
  */
-class GetPowermailFields {
+class GetPowermailFields
+{
 
-       /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $databaseConnection = NULL;
+    /**
+     * @var \TYPO3\CMS\Core\Database\DatabaseConnection
+     */
+    protected $databaseConnection = null;
 
-       /**
-        * @var array
-        */
-       protected $params = array();
+    /**
+     * @var array
+     */
+    protected $params = [];
 
-       /**
-        * @var int
-        */
-       protected $formUid = 0;
+    /**
+     * @var int
+     */
+    protected $formUid = 0;
 
-       /**
-        * @var array
-        */
-       protected $defaultFieldTypes = array(
-               'input',
-               'textarea',
-               'select',
-               'radio',
-               'check'
-       );
+    /**
+     * @var array
+     */
+    protected $defaultFieldTypes = [
+        'input',
+        'textarea',
+        'select',
+        'radio',
+        'check'
+    ];
 
-       /**
-        * show all fields in the backend
-        *
-        * @param array $params
-        * @return void
-        */
-       public function getFields(array &$params) {
-               $this->initialize($params);
-               $this->addFieldsToParams();
-               $this->addFieldsetsToParams();
-       }
+    /**
+     * show all fields in the backend
+     *
+     * @param array $params
+     * @return void
+     */
+    public function getFields(array &$params)
+    {
+        $this->initialize($params);
+        $this->addFieldsToParams();
+        $this->addFieldsetsToParams();
+    }
 
-       /**
-        * Add fields to params array
-        *
-        * @return void
-        */
-       protected function addFieldsToParams() {
-               $fields = $this->getFieldsFromForm();
-               $this->params['items'][] = array('powermail Fields', '--div--');
-               foreach ($fields as $properties) {
-                       $this->params['items'][] = array(
-                               $this->getLabelFromFieldProperties($properties),
-                               $properties['uid']
-                       );
-               }
-       }
+    /**
+     * Add fields to params array
+     *
+     * @return void
+     */
+    protected function addFieldsToParams()
+    {
+        $fields = $this->getFieldsFromForm();
+        $this->params['items'][] = [
+            'powermail Fields',
+            '--div--'
+        ];
+        foreach ($fields as $properties) {
+            $this->params['items'][] = [
+                $this->getLabelFromFieldProperties($properties),
+                $properties['uid']
+            ];
+        }
+    }
 
-       /**
-        * Add fieldsets to Params
-        *
-        * @return void
-        */
-       protected function addFieldsetsToParams() {
-               if (empty($this->params['config']['itemsProcFunc_addFieldsets'])) {
-                       return;
-               }
-               $fieldsets = $this->getFieldsetsFromForm();
-               $this->params['items'][] = array('powermail Fieldsets', '--div--');
-               foreach ($fieldsets as $properties) {
-                       $this->params['items'][] = array(
-                               $properties['title'] . ' (' . $properties['uid'] . ')',
-                               'fieldset:' . $properties['uid']
-                       );
-               }
-       }
+    /**
+     * Add fieldsets to Params
+     *
+     * @return void
+     */
+    protected function addFieldsetsToParams()
+    {
+        if (!empty($this->params['config']['itemsProcFunc_addFieldsets'])) {
+            $fieldsets = $this->getFieldsetsFromForm();
+            $this->params['items'][] = [
+                'powermail Fieldsets',
+                '--div--'
+            ];
+            foreach ($fieldsets as $properties) {
+                $this->params['items'][] = [
+                    $properties['title'] . ' (' . $properties['uid'] . ')',
+                    'fieldset:' . $properties['uid']
+                ];
+            }
+        }
+    }
 
-       /**
-        * Get fields
-        *
-        * @return array
-        */
-       protected function getFieldsFromForm() {
-               $fields = array();
-               $select = 'f.uid, f.title, f.marker';
-               $from = '
-                       tx_powermail_domain_model_fields f
-                       left join tx_powermail_domain_model_pages p on f.pages = p.uid
-                       left join tx_powermail_domain_model_forms fo on p.forms = fo.uid
-               ';
-               $where = 'f.hidden = 0 and f.deleted = 0 and f.type in (' . $this->getDefaultFieldTypesForQuery() . ')';
-               if ($this->getFormUid() > 0) {
-                       $where .= ' and fo.uid = ' . $this->getFormUid();
-               }
-               $groupBy = '';
-               $orderBy = 'f.sorting';
-               $limit = 10000;
-               $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
-               if ($res) {
-                       while (($row = $this->databaseConnection->sql_fetch_assoc($res))) {
-                               $fields[] = $row;
-                       }
-               }
-               return $fields;
-       }
+    /**
+     * Get fields
+     *
+     * @return array
+     */
+    protected function getFieldsFromForm()
+    {
+        $fields = [];
+        $select = 'f.uid, f.title, f.marker';
+        $from = 'tx_powermail_domain_model_fields f ' .
+            'left join tx_powermail_domain_model_pages p on f.pages = p.uid ' .
+            'left join tx_powermail_domain_model_forms fo on p.forms = fo.uid';
+        $where = 'f.hidden = 0 and f.deleted = 0 and f.type in (' . $this->getDefaultFieldTypesForQuery() . ')';
+        if ($this->getFormUid() > 0) {
+            $where .= ' and fo.uid = ' . $this->getFormUid();
+        }
+        $groupBy = '';
+        $orderBy = 'f.sorting';
+        $limit = 10000;
+        $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
+        if ($res) {
+            while (($row = $this->databaseConnection->sql_fetch_assoc($res))) {
+                $fields[] = $row;
+            }
+        }
+        return $fields;
+    }
 
-       /**
-        * give me all fieldsets in an array
-        *
-        * @return array
-        */
-       protected function getFieldsetsFromForm() {
-               $fieldsets = array();
-               $select = 'uid, title';
-               $from = 'tx_powermail_domain_model_pages';
-               $where = 'forms = ' . $this->getFormUid() . ' AND hidden = 0 AND deleted = 0';
-               $groupBy = '';
-               $orderBy = 'sorting';
-               $limit = '';
-               $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
-               if ($res) {
-                       while (($row = $this->databaseConnection->sql_fetch_assoc($res))) {
-                               $fieldsets[] = $row;
-                       }
-               }
-               return $fieldsets;
-       }
+    /**
+     * give me all fieldsets in an array
+     *
+     * @return array
+     */
+    protected function getFieldsetsFromForm()
+    {
+        $fieldsets = [];
+        $select = 'uid, title';
+        $from = 'tx_powermail_domain_model_pages';
+        $where = 'forms = ' . $this->getFormUid() . ' AND hidden = 0 AND deleted = 0';
+        $groupBy = '';
+        $orderBy = 'sorting';
+        $limit = '';
+        $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
+        if ($res) {
+            while (($row = $this->databaseConnection->sql_fetch_assoc($res))) {
+                $fieldsets[] = $row;
+            }
+        }
+        return $fieldsets;
+    }
 
-       /**
-        * Get Form Uid from Rule
-        *
-        * @param int $conditionUid
-        * @return int formUid
-        */
-       protected function getFormUidFromCondition($conditionUid) {
-               $select = 'cc.form';
-               $from = 'tx_powermailcond_domain_model_conditioncontainer cc
-                       left join tx_powermailcond_domain_model_condition c on cc.uid = c.conditioncontainer';
-               $where = 'c.uid = ' . (int) $conditionUid . ' AND c.hidden = 0 AND c.deleted = 0';
-               $groupBy = '';
-               $orderBy = '';
-               $limit = 1;
-               $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
-               if ($res) {
-                       $row = $this->databaseConnection->sql_fetch_assoc($res);
-                       return (int) $row['form'];
-               }
-               return 0;
-       }
+    /**
+     * Get Form Uid from Rule
+     *
+     * @param int $conditionUid
+     * @return int formUid
+     */
+    protected function getFormUidFromCondition($conditionUid)
+    {
+        $select = 'cc.form';
+        $from = 'tx_powermailcond_domain_model_conditioncontainer cc ' .
+            'left join tx_powermailcond_domain_model_condition c on cc.uid = c.conditioncontainer';
+        $where = 'c.uid = ' . (int) $conditionUid . ' AND c.hidden = 0 AND c.deleted = 0';
+        $groupBy = '';
+        $orderBy = '';
+        $limit = 1;
+        $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
+        if ($res) {
+            $row = $this->databaseConnection->sql_fetch_assoc($res);
+            return (int) $row['form'];
+        }
+        return 0;
+    }
 
-       /**
-        * Get Form Uid from Condition Container
-        *
-        * @param int $conditionContainerUid
-        * @return int formUid
-        */
-       protected function getFormUidFromConditionContainer($conditionContainerUid) {
-               $select = 'cc.form';
-               $from = 'tx_powermailcond_domain_model_conditioncontainer cc';
-               $where = 'cc.uid = ' . (int) $conditionContainerUid . ' AND cc.hidden = 0 AND cc.deleted = 0';
-               $groupBy = '';
-               $orderBy = '';
-               $limit = 1;
-               $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
-               if ($res) {
-                       $row = $this->databaseConnection->sql_fetch_assoc($res);
-                       return (int) $row['form'];
-               }
-               return 0;
-       }
+    /**
+     * Get Form Uid from Condition Container
+     *
+     * @param int $conditionContainerUid
+     * @return int formUid
+     */
+    protected function getFormUidFromConditionContainer($conditionContainerUid)
+    {
+        $select = 'cc.form';
+        $from = 'tx_powermailcond_domain_model_conditioncontainer cc';
+        $where = 'cc.uid = ' . (int) $conditionContainerUid . ' AND cc.hidden = 0 AND cc.deleted = 0';
+        $groupBy = '';
+        $orderBy = '';
+        $limit = 1;
+        $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
+        if ($res) {
+            $row = $this->databaseConnection->sql_fetch_assoc($res);
+            return (int) $row['form'];
+        }
+        return 0;
+    }
 
-       /**
-        * Build a label
-        *
-        * @param array $properties
-        * @return string
-        */
-       protected function getLabelFromFieldProperties(array $properties) {
-               return $properties['title'] . ', {' . $properties['marker'] . '}, uid' . $properties['uid'];
-       }
+    /**
+     * Build a label
+     *
+     * @param array $properties
+     * @return string
+     */
+    protected function getLabelFromFieldProperties(array $properties)
+    {
+        return $properties['title'] . ', {' . $properties['marker'] . '}, uid' . $properties['uid'];
+    }
 
-       /**
-        * @param array $params
-        * @return void
-        */
-       protected function initialize(array &$params) {
-               $this->databaseConnection = $GLOBALS['TYPO3_DB'];
-               $this->params = &$params;
-               $this
-                       ->setFormUid()
-                       ->setDefaultFieldTypes();
-       }
+    /**
+     * @param array $params
+     * @return void
+     */
+    protected function initialize(array &$params)
+    {
+        $this->databaseConnection = $GLOBALS['TYPO3_DB'];
+        $this->params = &$params;
+        $this->setFormUid()->setDefaultFieldTypes();
+    }
 
-       /**
-        * @return GetPowermailFields
-        */
-       public function setFormUid() {
-               $formUid = (int) $this->params['row']['form'];
-               if ($formUid === 0) {
-                       $formUid = $this->getFormUidFromConditionContainer((int) $this->params['row']['conditioncontainer']);
-               }
-               if (!empty($this->params['row']['conditions'])) {
-                       $formUid = $this->getFormUidFromCondition($this->params['row']['conditions']);
-               }
-               $this->formUid = $formUid;
-               return $this;
-       }
+    /**
+     * @return GetPowermailFields
+     */
+    public function setFormUid()
+    {
+        $formUid = (int) $this->params['row']['form'];
+        if ($formUid === 0) {
+            $formUid = $this->getFormUidFromConditionContainer((int) $this->params['row']['conditioncontainer']);
+        }
+        if (!empty($this->params['row']['conditions'])) {
+            $formUid = $this->getFormUidFromCondition($this->params['row']['conditions']);
+        }
+        $this->formUid = $formUid;
+        return $this;
+    }
 
-       /**
-        * @return int
-        */
-       public function getFormUid() {
-               return $this->formUid;
-       }
+    /**
+     * @return int
+     */
+    public function getFormUid()
+    {
+        return $this->formUid;
+    }
 
-       /**
-        * @return GetPowermailFields
-        */
-       public function setDefaultFieldTypes() {
-               if (!empty($this->params['config']['itemsProcFuncValue'])) {
-                       $this->defaultFieldTypes = GeneralUtility::trimExplode(',', $this->params['config']['itemsProcFuncValue'], TRUE);
-               }
-               return $this;
-       }
+    /**
+     * @return GetPowermailFields
+     */
+    public function setDefaultFieldTypes()
+    {
+        if (!empty($this->params['config']['itemsProcFuncValue'])) {
+            $this->defaultFieldTypes =
+                GeneralUtility::trimExplode(',', $this->params['config']['itemsProcFuncValue'], true);
+        }
+        return $this;
+    }
 
-       /**
-        * @return array
-        */
-       public function getDefaultFieldTypes() {
-               return $this->defaultFieldTypes;
-       }
+    /**
+     * @return array
+     */
+    public function getDefaultFieldTypes()
+    {
+        return $this->defaultFieldTypes;
+    }
 
-       /**
-        * @return string
-        */
-       public function getDefaultFieldTypesForQuery() {
-               $fieldTypes = $this->getDefaultFieldTypes();
-               return ArrayUtility::getQuotedList($fieldTypes);
-       }
+    /**
+     * @return string
+     */
+    public function getDefaultFieldTypesForQuery()
+    {
+        $fieldTypes = $this->getDefaultFieldTypes();
+        return ArrayUtility::getQuotedList($fieldTypes);
+    }
 }
index 68536d7..a3fed6f 100644 (file)
@@ -34,64 +34,68 @@ use TYPO3\CMS\Backend\Form\FormEngine;
  *
  * @package powermail_cond
  * @license http://www.gnu.org/licenses/lgpl.html
- *                     GNU Lesser General Public License, version 3 or later
+ *            GNU Lesser General Public License, version 3 or later
  */
-class GetPowermailFormsWithoutConditionRelation {
+class GetPowermailFormsWithoutConditionRelation
+{
 
-       /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $databaseConnection = NULL;
+    /**
+     * @var \TYPO3\CMS\Core\Database\DatabaseConnection
+     */
+    protected $databaseConnection = null;
 
-       /**
-        * @var array
-        */
-       protected $params = array();
+    /**
+     * @var array
+     */
+    protected $params = [];
 
-       /**
-        * @var int
-        */
-       protected $currentFormUid = 0;
+    /**
+     * @var int
+     */
+    protected $currentFormUid = 0;
 
-       /**
-        * remove forms that are already related to a condition container
-        *
-        * @param array $params
-        * @return void
-        */
-       public function filterForms(array &$params) {
-               $this->initialize($params);
-               foreach ((array) $this->params['items'] as $key => $form) {
-                       if ($this->hasFormRelatedConditionContainers((int) $form[1]) && (int) $form[1] !== $this->currentFormUid) {
-                               unset($this->params['items'][$key]);
-                       }
-               }
-       }
+    /**
+     * remove forms that are already related to a condition container
+     *
+     * @param array $params
+     * @return void
+     */
+    public function filterForms(array &$params)
+    {
+        $this->initialize($params);
+        foreach ((array) $this->params['items'] as $key => $form) {
+            if ($this->hasFormRelatedConditionContainers((int) $form[1]) && (int) $form[1] !== $this->currentFormUid) {
+                unset($this->params['items'][$key]);
+            }
+        }
+    }
 
-       /**
-        * @param int $formUid
-        * @return bool
-        */
-       protected function hasFormRelatedConditionContainers($formUid) {
-               $select = 'cc.uid';
-               $from = 'tx_powermailcond_domain_model_conditioncontainer cc';
-               $where = 'cc.form = ' . (int) $formUid . ' and cc.deleted = 0';
-               $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where);
-               if ($res) {
-                       while (($row = $this->databaseConnection->sql_fetch_assoc($res))) {
-                               return TRUE;
-                       }
-               }
-               return FALSE;
-       }
+    /**
+     * @param int $formUid
+     * @return bool
+     */
+    protected function hasFormRelatedConditionContainers($formUid)
+    {
+        $select = 'cc.uid';
+        $from = 'tx_powermailcond_domain_model_conditioncontainer cc';
+        $where = 'cc.form = ' . (int) $formUid . ' and cc.deleted = 0';
+        $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where);
+        if ($res) {
+            while ($this->databaseConnection->sql_fetch_assoc($res)) {
+                return true;
+            }
+        }
+        return false;
+    }
 
-       /**
-        * @param array $params
-        * @return void
-        */
-       protected function initialize(array &$params) {
-               $this->databaseConnection = $GLOBALS['TYPO3_DB'];
-               $this->params = &$params;
-               $this->currentFormUid = (int) $this->params['row']['form'];
-       }
+    /**
+     * @param array $params
+     * @return void
+     */
+    protected function initialize(array &$params)
+    {
+        $this->databaseConnection = $GLOBALS['TYPO3_DB'];
+        $this->params = &$params;
+        $this->currentFormUid = (int) $this->params['row']['form'];
+    }
 }
index f0e6e17..f538ef4 100644 (file)
@@ -34,19 +34,21 @@ use TYPO3\CMS\Extbase\Utility\ArrayUtility as ArrayUtilityExtbase;
  *
  * @package In2code\In2publish\Utility
  */
-class ArrayUtility extends ArrayUtilityExtbase {
+class ArrayUtility extends ArrayUtilityExtbase
+{
 
-       /**
-        * Get quoted list from array
-        *
-        * @param array $array
-        * @return array
-        */
-       public static function getQuotedList(array $array) {
-               $list = '';
-               foreach ($array as $value) {
-                       $list .= '"' . $value . '",';
-               }
-               return trim($list, ',');
-       }
+    /**
+     * Get quoted list from array
+     *
+     * @param array $array
+     * @return array
+     */
+    public static function getQuotedList(array $array)
+    {
+        $list = '';
+        foreach ($array as $value) {
+            $list .= '"' . $value . '",';
+        }
+        return trim($list, ',');
+    }
 }
index d12b4d6..7e1bdf9 100644 (file)
 <?php
 use In2code\PowermailCond\Utility\ConfigurationUtility;
 
-return array(
-       'ctrl' => array(
-               'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions',
-               'label' => 'title',
-               'tstamp' => 'tstamp',
-               'crdate' => 'crdate',
-               'cruser_id' => 'cruser_id',
-               'languageField' => 'sys_language_uid',
-               'sortby' => 'sorting',
-               'delete' => 'deleted',
-               'enablecolumns' => array(
-                       'disabled' => 'hidden',
-                       'starttime' => 'starttime',
-                       'endtime' => 'endtime',
-               ),
-               'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_conditions.gif')
-       ),
-       'interface' => array(
-               'showRecordFieldList' => 'sys_language_uid,l18n_parent,l18n_diffsource,hidden,starttime,
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'languageField' => 'sys_language_uid',
+        'sortby' => 'sorting',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden',
+            'starttime' => 'starttime',
+            'endtime' => 'endtime',
+        ],
+        'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_conditions.gif')
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'sys_language_uid,l18n_parent,l18n_diffsource,hidden,starttime,
                        endtime,conditioncontainer,title,target_field,actions,filter_select_field,rules,conjunction',
-       ),
-       'types' => array(
-               '1' => array('showitem' => 'conditioncontainer, title, target_field, actions, filter_select_field, conjunction, rules'),
-       ),
-       'palettes' => array(
-               '1' => array(),
-       ),
-       'columns' => array(
-               'sys_language_uid' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'foreign_table' => 'sys_language',
-                               'foreign_table_where' => 'ORDER BY sys_language.title',
-                               'items' => array(
-                                       array('LLL:EXT:lang/locallang_general.xml:LGL.allLanguages', -1),
-                                       array('LLL:EXT:lang/locallang_general.xml:LGL.default_value', 0)
-                               ),
-                       ),
-               ),
-               'l18n_parent' => array (
-                       'displayCond' => 'FIELD:sys_language_uid:>:0',
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
-                       'config' => array (
-                               'type'  => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array (
-                                       array('', 0),
-                               ),
-                               'foreign_table' => 'tx_powermailcond_conditions',
-                               'foreign_table_where' =>
-                                       'AND tx_powermailcond_conditions.pid=###CURRENT_PID### AND tx_powermailcond_conditions.sys_language_uid IN (-1,0)',
-                       )
-               ),
-               'l18n_diffsource' => array (
-                       'config' => array (
-                               'type' => 'passthrough'
-                       )
-               ),
-               'hidden' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
-                       'config' => array(
-                               'type' => 'check',
-                       ),
-               ),
-               'starttime' => array(
-                       'exclude' => 1,
-                       'l10n_mode' => 'mergeIfNotBlank',
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => 13,
-                               'max' => 20,
-                               'eval' => 'datetime',
-                               'checkbox' => 0,
-                               'default' => 0,
-                               'range' => array(
-                                       'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
-                               ),
-                       ),
-               ),
-               'endtime' => array(
-                       'exclude' => 1,
-                       'l10n_mode' => 'mergeIfNotBlank',
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => 13,
-                               'max' => 20,
-                               'eval' => 'datetime',
-                               'checkbox' => 0,
-                               'default' => 0,
-                               'range' => array(
-                                       'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
-                               ),
-                       ),
-               ),
-               'title' => Array (
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.title',
-                       'config' => Array (
-                               'type' => 'input',
-                               'size' => '30',
-                       )
-               ),
-               'rules' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.rules',
-                       'config' => array(
-                               'type' => 'inline',
-                               'foreign_table' => 'tx_powermailcond_domain_model_rule',
-                               'foreign_table_where' =>
-                                       'AND tx_powermailcond_domain_model_rule.pid=###CURRENT_PID### ORDER BY tx_powermailcond_domain_model_rule.sorting',
-                               'foreign_field' => 'conditions',
-                               'maxitems' => 99,
-                               'appearance' => array(
-                                       'collapseAll' => 1,
-                                       'expandSingle' => 1,
-                                       'useSortable' => 1,
-                                       'newRecordLinkAddTitle' => 1,
-                                       'newRecordLinkPosition' => 'both',
-                               ),
-                       ),
-               ),
-               'conjunction' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.conjunction',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       // OR
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.conjunction.I.1',
-                                               \In2code\PowermailCond\Domain\Model\Condition::CONJUNCTION_OR
-                                       ),
-
-                                       // AND
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.conjunction.I.0',
-                                               \In2code\PowermailCond\Domain\Model\Condition::CONJUNCTION_AND
-                                       ),
-                               ),
-                               'size' => 1,
-                               'maxitems' => 1,
-                       ),
-               ),
-               'target_field' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.targetField',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.targetField.I.0',
-                                               '0'
-                                       ),
-                               ),
-                               'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
-                               'itemsProcFunc_addFieldsets' => TRUE,
-                               'size' => 1,
-                               'maxitems' => 1,
-                               'eval' => 'required'
-                       ),
-               ),
-               'actions' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.action',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       // title main
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.action.I.main',
-                                               '--div--'
-                                       ),
-
-                                       // hide
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.action.I.0',
-                                               \In2code\PowermailCond\Domain\Model\Condition::ACTION_HIDE
-                                       ),
-
-                                       // unhide
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.action.I.1',
-                                               \In2code\PowermailCond\Domain\Model\Condition::ACTION_UN_HIDE
-                                       ),
-
-                                       // title additional
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.action.I.additional',
-                                               '--div--'
-                                       ),
-                               ),
-                               'size' => 1,
-                               'maxitems' => 1,
-                       ),
-               ),
-               'conditioncontainer' => array(
-                       'l10n_mode' => 'noCopy',
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.conditioncontainer',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array(
-                                               '',
-                                               0
-                                       ),
-                               ),
-                               'foreign_table' => 'tx_powermailcond_domain_model_conditioncontainer',
-                               'foreign_table_where' =>
-                                       'AND tx_powermailcond_domain_model_conditioncontainer.pid=###CURRENT_PID###
-                                       AND tx_powermailcond_domain_model_conditioncontainer.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)',
-                       ),
-               ),
-       ),
-);
+    ],
+    'types' => [
+        '1' => ['showitem' =>
+            'conditioncontainer, title, target_field, actions, filter_select_field, conjunction, rules'],
+    ],
+    'palettes' => [
+        '1' => [],
+    ],
+    'columns' => [
+        'sys_language_uid' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'foreign_table' => 'sys_language',
+                'foreign_table_where' => 'ORDER BY sys_language.title',
+                'items' => [
+                    [
+                        'LLL:EXT:lang/locallang_general.xml:LGL.allLanguages',
+                        -1
+                    ],
+                    [
+                        'LLL:EXT:lang/locallang_general.xml:LGL.default_value',
+                        0
+                    ]
+                ],
+            ],
+        ],
+        'l18n_parent' => [
+            'displayCond' => 'FIELD:sys_language_uid:>:0',
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        '',
+                        0
+                    ],
+                ],
+                'foreign_table' => 'tx_powermailcond_conditions',
+                'foreign_table_where' => 'AND tx_powermailcond_conditions.pid=###CURRENT_PID### AND ' .
+                    'tx_powermailcond_conditions.sys_language_uid IN (-1,0)',
+            ]
+        ],
+        'l18n_diffsource' => [
+            'config' => [
+                'type' => 'passthrough'
+            ]
+        ],
+        'hidden' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+            'config' => [
+                'type' => 'check',
+            ],
+        ],
+        'starttime' => [
+            'exclude' => 1,
+            'l10n_mode' => 'mergeIfNotBlank',
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
+            'config' => [
+                'type' => 'input',
+                'size' => 13,
+                'max' => 20,
+                'eval' => 'datetime',
+                'checkbox' => 0,
+                'default' => 0,
+                'range' => [
+                    'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+                ],
+            ],
+        ],
+        'endtime' => [
+            'exclude' => 1,
+            'l10n_mode' => 'mergeIfNotBlank',
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
+            'config' => [
+                'type' => 'input',
+                'size' => 13,
+                'max' => 20,
+                'eval' => 'datetime',
+                'checkbox' => 0,
+                'default' => 0,
+                'range' => [
+                    'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+                ],
+            ],
+        ],
+        'title' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.title',
+            'config' => [
+                'type' => 'input',
+                'size' => '30',
+            ]
+        ],
+        'rules' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.rules',
+            'config' => [
+                'type' => 'inline',
+                'foreign_table' => 'tx_powermailcond_domain_model_rule',
+                'foreign_table_where' => 'AND tx_powermailcond_domain_model_rule.pid=###CURRENT_PID### ' .
+                    'ORDER BY tx_powermailcond_domain_model_rule.sorting',
+                'foreign_field' => 'conditions',
+                'maxitems' => 99,
+                'appearance' => [
+                    'collapseAll' => 1,
+                    'expandSingle' => 1,
+                    'useSortable' => 1,
+                    'newRecordLinkAddTitle' => 1,
+                    'newRecordLinkPosition' => 'both',
+                ],
+            ],
+        ],
+        'conjunction' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.conjunction',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    // OR
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.conjunction.I.1',
+                        \In2code\PowermailCond\Domain\Model\Condition::CONJUNCTION_OR
+                    ],
+                    // AND
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.conjunction.I.0',
+                        \In2code\PowermailCond\Domain\Model\Condition::CONJUNCTION_AND
+                    ],
+                ],
+                'size' => 1,
+                'maxitems' => 1,
+            ],
+        ],
+        'target_field' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.targetField',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.targetField.I.0',
+                        '0'
+                    ],
+                ],
+                'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
+                'itemsProcFunc_addFieldsets' => true,
+                'size' => 1,
+                'maxitems' => 1,
+                'eval' => 'required'
+            ],
+        ],
+        'actions' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.action',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    // title main
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.action.I.main',
+                        '--div--'
+                    ],
+                    // hide
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.action.I.0',
+                        \In2code\PowermailCond\Domain\Model\Condition::ACTION_HIDE
+                    ],
+                    // unhide
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.action.I.1',
+                        \In2code\PowermailCond\Domain\Model\Condition::ACTION_UN_HIDE
+                    ],
+                    // title additional
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditions.action.I.additional',
+                        '--div--'
+                    ],
+                ],
+                'size' => 1,
+                'maxitems' => 1,
+            ],
+        ],
+        'conditioncontainer' => [
+            'l10n_mode' => 'noCopy',
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditions.conditioncontainer',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        '',
+                        0
+                    ],
+                ],
+                'foreign_table' => 'tx_powermailcond_domain_model_conditioncontainer',
+                'foreign_table_where' => 'AND tx_powermailcond_domain_model_conditioncontainer.pid=###CURRENT_PID### ' .
+                    'AND tx_powermailcond_domain_model_conditioncontainer.sys_language_uid IN ' .
+                    '(-1,###REC_FIELD_sys_language_uid###)',
+            ],
+        ],
+    ],
+];
index 2d9b6b0..2a37112 100644 (file)
 <?php
 use In2code\PowermailCond\Utility\ConfigurationUtility;
 
-return array(
-       'ctrl' => array(
-               'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditioncontainer',
-               'label' => 'title',
-               'tstamp' => 'tstamp',
-               'crdate' => 'crdate',
-               'cruser_id' => 'cruser_id',
-               'languageField' => 'sys_language_uid',
-               'sortby' => 'sorting',
-               'delete' => 'deleted',
-               'enablecolumns' => array(
-                       'disabled' => 'hidden',
-                       'starttime' => 'starttime',
-                       'endtime' => 'endtime',
-               ),
-               'requestUpdate' => 'form',
-               'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_conditions.gif')
-       ),
-       'interface' => array(
-               'showRecordFieldList' => 'sys_language_uid,l18n_parent,l18n_diffsource,hidden,starttime,
-                       endtime,title,form,conditions',
-       ),
-       'types' => array(
-               '1' => array('showitem' => 'title, form, conditions'),
-       ),
-       'palettes' => array(
-               '1' => array(),
-       ),
-       'columns' => array(
-               'sys_language_uid' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'foreign_table' => 'sys_language',
-                               'foreign_table_where' => 'ORDER BY sys_language.title',
-                               'items' => array(
-                                       array('LLL:EXT:lang/locallang_general.xml:LGL.allLanguages', -1),
-                                       array('LLL:EXT:lang/locallang_general.xml:LGL.default_value', 0)
-                               ),
-                       ),
-               ),
-               'l18n_parent' => array (
-                       'displayCond' => 'FIELD:sys_language_uid:>:0',
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
-                       'config' => array (
-                               'type'  => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array (
-                                       array('', 0),
-                               ),
-                               'foreign_table' => 'tx_powermailcond_conditioncontainer',
-                               'foreign_table_where' => 'AND tx_powermailcond_conditioncontainer.pid=###CURRENT_PID### AND ' .
-                                       'tx_powermailcond_conditioncontainer.sys_language_uid IN (-1,0)',
-                       )
-               ),
-               'l18n_diffsource' => array (
-                       'config' => array (
-                               'type' => 'passthrough'
-                       )
-               ),
-               'hidden' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
-                       'config' => array(
-                               'type' => 'check',
-                       ),
-               ),
-               'starttime' => array(
-                       'exclude' => 1,
-                       'l10n_mode' => 'mergeIfNotBlank',
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => 13,
-                               'max' => 20,
-                               'eval' => 'datetime',
-                               'checkbox' => 0,
-                               'default' => 0,
-                               'range' => array(
-                                       'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
-                               ),
-                       ),
-               ),
-               'endtime' => array(
-                       'exclude' => 1,
-                       'l10n_mode' => 'mergeIfNotBlank',
-                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => 13,
-                               'max' => 20,
-                               'eval' => 'datetime',
-                               'checkbox' => 0,
-                               'default' => 0,
-                               'range' => array(
-                                       'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
-                               ),
-                       ),
-               ),
-               'title' => Array (
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditioncontainer.title',
-                       'config' => Array (
-                               'type' => 'input',
-                               'size' => '30',
-                       )
-               ),
-               'form' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditioncontainer.form',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditioncontainer.form.pleaseChoose',
-                                               ''
-                                       )
-                               ),
-                               'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFormsWithoutConditionRelation->filterForms',
-                               'itemsProcFunc_addFieldsets' => TRUE,
-                               'maxitems' => 1,
-                               'size' => 1,
-                               'minitems' => 1,
-                               'requestUpdate' => 1,
-                               'foreign_table' => 'tx_powermail_domain_model_forms',
-                               'foreign_table_where' => '
-                                       AND tx_powermail_domain_model_forms.deleted = 0
-                                       AND tx_powermail_domain_model_forms.hidden = 0
-                                       AND tx_powermail_domain_model_forms.sys_language_uid = 0
-                                       order by tx_powermail_domain_model_forms.title
-                               '
-                       )
-               ),
-               'conditions' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditioncontainer.conditions',
-                       'config' => array(
-                               'type' => 'inline',
-                               'foreign_table' => 'tx_powermailcond_domain_model_condition',
-                               'foreign_table_where' =>
-                                       'AND tx_powermailcond_domain_model_condition.pid=###CURRENT_PID### ORDER BY tx_powermailcond_domain_model_condition.sorting',
-                               'foreign_field' => 'conditioncontainer',
-                               'maxitems' => 99,
-                               'appearance' => array(
-                                       'collapseAll' => 1,
-                                       'expandSingle' => 1,
-                                       'useSortable' => 1,
-                                       'newRecordLinkAddTitle' => 1,
-                                       'newRecordLinkPosition' => 'both',
-                               ),
-                       ),
-                       'displayCond' => 'FIELD:form:>:0'
-               ),
-       ),
-);
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+            'tx_powermailcond_conditioncontainer',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'languageField' => 'sys_language_uid',
+        'sortby' => 'sorting',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden',
+            'starttime' => 'starttime',
+            'endtime' => 'endtime',
+        ],
+        'requestUpdate' => 'form',
+        'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_conditions.gif')
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'sys_language_uid,l18n_parent,l18n_diffsource,hidden,starttime,' .
+            'endtime,title,form,conditions',
+    ],
+    'types' => [
+        '1' => ['showitem' => 'title, form, conditions'],
+    ],
+    'palettes' => [
+        '1' => [],
+    ],
+    'columns' => [
+        'sys_language_uid' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'foreign_table' => 'sys_language',
+                'foreign_table_where' => 'ORDER BY sys_language.title',
+                'items' => [
+                    [
+                        'LLL:EXT:lang/locallang_general.xml:LGL.allLanguages',
+                        -1
+                    ],
+                    [
+                        'LLL:EXT:lang/locallang_general.xml:LGL.default_value',
+                        0
+                    ]
+                ],
+            ],
+        ],
+        'l18n_parent' => [
+            'displayCond' => 'FIELD:sys_language_uid:>:0',
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        '',
+                        0
+                    ],
+                ],
+                'foreign_table' => 'tx_powermailcond_conditioncontainer',
+                'foreign_table_where' => 'AND tx_powermailcond_conditioncontainer.pid=###CURRENT_PID### AND ' .
+                    'tx_powermailcond_conditioncontainer.sys_language_uid IN (-1,0)',
+            ]
+        ],
+        'l18n_diffsource' => [
+            'config' => [
+                'type' => 'passthrough'
+            ]
+        ],
+        'hidden' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+            'config' => [
+                'type' => 'check',
+            ],
+        ],
+        'starttime' => [
+            'exclude' => 1,
+            'l10n_mode' => 'mergeIfNotBlank',
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
+            'config' => [
+                'type' => 'input',
+                'size' => 13,
+                'max' => 20,
+                'eval' => 'datetime',
+                'checkbox' => 0,
+                'default' => 0,
+                'range' => [
+                    'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+                ],
+            ],
+        ],
+        'endtime' => [
+            'exclude' => 1,
+            'l10n_mode' => 'mergeIfNotBlank',
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
+            'config' => [
+                'type' => 'input',
+                'size' => 13,
+                'max' => 20,
+                'eval' => 'datetime',
+                'checkbox' => 0,
+                'default' => 0,
+                'range' => [
+                    'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+                ],
+            ],
+        ],
+        'title' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditioncontainer.title',
+            'config' => [
+                'type' => 'input',
+                'size' => '30',
+            ]
+        ],
+        'form' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditioncontainer.form',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_conditioncontainer.form.pleaseChoose',
+                        ''
+                    ]
+                ],
+                'itemsProcFunc' =>
+                    'In2code\PowermailCond\UserFunc\GetPowermailFormsWithoutConditionRelation->filterForms',
+                'itemsProcFunc_addFieldsets' => true,
+                'maxitems' => 1,
+                'size' => 1,
+                'minitems' => 1,
+                'requestUpdate' => 1,
+                'foreign_table' => 'tx_powermail_domain_model_forms',
+                'foreign_table_where' => 'AND tx_powermail_domain_model_forms.deleted = 0 ' .
+                    'AND tx_powermail_domain_model_forms.hidden = 0 ' .
+                    'AND tx_powermail_domain_model_forms.sys_language_uid = 0 ' .
+                    'order by tx_powermail_domain_model_forms.title'
+            ]
+        ],
+        'conditions' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_conditioncontainer.conditions',
+            'config' => [
+                'type' => 'inline',
+                'foreign_table' => 'tx_powermailcond_domain_model_condition',
+                'foreign_table_where' => 'AND tx_powermailcond_domain_model_condition.pid=###CURRENT_PID### ' .
+                    'ORDER BY tx_powermailcond_domain_model_condition.sorting',
+                'foreign_field' => 'conditioncontainer',
+                'maxitems' => 99,
+                'appearance' => [
+                    'collapseAll' => 1,
+                    'expandSingle' => 1,
+                    'useSortable' => 1,
+                    'newRecordLinkAddTitle' => 1,
+                    'newRecordLinkPosition' => 'both',
+                ],
+            ],
+            'displayCond' => 'FIELD:form:>:0'
+        ],
+    ],
+];
index 83b55a1..e85cc3a 100644 (file)
 <?php
 use In2code\PowermailCond\Utility\ConfigurationUtility;
 
-return array(
-       'ctrl' => array(
-               'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules',
-               'label' => 'title',
-               'tstamp' => 'tstamp',
-               'crdate' => 'crdate',
-               'cruser_id' => 'cruser_id',
-               'sortby' => 'sorting',
-               'delete' => 'deleted',
-               'enablecolumns' => array(
-                       'disabled' => 'hidden'
-               ),
-               'requestUpdate' => 'ops',
-               'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_rules.gif')
-       ),
-       'interface' => array(
-               'showRecordFieldList' => 'hidden,conditions,title,start_field,ops,cond_string,equal_field',
-       ),
-       'types' => array(
-               '0' => array('showitem' => 'conditions,title,start_field,ops,cond_string,equal_field')
-       ),
-       'palettes' => array(
-               '1' => array(),
-       ),
-       'columns' => array(
-               'hidden' => array(
-                       'exclude' => 1,
-                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
-                       'config'  => array(
-                               'type' => 'check',
-                               'default' => '0'
-                       )
-               ),
-               'title' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.title',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => '30',
-                       )
-               ),
-               'start_field' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.startField',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array('LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.startField.I.0', '0'),
-                               ),
-                               'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
-                               // allow only this types of fields in selector
-                               'itemsProcFuncValue' => 'input,textarea,select,radio,check',
-                               'size' => 1,
-                               'maxitems' => 1,
-                               'eval' => 'required'
-                       )
-               ),
-               'ops' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       // title operators
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.operators',
-                                               '--div--'
-                                       ),
-
-                                       // is set
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.0',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_IS_SET
-                                       ),
-
-                                       // is not set
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.1',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_IS_SET
-                                       ),
-
-                                       // title operatorsComparisonValue
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
-                                                       'tx_powermailcond_rules.operator.I.operatorsComparisonValue',
-                                               '--div--'
-                                       ),
-
-                                       // contains
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.2',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_CONTAINS_VALUE
-                                       ),
-
-                                       // contains not
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.3',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_CONTAINS_VALUE
-                                       ),
-
-                                       // is
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.4',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_IS
-                                       ),
-
-                                       // is not
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.5',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_IS
-                                       ),
-
-                                       // is greater than
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.6',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_GREATER_THAN
-                                       ),
-
-                                       // is less than
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.7',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_LESS_THAN
-                                       ),
-
-                                       // title operatorsComparisonField
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
-                                                       'tx_powermailcond_rules.operator.I.operatorsComparisonField',
-                                               '--div--'
-                                       ),
-
-                                       // contains value from field
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.8',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_CONTAINS_VALUE_FROM_FIELD
-                                       ),
-
-                                       // contains not value from field
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.operator.I.9',
-                                               \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD
-                                       ),
-                               ),
-                               'size' => 1,
-                               'maxitems' => 1
-                       )
-               ),
-               'cond_string' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.condstring',
-                       'config' => array(
-                               'type' => 'text',
-                               'cols' => '30',
-                               'rows' => '2',
-                       ),
-                       // show only if ops value is greater than 1
-                       'displayCond' => 'FIELD:ops:IN:2,3,4,5,6,7'
-               ),
-               'equal_field' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.equalField',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.equalField.I.0',
-                                               '0'
-                                       ),
-                               ),
-                               'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
-                               // allow only this types of fields in selector
-                               'itemsProcFuncValue' => 'input,textarea,select,radio,check',
-                               'size' => 1,
-                               'maxitems' => 1
-                       ),
-                       'displayCond' => 'FIELD:ops:IN:8,9'
-               ),
-               'conditions' => array(
-                       'l10n_mode' => 'noCopy',
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules.condition',
-                       'config' => array(
-                               'type' => 'select',
-                               'renderType' => 'selectSingle',
-                               'items' => array(
-                                       array(
-                                               '',
-                                               0
-                                       ),
-                               ),
-                               'foreign_table' => 'tx_powermailcond_domain_model_condition',
-                               'foreign_table_where' =>
-                                       'AND tx_powermailcond_domain_model_condition.pid=###CURRENT_PID###
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_rules',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'sortby' => 'sorting',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden'
+        ],
+        'requestUpdate' => 'ops',
+        'iconfile' => ConfigurationUtility::getIconPath('icon_tx_powermailcond_rules.gif')
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'hidden,conditions,title,start_field,ops,cond_string,equal_field',
+    ],
+    'types' => [
+        '0' => ['showitem' => 'conditions,title,start_field,ops,cond_string,equal_field']
+    ],
+    'palettes' => [
+        '1' => [],
+    ],
+    'columns' => [
+        'hidden' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+            'config' => [
+                'type' => 'check',
+                'default' => '0'
+            ]
+        ],
+        'title' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.title',
+            'config' => [
+                'type' => 'input',
+                'size' => '30',
+            ]
+        ],
+        'start_field' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.startField',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.startField.I.0',
+                        '0'
+                    ],
+                ],
+                'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
+                // allow only this types of fields in selector
+                'itemsProcFuncValue' => 'input,textarea,select,radio,check',
+                'size' => 1,
+                'maxitems' => 1,
+                'eval' => 'required'
+            ]
+        ],
+        'ops' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.operator',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    // title operators
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.operators',
+                        '--div--'
+                    ],
+                    // is set
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.0',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_IS_SET
+                    ],
+                    // is not set
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.1',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_IS_SET
+                    ],
+                    // title operatorsComparisonValue
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.operatorsComparisonValue',
+                        '--div--'
+                    ],
+                    // contains
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.2',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_CONTAINS_VALUE
+                    ],
+                    // contains not
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.3',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_CONTAINS_VALUE
+                    ],
+                    // is
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.4',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_IS
+                    ],
+                    // is not
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.5',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_IS
+                    ],
+                    // is greater than
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.6',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_GREATER_THAN
+                    ],
+                    // is less than
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.7',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_LESS_THAN
+                    ],
+                    // title operatorsComparisonField
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.operatorsComparisonField',
+                        '--div--'
+                    ],
+                    // contains value from field
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.8',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_CONTAINS_VALUE_FROM_FIELD
+                    ],
+                    // contains not value from field
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.operator.I.9',
+                        \In2code\PowermailCond\Domain\Model\Rule::OPERATOR_NOT_CONTAINS_VALUE_FROM_FIELD
+                    ],
+                ],
+                'size' => 1,
+                'maxitems' => 1
+            ]
+        ],
+        'cond_string' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.condstring',
+            'config' => [
+                'type' => 'text',
+                'cols' => '30',
+                'rows' => '2',
+            ],
+            // show only if ops value is greater than 1
+            'displayCond' => 'FIELD:ops:IN:2,3,4,5,6,7'
+        ],
+        'equal_field' => [
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.equalField',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                        'tx_powermailcond_rules.equalField.I.0',
+                        '0'
+                    ],
+                ],
+                'itemsProcFunc' => 'In2code\PowermailCond\UserFunc\GetPowermailFields->getFields',
+                // allow only this types of fields in selector
+                'itemsProcFuncValue' => 'input,textarea,select,radio,check',
+                'size' => 1,
+                'maxitems' => 1
+            ],
+            'displayCond' => 'FIELD:ops:IN:8,9'
+        ],
+        'conditions' => [
+            'l10n_mode' => 'noCopy',
+            'exclude' => 1,
+            'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:' .
+                'tx_powermailcond_rules.condition',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'items' => [
+                    [
+                        '',
+                        0
+                    ],
+                ],
+                'foreign_table' => 'tx_powermailcond_domain_model_condition',
+                'foreign_table_where' => 'AND tx_powermailcond_domain_model_condition.pid=###CURRENT_PID###
                                        AND tx_powermailcond_domain_model_condition.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)',
-                       ),
-               ),
-       ),
-);
+            ],
+        ],
+    ],
+];
index 163790a..93b30d6 100644 (file)
 # writing. "version" and "dependencies" must not be touched!
 ########################################################################
 
-$EM_CONF[$_EXTKEY] = array(
-       'title' => 'Powermail Conditions',
-       'description' => 'Add conditions (via AJAX) to powermail (2.9 or newer) forms for fields and pages',
-       'category' => 'plugin',
-       'shy' => 0,
-       'version' => '3.0.4',
-       'dependencies' => 'powermail',
-       'conflicts' => '',
-       'priority' => '',
-       'loadOrder' => '',
-       'module' => '',
-       'state' => 'stable',
-       'uploadfolder' => 0,
-       'createDirs' => '',
-       'modify_tables' => '',
-       'clearcacheonload' => 1,
-       'lockType' => '',
-       'author' => 'Alex Kellner',
-       'author_email' => 'alexander.kellner@in2code.de',
-       'author_company' => 'in2code.de',
-       'CGLcompliance' => '',
-       'CGLcompliance_note' => '',
-       'constraints' => array(
-               'depends' => array(
-                       'powermail' => '2.9.0-2.99.99',
-                       'extbase' => '6.2.0-7.99.99',
-                       'fluid' => '6.2.0-7.99.99',
-                       'typo3' => '6.2.0-7.99.99',
-               ),
-               'conflicts' => array(
-               ),
-               'suggests' => array(
-               ),
-       ),
-       '_md5_values_when_last_written' => '',
-);
+$EM_CONF[$_EXTKEY] = [
+    'title' => 'Powermail Conditions',
+    'description' => 'Add conditions (via AJAX) to powermail (2.9 or newer) forms for fields and pages',
+    'category' => 'plugin',
+    'shy' => 0,
+    'version' => '3.0.4',
+    'dependencies' => 'powermail',
+    'conflicts' => '',
+    'priority' => '',
+    'loadOrder' => '',
+    'module' => '',
+    'state' => 'stable',
+    'uploadfolder' => 0,
+    'createDirs' => '',
+    'modify_tables' => '',
+    'clearcacheonload' => 1,
+    'lockType' => '',
+    'author' => 'Alex Kellner',
+    'author_email' => 'alexander.kellner@in2code.de',
+    'author_company' => 'in2code.de',
+    'CGLcompliance' => '',
+    'CGLcompliance_note' => '',
+    'constraints' => [
+        'depends' => [
+            'powermail' => '2.9.0-2.99.99',
+            'extbase' => '6.2.0-7.99.99',
+            'fluid' => '6.2.0-7.99.99',
+            'typo3' => '6.2.0-7.99.99',
+            'php' => '5.5.0-0.0.0'
+        ],
+        'conflicts' => [
+        ],
+        'suggests' => [
+        ],
+    ],
+    '_md5_values_when_last_written' => '',
+];
index 960615c..55c7931 100644 (file)
@@ -1,22 +1,22 @@
 <?php
-if (!defined ('TYPO3_MODE')) {
-       die ('Access denied.');
+if (!defined('TYPO3_MODE')) {
+    die ('Access denied.');
 }
 
 /**
  * Include Plugins
  */
 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-       'In2code.' . $_EXTKEY,
-       'Pi1',
-       array(
-               'Condition' => 'buildCondition'
-       ),
-       array(
-               'Condition' => 'buildCondition'
-       )
+    'In2code.' . $_EXTKEY,
+    'Pi1',
+    [
+        'Condition' => 'buildCondition'
+    ],
+    [
+        'Condition' => 'buildCondition'
+    ]
 );
 
-$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['In2code\\Powermail\\Domain\\Validator\\InputValidator'] = array(
-       'className' => 'In2code\\PowermailCond\\Domain\\Validator\\ConditionAwareValidator',
-);
+$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['In2code\\Powermail\\Domain\\Validator\\InputValidator'] = [
+    'className' => 'In2code\\PowermailCond\\Domain\\Validator\\ConditionAwareValidator',
+];
index 66f735f..b3b38c9 100644 (file)
@@ -1,13 +1,13 @@
 <?php
-if (!defined ('TYPO3_MODE')) {
-       die ('Access denied.');
+if (!defined('TYPO3_MODE')) {
+    die ('Access denied.');
 }
 
 /**
  * Add TypoScript Static Template
  */
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
-       'powermail_cond',
-       'Configuration/TypoScript/',
-       'Main TypoScript'
-);
\ No newline at end of file
+    'powermail_cond',
+    'Configuration/TypoScript/',
+    'Main TypoScript'
+);