[TASK] Refactoring for version 3.0
authorAlex Kellner <alexander.kellner@in2code.de>
Thu, 10 Sep 2015 18:18:12 +0000 (20:18 +0200)
committerAlex Kellner <alexander.kellner@in2code.de>
Thu, 10 Sep 2015 18:18:12 +0000 (20:18 +0200)
Refactored and added ConditionContainer table and TCA

12 files changed:
Classes/Controller/ConditionController.php
Classes/Domain/Model/ConditionContainer.php
Classes/Domain/Repository/ConditionContainerRepository.php [new file with mode: 0644]
Classes/Domain/Repository/ConditionRepository.php [deleted file]
Classes/UserFunc/GetPowermailFields.php
Classes/UserFunc/GetPowermailFormsWithoutConditionRelation.php [new file with mode: 0644]
Classes/Utility/ArrayUtility.php
Configuration/TCA/tx_powermailcond_domain_model_condition.php
Configuration/TCA/tx_powermailcond_domain_model_conditioncontainer.php [new file with mode: 0644]
Configuration/TCA/tx_powermailcond_domain_model_rule.php
Resources/Private/Language/locallang_db.xml
ext_tables.sql

index 1f72f1f..aee90cb 100644 (file)
@@ -49,10 +49,10 @@ class ConditionController extends ActionController {
        protected $formRepository;
 
        /**
-        * @var \In2code\PowermailCond\Domain\Repository\ConditionRepository
+        * @var \In2code\PowermailCond\Domain\Repository\ConditionContainerRepository
         * @inject
         */
-       protected $conditionRepository;
+       protected $conditionContainerRepository;
 
        /**
         * Build Condition for AJAX call
@@ -77,7 +77,8 @@ class ConditionController extends ActionController {
                        }
                }
 
-               $conditionContainer = new ConditionContainer($this->conditionRepository->findByForm($form));
+               /** @var ConditionContainer $conditionContainer */
+               $conditionContainer = $this->conditionContainerRepository->findOneByForm($form);
                $arguments = $conditionContainer->applyConditions($form, $arguments);
 
                /** @var TypoScriptFrontendController $feUser */
index d446d3f..e570453 100644 (file)
@@ -28,31 +28,7 @@ namespace In2code\PowermailCond\Domain\Model;
  ***************************************************************/
 
 use In2code\Powermail\Domain\Model\Form;
-use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2015 Alex Kellner <alexander.kellner@in2code.de>, in2code.de
- *
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
+use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
 
 /**
  * Condition Model
@@ -61,7 +37,7 @@ use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
  * @license http://www.gnu.org/licenses/lgpl.html
  *                     GNU Lesser General Public License, version 3 or later
  */
-class ConditionContainer {
+class ConditionContainer extends AbstractEntity {
 
        /**
         * @var int
@@ -69,21 +45,21 @@ class ConditionContainer {
        protected $loopCount = 0;
 
        /**
-        * @var Condition[]
+        * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\In2code\PowermailCond\Domain\Model\Condition>
         */
-       protected $conditions = array();
+       protected $conditions = NULL;
 
        /**
         * @var bool
         */
        protected $somethingChanged = TRUE;
 
-       /**
-        * @param QueryResult $conditions
-        */
-       public function __construct(QueryResult $conditions) {
-               $this->conditions = $conditions;
-       }
+//     /**
+//      * @param QueryResult $conditions
+//      */
+//     public function __construct(QueryResult $conditions) {
+//             $this->conditions = $conditions;
+//     }
 
        /**
         * @param Form $form
diff --git a/Classes/Domain/Repository/ConditionContainerRepository.php b/Classes/Domain/Repository/ConditionContainerRepository.php
new file mode 100644 (file)
index 0000000..c4c1273
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+namespace In2code\PowermailCond\Domain\Repository;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2015 in2code.de
+ *  Alex Kellner <alexander.kellner@in2code.de>,
+ *  Oliver Eglseder <oliver.eglseder@in2code.de>
+ *
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+/**
+ * ConditionContainerRepository
+ *
+ * @package powermail
+ * @license http://www.gnu.org/licenses/lgpl.html
+ *            GNU Lesser General Public License, version 3 or later
+ */
+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);
+       }
+}
diff --git a/Classes/Domain/Repository/ConditionRepository.php b/Classes/Domain/Repository/ConditionRepository.php
deleted file mode 100644 (file)
index ab2261a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-namespace In2code\PowermailCond\Domain\Repository;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2015 in2code.de
- *  Alex Kellner <alexander.kellner@in2code.de>,
- *  Oliver Eglseder <oliver.eglseder@in2code.de>
- *
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
-use TYPO3\CMS\Extbase\Persistence\Repository;
-
-/**
- * ConditionRepository
- *
- * @package powermail
- * @license http://www.gnu.org/licenses/lgpl.html
- *            GNU Lesser General Public License, version 3 or later
- */
-class ConditionRepository 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);
-       }
-}
index 387cdd7..429fcb3 100644 (file)
@@ -177,9 +177,31 @@ class GetPowermailFields {
         * @return int formUid
         */
        protected function getFormUidFromCondition($conditionUid) {
-               $select = 'form';
-               $from = 'tx_powermailcond_domain_model_condition';
-               $where = 'uid = ' . (int) $conditionUid . ' AND hidden = 0 AND deleted = 0';
+               $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;
@@ -220,6 +242,9 @@ class 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']);
                }
diff --git a/Classes/UserFunc/GetPowermailFormsWithoutConditionRelation.php b/Classes/UserFunc/GetPowermailFormsWithoutConditionRelation.php
new file mode 100644 (file)
index 0000000..6b85f8a
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+namespace In2code\PowermailCond\UserFunc;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2015 in2code.de
+ *  Alex Kellner <alexander.kellner@in2code.de>,
+ *  Oliver Eglseder <oliver.eglseder@in2code.de>
+ *
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Backend\Form\FormEngine;
+
+/**
+ * Get powermail forms that have no related condition containers
+ *
+ * @package powermail_cond
+ * @license http://www.gnu.org/licenses/lgpl.html
+ *                     GNU Lesser General Public License, version 3 or later
+ */
+class GetPowermailFormsWithoutConditionRelation {
+
+       /**
+        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected $databaseConnection = NULL;
+
+       /**
+        * @var array
+        */
+       protected $params = array();
+
+       /**
+        * @var FormEngine
+        */
+       protected $formEngine = NULL;
+
+       /**
+        * @var int
+        */
+       protected $currentFormUid = 0;
+
+       /**
+        * remove forms that are already related to a condition container
+        *
+        * @param array $params
+        * @param FormEngine $formEngine
+        * @return void
+        */
+       public function filterForms(array &$params, FormEngine $formEngine) {
+               $this->initialize($params, $formEngine);
+               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 array $params
+        * @param FormEngine $formEngine
+        * @return void
+        */
+       protected function initialize(array &$params, FormEngine $formEngine) {
+               $this->databaseConnection = $GLOBALS['TYPO3_DB'];
+               $this->params = &$params;
+               $this->formEngine = $formEngine;
+               $this->currentFormUid = (int) $this->params['row']['form'];
+       }
+}
index 3ce1872..f0e6e17 100644 (file)
@@ -39,6 +39,7 @@ class ArrayUtility extends ArrayUtilityExtbase {
        /**
         * Get quoted list from array
         *
+        * @param array $array
         * @return array
         */
        public static function getQuotedList(array $array) {
index 753f14a..d72ea82 100644 (file)
@@ -14,16 +14,15 @@ return array(
                        'starttime' => 'starttime',
                        'endtime' => 'endtime',
                ),
-               'requestUpdate' => 'form',
                'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('powermail_cond') .
                        'Resources/Public/Icons/icon_tx_powermailcond_conditions.gif'
        ),
        'interface' => array(
                'showRecordFieldList' => 'sys_language_uid,l18n_parent,l18n_diffsource,hidden,starttime,
-                       endtime,title,target_field,actions,filter_select_field,rules,conjunction,form',
+                       endtime,conditioncontainer,title,target_field,actions,filter_select_field,rules,conjunction',
        ),
        'types' => array(
-               '1' => array('showitem' => 'title, form, target_field, actions, filter_select_field, conjunction, rules'),
+               '1' => array('showitem' => 'conditioncontainer, title, target_field, actions, filter_select_field, conjunction, rules'),
        ),
        'palettes' => array(
                '1' => array(),
@@ -108,30 +107,6 @@ return array(
                                'size' => '30',
                        )
                ),
-               'form' => array(
-                       'exclude' => 1,
-                       'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.form',
-                       'config' => array(
-                               'type' => 'select',
-                               'items' => array(
-                                       array(
-                                               'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.form.pleaseChoose',
-                                               ''
-                                       )
-                               ),
-                               '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
-                               '
-                       )
-               ),
                'rules' => array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:powermail_cond/Resources/Private/Language/locallang_db.xml:tx_powermailcond_conditions.rules',
@@ -150,7 +125,6 @@ return array(
                                        'newRecordLinkPosition' => 'both',
                                ),
                        ),
-                       'displayCond' => 'FIELD:form:>:0'
                ),
                'conjunction' => array(
                        'exclude' => 1,
@@ -173,7 +147,6 @@ return array(
                                'size' => 1,
                                'maxitems' => 1,
                        ),
-                       'displayCond' => 'FIELD:form:>:0'
                ),
                'target_field' => array(
                        'exclude' => 1,
@@ -192,7 +165,6 @@ return array(
                                'maxitems' => 1,
                                'eval' => 'required'
                        ),
-                       'displayCond' => 'FIELD:form:>:0'
                ),
                'actions' => array(
                        'exclude' => 1,
@@ -227,7 +199,24 @@ return array(
                                'size' => 1,
                                'maxitems' => 1,
                        ),
-                       'displayCond' => 'FIELD:form:>:0'
+               ),
+               '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',
+                               '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###)',
+                       ),
                ),
        ),
 );
