[TASK] Remove old class files from ext:t3editor 60/27460/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 8 Feb 2014 14:22:20 +0000 (15:22 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 8 Feb 2014 18:27:04 +0000 (19:27 +0100)
Change-Id: Id7cd8fdaecf663462b8d02a4bf2ca272293cea4f
Resolves: #55792
Related: #47756
Releases: 6.2
Reviewed-on: https://review.typo3.org/27460
Reviewed-by: Marcin SÄ…gol
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
17 files changed:
typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/t3editor/Classes/CodeCompletion.php
typo3/sysext/t3editor/Classes/FormWizard.php
typo3/sysext/t3editor/Classes/Hook/FileEditHook.php
typo3/sysext/t3editor/Classes/Hook/TypoScriptTemplateInfoHook.php
typo3/sysext/t3editor/Classes/T3Editor.php [deleted file]
typo3/sysext/t3editor/Classes/T3editor.php [new file with mode: 0644]
typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php
typo3/sysext/t3editor/Classes/class.tx_t3editor.php [deleted file]
typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_fileedit.php [deleted file]
typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php [deleted file]
typo3/sysext/t3editor/Classes/class.tx_t3editor_tceforms_wizard.php [deleted file]
typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_codecompletion.php [deleted file]
typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_tsrefloader.php [deleted file]
typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php
typo3/sysext/t3editor/ext_localconf.php
typo3/sysext/t3editor/ext_tables.php

index 9ece7ae..f187a67 100644 (file)
@@ -6299,32 +6299,32 @@ class tx_sysactionToolbarMenu extends \TYPO3\CMS\SysAction\ActionToolbarMenu {}
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor_codecompletion extends \TYPO3\CMS\T3Editor\CodeCompletion {}
+class tx_t3editor_codecompletion extends \TYPO3\CMS\T3editor\CodeCompletion {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor_tceforms_wizard extends \TYPO3\CMS\T3Editor\FormWizard {}
+class tx_t3editor_tceforms_wizard extends \TYPO3\CMS\T3editor\FormWizard {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor_hooks_fileedit extends \TYPO3\CMS\T3Editor\Hook\FileEditHook {}
+class tx_t3editor_hooks_fileedit extends \TYPO3\CMS\T3editor\Hook\FileEditHook {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor_hooks_tstemplateinfo extends \TYPO3\CMS\T3Editor\Hook\TypoScriptTemplateInfoHook {}
+class tx_t3editor_hooks_tstemplateinfo extends \TYPO3\CMS\T3editor\Hook\TypoScriptTemplateInfoHook {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor extends \TYPO3\CMS\T3Editor\T3Editor {}
+class tx_t3editor extends \TYPO3\CMS\T3editor\T3editor {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_t3editor_TSrefLoader extends \TYPO3\CMS\T3Editor\TypoScriptReferenceLoader {}
+class tx_t3editor_TSrefLoader extends \TYPO3\CMS\T3editor\TypoScriptReferenceLoader {}
 
 /**
  * @deprecated since 6.0 will be removed in 7.0
index d845b63..d0158d9 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3Editor;
+namespace TYPO3\CMS\T3editor;
 
 /***************************************************************
  *  Copyright notice
@@ -41,6 +41,13 @@ class CodeCompletion {
        protected $ajaxObj;
 
        /**
+        * Default constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
+       }
+
+       /**
         * General processor for AJAX requests.
         * (called by typo3/ajax.php)
         *
index 5449a87..cba243f 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3Editor;
+namespace TYPO3\CMS\T3editor;
 
 /***************************************************************
  *  Copyright notice
@@ -42,14 +42,14 @@ class FormWizard {
         * @return string|NULL
         */
        public function main($parameters, $pObj) {
-               $t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3Editor\\T3Editor');
+               $t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3editor\\T3editor');
                if (!$t3editor->isEnabled()) {
                        return;
                }
                if ($parameters['params']['format'] !== '') {
                        $t3editor->setModeByType($parameters['params']['format']);
                } else {
-                       $t3editor->setMode(\TYPO3\CMS\T3Editor\T3Editor::MODE_MIXED);
+                       $t3editor->setMode(\TYPO3\CMS\T3editor\T3editor::MODE_MIXED);
                }
                $config = $GLOBALS['TCA'][$parameters['table']]['columns'][$parameters['field']]['config'];
                $doc = $GLOBALS['SOBE']->doc;
index c85ac71..1e602d0 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3Editor\Hook;
+namespace TYPO3\CMS\T3editor\Hook;
 
 /***************************************************************
  *  Copyright notice
@@ -35,7 +35,7 @@ namespace TYPO3\CMS\T3Editor\Hook;
 class FileEditHook {
 
        /**
-        * @var \TYPO3\CMS\T3Editor\T3Editor
+        * @var \TYPO3\CMS\T3editor\T3editor
         */
        protected $t3editor = NULL;
 
@@ -45,11 +45,11 @@ class FileEditHook {
        protected $ajaxSaveType = 'TypoScriptTemplateInformationModuleFunctionController';
 
        /**
-        * @return \TYPO3\CMS\T3Editor\T3Editor
+        * @return \TYPO3\CMS\T3editor\T3editor
         */
        protected function getT3editor() {
                if ($this->t3editor == NULL) {
-                       $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3Editor\\T3Editor')->setAjaxSaveType($this->ajaxSaveType);
+                       $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3editor\\T3editor')->setAjaxSaveType($this->ajaxSaveType);
                }
                return $this->t3editor;
        }
index 2ee7183..76df038 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3Editor\Hook;
+namespace TYPO3\CMS\T3editor\Hook;
 
 /***************************************************************
  *  Copyright notice
@@ -35,7 +35,7 @@ namespace TYPO3\CMS\T3Editor\Hook;
 class TypoScriptTemplateInfoHook {
 
        /**
-        * @var \TYPO3\CMS\T3Editor\T3Editor
+        * @var \TYPO3\CMS\T3editor\T3editor
         */
        protected $t3editor = NULL;
 
@@ -45,11 +45,11 @@ class TypoScriptTemplateInfoHook {
        protected $ajaxSaveType = 'TypoScriptTemplateInformationModuleFunctionController';
 
        /**
-        * @return \TYPO3\CMS\T3Editor\T3Editor
+        * @return \TYPO3\CMS\T3editor\T3editor
         */
        protected function getT3editor() {
                if ($this->t3editor == NULL) {
-                       $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3Editor\\T3Editor')->setMode(\TYPO3\CMS\T3Editor\T3Editor::MODE_TYPOSCRIPT)->setAjaxSaveType($this->ajaxSaveType);
+                       $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\T3editor\\T3editor')->setMode(\TYPO3\CMS\T3editor\T3editor::MODE_TYPOSCRIPT)->setAjaxSaveType($this->ajaxSaveType);
                }
                return $this->t3editor;
        }
diff --git a/typo3/sysext/t3editor/Classes/T3Editor.php b/typo3/sysext/t3editor/Classes/T3Editor.php
deleted file mode 100644 (file)
index c1a258c..0000000
+++ /dev/null
@@ -1,446 +0,0 @@
-<?php
-namespace TYPO3\CMS\T3Editor;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2007-2013 Tobias Liebig <mail_typo3@etobi.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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!
- ***************************************************************/
-
-/**
- * Provides a javascript-driven code editor with syntax highlighting for TS, HTML, CSS and more
- *
- * @author Tobias Liebig <mail_typo3@etobi.de>
- */
-class T3Editor implements \TYPO3\CMS\Core\SingletonInterface {
-
-       const MODE_TYPOSCRIPT = 'typoscript';
-       const MODE_JAVASCRIPT = 'javascript';
-       const MODE_CSS = 'css';
-       const MODE_XML = 'xml';
-       const MODE_HTML = 'html';
-       const MODE_PHP = 'php';
-       const MODE_SPARQL = 'sparql';
-       const MODE_MIXED = 'mixed';
-       /**
-        * @var string
-        */
-       protected $mode = '';
-
-       /**
-        * @var string
-        */
-       protected $ajaxSaveType = '';
-
-       /**
-        * Counts the editors on the current page
-        *
-        * @var integer
-        */
-       protected $editorCounter = 0;
-
-       /**
-        * Flag to enable the t3editor
-        *
-        * @var boolean
-        */
-       protected $_isEnabled = TRUE;
-
-       /**
-        * sets the type of code to edit (::MODE_TYPOSCRIPT, ::MODE_JAVASCRIPT)
-        *
-        * @param $mode string Expects one of the predefined constants
-        * @return \TYPO3\CMS\T3Editor\T3Editor
-        */
-       public function setMode($mode) {
-               $this->mode = $mode;
-               return $this;
-       }
-
-       /**
-        * Set the AJAX save type
-        *
-        * @param string $ajaxSaveType
-        * @return \TYPO3\CMS\T3Editor\T3Editor
-        */
-       public function setAjaxSaveType($ajaxSaveType) {
-               $this->ajaxSaveType = $ajaxSaveType;
-               return $this;
-       }
-
-       /**
-        * Set mode by file
-        *
-        * @param string $file
-        * @return string
-        */
-       public function setModeByFile($file) {
-               $fileInfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
-               return $this->setModeByType($fileInfo['fileext']);
-       }
-
-       /**
-        * Set mode by type
-        *
-        * @param string $type
-        * @return void
-        */
-       public function setModeByType($type) {
-               switch ($type) {
-                       case 'html':
-
-                       case 'htm':
-
-                       case 'tmpl':
-                               $mode = self::MODE_HTML;
-                               break;
-                       case 'js':
-                               $mode = self::MODE_JAVASCRIPT;
-                               break;
-                       case 'xml':
-
-                       case 'svg':
-                               $mode = self::MODE_XML;
-                               break;
-                       case 'css':
-                               $mode = self::MODE_CSS;
-                               break;
-                       case 'ts':
-                               $mode = self::MODE_TYPOSCRIPT;
-                               break;
-                       case 'sparql':
-                               $mode = self::MODE_SPARQL;
-                               break;
-                       case 'php':
-
-                       case 'phpsh':
-
-                       case 'inc':
-                               $mode = self::MODE_PHP;
-                               break;
-                       default:
-                               $mode = self::MODE_MIXED;
-               }
-               $this->setMode($mode);
-       }
-
-       /**
-        * Get mode
-        *
-        * @return string
-        */
-       public function getMode() {
-               return $this->mode;
-       }
-
-       /**
-        * @return boolean TRUE if the t3editor is enabled
-        */
-       public function isEnabled() {
-               return $this->_isEnabled;
-       }
-
-       /**
-        * Creates a new instance of the class
-        */
-       public function __construct() {
-               // Disable pmktextarea to avoid conflicts (thanks Peter Klein for this suggestion)
-               $GLOBALS['BE_USER']->uc['disablePMKTextarea'] = 1;
-       }
-
-       /**
-        * Retrieves JavaScript code (header part) for editor
-        *
-        * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
-        * @return string JavaScript code
-        */
-       public function getJavascriptCode($doc) {
-               $content = '';
-               if ($this->isEnabled()) {
-                       $path_t3e = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor');
-                       $path_codemirror = 'contrib/codemirror/js/';
-                       // Include needed javascript-frameworks
-                       $pageRenderer = $doc->getPageRenderer();
-                       /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
-                       $pageRenderer->loadPrototype();
-                       $pageRenderer->loadScriptaculous();
-                       // Include editor-css
-                       $content .= '<link href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename(($GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/css/t3editor.css')) . '" type="text/css" rel="stylesheet" />';
-                       // Include editor-js-lib
-                       $doc->loadJavascriptLib($path_codemirror . 'codemirror.js');
-                       $doc->loadJavascriptLib($path_t3e . 'res/jslib/t3editor.js');
-
-                       $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS(
-                               'T3editor = T3editor || {};' .
-                               'T3editor.lang = ' . json_encode($this->getJavaScriptLabels()) . ';' . LF .
-                               'T3editor.PATH_t3e = "' . $GLOBALS['BACK_PATH'] . $path_t3e . '"; ' . LF .
-                               'T3editor.PATH_codemirror = "' . $GLOBALS['BACK_PATH'] . $path_codemirror . '"; ' . LF .
-                               'T3editor.URL_typo3 = "' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir) . '"; ' . LF .
-                               'T3editor.template = ' . $this->getPreparedTemplate() . ';' . LF .
-                               'T3editor.ajaxSavetype = "' . $this->ajaxSaveType . '";' . LF
-                       );
-                       $content .= $this->getModeSpecificJavascriptCode();
-               }
-               return $content;
-       }
-
-       /**
-        * Get mode specific JavaScript code
-        *
-        * @return string
-        */
-       public function getModeSpecificJavascriptCode() {
-               if (empty($this->mode)) {
-                       return '';
-               }
-               $path_t3e = $GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor');
-               $content = '';
-               if ($this->mode === self::MODE_TYPOSCRIPT) {
-                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsref.js' . '"></script>';
-                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/completionresult.js' . '"></script>';
-                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsparser.js' . '"></script>';
-                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tscodecompletion.js' . '"></script>';
-               }
-               $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS('T3editor.parserfile = ' . $this->getParserfileByMode($this->mode) . ';' . LF . 'T3editor.stylesheet = ' . $this->getStylesheetByMode($this->mode) . ';');
-               return $content;
-       }
-
-       /**
-        * Get the template code, prepared for javascript (no line breaks, quoted in single quotes)
-        *
-        * @return string The template code, prepared to use in javascript
-        */
-       protected function getPreparedTemplate() {
-               $T3Editor_template = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:t3editor/res/templates/t3editor.html'));
-               $T3Editor_template = addslashes($T3Editor_template);
-               $T3Editor_template = str_replace(array(CR, LF), array('', '\' + \''), $T3Editor_template);
-               return '\'' . $T3Editor_template . '\'';
-       }
-
-       /**
-        * Determine the correct parser js file for given mode
-        *
-        * @param string $mode
-        * @return string Parser file name
-        */
-       protected function getParserfileByMode($mode) {
-               switch ($mode) {
-                       case self::MODE_TYPOSCRIPT:
-                               $relPath = ($GLOBALS['BACK_PATH'] ? $GLOBALS['BACK_PATH'] : '../../../') . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/jslib/parse_typoscript/';
-                               $parserfile = '["' . $relPath . 'tokenizetyposcript.js", "' . $relPath . 'parsetyposcript.js"]';
-                               break;
-                       case self::MODE_JAVASCRIPT:
-                               $parserfile = '["tokenizejavascript.js", "parsejavascript.js"]';
-                               break;
-                       case self::MODE_CSS:
-                               $parserfile = '"parsecss.js"';
-                               break;
-                       case self::MODE_XML:
-                               $parserfile = '"parsexml.js"';
-                               break;
-                       case self::MODE_SPARQL:
-                               $parserfile = '"parsesparql.js"';
-                               break;
-                       case self::MODE_HTML:
-                               $parserfile = '["tokenizejavascript.js", "parsejavascript.js", "parsecss.js", "parsexml.js", "parsehtmlmixed.js"]';
-                               break;
-                       case self::MODE_PHP:
-
-                       case self::MODE_MIXED:
-                               $parserfile = '[' . '"tokenizejavascript.js", ' . '"parsejavascript.js", ' . '"parsecss.js", ' . '"parsexml.js", ' . '"../contrib/php/js/tokenizephp.js", ' . '"../contrib/php/js/parsephp.js", ' . '"../contrib/php/js/parsephphtmlmixed.js"' . ']';
-                               break;
-               }
-               return $parserfile;
-       }
-
-       /**
-        * Determine the correct css file for given mode
-        *
-        * @param string $mode
-        * @return string css file name
-        */
-       protected function getStylesheetByMode($mode) {
-               switch ($mode) {
-                       case self::MODE_TYPOSCRIPT:
-                               $stylesheet = 'T3editor.PATH_t3e + "res/css/typoscriptcolors.css"';
-                               break;
-                       case self::MODE_JAVASCRIPT:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/jscolors.css"';
-                               break;
-                       case self::MODE_CSS:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/csscolors.css"';
-                               break;
-                       case self::MODE_XML:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css"';
-                               break;
-                       case self::MODE_HTML:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css", ' . 'T3editor.PATH_codemirror + "../css/jscolors.css", ' . 'T3editor.PATH_codemirror + "../css/csscolors.css"';
-                               break;
-                       case self::MODE_SPARQL:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/sparqlcolors.css"';
-                               break;
-                       case self::MODE_PHP:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../contrib/php/css/phpcolors.css"';
-                               break;
-                       case self::MODE_MIXED:
-                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css", ' . 'T3editor.PATH_codemirror + "../css/jscolors.css", ' . 'T3editor.PATH_codemirror + "../css/csscolors.css", ' . 'T3editor.PATH_codemirror + "../contrib/php/css/phpcolors.css"';
-                               break;
-               }
-               if ($stylesheet != '') {
-                       $stylesheet = '' . $stylesheet . ', ';
-               }
-               return '[' . $stylesheet . 'T3editor.PATH_t3e + "res/css/t3editor_inner.css"]';
-       }
-
-       /**
-        * Gets the labels to be used in JavaScript in the Ext JS interface.
-        * TODO this method is copied from EXT:Recycler, maybe this should be refactored into a helper class
-        *
-        * @return array The labels to be used in JavaScript
-        */
-       protected function getJavaScriptLabels() {
-               $coreLabels = array();
-               $extensionLabels = $this->getJavaScriptLabelsFromLocallang('js.', 'label_');
-               return array_merge($coreLabels, $extensionLabels);
-       }
-
-       /**
-        * Gets labels to be used in JavaScript fetched from the current locallang file.
-        * TODO this method is copied from EXT:Recycler, maybe this should be refactored into a helper class
-        *
-        * @param string $selectionPrefix Prefix to select the correct labels (default: 'js.')
-        * @param string $stripFromSelectionName Sub-prefix to be removed from label names in the result (default: '')
-        * @return array Lables to be used in JavaScript of the current locallang file
-        * @todo Check, whether this method can be moved in a generic way to $GLOBALS['LANG']
-        */
-       protected function getJavaScriptLabelsFromLocallang($selectionPrefix = 'js.', $stripFromSelectionName = '') {
-               $extraction = array();
-               $labels = array_merge((array) $GLOBALS['LOCAL_LANG']['default'], (array) $GLOBALS['LOCAL_LANG'][$GLOBALS['LANG']->lang]);
-               // Regular expression to strip the selection prefix and possibly something from the label name:
-               $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#';
-               // Iterate throuh all locallang lables:
-               foreach ($labels as $label => $value) {
-                       if (strpos($label, $selectionPrefix) === 0) {
-                               $key = preg_replace($labelPattern, '', $label);
-                               $extraction[$key] = $value;
-                       }
-               }
-               return $extraction;
-       }
-
-       /**
-        * Generates HTML with code editor
-        *
-        * @param string $name Name attribute of HTML tag
-        * @param string $class Class attribute of HTML tag
-        * @param string $content Content of the editor
-        * @param string $additionalParams Any additional editor parameters
-        * @param string $alt Alt attribute
-        * @param array $hiddenfields
-        * @return string Generated HTML code for editor
-        */
-       public function getCodeEditor($name, $class = '', $content = '', $additionalParams = '', $alt = '', array $hiddenfields = array()) {
-               $code = '';
-               if ($this->isEnabled()) {
-                       $this->editorCounter++;
-                       $class .= ' t3editor';
-                       $alt = htmlspecialchars($alt);
-                       if (!empty($alt)) {
-                               $alt = ' alt="' . $alt . '"';
-                       }
-                       $code .= '<div>' . '<textarea id="t3editor_' . $this->editorCounter . '" ' . 'name="' . $name . '" ' . 'class="' . $class . '" ' . $additionalParams . ' ' . $alt . '>' . htmlspecialchars($content) . '</textarea></div>';
-                       $checked = $GLOBALS['BE_USER']->uc['disableT3Editor'] ? 'checked="checked"' : '';
-                       $code .= '<br /><br />' . '<input type="checkbox" ' . 'class="checkbox t3editor_disableEditor" ' . 'onclick="T3editor.toggleEditor(this);" ' . 'name="t3editor_disableEditor" ' . 'value="true" ' . 'id="t3editor_disableEditor_' . $this->editorCounter . '_checkbox" ' . $checked . ' />&nbsp;' . '<label for="t3editor_disableEditor_' . $this->editorCounter . '_checkbox">' . $GLOBALS['LANG']->getLL('deactivate') . '</label>' . '<br /><br />';
-                       if (count($hiddenfields)) {
-                               foreach ($hiddenfields as $name => $value) {
-                                       $code .= '<input type="hidden" ' . 'name="' . $name . '" ' . 'value="' . $value . '" />';
-                               }
-                       }
-               } else {
-                       // Fallback
-                       if (!empty($class)) {
-                               $class = 'class="' . $class . '" ';
-                       }
-                       $code .= '<textarea name="' . $name . '" ' . $class . $additionalParams . '>' . $content . '</textarea>';
-               }
-               return $code;
-       }
-
-       /**
-        * Save the content from t3editor retrieved via Ajax
-        *
-        * new Ajax.Request('/dev/t3e/dummy/typo3/ajax.php', {
-        * parameters: {
-        * ajaxID: 'T3Editor::saveCode',
-        * t3editor_savetype: 'TypoScriptTemplateInformationModuleFunctionController'
-        * }
-        * });
-        *
-        * @param array $params Parameters (not used yet)
-        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj AjaxRequestHandler to handle response
-        */
-       public function ajaxSaveCode($params, $ajaxObj) {
-               // cancel if its not an Ajax request
-               if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
-                       $ajaxObj->setContentFormat('json');
-                       $codeType = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t3editor_savetype');
-                       $savingsuccess = FALSE;
-                       try {
-                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'])) {
-                                       $_params = array(
-                                               'pObj' => &$this,
-                                               'type' => $codeType,
-                                               'ajaxObj' => &$ajaxObj
-                                       );
-                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'] as $key => $_funcRef) {
-                                               $savingsuccess = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this) || $savingsuccess;
-                                       }
-                               }
-                       } catch (\Exception $e) {
-                               $ajaxObj->setContent(array('result' => FALSE, 'exceptionMessage' => htmlspecialchars($e->getMessage()), 'exceptionCode' => $e->getCode()));
-                               return;
-                       }
-                       $ajaxObj->setContent(array('result' => $savingsuccess));
-               }
-       }
-
-       /**
-        * Gets plugins that are defined at $TYPO3_CONF_VARS['EXTCONF']['t3editor']['plugins']
-        * (called by typo3/ajax.php)
-        *
-        * @param array $params additional parameters (not used here)
-        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj The AjaxRequestHandler object of this request
-        * @return void
-        * @author Oliver Hader <oliver@typo3.org>
-        */
-       public function getPlugins($params, \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj) {
-               $result = array();
-               $plugins = &$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['t3editor']['plugins'];
-               if (is_array($plugins)) {
-                       $result = array_values($plugins);
-               }
-               $ajaxObj->setContent($result);
-               $ajaxObj->setContentFormat('jsonbody');
-       }
-
-}
diff --git a/typo3/sysext/t3editor/Classes/T3editor.php b/typo3/sysext/t3editor/Classes/T3editor.php
new file mode 100644 (file)
index 0000000..f74e071
--- /dev/null
@@ -0,0 +1,447 @@
+<?php
+namespace TYPO3\CMS\T3editor;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2007-2013 Tobias Liebig <mail_typo3@etobi.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 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.
+ *  A copy is found in the text file GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * Provides a javascript-driven code editor with syntax highlighting for TS, HTML, CSS and more
+ *
+ * @author Tobias Liebig <mail_typo3@etobi.de>
+ */
+class T3editor implements \TYPO3\CMS\Core\SingletonInterface {
+
+       const MODE_TYPOSCRIPT = 'typoscript';
+       const MODE_JAVASCRIPT = 'javascript';
+       const MODE_CSS = 'css';
+       const MODE_XML = 'xml';
+       const MODE_HTML = 'html';
+       const MODE_PHP = 'php';
+       const MODE_SPARQL = 'sparql';
+       const MODE_MIXED = 'mixed';
+       /**
+        * @var string
+        */
+       protected $mode = '';
+
+       /**
+        * @var string
+        */
+       protected $ajaxSaveType = '';
+
+       /**
+        * Counts the editors on the current page
+        *
+        * @var integer
+        */
+       protected $editorCounter = 0;
+
+       /**
+        * Flag to enable the t3editor
+        *
+        * @var boolean
+        */
+       protected $_isEnabled = TRUE;
+
+       /**
+        * sets the type of code to edit (::MODE_TYPOSCRIPT, ::MODE_JAVASCRIPT)
+        *
+        * @param $mode string Expects one of the predefined constants
+        * @return \TYPO3\CMS\T3editor\T3editor
+        */
+       public function setMode($mode) {
+               $this->mode = $mode;
+               return $this;
+       }
+
+       /**
+        * Set the AJAX save type
+        *
+        * @param string $ajaxSaveType
+        * @return \TYPO3\CMS\T3editor\T3editor
+        */
+       public function setAjaxSaveType($ajaxSaveType) {
+               $this->ajaxSaveType = $ajaxSaveType;
+               return $this;
+       }
+
+       /**
+        * Set mode by file
+        *
+        * @param string $file
+        * @return string
+        */
+       public function setModeByFile($file) {
+               $fileInfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
+               return $this->setModeByType($fileInfo['fileext']);
+       }
+
+       /**
+        * Set mode by type
+        *
+        * @param string $type
+        * @return void
+        */
+       public function setModeByType($type) {
+               switch ($type) {
+                       case 'html':
+
+                       case 'htm':
+
+                       case 'tmpl':
+                               $mode = self::MODE_HTML;
+                               break;
+                       case 'js':
+                               $mode = self::MODE_JAVASCRIPT;
+                               break;
+                       case 'xml':
+
+                       case 'svg':
+                               $mode = self::MODE_XML;
+                               break;
+                       case 'css':
+                               $mode = self::MODE_CSS;
+                               break;
+                       case 'ts':
+                               $mode = self::MODE_TYPOSCRIPT;
+                               break;
+                       case 'sparql':
+                               $mode = self::MODE_SPARQL;
+                               break;
+                       case 'php':
+
+                       case 'phpsh':
+
+                       case 'inc':
+                               $mode = self::MODE_PHP;
+                               break;
+                       default:
+                               $mode = self::MODE_MIXED;
+               }
+               $this->setMode($mode);
+       }
+
+       /**
+        * Get mode
+        *
+        * @return string
+        */
+       public function getMode() {
+               return $this->mode;
+       }
+
+       /**
+        * @return boolean TRUE if the t3editor is enabled
+        */
+       public function isEnabled() {
+               return $this->_isEnabled;
+       }
+
+       /**
+        * Creates a new instance of the class
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
+               // Disable pmktextarea to avoid conflicts (thanks Peter Klein for this suggestion)
+               $GLOBALS['BE_USER']->uc['disablePMKTextarea'] = 1;
+       }
+
+       /**
+        * Retrieves JavaScript code (header part) for editor
+        *
+        * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
+        * @return string JavaScript code
+        */
+       public function getJavascriptCode($doc) {
+               $content = '';
+               if ($this->isEnabled()) {
+                       $path_t3e = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor');
+                       $path_codemirror = 'contrib/codemirror/js/';
+                       // Include needed javascript-frameworks
+                       $pageRenderer = $doc->getPageRenderer();
+                       /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
+                       $pageRenderer->loadPrototype();
+                       $pageRenderer->loadScriptaculous();
+                       // Include editor-css
+                       $content .= '<link href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename(($GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/css/t3editor.css')) . '" type="text/css" rel="stylesheet" />';
+                       // Include editor-js-lib
+                       $doc->loadJavascriptLib($path_codemirror . 'codemirror.js');
+                       $doc->loadJavascriptLib($path_t3e . 'res/jslib/t3editor.js');
+
+                       $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS(
+                               'T3editor = T3editor || {};' .
+                               'T3editor.lang = ' . json_encode($this->getJavaScriptLabels()) . ';' . LF .
+                               'T3editor.PATH_t3e = "' . $GLOBALS['BACK_PATH'] . $path_t3e . '"; ' . LF .
+                               'T3editor.PATH_codemirror = "' . $GLOBALS['BACK_PATH'] . $path_codemirror . '"; ' . LF .
+                               'T3editor.URL_typo3 = "' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir) . '"; ' . LF .
+                               'T3editor.template = ' . $this->getPreparedTemplate() . ';' . LF .
+                               'T3editor.ajaxSavetype = "' . $this->ajaxSaveType . '";' . LF
+                       );
+                       $content .= $this->getModeSpecificJavascriptCode();
+               }
+               return $content;
+       }
+
+       /**
+        * Get mode specific JavaScript code
+        *
+        * @return string
+        */
+       public function getModeSpecificJavascriptCode() {
+               if (empty($this->mode)) {
+                       return '';
+               }
+               $path_t3e = $GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor');
+               $content = '';
+               if ($this->mode === self::MODE_TYPOSCRIPT) {
+                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsref.js' . '"></script>';
+                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/completionresult.js' . '"></script>';
+                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsparser.js' . '"></script>';
+                       $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tscodecompletion.js' . '"></script>';
+               }
+               $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS('T3editor.parserfile = ' . $this->getParserfileByMode($this->mode) . ';' . LF . 'T3editor.stylesheet = ' . $this->getStylesheetByMode($this->mode) . ';');
+               return $content;
+       }
+
+       /**
+        * Get the template code, prepared for javascript (no line breaks, quoted in single quotes)
+        *
+        * @return string The template code, prepared to use in javascript
+        */
+       protected function getPreparedTemplate() {
+               $T3editor_template = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:t3editor/res/templates/t3editor.html'));
+               $T3editor_template = addslashes($T3editor_template);
+               $T3editor_template = str_replace(array(CR, LF), array('', '\' + \''), $T3editor_template);
+               return '\'' . $T3editor_template . '\'';
+       }
+
+       /**
+        * Determine the correct parser js file for given mode
+        *
+        * @param string $mode
+        * @return string Parser file name
+        */
+       protected function getParserfileByMode($mode) {
+               switch ($mode) {
+                       case self::MODE_TYPOSCRIPT:
+                               $relPath = ($GLOBALS['BACK_PATH'] ? $GLOBALS['BACK_PATH'] : '../../../') . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/jslib/parse_typoscript/';
+                               $parserfile = '["' . $relPath . 'tokenizetyposcript.js", "' . $relPath . 'parsetyposcript.js"]';
+                               break;
+                       case self::MODE_JAVASCRIPT:
+                               $parserfile = '["tokenizejavascript.js", "parsejavascript.js"]';
+                               break;
+                       case self::MODE_CSS:
+                               $parserfile = '"parsecss.js"';
+                               break;
+                       case self::MODE_XML:
+                               $parserfile = '"parsexml.js"';
+                               break;
+                       case self::MODE_SPARQL:
+                               $parserfile = '"parsesparql.js"';
+                               break;
+                       case self::MODE_HTML:
+                               $parserfile = '["tokenizejavascript.js", "parsejavascript.js", "parsecss.js", "parsexml.js", "parsehtmlmixed.js"]';
+                               break;
+                       case self::MODE_PHP:
+
+                       case self::MODE_MIXED:
+                               $parserfile = '[' . '"tokenizejavascript.js", ' . '"parsejavascript.js", ' . '"parsecss.js", ' . '"parsexml.js", ' . '"../contrib/php/js/tokenizephp.js", ' . '"../contrib/php/js/parsephp.js", ' . '"../contrib/php/js/parsephphtmlmixed.js"' . ']';
+                               break;
+               }
+               return $parserfile;
+       }
+
+       /**
+        * Determine the correct css file for given mode
+        *
+        * @param string $mode
+        * @return string css file name
+        */
+       protected function getStylesheetByMode($mode) {
+               switch ($mode) {
+                       case self::MODE_TYPOSCRIPT:
+                               $stylesheet = 'T3editor.PATH_t3e + "res/css/typoscriptcolors.css"';
+                               break;
+                       case self::MODE_JAVASCRIPT:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/jscolors.css"';
+                               break;
+                       case self::MODE_CSS:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/csscolors.css"';
+                               break;
+                       case self::MODE_XML:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css"';
+                               break;
+                       case self::MODE_HTML:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css", ' . 'T3editor.PATH_codemirror + "../css/jscolors.css", ' . 'T3editor.PATH_codemirror + "../css/csscolors.css"';
+                               break;
+                       case self::MODE_SPARQL:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/sparqlcolors.css"';
+                               break;
+                       case self::MODE_PHP:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../contrib/php/css/phpcolors.css"';
+                               break;
+                       case self::MODE_MIXED:
+                               $stylesheet = 'T3editor.PATH_codemirror + "../css/xmlcolors.css", ' . 'T3editor.PATH_codemirror + "../css/jscolors.css", ' . 'T3editor.PATH_codemirror + "../css/csscolors.css", ' . 'T3editor.PATH_codemirror + "../contrib/php/css/phpcolors.css"';
+                               break;
+               }
+               if ($stylesheet != '') {
+                       $stylesheet = '' . $stylesheet . ', ';
+               }
+               return '[' . $stylesheet . 'T3editor.PATH_t3e + "res/css/t3editor_inner.css"]';
+       }
+
+       /**
+        * Gets the labels to be used in JavaScript in the Ext JS interface.
+        * TODO this method is copied from EXT:Recycler, maybe this should be refactored into a helper class
+        *
+        * @return array The labels to be used in JavaScript
+        */
+       protected function getJavaScriptLabels() {
+               $coreLabels = array();
+               $extensionLabels = $this->getJavaScriptLabelsFromLocallang('js.', 'label_');
+               return array_merge($coreLabels, $extensionLabels);
+       }
+
+       /**
+        * Gets labels to be used in JavaScript fetched from the current locallang file.
+        * TODO this method is copied from EXT:Recycler, maybe this should be refactored into a helper class
+        *
+        * @param string $selectionPrefix Prefix to select the correct labels (default: 'js.')
+        * @param string $stripFromSelectionName Sub-prefix to be removed from label names in the result (default: '')
+        * @return array Lables to be used in JavaScript of the current locallang file
+        * @todo Check, whether this method can be moved in a generic way to $GLOBALS['LANG']
+        */
+       protected function getJavaScriptLabelsFromLocallang($selectionPrefix = 'js.', $stripFromSelectionName = '') {
+               $extraction = array();
+               $labels = array_merge((array) $GLOBALS['LOCAL_LANG']['default'], (array) $GLOBALS['LOCAL_LANG'][$GLOBALS['LANG']->lang]);
+               // Regular expression to strip the selection prefix and possibly something from the label name:
+               $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#';
+               // Iterate throuh all locallang lables:
+               foreach ($labels as $label => $value) {
+                       if (strpos($label, $selectionPrefix) === 0) {
+                               $key = preg_replace($labelPattern, '', $label);
+                               $extraction[$key] = $value;
+                       }
+               }
+               return $extraction;
+       }
+
+       /**
+        * Generates HTML with code editor
+        *
+        * @param string $name Name attribute of HTML tag
+        * @param string $class Class attribute of HTML tag
+        * @param string $content Content of the editor
+        * @param string $additionalParams Any additional editor parameters
+        * @param string $alt Alt attribute
+        * @param array $hiddenfields
+        * @return string Generated HTML code for editor
+        */
+       public function getCodeEditor($name, $class = '', $content = '', $additionalParams = '', $alt = '', array $hiddenfields = array()) {
+               $code = '';
+               if ($this->isEnabled()) {
+                       $this->editorCounter++;
+                       $class .= ' t3editor';
+                       $alt = htmlspecialchars($alt);
+                       if (!empty($alt)) {
+                               $alt = ' alt="' . $alt . '"';
+                       }
+                       $code .= '<div>' . '<textarea id="t3editor_' . $this->editorCounter . '" ' . 'name="' . $name . '" ' . 'class="' . $class . '" ' . $additionalParams . ' ' . $alt . '>' . htmlspecialchars($content) . '</textarea></div>';
+                       $checked = $GLOBALS['BE_USER']->uc['disableT3Editor'] ? 'checked="checked"' : '';
+                       $code .= '<br /><br />' . '<input type="checkbox" ' . 'class="checkbox t3editor_disableEditor" ' . 'onclick="T3editor.toggleEditor(this);" ' . 'name="t3editor_disableEditor" ' . 'value="true" ' . 'id="t3editor_disableEditor_' . $this->editorCounter . '_checkbox" ' . $checked . ' />&nbsp;' . '<label for="t3editor_disableEditor_' . $this->editorCounter . '_checkbox">' . $GLOBALS['LANG']->getLL('deactivate') . '</label>' . '<br /><br />';
+                       if (count($hiddenfields)) {
+                               foreach ($hiddenfields as $name => $value) {
+                                       $code .= '<input type="hidden" ' . 'name="' . $name . '" ' . 'value="' . $value . '" />';
+                               }
+                       }
+               } else {
+                       // Fallback
+                       if (!empty($class)) {
+                               $class = 'class="' . $class . '" ';
+                       }
+                       $code .= '<textarea name="' . $name . '" ' . $class . $additionalParams . '>' . $content . '</textarea>';
+               }
+               return $code;
+       }
+
+       /**
+        * Save the content from t3editor retrieved via Ajax
+        *
+        * new Ajax.Request('/dev/t3e/dummy/typo3/ajax.php', {
+        * parameters: {
+        * ajaxID: 'T3editor::saveCode',
+        * t3editor_savetype: 'TypoScriptTemplateInformationModuleFunctionController'
+        * }
+        * });
+        *
+        * @param array $params Parameters (not used yet)
+        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj AjaxRequestHandler to handle response
+        */
+       public function ajaxSaveCode($params, $ajaxObj) {
+               // cancel if its not an Ajax request
+               if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
+                       $ajaxObj->setContentFormat('json');
+                       $codeType = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t3editor_savetype');
+                       $savingsuccess = FALSE;
+                       try {
+                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'])) {
+                                       $_params = array(
+                                               'pObj' => &$this,
+                                               'type' => $codeType,
+                                               'ajaxObj' => &$ajaxObj
+                                       );
+                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'] as $key => $_funcRef) {
+                                               $savingsuccess = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this) || $savingsuccess;
+                                       }
+                               }
+                       } catch (\Exception $e) {
+                               $ajaxObj->setContent(array('result' => FALSE, 'exceptionMessage' => htmlspecialchars($e->getMessage()), 'exceptionCode' => $e->getCode()));
+                               return;
+                       }
+                       $ajaxObj->setContent(array('result' => $savingsuccess));
+               }
+       }
+
+       /**
+        * Gets plugins that are defined at $TYPO3_CONF_VARS['EXTCONF']['t3editor']['plugins']
+        * (called by typo3/ajax.php)
+        *
+        * @param array $params additional parameters (not used here)
+        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj The AjaxRequestHandler object of this request
+        * @return void
+        * @author Oliver Hader <oliver@typo3.org>
+        */
+       public function getPlugins($params, \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj) {
+               $result = array();
+               $plugins = &$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['t3editor']['plugins'];
+               if (is_array($plugins)) {
+                       $result = array_values($plugins);
+               }
+               $ajaxObj->setContent($result);
+               $ajaxObj->setContentFormat('jsonbody');
+       }
+
+}
index 1c977c2..7bc485c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3Editor;
+namespace TYPO3\CMS\T3editor;
 
 /***************************************************************
  *  Copyright notice
@@ -46,6 +46,13 @@ class TypoScriptReferenceLoader {
        protected $ajaxObj;
 
        /**
+        * Default constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
+       }
+
+       /**
         * General processor for AJAX requests.
         * (called by typo3/ajax.php)
         *
diff --git a/typo3/sysext/t3editor/Classes/class.tx_t3editor.php b/typo3/sysext/t3editor/Classes/class.tx_t3editor.php
deleted file mode 100644 (file)
index 6784421..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2007-2013 Tobias Liebig <mail_typo3@etobi.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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!
- ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
-/*
- * @deprecated since 6.0, the classname tx_t3editor and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/T3Editor.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/T3Editor.php';
diff --git a/typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_fileedit.php b/typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_fileedit.php
deleted file mode 100644 (file)
index a329b78..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2010-2013 Tobias Liebig <mail_typo3@etobi.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor', 'Classes/class.tx_t3editor.php');
-/*
- * @deprecated since 6.0, the classname tx_t3editor_hooks_fileedit and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/Hook/FileEditHook.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/Hook/FileEditHook.php';
diff --git a/typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php b/typo3/sysext/t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php
deleted file mode 100644 (file)
index 64755bc..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2007-2013 Tobias Liebig <mail_typo3@etobi.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor', 'Classes/class.tx_t3editor.php');
-/*
- * @deprecated since 6.0, the classname tx_t3editor_hooks_tstemplateinfo and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/Hook/TypoScriptTemplateInfoHook.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/Hook/TypoScriptTemplateInfoHook.php';
diff --git a/typo3/sysext/t3editor/Classes/class.tx_t3editor_tceforms_wizard.php b/typo3/sysext/t3editor/Classes/class.tx_t3editor_tceforms_wizard.php
deleted file mode 100644 (file)
index 600552f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2007-2013 Tobias Liebig <mail_typo3@etobi.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor', 'Classes/class.tx_t3editor.php');
-/*
- * @deprecated since 6.0, the classname tx_t3editor_tceforms_wizard and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/FormWizard.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/FormWizard.php';
diff --git a/typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_codecompletion.php b/typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_codecompletion.php
deleted file mode 100644 (file)
index 45cc986..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2008-2013 Stephan Petzl <spetzl@gmx.at> and Christian Kartnig <office@hahnepeter.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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!
- ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
-/*
- * @deprecated since 6.0, the classname tx_t3editor_codecompletion and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/CodeCompletion.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/CodeCompletion.php';
diff --git a/typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_tsrefloader.php b/typo3/sysext/t3editor/Classes/ts_codecompletion/class.tx_t3editor_tsrefloader.php
deleted file mode 100644 (file)
index 3c84ce5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2008-2013 Stephan Petzl <spetzl@gmx.at> and Christian Kartnig <office@hahnepeter.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 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.
- *  A copy is found in the text file GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- *  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!
- ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
-/*
- * @deprecated since 6.0, the classname tx_t3editor_TSrefLoader and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3editor') . 'Classes/TypoScriptReferenceLoader.php';
index 30e36d1..b4f2ebf 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 return array(
-       'tx_t3editor_codecompletion' => 'TYPO3\\CMS\\T3Editor\\CodeCompletion',
-       'tx_t3editor_tceforms_wizard' => 'TYPO3\\CMS\\T3Editor\\FormWizard',
-       'tx_t3editor_hooks_fileedit' => 'TYPO3\\CMS\\T3Editor\\Hook\\FileEditHook',
-       'tx_t3editor_hooks_tstemplateinfo' => 'TYPO3\\CMS\\T3Editor\\Hook\\TypoScriptTemplateInfoHook',
-       'tx_t3editor' => 'TYPO3\\CMS\\T3Editor\\T3Editor',
-       'tx_t3editor_TSrefLoader' => 'TYPO3\\CMS\\T3Editor\\TypoScriptReferenceLoader',
+       'tx_t3editor_codecompletion' => 'TYPO3\\CMS\\T3editor\\CodeCompletion',
+       'tx_t3editor_tceforms_wizard' => 'TYPO3\\CMS\\T3editor\\FormWizard',
+       'tx_t3editor_hooks_fileedit' => 'TYPO3\\CMS\\T3editor\\Hook\\FileEditHook',
+       'tx_t3editor_hooks_tstemplateinfo' => 'TYPO3\\CMS\\T3editor\\Hook\\TypoScriptTemplateInfoHook',
+       'tx_t3editor' => 'TYPO3\\CMS\\T3editor\\T3editor',
+       'tx_t3editor_TSrefLoader' => 'TYPO3\\CMS\\T3editor\\TypoScriptReferenceLoader',
 );
index 2af6c59..0c8d006 100644 (file)
@@ -4,11 +4,11 @@ if (!defined('TYPO3_MODE')) {
 }
 if (TYPO3_MODE == 'BE') {
        // Register hooks for tstemplate module
-       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php:&TYPO3\\CMS\\T3Editor\\Hook\\TypoScriptTemplateInfoHook->preStartPageHook';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'][] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php:&TYPO3\\CMS\\T3Editor\\Hook\\TypoScriptTemplateInfoHook->postOutputProcessingHook';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['tx_tstemplateinfo'] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_tstemplateinfo.php:&TYPO3\\CMS\\T3Editor\\Hook\\TypoScriptTemplateInfoHook->save';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['file_edit'] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_fileedit.php:&TYPO3\\CMS\\T3Editor\\Hook\\FileEditHook->save';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_fileedit.php:&TYPO3\\CMS\\T3Editor\\Hook\\FileEditHook->preStartPageHook';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'][] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_fileedit.php:&TYPO3\\CMS\\T3Editor\\Hook\\FileEditHook->preOutputProcessingHook';
-       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'][] = 'EXT:t3editor/Classes/class.tx_t3editor_hooks_fileedit.php:&TYPO3\\CMS\\T3Editor\\Hook\\FileEditHook->postOutputProcessingHook';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = 'TYPO3\\CMS\\T3editor\\Hook\\TypoScriptTemplateInfoHook->preStartPageHook';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'][] = 'TYPO3\\CMS\\T3editor\\Hook\\TypoScriptTemplateInfoHook->postOutputProcessingHook';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['tx_tstemplateinfo'] = 'TYPO3\\CMS\\T3editor\\Hook\\TypoScriptTemplateInfoHook->save';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['file_edit'] = 'TYPO3\\CMS\\T3editor\\Hook\\FileEditHook->save';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = 'TYPO3\\CMS\\T3editor\\Hook\\FileEditHook->preStartPageHook';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'][] = 'TYPO3\\CMS\\T3editor\\Hook\\FileEditHook->preOutputProcessingHook';
+       $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'][] = 'TYPO3\\CMS\\T3editor\\Hook\\FileEditHook->postOutputProcessingHook';
 }
index c07ba49..81e018c 100644 (file)
@@ -2,18 +2,20 @@
 if (!defined('TYPO3_MODE')) {
        die('Access denied.');
 }
+
 if (TYPO3_MODE === 'BE') {
        // Register AJAX handlers:
-       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor::saveCode'] = 'EXT:t3editor/Classes/class.tx_t3editor.php:TYPO3\\CMS\\T3Editor\\T3Editor->ajaxSaveCode';
-       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor::getPlugins'] = 'EXT:t3editor/Classes/class.tx_t3editor.php:TYPO3\\CMS\\T3Editor\\T3Editor->getPlugins';
-       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor_TSrefLoader::getTypes'] = 'EXT:t3editor/Classes/ts_codecompletion/class.tx_t3editor_tsrefloader.php:TYPO3\\CMS\\T3Editor\\TypoScriptReferenceLoader->processAjaxRequest';
-       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor_TSrefLoader::getDescription'] = 'EXT:t3editor/Classes/ts_codecompletion/class.tx_t3editor_tsrefloader.php:TYPO3\\CMS\\T3Editor\\TypoScriptReferenceLoader->processAjaxRequest';
-       $TYPO3_CONF_VARS['BE']['AJAX']['CodeCompletion::loadTemplates'] = 'EXT:t3editor/Classes/ts_codecompletion/class.tx_t3editor_codecompletion.php:TYPO3\\CMS\\T3Editor\\CodeCompletion->processAjaxRequest';
+       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor::saveCode'] = 'TYPO3\\CMS\\T3editor\\T3editor->ajaxSaveCode';
+       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor::getPlugins'] = 'TYPO3\\CMS\\T3editor\\T3editor->getPlugins';
+       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor_TSrefLoader::getTypes'] = 'TYPO3\\CMS\\T3editor\\TypoScriptReferenceLoader->processAjaxRequest';
+       $TYPO3_CONF_VARS['BE']['AJAX']['T3Editor_TSrefLoader::getDescription'] = 'TYPO3\\CMS\\T3editor\\TypoScriptReferenceLoader->processAjaxRequest';
+       $TYPO3_CONF_VARS['BE']['AJAX']['CodeCompletion::loadTemplates'] = 'TYPO3\\CMS\\T3editor\\CodeCompletion->processAjaxRequest';
+
        // Add the t3editor wizard on the bodytext field of tt_content
        $TCA['tt_content']['columns']['bodytext']['config']['wizards']['t3editor'] = array(
                'enableByTypeConfig' => 1,
                'type' => 'userFunc',
-               'userFunc' => 'EXT:t3editor/Classes/class.tx_t3editor_tceforms_wizard.php:TYPO3\\CMS\\T3Editor\\FormWizard->main',
+               'userFunc' => 'TYPO3\\CMS\\T3editor\\FormWizard->main',
                'title' => 't3editor',
                'icon' => 'wizard_table.gif',
                'script' => 'wizard_table.php',
@@ -22,6 +24,7 @@ if (TYPO3_MODE === 'BE') {
                        'style' => 'width:98%; height: 60%;'
                )
        );
+
        // Activate the t3editor only for type html
        $TCA['tt_content']['types']['html']['showitem'] = str_replace('bodytext,', 'bodytext;LLL:EXT:cms/locallang_ttc.xlf:bodytext.ALT.html_formlabel;;nowrap:wizards[t3editor],', $TCA['tt_content']['types']['html']['showitem']);
 }