Completed base logic
authorfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 18 Jan 2010 15:01:40 +0000 (15:01 +0000)
committerfrancois <francois@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 18 Jan 2010 15:01:40 +0000 (15:01 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/expressions_sandbox/trunk@28969 735d13b6-9817-0410-8766-e36946ffe9aa

pi1/class.tx_expressionssandbox_pi1.php
pi1/locallang.xml

index 71c9b42..899d8ec 100644 (file)
@@ -22,7 +22,8 @@
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
 
-require_once(PATH_tslib.'class.tslib_pibase.php');
+require_once(PATH_tslib . 'class.tslib_pibase.php');
+require_once(t3lib_extMgm::extPath('expressions', 'class.tx_expressions_parser.php'));
 
 
 /**
@@ -49,10 +50,19 @@ class tx_expressionssandbox_pi1 extends tslib_pibase {
        function main($content, $conf) {
                $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!
                $this->init($conf);
+               $content = '';
 
                $expressionsField = $this->conf['expressionsField'];
-               $content = nl2br($expressionsField);
-       
+               $expressions = t3lib_div::trimExplode("\n", $expressionsField, TRUE);
+               foreach ($expressions as $anExpression) {
+                       try {
+                               $result = tx_expressions_parser::evaluateExpression($anExpression);
+                               $content .= '<p>' . sprintf($this->pi_getLL('expression_parsed'), $anExpression, $result) . '</p>';
+                       }
+                       catch (Exception $e) {
+                               $content .= '<p>' . sprintf($this->pi_getLL('expression_not_parsed'), $anExpression) . '</p>';
+                       }
+               }
                return $this->pi_wrapInBaseClass($content);
        }
 
index 2077b3b..a5825b5 100644 (file)
@@ -6,11 +6,8 @@
        </meta>
        <data type="array">
                <languageKey index="default" type="array">
-                       <label index="list_mode_1">Mode 1</label>
-                       <label index="list_mode_2">Mode 2</label>
-                       <label index="list_mode_3">Mode 3</label>
-                       <label index="back">Back</label>
-                       <label index="submit_button_label">Click here to submit value</label>
+                       <label index="expression_parsed">Expression: %1$s => Result: %2$s</label>
+                       <label index="expression_not_parsed">Expression: %s could not be parsed</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file