Fixed bug #17270: t3editor not enabled when editing .php/.inc files
authorTobias Liebig <mail@etobi.de>
Mon, 24 Jan 2011 21:14:50 +0000 (21:14 +0000)
committerTobias Liebig <mail@etobi.de>
Mon, 24 Jan 2011 21:14:50 +0000 (21:14 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10284 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/t3editor/classes/class.tx_t3editor.php

index de0b398..332d4a4 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
 2011-01-24  Tobias Liebig  <mail_typo3@etobi.de>
 
        * Fixed bug #17078: in fileadmin saving changes from t3editor doesn't work
+       * Fixed bug #17270: t3editor not enabled when editing .php/.inc files
 
 2011-01-24  Francois Suter  <francois.suter@typo3.org>
 
index fb4cf49..cbaea3a 100644 (file)
@@ -41,6 +41,8 @@ class tx_t3editor implements t3lib_Singleton {
        const MODE_CSS = 'css';
        const MODE_XML = 'xml';
        const MODE_HTML = 'html';
+       const MODE_PHP = 'php';
+       const MODE_MIXED = 'mixed';
 
        protected $mode = '';
 
@@ -102,8 +104,13 @@ class tx_t3editor implements t3lib_Singleton {
                        case 'ts':
                                $mode = self::MODE_TYPOSCRIPT;
                                break;
+                       case 'php':
+                       case 'phpsh':
+                       case 'inc':
+                               $mode = self::MODE_PHP;
+                               break;
                        default:
-                               $mode = FALSE;
+                               $mode = self::MODE_MIXED;
                }
                $this->setMode($mode);
        }
@@ -197,14 +204,15 @@ class tx_t3editor implements t3lib_Singleton {
                return $content;
        }
 
-    public function getModeSpecificJavascriptCode() {
-        if (empty($this->mode)) {
-            return '';
-        }
+       public function getModeSpecificJavascriptCode() {
+               if (empty($this->mode)) {
+                       return '';
+               }
 
-        $path_t3e = $GLOBALS['BACK_PATH'] . t3lib_extmgm::extRelPath('t3editor');
+               $path_t3e = $GLOBALS['BACK_PATH'] . t3lib_extmgm::extRelPath('t3editor');
+               $content = '';
 
-        if ($this->mode == self::MODE_TYPOSCRIPT) {
+               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>';
@@ -246,23 +254,36 @@ class tx_t3editor implements t3lib_Singleton {
                        case tx_t3editor::MODE_TYPOSCRIPT:
                                $relPath = $GLOBALS['BACK_PATH'] . t3lib_extmgm::extRelPath('t3editor') . 'res/jslib/parse_typoscript/';
                                $parserfile = '["' . $relPath . 'tokenizetyposcript.js", "' . $relPath . 'parsetyposcript.js"]';
-                       break;
+                               break;
 
                        case tx_t3editor::MODE_JAVASCRIPT:
                                $parserfile = '["tokenizejavascript.js", "parsejavascript.js"]';
-                       break;
+                               break;
 
                        case tx_t3editor::MODE_CSS:
                                $parserfile = '"parsecss.js"';
-                       break;
+                               break;
 
                        case tx_t3editor::MODE_XML:
                                $parserfile = '"parsexml.js"';
-                       break;
+                               break;
 
                        case tx_t3editor::MODE_HTML:
                                $parserfile = '["tokenizejavascript.js", "parsejavascript.js", "parsecss.js", "parsexml.js", "parsehtmlmixed.js"]';
-                       break;
+                               break;
+
+                       case tx_t3editor::MODE_PHP:
+                       case tx_t3editor::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;
        }
@@ -292,8 +313,20 @@ class tx_t3editor implements t3lib_Singleton {
                        break;
 
                        case tx_t3editor::MODE_HTML:
-                               $stylesheet = '"res/css/xmlcolors.css"';
-                               // FIXME add css and js files
+                               $stylesheet = '"res/css/xmlcolors.css", ' .
+                                       'T3editor.PATH_t3e + "res/css/jscolors.css", ' .
+                                       'T3editor.PATH_t3e + "res/css/csscolors.css"';
+                       break;
+
+                       case tx_t3editor::MODE_PHP:
+                               $stylesheet = '"../../contrib/codemirror/contrib/php/css/phpcolors.css"';
+                       break;
+
+                       case tx_t3editor::MODE_MIXED:
+                               $stylesheet = '"res/css/xmlcolors.css", ' .
+                                       'T3editor.PATH_t3e + "res/css/jscolors.css", ' .
+                                       'T3editor.PATH_t3e + "res/css/csscolors.css", ' .
+                                       'T3editor.PATH_codemirror + "../contrib/php/css/phpcolors.css"';
                        break;
                }
                return '[T3editor.PATH_t3e + ' . $stylesheet . ', T3editor.PATH_t3e + "res/css/t3editor_inner.css"]';
@@ -473,4 +506,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/t3editor/classes/class.tx_t3editor.php']);
 }
 
-?>
\ No newline at end of file
+?>