[TASK] Compatibility with TYPO3 CMS 7 22/43022/2
authorFrancois Suter <francois@typo3.org>
Fri, 4 Sep 2015 12:45:45 +0000 (14:45 +0200)
committerFrancois Suter <francois@typo3.org>
Fri, 4 Sep 2015 13:07:01 +0000 (15:07 +0200)
Move to namespaces and ensure compatibility with TYPO3 7.x.

Resolves: #69532
Releases: 2.0
Change-Id: I279aa5c1eea92e862f676f2c68f0f77ce4fd621f
Reviewed-on: http://review.typo3.org/43022
Reviewed-by: Francois Suter <francois@typo3.org>
Tested-by: Francois Suter <francois@typo3.org>
ChangeLog
Classes/Controller/SandboxController.php [new file with mode: 0644]
Classes/Controller/locallang.xml [new file with mode: 0644]
ext_emconf.php
ext_icon.gif [deleted file]
ext_icon.png [new file with mode: 0644]
ext_localconf.php
ext_tables.php
pi1/class.tx_expressionssandbox_pi1.php [deleted file]
pi1/locallang.xml [deleted file]

index a03133e..6e64936 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-04 Francois Suter (Cobweb)  <typo3@cobweb.ch>
+
+       * Verified compatibility with TYPO3 CMS 7, resolves #69532
+
 2014-05-09 Francois Suter (Cobweb)  <typo3@cobweb.ch>
 
        * Verified compatibility with TYPO3 6.2, resolves #58667
