Added flexform
authorfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 18 Jan 2010 14:20:45 +0000 (14:20 +0000)
committerfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 18 Jan 2010 14:20:45 +0000 (14:20 +0000)
Added skeleton code to pi1

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/expressions_sandbox/trunk@28959 735d13b6-9817-0410-8766-e36946ffe9aa

ext_tables.php
flexform_ds.xml [new file with mode: 0644]
locallang_db.xml
pi1/class.tx_expressionssandbox_pi1.php

index 9edb03d..3d112f1 100644 (file)
@@ -3,13 +3,18 @@ if (!defined ('TYPO3_MODE')) {
        die ('Access denied.');
 }
 
+       // Hide some default fields
 t3lib_div::loadTCA('tt_content');
-$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1']='layout,select_key';
-
+$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1'] = 'layout,select_key,pages';
 
+       // Add pi1 to the list of plugins
 t3lib_extMgm::addPlugin(array(
        'LLL:EXT:expressions_sandbox/locallang_db.xml:tt_content.list_type_pi1',
        $_EXTKEY . '_pi1',
        t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif'
 ),'list_type');
+
+       // Activate the display of the plug-in flexform field and set FlexForm defintion
+$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1'] = 'pi_flexform';
+t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pi1', 'FILE:EXT:expressions_sandbox/flexform_ds.xml');
 ?>
\ No newline at end of file
diff --git a/flexform_ds.xml b/flexform_ds.xml
new file mode 100644 (file)
index 0000000..553e21b
--- /dev/null
@@ -0,0 +1,25 @@
+<T3DataStructure>
+       <meta>
+               <langDisable>1</langDisable>
+       </meta>
+       <sheets>
+               <sDEF>
+                       <ROOT>
+                               <TCEforms>
+                                       <sheetTitle>LLL:EXT:expressions_sandbox/locallang_db.xml:expressions_sandbox.pi_flexform.sheetExpressions</sheetTitle>
+                               </TCEforms>
+                               <type>array</type>
+                               <el>
+                                       <expressionsField>
+                                               <TCEforms>
+                                                       <label>LLL:EXT:expressions_sandbox/locallang_db.xml:expressions_sandbox.pi_flexform.expressionsField</label>
+                                                       <config>
+                                                               <type>text</type>
+                                                       </config>
+                                               </TCEforms>
+                                       </expressionsField>
+                               </el>
+                       </ROOT>
+               </sDEF>
+       </sheets>
+</T3DataStructure>
\ No newline at end of file
index 132c197..01bea67 100644 (file)
@@ -7,6 +7,8 @@
        <data type="array">
                <languageKey index="default" type="array">
                        <label index="tt_content.list_type_pi1">Expressions sandbox</label>
+                       <label index="expressions_sandbox.pi_flexform.sheetExpressions">Expressions</label>
+                       <label index="expressions_sandbox.pi_flexform.expressionsField">Expressions</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
index 823e61a..71c9b42 100644 (file)
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- * Hint: use extdeveval to insert/update function index above.
- */
 
 require_once(PATH_tslib.'class.tslib_pibase.php');
 
@@ -33,9 +28,11 @@ require_once(PATH_tslib.'class.tslib_pibase.php');
 /**
  * Plugin 'Expressions sandbox' for the 'expressions_sandbox' extension.
  *
- * @author     Francois Suter (Cobweb) <typo3@cobweb.ch>
- * @package    TYPO3
+ * @author             Francois Suter (Cobweb) <typo3@cobweb.ch>
+ * @package            TYPO3
  * @subpackage tx_expressionssandbox
+ *
+ * $Id$
  */
 class tx_expressionssandbox_pi1 extends tslib_pibase {
        var $prefixId      = 'tx_expressionssandbox_pi1';               // Same as class name
@@ -50,27 +47,41 @@ class tx_expressionssandbox_pi1 extends tslib_pibase {
         * @return      The content that is displayed on the website
         */
        function main($content, $conf) {
-               $this->conf = $conf;
-               $this->pi_setPiVarDefaults();
-               $this->pi_loadLL();
                $this->pi_USER_INT_obj = 1;     // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
-       
-               $content='
-                       <strong>This is a few paragraphs:</strong><br />
-                       <p>This is line 1</p>
-                       <p>This is line 2</p>
-       
-                       <h3>This is a form:</h3>
-                       <form action="'.$this->pi_getPageLink($GLOBALS['TSFE']->id).'" method="POST">
-                               <input type="text" name="'.$this->prefixId.'[input_field]" value="'.htmlspecialchars($this->piVars['input_field']).'">
-                               <input type="submit" name="'.$this->prefixId.'[submit_button]" value="'.htmlspecialchars($this->pi_getLL('submit_button_label')).'">
-                       </form>
-                       <br />
-                       <p>You can click here to '.$this->pi_linkToPage('get to this page again',$GLOBALS['TSFE']->id).'</p>
-               ';
+               $this->init($conf);
+
+               $expressionsField = $this->conf['expressionsField'];
+               $content = nl2br($expressionsField);
        
                return $this->pi_wrapInBaseClass($content);
        }
+
+       /**
+        * This method performs various initialisations
+        *
+        * @param       array           $conf: plugin configuration, as received by the main() method
+        * @return      void
+        */
+       function init($conf) {
+               $this->pi_loadLL();
+                       // Base configuration is equal the the plugin's TS setup
+               $this->conf = $conf;
+
+                       // Load the flexform and loop on all its values to override TS setup values
+               $this->pi_initPIflexForm();
+               if (is_array($this->cObj->data['pi_flexform']['data'])) {
+                       foreach ($this->cObj->data['pi_flexform']['data'] as $sheet => $langData) {
+                               foreach ($langData as $fields) {
+                                       foreach ($fields as $field => $value) {
+                                               $value = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], $field, $sheet);
+                                               if (!empty($value)) {
+                                                       $this->conf[$field] = $value;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
 }