diff --git a/Configuration/TCA/tx_powermailcond_domain_model_conditioncontainer.php b/Configuration/TCA/tx_powermailcond_domain_model_conditioncontainer.php
new file mode 100644 (file)
index 0000000..8207d14
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+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' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('powermail_cond') .
+                       'Resources/Public/Icons/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',
+                               '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',
+                               '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',
+                               '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'
+               ),
+       ),
+);
index ae40624..1e2f68e 100644 (file)
@@ -16,10 +16,10 @@ return array(
                        'Resources/Public/Icons/icon_tx_powermailcond_rules.gif'
        ),
        'interface' => array(
-               'showRecordFieldList' => 'hidden,start_field,ops,cond_string,equal_field',
+               'showRecordFieldList' => 'hidden,conditions,title,start_field,ops,cond_string,equal_field',
        ),
        'types' => array(
-               '0' => array('showitem' => 'title,start_field,ops,cond_string,equal_field')
+               '0' => array('showitem' => 'conditions,title,start_field,ops,cond_string,equal_field')
        ),
        'palettes' => array(
                '1' => array(),
@@ -175,5 +175,23 @@ return array(
                        ),
                        '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',
+                               'items' => array(
+                                       array(
+                                               '',
+                                               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 2f26d42..be0e538 100644 (file)
@@ -6,10 +6,13 @@
        </meta>
        <data type="array">
                <languageKey index="default" type="array">
-                       <label index="tx_powermailcond_conditions">Conditions</label>
+                       <label index="tx_powermailcond_conditioncontainer">Condition container</label>
+                       <label index="tx_powermailcond_conditioncontainer.title">Title</label>
+                       <label index="tx_powermailcond_conditioncontainer.form">Form</label>
+                       <label index="tx_powermailcond_conditioncontainer.form.pleaseChoose">Please choose...</label>
+                       <label index="tx_powermailcond_conditioncontainer.conditions">Conditions</label>
+                       <label index="tx_powermailcond_conditions">Condition</label>
                        <label index="tx_powermailcond_conditions.title">Title</label>
-                       <label index="tx_powermailcond_conditions.form">Form</label>
-                       <label index="tx_powermailcond_conditions.form.pleaseChoose">Please choose...</label>
                        <label index="tx_powermailcond_conditions.targetField">Which field is affected (target field)?</label>
                        <label index="tx_powermailcond_conditions.targetField.I.0">Please choose...</label>
                        <label index="tx_powermailcond_conditions.action">What should happen to the chosen field?</label>
@@ -21,7 +24,8 @@
                        <label index="tx_powermailcond_conditions.conjunction">Conjunction of the rules (if more than only 1)</label>
                        <label index="tx_powermailcond_conditions.conjunction.I.0">AND</label>
                        <label index="tx_powermailcond_conditions.conjunction.I.1">OR</label>
-                       <label index="tx_powermailcond_rules">Rules</label>
+                       <label index="tx_powermailcond_conditions.conditioncontainer">Condition container</label>
+                       <label index="tx_powermailcond_rules">Rule</label>
                        <label index="tx_powermailcond_rules.title">Title</label>
                        <label index="tx_powermailcond_rules.startField">Which field starts the condition (start field)?</label>
                        <label index="tx_powermailcond_rules.startField.I.0">Please choose...</label>
                        <label index="tx_powermailcond_rules.condstring">Value</label>
                        <label index="tx_powermailcond_rules.equalField">Field for comparison</label>
                        <label index="tx_powermailcond_rules.equalField.I.0">Please choose...</label>
+                       <label index="tx_powermailcond_rules.condition">Condition</label>
                </languageKey>
                <languageKey index="de" type="array">
-                       <label index="tx_powermailcond_conditions">Bedingungen</label>
+                       <label index="tx_powermailcond_conditioncontainer">Bedingungssammlung</label>
+                       <label index="tx_powermailcond_conditioncontainer.title">Bezeichnung</label>
+                       <label index="tx_powermailcond_conditioncontainer.form">Formular</label>
+                       <label index="tx_powermailcond_conditioncontainer.form.pleaseChoose">Bitte wählen...</label>
+                       <label index="tx_powermailcond_conditioncontainer.conditions">Bedingungen</label>
+                       <label index="tx_powermailcond_conditions">Bedingung</label>
                        <label index="tx_powermailcond_conditions.title">Bezeichnung</label>
-                       <label index="tx_powermailcond_conditions.form">Formular</label>
-                       <label index="tx_powermailcond_conditions.form.pleaseChoose">Bitte wählen...</label>
                        <label index="tx_powermailcond_conditions.targetField">Welches Feld ist betroffen (Zielfeld)?</label>
                        <label index="tx_powermailcond_conditions.targetField.I.0">Bitte wählen...</label>
                        <label index="tx_powermailcond_conditions.action">Was soll mit dem gewählten Feld passieren?</label>
@@ -59,7 +67,8 @@
                        <label index="tx_powermailcond_conditions.conjunction">Logische Verknüpfung der Regeln (wenn mehr als 1 Regel)</label>
                        <label index="tx_powermailcond_conditions.conjunction.I.0">UND</label>
                        <label index="tx_powermailcond_conditions.conjunction.I.1">ODER</label>
-                       <label index="tx_powermailcond_rules">Regeln</label>
+                       <label index="tx_powermailcond_conditions.conditioncontainer">Bedingungssammlung</label>
+                       <label index="tx_powermailcond_rules">Regel</label>
                        <label index="tx_powermailcond_rules.title">Bezeichnung</label>
                        <label index="tx_powermailcond_rules.startField">Welches Feld löst die Bedingung aus (Startfeld)?</label>
                        <label index="tx_powermailcond_rules.startField.I.0">Bitte wählen...</label>
@@ -80,6 +89,7 @@
                        <label index="tx_powermailcond_rules.condstring">Wert</label>
                        <label index="tx_powermailcond_rules.equalField">Vergleichsfeld</label>
                        <label index="tx_powermailcond_rules.equalField.I.0">Bitte wählen...</label>
+                       <label index="tx_powermailcond_rules.condition">Bedingung</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
index e60ad68..6ef2d9d 100644 (file)
@@ -1,4 +1,31 @@
 #\r
+# Table structure for table 'tx_powermailcond_domain_model_conditioncontainer'\r
+#\r
+CREATE TABLE tx_powermailcond_domain_model_conditioncontainer (\r
+       uid int(11) NOT NULL auto_increment,\r
+       pid int(11) DEFAULT '0' NOT NULL,\r
+       tstamp int(11) DEFAULT '0' NOT NULL,\r
+       crdate int(11) DEFAULT '0' NOT NULL,\r
+       cruser_id int(11) DEFAULT '0' NOT NULL,\r
+       sys_language_uid int(11) DEFAULT '0' NOT NULL,\r
+       l18n_parent int(11) DEFAULT '0' NOT NULL,\r
+       l18n_diffsource mediumblob NOT NULL,\r
+       sorting int(10) DEFAULT '0' NOT NULL,\r
+       deleted tinyint(4) DEFAULT '0' NOT NULL,\r
+       hidden tinyint(4) DEFAULT '0' NOT NULL,\r
+       starttime int(11) DEFAULT '0' NOT NULL,\r
+       endtime int(11) DEFAULT '0' NOT NULL,\r
+\r
+       conditions int(11) DEFAULT '0' NOT NULL,\r
+\r
+       title tinytext NOT NULL,\r
+       form int(11) DEFAULT '0' NOT NULL,\r
+\r
+       PRIMARY KEY (uid),\r
+       KEY parent (pid)\r
+);\r
+\r
+#\r
 # Table structure for table 'tx_powermailcond_domain_model_condition'\r
 #\r
 CREATE TABLE tx_powermailcond_domain_model_condition (\r
@@ -17,13 +44,13 @@ CREATE TABLE tx_powermailcond_domain_model_condition (
        endtime int(11) DEFAULT '0' NOT NULL,\r
 \r
        rules int(11) DEFAULT '0' NOT NULL,\r
+       conditioncontainer int(11) DEFAULT '0' NOT NULL,\r
 \r
        title tinytext NOT NULL,\r
        target_field tinytext NOT NULL,\r
        actions tinytext NOT NULL,\r
        conjunction tinytext NOT NULL,\r
-       form int(11) DEFAULT '0' NOT NULL,\r
-       \r
+\r
        PRIMARY KEY (uid),\r
        KEY parent (pid)\r
 );\r