diff --git a/Classes/Controller/SandboxController.php b/Classes/Controller/SandboxController.php
new file mode 100644 (file)
index 0000000..aadc3cd
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+namespace Cobweb\ExpressionsSandbox\Controller;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+
+/**
+ * Plugin 'Expressions sandbox' for the 'expressions_sandbox' extension.
+ *
+ * @author Francois Suter (Cobweb) <typo3@cobweb.ch>
+ * @package TYPO3
+ * @subpackage tx_expressionssandbox
+ */
+class SandboxController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
+       public $prefixId      = 'tx_expressionssandbox_pi1';            // Same as class name
+       public $scriptRelPath = 'Classes/Controller/SandboxController.php';     // Path to this script relative to the extension dir.
+       public $extKey        = 'expressions_sandbox';  // The extension key.
+
+       /**
+        * The main method of the PlugIn
+        *
+        * @param string $content The PlugIn's content (empty in this case)
+        * @param array $conf The PlugIn configuration
+        * @return string The content that is displayed on the website
+        */
+       public 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'];
+               $expressions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode("\n", $expressionsField, TRUE);
+               foreach ($expressions as $anExpression) {
+                       try {
+                               $result = \Cobweb\Expressions\ExpressionParser::evaluateExpression($anExpression);
+                               if (is_array($result)) {
+                                       $result = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($result);
+                               }
+                               $content .= '<p>' . sprintf($this->pi_getLL('expression_parsed'), '<code>' . $anExpression . '</code>', '<strong>' . $result . '</strong>') . '</p>';
+                       }
+                       catch (\Exception $e) {
+                               $content .= '<p>' . sprintf($this->pi_getLL('expression_not_parsed'), '<code>' . $anExpression . '</code>') . '</p>';
+                       }
+               }
+               return $this->pi_wrapInBaseClass($content);
+       }
+
+       /**
+        * This method performs various initialisations
+        *
+        * @param array $conf Plugin configuration, as received by the main() method
+        * @return void
+        */
+       protected function init($conf) {
+               $this->pi_loadLL();
+               // Base configuration is equal to the plug-in'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;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/Classes/Controller/locallang.xml b/Classes/Controller/locallang.xml
new file mode 100644 (file)
index 0000000..a5825b5
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for plugin &quot;tx_expressionssandbox_pi1&quot;</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <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
index 13c6b88..b2db4a7 100644 (file)
@@ -29,11 +29,11 @@ $EM_CONF[$_EXTKEY] = array(
        'clearCacheOnLoad' => 0,
        'lockType' => '',
        'author_company' => '',
-       'version' => '1.1.0',
+       'version' => '2.0.0-dev',
        'constraints' => array(
                'depends' => array(
-                       'expressions' => '',
-                       'typo3' => '4.5.0-6.2.99'
+                       'expressions' => '2.0.0-0.0.0',
+                       'typo3' => '6.2.0-7.5.99'
                ),
                'conflicts' => array(
                ),
diff --git a/ext_icon.gif b/ext_icon.gif
deleted file mode 100644 (file)
index 377b1f8..0000000
Binary files a/ext_icon.gif and /dev/null differ
diff --git a/ext_icon.png b/ext_icon.png
new file mode 100644 (file)
index 0000000..5f16c92
Binary files /dev/null and b/ext_icon.png differ
index 49e510a..799f93e 100644 (file)
@@ -3,5 +3,10 @@ if (!defined ('TYPO3_MODE')) {
        die ('Access denied.');
 }
 
-t3lib_extMgm::addPItoST43($_EXTKEY, 'pi1/class.tx_expressionssandbox_pi1.php', '_pi1', 'list_type', 0);
-?>
\ No newline at end of file
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43(
+       $_EXTKEY,
+       'Classes/Controller/SandboxController.php',
+       '_pi1',
+       'list_type',
+       0
+);
index 653c479..393ab2e 100644 (file)
@@ -3,18 +3,29 @@ 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,pages';
+// Hide some default fields
+$GLOBALS['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');
+// Add pi1 to the list of plugins
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
+       array(
+               'LLL:EXT:expressions_sandbox/locallang_db.xml:tt_content.list_type_pi1',
+               $_EXTKEY . '_pi1',
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'ext_icon.png'
+       ),
+       'list_type'
+);
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript(
+       'Cobweb.ExpressionsSandbox',
+       'setup', '
+               plugin.tx_expressionssandbox_pi1 = USER_INT
+               plugin.tx_expressionssandbox_pi1.userFunc = Cobweb\\ExpressionsSandbox\\Controller\\SandboxController->main
+       '
+);
 
-       // Activate the display of the plug-in flexform field and set FlexForm definition
-$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
+// Activate the display of the plug-in flexform field and set FlexForm definition
+$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY . '_pi1'] = 'pi_flexform';
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
+       $_EXTKEY . '_pi1',
+       'FILE:EXT:expressions_sandbox/flexform_ds.xml'
+);
diff --git a/pi1/class.tx_expressionssandbox_pi1.php b/pi1/class.tx_expressionssandbox_pi1.php
deleted file mode 100644 (file)
index f285aea..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2010-2013 Francois Suter (Cobweb) <typo3@cobweb.ch>
-*  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 2 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!
-***************************************************************/
-
-require_once(t3lib_extMgm::extPath('expressions', 'class.tx_expressions_parser.php'));
-
-
-/**
- * Plugin 'Expressions sandbox' for the 'expressions_sandbox' extension.
- *
- * @author             Francois Suter (Cobweb) <typo3@cobweb.ch>
- * @package            TYPO3
- * @subpackage tx_expressionssandbox
- *
- * $Id$
- */
-class tx_expressionssandbox_pi1 extends tslib_pibase {
-       public $prefixId      = 'tx_expressionssandbox_pi1';            // Same as class name
-       public $scriptRelPath = 'pi1/class.tx_expressionssandbox_pi1.php';      // Path to this script relative to the extension dir.
-       public $extKey        = 'expressions_sandbox';  // The extension key.
-
-       /**
-        * The main method of the PlugIn
-        *
-        * @param string $content The PlugIn's content (empty in this case)
-        * @param array $conf The PlugIn configuration
-        * @return string The content that is displayed on the website
-        */
-       public 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'];
-               $expressions = t3lib_div::trimExplode("\n", $expressionsField, TRUE);
-               foreach ($expressions as $anExpression) {
-                       try {
-                               $result = tx_expressions_parser::evaluateExpression($anExpression);
-                               if (is_array($result)) {
-                                       $result = t3lib_utility_Debug::viewArray($result);
-                               }
-                               $content .= '<p>' . sprintf($this->pi_getLL('expression_parsed'), '<code>' . $anExpression . '</code>', '<strong>' . $result . '</strong>') . '</p>';
-                       }
-                       catch (Exception $e) {
-                               $content .= '<p>' . sprintf($this->pi_getLL('expression_not_parsed'), '<code>' . $anExpression . '</code>') . '</p>';
-                       }
-               }
-               return $this->pi_wrapInBaseClass($content);
-       }
-
-       /**
-        * This method performs various initialisations
-        *
-        * @param       array           $conf: plugin configuration, as received by the main() method
-        * @return      void
-        */
-       protected function init($conf) {
-               $this->pi_loadLL();
-                       // Base configuration is equal the the plug-in'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;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-
-
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/expressions_sandbox/pi1/class.tx_expressionssandbox_pi1.php'])        {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/expressions_sandbox/pi1/class.tx_expressionssandbox_pi1.php']);
-}
-
-?>
\ No newline at end of file
diff --git a/pi1/locallang.xml b/pi1/locallang.xml
deleted file mode 100644 (file)
index a5825b5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<T3locallang>
-       <meta type="array">
-               <type>module</type>
-               <description>Language labels for plugin &quot;tx_expressionssandbox_pi1&quot;</description>
-       </meta>
-       <data type="array">
-               <languageKey index="default" type="array">
-                       <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