Index: branches/5.3.x/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r15677 -r15690 --- branches/5.3.x/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 15677) +++ branches/5.3.x/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 15690) @@ -1,6 +1,6 @@ Application->isCachingType(CACHING_TYPE_MEMORY); } + + /** + * Generates HTML for additional js and css files inclusion in accordance to selected editor language + * + * @param Array $params + * @return string + * @access protected + */ + protected function IncludeCodeMirrorFilesByLanguage($params) + { + $ret = ''; + $language = $params['language']; + + $language_map = Array ( + 'application/x-httpd-php' => Array ( + 'htmlmixed.js', 'xml.js', 'javascript.js', 'css.js', 'clike.js', 'php.js' + ), + 'text/html' => Array ( + 'xml.js', 'javascript.js', 'css.js', 'htmlmixed.js' + ) + ); + + if ( !isset($language_map[$language]) ) { + $language_map[$language] = Array ($language . '.js'); + } + + foreach ($language_map[$language] as $filename) { + $ret .= $this->_includeCodeMirrorFile($filename, $params); + } + + return $ret; + } + + /** + * Generates code for one CodeMirror additional file inclusion + * + * @param string $filename + * @param Array $params + * @return string + * @access protected + * @throws InvalidArgumentException + */ + protected function _includeCodeMirrorFile($filename, $params) + { + static $included = Array (); + + $name = pathinfo($filename, PATHINFO_FILENAME); + $extension = pathinfo($filename, PATHINFO_EXTENSION); + + if ( $extension != 'js' && $extension != 'css' ) { + throw new InvalidArgumentException('Extension "' . $extension . '" not supported'); + } + + if ( isset($included[$filename]) ) { + return ''; + } + + $included[$filename] = 1; + + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + $block_params['resource_extension'] = $extension; + $block_params['resource_file'] = $name . '/' . $filename; + + return $this->Application->ParseBlock($block_params); + } } \ No newline at end of file