Index: branches/RC/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r11649 -r11661 --- branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11649) +++ branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11661) @@ -1351,8 +1351,17 @@ $ret .= '' . "\n"; $ret .= '' . "\n"; $ret .= '' . "\n"; + $ret .= '' . "\n"; $ret .= ' \ No newline at end of file Index: branches/RC/core/units/email_messages/email_messages_config.php =================================================================== diff -u -N -r11623 -r11661 --- branches/RC/core/units/email_messages/email_messages_config.php (.../email_messages_config.php) (revision 11623) +++ branches/RC/core/units/email_messages/email_messages_config.php (.../email_messages_config.php) (revision 11661) @@ -114,7 +114,7 @@ 'Subject' => Array( 'title'=>'la_col_Subject', 'filter_block' => 'grid_like_filter'), 'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'label_grid_checkbox_td', 'filter_block' => 'grid_like_filter'), 'Type' => Array( 'title'=>'la_col_Type', 'filter_block' => 'grid_options_filter'), - 'LanguageId' => Array( 'title'=>'la_col_PackName', 'filter_block' => 'grid_options_filter'), + 'LanguageId' => Array( 'title'=>'la_col_Language', 'filter_block' => 'grid_options_filter'), ), ), Index: branches/RC/core/units/general/helpers/template_helper.php =================================================================== diff -u -N -r11495 -r11661 --- branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11495) +++ branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11661) @@ -37,41 +37,67 @@ */ var $_sourceTemplate = ''; - function TemplateHelper() + var $_initMade = false; + + /** + * Performs init ot helper + * + * @param kDBItem $object + */ + function InitHelper(&$object) { - parent::kHelper(); + if ($this->_initMade) { + return ; + } + define('DBG_IGNORE_FATAL_ERRORS', 1); + // 1. get block information $block_info = $this->Application->GetVar('block'); list ($this->_blockName, $this->_functionName) = explode(':', $block_info); - $this->_parseTemplate(); + $this->_parseTemplate($object); if (array_key_exists($this->_functionName, $this->Application->Parser->ElementLocations)) { $this->_blockLocation = $this->Application->Parser->ElementLocations[$this->_functionName]; } + + $this->_initMade = true; } function _getSourceTemplate() { // get source template $t = $this->Application->GetVar('source'); - - $cms_handler =& $this->Application->recallObject('st_EventHandler'); - /* @var $cms_handler StructureEventHandler */ - if (!$this->Application->TemplatesCache->TemplateExists($t) && !$this->Application->IsAdmin()) { + if (!$this->Application->TemplatesCache->TemplateExists($t)) { + $cms_handler =& $this->Application->recallObject('st_EventHandler'); + /* @var $cms_handler StructureEventHandler */ + $t = $cms_handler->GetDesignTemplate($t); } $this->_sourceTemplate = $t; } + function _getThemeName() + { + $theme_id = (int)$this->Application->GetVar('theme_id'); + + $sql = 'SELECT Name + FROM ' . $this->Application->getUnitOption('theme', 'TableName') . ' + WHERE ' . $this->Application->getUnitOption('theme', 'IDField') . ' = ' . $theme_id; + return $this->Conn->GetOne($sql); + } + /** * Render source template to get parse errors OR it's element locations * + * @param kDBItem $object + * @param string $append + * @return bool */ - function _parseTemplate($append = '') + function _parseTemplate(&$object, $append = '') { // 1. set internal error handler to catch all parsing errors $error_handlers = $this->Application->errorHandlers; @@ -80,10 +106,12 @@ ); // 2. parse template - $this->Application->InitParser(); // we have no parser when saving block content + $this->Application->InitParser( $this->_getThemeName() ); // we have no parser when saving block content + $this->_getSourceTemplate(); - $this->Application->Parser->Run($this->_sourceTemplate . $append); + // design templates have leading "/" in the beginning + $this->Application->Parser->Run(ltrim($this->_sourceTemplate, '/') . $append); // 3. restore original error handler $this->Application->errorHandlers = $error_handlers; @@ -94,15 +122,15 @@ $filename = $this->_getTemplateFile(false, $append . '.tpl'); if (!unlink($filename)) { $error_file = $this->_getTemplateFile(true, $append . '.tpl'); - $this->Application->SetVar('Failed to delete temporary template "' . $error_file . '"'); + $object->SetError('FileContents', 'template_delete_failed', '+Failed to delete temporary template "' . $error_file . '"'); return false; } } else { // 3.2. restore backup if (!rename($this->_getTemplateFile(false, '.tpl.bak'), $this->_getTemplateFile(false))) { $error_file = $this->_getTemplateFile(true); - $this->Application->SetVar('Failed to restore template "' . $error_file . '" from backup.'); + $object->SetError('FileContents', 'template_restore_failed', '+Failed to restore template "' . $error_file . '" from backup.'); return false; } } @@ -146,12 +174,6 @@ break; case 'content': - $function_body = $this->Application->GetVar('function_body'); - if ($function_body !== false) { - // error happened -> use unsaved template content - return unhtmlentities( $function_body ); - } - $template_body = file_get_contents( $this->_getTemplateFile() ); $length = $this->_blockLocation['end_pos'] - $this->_blockLocation['start_pos']; @@ -191,26 +213,25 @@ /** * Saves new version of block to template, where it's located * - * @param kEvent $event + * @param kDBItem $object */ - function saveBlock(&$event) + function saveBlock(&$object) { $main_template = $this->_isMainTemplate(); $filename = $this->_getTemplateFile(false); // 1. get new template content - $new_template_body = $this->_getNewTemplateContent($filename, $lines_before); + $new_template_body = $this->_getNewTemplateContent($object, $filename, $lines_before); if (is_bool($new_template_body) && ($new_template_body === true)) { // when nothing changed -> stop processing - echo '0'; return true; } // 2. backup original template if (!$main_template && !copy($filename, $filename . '.bak')) { // backup failed $error_file = $this->_getTemplateFile(true, '.tpl.bak'); - $this->Application->SetVar('error_msg', 'Failed to create backup template "' . $error_file . '" backup.'); + $object->SetError('FileContents', 'template_backup_failed', '+Failed to create backup template "' . $error_file . '" backup.'); return false; } @@ -220,14 +241,14 @@ if (!$fp) { // backup template create failed OR existing template save $error_file = $this->_getTemplateFile(true, $main_template ? '.tmp.tpl' : '.tpl'); - $this->Application->SetVar('error_msg', 'Failed to save template "' . $error_file . '" changes.'); + $object->SetError('FileContents', 'template_changes_save_failed', '+Failed to save template "' . $error_file . '" changes.'); return false; } fwrite($fp, $new_template_body); fclose($fp); // 3. parse template to check for errors - $this->_parseTemplate($main_template ? '.tmp' : ''); + $this->_parseTemplate($object, $main_template ? '.tmp' : ''); if ($this->_parseErrors) { $error_msg = Array (); @@ -240,7 +261,7 @@ $error_msg[] = $error_data['msg'] . ' at line ' . ($error_data['line'] - $lines_before); } - $this->Application->SetVar('error_msg', 'Template syntax errors:
' . implode('
', $error_msg)); + $object->SetError('FileContents', 'template_syntax_error', '+Template syntax errors:
' . implode('
', $error_msg)); return false; } @@ -249,7 +270,7 @@ if (!rename($this->_getTemplateFile(false, '.tmp.tpl'), $filename)) { // failed to save new content to original template $error_file = $this->_getTemplateFile(true); - $this->Application->SetVar('error_msg', 'Failed to save template "' . $error_file . '".'); + $object->SetError('FileContents', 'template_save_failed', '+Failed to save template "' . $error_file . '".'); return false; } } @@ -258,23 +279,20 @@ unlink( $this->_getTemplateFile(false, '.tpl.bak') ); } - define('DBG_SKIP_REPORTING', 1); - $this->Application->Redirect($this->Application->GetVar('source')); - echo 1; // were changes - return true; } /** * Returns new template content of "true", when nothing is changed * + * @param kDBItem $object * @param string $filename * @param int $lines_before * @return mixed */ - function _getNewTemplateContent($filename, &$lines_before) + function _getNewTemplateContent(&$object, $filename, &$lines_before) { - $new_content = unhtmlentities( $this->Application->GetVar('function_body') ); + $new_content = $object->GetDBField('FileContents'); $template_body = file_get_contents($filename); $lines_before = substr_count(substr($template_body, 0, $this->_blockLocation['start_pos']), "\n"); @@ -288,11 +306,16 @@ function _saveError($errno, $errstr, $errfile, $errline, $errcontext) { - if (defined('E_STRICT') && ($errno == E_STRICT)) { - // always ignore strict errors here (specially when not in debug mode) + if ($errno != E_USER_ERROR) { + // ignore all minor errors, except fatals from parser return true; } + /*if (defined('E_STRICT') && ($errno == E_STRICT)) { + // always ignore strict errors here (specially when not in debug mode) + return true; + }*/ + $this->_parseErrors[] = Array ('msg' => $errstr, 'file' => $errfile, 'line' => $errline); return true; } Index: branches/RC/core/admin_templates/themes/codepress/languages/html.css =================================================================== diff -u -N --- branches/RC/core/admin_templates/themes/codepress/languages/html.css (revision 0) +++ branches/RC/core/admin_templates/themes/codepress/languages/html.css (revision 11661) @@ -0,0 +1,18 @@ +/* + * CodePress color styles for HTML syntax highlighting + */ + +b {color:#000080;} /* tags */ +ins, ins b, ins s, ins em {color:gray;} /* comments */ +s, s b {color:#7777e4;} /* attribute values */ +a {color:green;} /* links */ +u {color:#E67300;} /* forms */ +big {color:#db0000;} /* images */ +em, em b {color:#800080;} /* style */ +strong {color:#800000;} /* script */ +tt i {color:darkblue;font-weight:bold;} /* script reserved words */ + +b.inp-tag { + color: #CF3E33; + font-style: italic; +} \ No newline at end of file Index: branches/RC/core/install/english.lang =================================================================== diff -u -N -r11641 -r11661 --- branches/RC/core/install/english.lang (.../english.lang) (revision 11641) +++ branches/RC/core/install/english.lang (.../english.lang) (revision 11661) @@ -709,6 +709,7 @@ QmFja2dyb3VuZCBJbWFnZQ== QmFja2dyb3VuZCBQb3NpdGlvbg== QmFja2dyb3VuZCBSZXBlYXQ= + RWxlbWVudCBQb3NpdGlvbg== Qm9yZGVyIEJvdHRvbQ== Qm9yZGVyIExlZnQ= Qm9yZGVyIFJpZ2h0 @@ -770,6 +771,7 @@ RmllbGRzIHNlcGFyYXRlZCBieQ== RmllbGQgVGl0bGVz RmllbGQgVmFsdWU= + RmlsZSBDb250ZW50cw== RmlsZW5hbWU= RmlsZW5hbWUgUmVwbGFjZW1lbnRz Rmlyc3QgTmFtZQ== @@ -2042,6 +2044,7 @@ RWRpdGluZyBTcGVsbGluZyBEaWN0aW9uYXJ5 RWRpdGluZyBTdG9wIFdvcmQ= RWRpdGluZyBTdHlsZQ== + RWRpdGluZyBUaGVtZSBGaWxl RWRpdGluZyBUaGVzYXVydXM= RWRpdGluZyBUcmFuc2xhdGlvbg== RWRpdGluZyBCYXNlIFN0eWxl Index: branches/RC/core/admin_templates/themes/codepress/languages/html.js =================================================================== diff -u -N --- branches/RC/core/admin_templates/themes/codepress/languages/html.js (revision 0) +++ branches/RC/core/admin_templates/themes/codepress/languages/html.js (revision 11661) @@ -0,0 +1,60 @@ +/* + * CodePress regular expressions for HTML syntax highlighting + */ + +// HTML +Language.syntax = [ + { input : /(<[^!]*?>)/g, output : '$1' }, // all tags + { input : /(<a .*?>|<\/a>)/g, output : '$1' }, // links + { input : /(<img .*?>)/g, output : '$1' }, // images + { input : /(<\/?(button|textarea|form|input|select|option|label).*?>)/g, output : '$1' }, // forms + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, // style tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, // script tags + { input : /=(".*?")/g, output : '=$1' }, // atributes double quote + { input : /=('.*?')/g, output : '=$1' }, // atributes single quote + { input : /(<!--.*?-->.)/g, output : '$1' }, // comments + { input : /(<[\/]?)(inp2\:.*?)(\s|[\/]?>)/g, output : '$1$2$3' }, // inp2 tags + { input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '$1' } // script reserved words +] + +Language.snippets = [ + { input : 'aref', output : '' }, + { input : 'h1', output : '

$0

' }, + { input : 'h2', output : '

$0

' }, + { input : 'h3', output : '

$0

' }, + { input : 'h4', output : '

$0

' }, + { input : 'h5', output : '
$0
' }, + { input : 'h6', output : '
$0
' }, + { input : 'html', output : '\n\t$0\n' }, + { input : 'head', output : '\n\t\n\t$0\n\t\n' }, + { input : 'img', output : '' }, + { input : 'input', output : '' }, + { input : 'label', output : '' }, + { input : 'legend', output : '\n\t$0\n' }, + { input : 'link', output : '' }, + { input : 'base', output : '' }, + { input : 'body', output : '\n\t$0\n' }, + { input : 'css', output : '' }, + { input : 'div', output : '
\n\t$0\n
' }, + { input : 'divid', output : '
\n\t\n
' }, + { input : 'dl', output : '
\n\t
\n\t\t$0\n\t
\n\t
\n
' }, + { input : 'fieldset', output : '
\n\t$0\n
' }, + { input : 'form', output : '
\n\t\n
' }, + { input : 'meta', output : '' }, + { input : 'p', output : '

$0

' }, + { input : 'script', output : '' }, + { input : 'scriptsrc', output : '' }, + { input : 'span', output : '$0' }, + { input : 'table', output : '\n\t\n\t\n
' }, + { input : 'style', output : '' } +] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] Index: branches/RC/core/admin_templates/index.tpl =================================================================== diff -u -N -r11623 -r11661 --- branches/RC/core/admin_templates/index.tpl (.../index.tpl) (revision 11623) +++ branches/RC/core/admin_templates/index.tpl (.../index.tpl) (revision 11661) @@ -12,7 +12,6 @@ - @@ -9,9 +7,6 @@ - - - ' } -] - -Language.complete = [ - { input : '\'',output : '\'$0\'' }, - { input : '"', output : '"$0"' }, - { input : '(', output : '\($0\)' }, - { input : '[', output : '\[$0\]' }, - { input : '{', output : '{\n\t$0\n}' } -] - -Language.shortcuts = [] Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/gecko.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/gecko.js (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/gecko.js (revision 0) @@ -1,313 +0,0 @@ -/* - * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ - * - * Copyright (C) 2007 Fernando M.A.d.S. - * - * Developers: - * Fernando M.A.d.S. - * Michael Hurni - * Contributors: - * Martin D. Kirk - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation. - * - * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php - */ - -CodePress = { - scrolling : false, - autocomplete : true, - - // set initial vars and start sh - initialize : function() { - if(typeof(editor)=='undefined' && !arguments[0]) return; - body = document.getElementsByTagName('body')[0]; - body.innerHTML = body.innerHTML.replace(/\n/g,""); - chars = '|32|46|62|8|'; // charcodes that trigger syntax highlighting - cc = '\u2009'; // carret char - editor = document.getElementsByTagName('pre')[0]; - document.designMode = 'on'; - document.addEventListener('keypress', this.keyHandler, true); - window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); - completeChars = this.getCompleteChars(); - completeEndingChars = this.getCompleteEndingChars(); - }, - - // treat key bindings - keyHandler : function(evt) { - keyCode = evt.keyCode; - charCode = evt.charCode; - fromChar = String.fromCharCode(charCode); - - if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) - CodePress.shortcuts(charCode?charCode:keyCode); - } - else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && CodePress.autocomplete) { // auto complete - if(!CodePress.completeEnding(fromChar)) - CodePress.complete(fromChar); - } - else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting - top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); - } - else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) - CodePress.snippets(evt); - } - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed - CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; - } - else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo - (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); - evt.preventDefault(); - } - else if(charCode==118 && evt.ctrlKey) { // handle paste - top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); - } - else if(charCode==99 && evt.ctrlKey) { // handle cut - //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF')); - } - - }, - - // put cursor back to its original position after every parsing - findString : function() { - if(self.find(cc)) - window.getSelection().getRangeAt(0).deleteContents(); - }, - - // split big files, highlighting parts of it - split : function(code,flag) { - if(flag=='scroll') { - this.scrolling = true; - return code; - } - else { - this.scrolling = false; - mid = code.indexOf(cc); - if(mid-2000<0) {ini=0;end=4000;} - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} - else {ini=mid-2000;end=mid+2000;} - code = code.substring(ini,end); - return code; - } - }, - - getEditor : function() { - if(!document.getElementsByTagName('pre')[0]) { - body = document.getElementsByTagName('body')[0]; - if(!body.innerHTML) return body; - if(body.innerHTML=="
") body.innerHTML = "
 
"; - else body.innerHTML = "
"+body.innerHTML+"
"; - } - return document.getElementsByTagName('pre')[0]; - }, - - // syntax highlighting parser - syntaxHighlight : function(flag) { - //if(document.designMode=='off') document.designMode='on' - if(flag != 'init') { window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));} - editor = CodePress.getEditor(); - o = editor.innerHTML; - o = o.replace(/
/g,'\n'); - o = o.replace(/<.*?>/g,''); - x = z = this.split(o,flag); - x = x.replace(/\n/g,'
'); - - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); - - for(i=0;i/g,'>'); - if(content.indexOf('$0')<0) content += cc; - else content = content.replace(/\$0/,cc); - content = content.replace(/\n/g,'
'); - var pattern = new RegExp(trigger+cc,'gi'); - evt.preventDefault(); // prevent the tab key from being added - this.syntaxHighlight('snippets',pattern,content); - } - } - - /* Modified to insert tab on FF - * @author Asad Khan - */ - if (noInsertion == 1) { - var range = window.getSelection().getRangeAt(0); - - // for the single line - range.setEnd(range.startContainer, range.startOffset); - - var ele = document.createTextNode('\t'); - range.insertNode(ele); - range.setStartAfter(ele); - - evt.preventDefault(); - } - }, - - readOnly : function() { - document.designMode = (arguments[0]) ? 'off' : 'on'; - }, - - complete : function(trigger) { - window.getSelection().getRangeAt(0).deleteContents(); - var complete = Language.complete; - for (var i=0; i/g,'\n'); - code = code.replace(/\u2009/g,''); - code = code.replace(/<.*?>/g,''); - code = code.replace(/</g,'<'); - code = code.replace(/>/g,'>'); - code = code.replace(/&/gi,'&'); - return code; - }, - - // put code inside editor - setCode : function() { - var code = arguments[0]; - code = code.replace(/\u2009/gi,''); - code = code.replace(/&/gi,'&'); - code = code.replace(//g,'>'); - editor.innerHTML = code; - if (code == '') - document.getElementsByTagName('body')[0].innerHTML = ''; - }, - - // undo and redo methods - actions : { - pos : -1, // actual history position - history : [], // history vector - - undo : function() { - editor = CodePress.getEditor(); - if(editor.innerHTML.indexOf(cc)==-1){ - if(editor.innerHTML != " ") - window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); - this.history[this.pos] = editor.innerHTML; - } - this.pos --; - if(typeof(this.history[this.pos])=='undefined') this.pos ++; - editor.innerHTML = this.history[this.pos]; - if(editor.innerHTML.indexOf(cc)>-1) editor.innerHTML+=cc; - CodePress.findString(); - }, - - redo : function() { - // editor = CodePress.getEditor(); - this.pos++; - if(typeof(this.history[this.pos])=='undefined') this.pos--; - editor.innerHTML = this.history[this.pos]; - CodePress.findString(); - }, - - next : function() { // get next vector position and clean old ones - if(this.pos>20) this.history[this.pos-21] = undefined; - return ++this.pos; - } - } -} - -Language={}; -window.addEventListener('load', function() { CodePress.initialize('new'); }, true); \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.css =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.css (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.css (revision 0) @@ -1,21 +0,0 @@ -body { - margin-top:13px; - _margin-top:14px; - background:white; - margin-left:32px; - font-family:monospace; - font-size:13px; - white-space:pre; - background-image:url("images/line-numbers.png"); - background-repeat:repeat-y; - background-position:0 3px; - line-height:16px; - height:100%; -} -pre {margin:0;} -html>body{background-position:0 2px;} -P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;} -b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;} - -body.hide-line-numbers {background:white;margin-left:16px;} -body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;} \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/opera.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/opera.js (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/opera.js (revision 0) @@ -1,260 +0,0 @@ -/* - * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ - * - * Copyright (C) 2007 Fernando M.A.d.S. - * - * Contributors : - * - * Michael Hurni - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation. - * - * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php - */ - - -CodePress = { - scrolling : false, - autocomplete : true, - - // set initial vars and start sh - initialize : function() { - if(typeof(editor)=='undefined' && !arguments[0]) return; - chars = '|32|46|62|'; // charcodes that trigger syntax highlighting - cc = '\u2009'; // control char - editor = document.getElementsByTagName('body')[0]; - document.designMode = 'on'; - document.addEventListener('keyup', this.keyHandler, true); - window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); - completeChars = this.getCompleteChars(); -// CodePress.syntaxHighlight('init'); - }, - - // treat key bindings - keyHandler : function(evt) { - keyCode = evt.keyCode; - charCode = evt.charCode; - - if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) - CodePress.shortcuts(charCode?charCode:keyCode); - } - else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete - CodePress.complete(String.fromCharCode(charCode)); - } - else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting - CodePress.syntaxHighlight('generic'); - } - else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) - CodePress.snippets(evt); - } - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed - CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; - } - else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo - (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); - evt.preventDefault(); - } - else if(keyCode==86 && evt.ctrlKey) { // paste - // TODO: pasted text should be parsed and highlighted - } - }, - - // put cursor back to its original position after every parsing - findString : function() { - var sel = window.getSelection(); - var range = window.document.createRange(); - var span = window.document.getElementsByTagName('span')[0]; - - range.selectNode(span); - sel.removeAllRanges(); - sel.addRange(range); - span.parentNode.removeChild(span); - //if(self.find(cc)) - //window.getSelection().getRangeAt(0).deleteContents(); - }, - - // split big files, highlighting parts of it - split : function(code,flag) { - if(flag=='scroll') { - this.scrolling = true; - return code; - } - else { - this.scrolling = false; - mid = code.indexOf(''); - if(mid-2000<0) {ini=0;end=4000;} - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} - else {ini=mid-2000;end=mid+2000;} - code = code.substring(ini,end); - return code; - } - }, - - // syntax highlighting parser - syntaxHighlight : function(flag) { - //if(document.designMode=='off') document.designMode='on' - if(flag!='init') { - var span = document.createElement('span'); - window.getSelection().getRangeAt(0).insertNode(span); - } - - o = editor.innerHTML; -// o = o.replace(/
/g,'\r\n'); -// o = o.replace(/<(b|i|s|u|a|em|tt|ins|big|cite|strong)?>/g,''); - //alert(o) - o = o.replace(/<(?!span|\/span|br).*?>/gi,''); -// alert(o) -// x = o; - x = z = this.split(o,flag); - //alert(z) -// x = x.replace(/\r\n/g,'
'); - x = x.replace(/\t/g, ' '); - - - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); - - for(i=0;i/g,'>'); - if(content.indexOf('$0')<0) content += cc; - else content = content.replace(/\$0/,cc); - content = content.replace(/\n/g,'
'); - var pattern = new RegExp(trigger+cc,'gi'); - evt.preventDefault(); // prevent the tab key from being added - this.syntaxHighlight('snippets',pattern,content); - } - } - }, - - readOnly : function() { - document.designMode = (arguments[0]) ? 'off' : 'on'; - }, - - complete : function(trigger) { - window.getSelection().getRangeAt(0).deleteContents(); - var complete = Language.complete; - for (var i=0; i/g,'\n'); - code = code.replace(/\u2009/g,''); - code = code.replace(/<.*?>/g,''); - code = code.replace(/</g,'<'); - code = code.replace(/>/g,'>'); - code = code.replace(/&/gi,'&'); - return code; - }, - - // put code inside editor - setCode : function() { - var code = arguments[0]; - code = code.replace(/\u2009/gi,''); - code = code.replace(/&/gi,'&'); - code = code.replace(//g,'>'); - editor.innerHTML = code; - }, - - // undo and redo methods - actions : { - pos : -1, // actual history position - history : [], // history vector - - undo : function() { - if(editor.innerHTML.indexOf(cc)==-1){ - window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); - this.history[this.pos] = editor.innerHTML; - } - this.pos--; - if(typeof(this.history[this.pos])=='undefined') this.pos++; - editor.innerHTML = this.history[this.pos]; - CodePress.findString(); - }, - - redo : function() { - this.pos++; - if(typeof(this.history[this.pos])=='undefined') this.pos--; - editor.innerHTML = this.history[this.pos]; - CodePress.findString(); - }, - - next : function() { // get next vector position and clean old ones - if(this.pos>20) this.history[this.pos-21] = undefined; - return ++this.pos; - } - } -} - -Language={}; -window.addEventListener('load', function() { CodePress.initialize('new'); }, true); Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.html =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.html (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.html (revision 0) @@ -1,35 +0,0 @@ - - - - CodePress - Real Time Syntax Highlighting Editor written in JavaScript - - - - - - - - - Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/msie.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/msie.js (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/msie.js (revision 0) @@ -1,304 +0,0 @@ -/* - * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ - * - * Copyright (C) 2007 Fernando M.A.d.S. - * - * Developers: - * Fernando M.A.d.S. - * Michael Hurni - * Contributors: - * Martin D. Kirk - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation. - * - * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php - */ - -CodePress = { - scrolling : false, - autocomplete : true, - - // set initial vars and start sh - initialize : function() { - if(typeof(editor)=='undefined' && !arguments[0]) return; - chars = '|32|46|62|'; // charcodes that trigger syntax highlighting - cc = '\u2009'; // carret char - editor = document.getElementsByTagName('pre')[0]; - editor.contentEditable = 'true'; - document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();} - document.attachEvent('onkeydown', this.metaHandler); - document.attachEvent('onkeypress', this.keyHandler); - window.attachEvent('onscroll', function() { if(!CodePress.scrolling) setTimeout(function(){CodePress.syntaxHighlight('scroll')},1)}); - completeChars = this.getCompleteChars(); - completeEndingChars = this.getCompleteEndingChars(); - setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top - }, - - // treat key bindings - keyHandler : function(evt) { - charCode = evt.keyCode; - fromChar = String.fromCharCode(charCode); - - if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1 )&& CodePress.autocomplete) { // auto complete - if(!CodePress.completeEnding(fromChar)) - CodePress.complete(fromChar); - } - else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting - CodePress.syntaxHighlight('generic'); - } - }, - - metaHandler : function(evt) { - keyCode = evt.keyCode; - - if(keyCode==9 || evt.tabKey) { - CodePress.snippets(); - } - else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo - (keyCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); - evt.returnValue = false; - } - else if(keyCode==34||keyCode==33) { // handle page up/down for IE - self.scrollBy(0, (keyCode==34) ? 200 : -200); - evt.returnValue = false; - } - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed - CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; - } - else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) - CodePress.shortcuts(keyCode); - evt.returnValue = false; - } - else if(keyCode==86 && evt.ctrlKey) { // handle paste - window.clipboardData.setData('Text',window.clipboardData.getData('Text').replace(/\t/g,'\u2008')); - top.setTimeout(function(){CodePress.syntaxHighlight('paste');},10); - } - else if(keyCode==67 && evt.ctrlKey) { // handle cut - // window.clipboardData.setData('Text',x[0]); - // code = window.clipboardData.getData('Text'); - } - }, - - // put cursor back to its original position after every parsing - - - findString : function() { - range = self.document.body.createTextRange(); - if(range.findText(cc)){ - range.select(); - range.text = ''; - } - }, - - // split big files, highlighting parts of it - split : function(code,flag) { - if(flag=='scroll') { - this.scrolling = true; - return code; - } - else { - this.scrolling = false; - mid = code.indexOf(cc); - if(mid-2000<0) {ini=0;end=4000;} - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} - else {ini=mid-2000;end=mid+2000;} - code = code.substring(ini,end); - return code.substring(code.indexOf('

'),code.lastIndexOf('

')+4); - } - }, - - // syntax highlighting parser - syntaxHighlight : function(flag) { - if(flag!='init') document.selection.createRange().text = cc; - o = editor.innerHTML; - if(flag=='paste') { // fix pasted text - o = o.replace(/
/g,'\r\n'); - o = o.replace(/\u2008/g,'\t'); - } - o = o.replace(/

/g,'\n'); - o = o.replace(/<\/P>/g,'\r'); - o = o.replace(/<.*?>/g,''); - o = o.replace(/ /g,''); - o = '

'+o+'

'; - o = o.replace(/\n\r/g,'

'); - o = o.replace(/\n/g,'

'); - o = o.replace(/\r/g,'<\/P>'); - o = o.replace(/

(

)+/,'

'); - o = o.replace(/<\/P>(<\/P>)+/,'

'); - o = o.replace(/

<\/P>/g,'


'); - x = z = this.split(o,flag); - - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); - - for(i=0;i/g,'>'); - if(content.indexOf('$0')<0) content += cc; - else content = content.replace(/\$0/,cc); - content = content.replace(/\n/g,'

'); - var pattern = new RegExp(trigger+cc,"gi"); - this.syntaxHighlight('snippets',pattern,content); - } - } - }, - - readOnly : function() { - editor.contentEditable = (arguments[0]) ? 'false' : 'true'; - }, - - complete : function(trigger) { - var complete = Language.complete; - for (var i=0; i/g,'\n'); - code = code.replace(/<\/p>/gi,'\r'); - code = code.replace(/

/i,''); // IE first line fix - code = code.replace(/

/gi,'\n'); - code = code.replace(/ /gi,''); - code = code.replace(/\u2009/g,''); - code = code.replace(/<.*?>/g,''); - code = code.replace(/</g,'<'); - code = code.replace(/>/g,'>'); - code = code.replace(/&/gi,'&'); - return code; - }, - - // put code inside editor - setCode : function() { - var code = arguments[0]; - code = code.replace(/\u2009/gi,''); - code = code.replace(/&/gi,'&'); - code = code.replace(//g,'>'); - editor.innerHTML = '

'+code+'
'; - }, - - - // undo and redo methods - actions : { - pos : -1, // actual history position - history : [], // history vector - - undo : function() { - if(editor.innerHTML.indexOf(cc)==-1){ - document.selection.createRange().text = cc; - this.history[this.pos] = editor.innerHTML; - } - this.pos--; - if(typeof(this.history[this.pos])=='undefined') this.pos++; - editor.innerHTML = this.history[this.pos]; - CodePress.findString(); - }, - - redo : function() { - this.pos++; - if(typeof(this.history[this.pos])=='undefined') this.pos--; - editor.innerHTML = this.history[this.pos]; - CodePress.findString(); - }, - - next : function() { // get next vector position and clean old ones - if(this.pos>20) this.history[this.pos-21] = undefined; - return ++this.pos; - } - } -} - -Language={}; -window.attachEvent('onload', function() { CodePress.initialize('new');}); \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/images/line-numbers.png =================================================================== diff -u -N -r11427 -r11661 Binary files differ Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/languages/html.css =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/languages/html.css (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/languages/html.css (revision 0) @@ -1,18 +0,0 @@ -/* - * CodePress color styles for HTML syntax highlighting - */ - -b {color:#000080;} /* tags */ -ins, ins b, ins s, ins em {color:gray;} /* comments */ -s, s b {color:#7777e4;} /* attribute values */ -a {color:green;} /* links */ -u {color:#E67300;} /* forms */ -big {color:#db0000;} /* images */ -em, em b {color:#800080;} /* style */ -strong {color:#800000;} /* script */ -tt i {color:darkblue;font-weight:bold;} /* script reserved words */ - -b.inp-tag { - color: #CF3E33; - font-style: italic; -} \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/template_manager.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/template_manager.js (revision 11610) +++ branches/RC/themes/default2009/platform/template_manager/inc/template_manager.js (revision 0) @@ -1,139 +0,0 @@ -function TemplateManager ($edit_url) { - this._editUrl = $edit_url; - - this._blocks = {}; - - this._blockOrder = Array (); - - $(document).ready( - function() { - aTemplateManager.searchBlocks(); - } - ); -} - -TemplateManager.prototype.onBtnClick = function ($e, $element) { - var $id = $element.id.replace(/_btn$/, ''); - var $block_info = this._blocks[$id]; - var $url = this._editUrl.replace('#BLOCK#', $block_info.block_name + ':' + $block_info.function_name).replace('#EVENT#', ''); - - this.setFullscreen(); - - TB.show( - { - url: $url, - onDataReceived: TemplateManager.prototype.onDataReceived, - onAfterShow: function() { - TemplateManager.prototype.initEditor.call(this); - } - } - ); - - $e.stopPropagation(); -} - -TemplateManager.prototype.setFullscreen = function ($restore) { - getFrame('head').$FrameResizer.fullScreen($restore); -} - -TemplateManager.prototype.saveBlock = function () { - var $url = this._editUrl.replace('#BLOCK#', $('#block').val() ).replace('#EVENT#', 'OnSaveBlock'); - - function_body.toggleEditor(); // disable editor (global variable from edit_template.tpl via ajax) - - TB.show( - { - url: $url, - onDataReceived: TemplateManager.prototype.onDataReceived, - onAfterShow: function() { - TemplateManager.prototype.initEditor.call(this); - }, - postParams: $('#template_editor_form').serializeArray() - } - ); - -} - -TemplateManager.prototype.cancelEditing = function () { - TB.remove(); - this.setFullscreen(true); -} - - -TemplateManager.prototype.onMouseOver = function ($e, $element) { - $($element).addClass('block-edit-btn-container-over'); - $e.stopPropagation(); -} - -TemplateManager.prototype.onMouseOut = function ($e, $element) { - $($element).removeClass('block-edit-btn-container-over'); - $e.stopPropagation(); -} - -TemplateManager.prototype.searchBlocks = function () { - $('div').each ( - function () { - var $id = $(this).attr('id'); - - if (!$id || $id.match(/parser_block\[.*\].*_btn$/) || !$id.match(/parser_block\[.*\]/)) { - // skip other divs - return true; - } - - TemplateManager.prototype.registerBlock.call(aTemplateManager, this); - } - ); -} - -TemplateManager.prototype.registerBlock = function ($element) { - var $params = $element.getAttribute('params').split(':'); - - this._blocks[$element.id] = { - block_name: $params[0], - function_name: $params[1] - }; - - var $btn = document.getElementById($element.id + '_btn'); - - $($btn).bind( - 'click', - function(ev) { - TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); - } - ); - - $($element).bind( - 'mouseover', - function(ev) { - TemplateManager.prototype.onMouseOver.call(aTemplateManager, ev, this); - } - ); - - $($element).bind( - 'mouseout', - function(ev) { - TemplateManager.prototype.onMouseOut.call(aTemplateManager, ev, this); - } - ); - - this._blockOrder.push($element.id); -} - -TemplateManager.prototype.onDataReceived = function ($data) { - if ($data == '0') { - TB.remove(); - return false; - } - - return true; -} - -TemplateManager.prototype.initEditor = function () { - var $id = 'function_body'; - - var $textarea = document.getElementById($id); - $textarea.id += '_cp'; - - window[$id] = new CodePress($textarea); - $( window[$id] ).insertBefore($textarea); -} \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/khtml.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/khtml.js (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/engines/khtml.js (revision 0) @@ -1 +0,0 @@ \ No newline at end of file Index: branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.js =================================================================== diff -u -N --- branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.js (revision 11427) +++ branches/RC/themes/default2009/platform/template_manager/inc/codepress/codepress.js (revision 0) @@ -1,138 +0,0 @@ -/* - * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ - * - * Copyright (C) 2006 Fernando M.A.d.S. - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation. - * - * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php - */ - -CodePress = function(obj) { - var self = document.createElement('iframe'); - self.textarea = obj; - self.textarea.disabled = true; - self.textarea.style.overflow = 'hidden'; - self.style.height = self.textarea.clientHeight +'px'; - self.style.width = self.textarea.clientWidth +'px'; - self.textarea.style.overflow = 'auto'; - self.style.border = '1px solid gray'; - self.frameBorder = 0; // remove IE internal iframe border - self.style.visibility = 'hidden'; - self.style.position = 'absolute'; - self.options = self.textarea.className; - - self.initialize = function() { - self.editor = self.contentWindow.CodePress; - self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0]; - self.editor.setCode(self.textarea.value); - self.setOptions(); - self.editor.syntaxHighlight('init'); - self.textarea.style.display = 'none'; - self.style.position = 'static'; - self.style.visibility = 'visible'; - self.style.display = 'inline'; - } - - // obj can by a textarea id or a string (code) - self.edit = function(obj,language) { - if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj; - if(!self.textarea.disabled) return; - self.language = language ? language : self.getLanguage(); - self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime(); - if(self.attachEvent) self.attachEvent('onload',self.initialize); - else self.addEventListener('load',self.initialize,false); - } - - self.getLanguage = function() { - for (language in CodePress.languages) - if(self.options.match('\\b'+language+'\\b')) - return CodePress.languages[language] ? language : 'generic'; - } - - self.setOptions = function() { - if(self.options.match('autocomplete-off')) self.toggleAutoComplete(); - if(self.options.match('readonly-on')) self.toggleReadOnly(); - if(self.options.match('linenumbers-off')) self.toggleLineNumbers(); - } - - self.getCode = function() { - return self.textarea.disabled ? self.editor.getCode() : self.textarea.value; - } - - self.setCode = function(code) { - self.textarea.disabled ? self.editor.setCode(code) : self.textarea.value = code; - } - - self.toggleAutoComplete = function() { - self.editor.autocomplete = (self.editor.autocomplete) ? false : true; - } - - self.toggleReadOnly = function() { - self.textarea.readOnly = (self.textarea.readOnly) ? false : true; - if(self.style.display != 'none') // prevent exception on FF + iframe with display:none - self.editor.readOnly(self.textarea.readOnly ? true : false); - } - - self.toggleLineNumbers = function() { - var cn = self.editor.body.className; - self.editor.body.className = (cn==''||cn=='show-line-numbers') ? 'hide-line-numbers' : 'show-line-numbers'; - } - - self.toggleEditor = function() { - if(self.textarea.disabled) { - self.textarea.value = self.getCode(); - self.textarea.disabled = false; - self.style.display = 'none'; - self.textarea.style.display = 'inline'; - } - else { - self.textarea.disabled = true; - self.setCode(self.textarea.value); - self.editor.syntaxHighlight('init'); - self.style.display = 'inline'; - self.textarea.style.display = 'none'; - } - } - - self.edit(); - return self; -} - -CodePress.languages = { - csharp : 'C#', - css : 'CSS', - generic : 'Generic', - html : 'HTML', - java : 'Java', - javascript : 'JavaScript', - perl : 'Perl', - ruby : 'Ruby', - php : 'PHP', - text : 'Text', - sql : 'SQL', - vbscript : 'VBScript' -} - - -CodePress.run = function() { - s = document.getElementsByTagName('script'); - for(var i=0,n=s.length;i + * + * Contributors : + * + * Michael Hurni + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // control char + editor = document.getElementsByTagName('body')[0]; + document.designMode = 'on'; + document.addEventListener('keyup', this.keyHandler, true); + window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); + completeChars = this.getCompleteChars(); +// CodePress.syntaxHighlight('init'); + }, + + // treat key bindings + keyHandler : function(evt) { + keyCode = evt.keyCode; + charCode = evt.charCode; + + if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(charCode?charCode:keyCode); + } + else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete + CodePress.complete(String.fromCharCode(charCode)); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting + CodePress.syntaxHighlight('generic'); + } + else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) + CodePress.snippets(evt); + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo + (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.preventDefault(); + } + else if(keyCode==86 && evt.ctrlKey) { // paste + // TODO: pasted text should be parsed and highlighted + } + }, + + // put cursor back to its original position after every parsing + findString : function() { + var sel = window.getSelection(); + var range = window.document.createRange(); + var span = window.document.getElementsByTagName('span')[0]; + + range.selectNode(span); + sel.removeAllRanges(); + sel.addRange(range); + span.parentNode.removeChild(span); + //if(self.find(cc)) + //window.getSelection().getRangeAt(0).deleteContents(); + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(''); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code; + } + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + //if(document.designMode=='off') document.designMode='on' + if(flag!='init') { + var span = document.createElement('span'); + window.getSelection().getRangeAt(0).insertNode(span); + } + + o = editor.innerHTML; +// o = o.replace(/
/g,'\r\n'); +// o = o.replace(/<(b|i|s|u|a|em|tt|ins|big|cite|strong)?>/g,''); + //alert(o) + o = o.replace(/<(?!span|\/span|br).*?>/gi,''); +// alert(o) +// x = o; + x = z = this.split(o,flag); + //alert(z) +// x = x.replace(/\r\n/g,'
'); + x = x.replace(/\t/g, ' '); + + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'
'); + var pattern = new RegExp(trigger+cc,'gi'); + evt.preventDefault(); // prevent the tab key from being added + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + document.designMode = (arguments[0]) ? 'off' : 'on'; + }, + + complete : function(trigger) { + window.getSelection().getRangeAt(0).deleteContents(); + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = code; + }, + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + if(editor.innerHTML.indexOf(cc)==-1){ + window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); + this.history[this.pos] = editor.innerHTML; + } + this.pos--; + if(typeof(this.history[this.pos])=='undefined') this.pos++; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + redo : function() { + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.addEventListener('load', function() { CodePress.initialize('new'); }, true); Index: branches/RC/core/admin_templates/themes/codepress/codepress.html =================================================================== diff -u -N --- branches/RC/core/admin_templates/themes/codepress/codepress.html (revision 0) +++ branches/RC/core/admin_templates/themes/codepress/codepress.html (revision 11661) @@ -0,0 +1,35 @@ + + + + CodePress - Real Time Syntax Highlighting Editor written in JavaScript + + + + + + + + + Index: branches/RC/core/units/general/helpers/themes_helper.php =================================================================== diff -u -N -r11646 -r11661 --- branches/RC/core/units/general/helpers/themes_helper.php (.../themes_helper.php) (revision 11646) +++ branches/RC/core/units/general/helpers/themes_helper.php (.../themes_helper.php) (revision 11661) @@ -193,14 +193,20 @@ */ function _getTemplateMetaInfo($template, $theme_id) { - if (!defined('DBG_NPARSER_FORCE_COMPILE')) { - $this->Application->InitParser(); - define('DBG_NPARSER_FORCE_COMPILE', 1); + static $init_made = false; + if (!$init_made) { + $this->Application->InitParser(true); + $init_made = true; } $template = 'theme:' . $this->_themeNames[$theme_id] . '/' . $template; $template_file = $this->Application->TemplatesCache->GetRealFilename($template); // ".tpl" was added before + return $this->parseTemplateMetaInfo($template_file); + } + + function parseTemplateMetaInfo($template_file) + { if (!file_exists($template_file)) { // when template without info it's placed in top category return Array (); Index: branches/RC/core/kernel/nparser/compiler.php =================================================================== diff -u -N -r11610 -r11661 --- branches/RC/core/kernel/nparser/compiler.php (.../compiler.php) (revision 11610) +++ branches/RC/core/kernel/nparser/compiler.php (.../compiler.php) (revision 11661) @@ -30,7 +30,7 @@ safeDefine('DBG_IGNORE_FATAL_ERRORS', 1); $i = $current; - $this->Application->InitParser(); + $this->Application->InitParser(true); while ($i < $total && $i < ($current + 20)) { $a_template = $templates[$i]; Index: branches/RC/core/admin_templates/js/template_manager.js =================================================================== diff -u -N --- branches/RC/core/admin_templates/js/template_manager.js (revision 0) +++ branches/RC/core/admin_templates/js/template_manager.js (revision 11661) @@ -0,0 +1,82 @@ +function TemplateManager ($edit_url) { + this._editUrl = $edit_url; + + this._blocks = {}; + + this._blockOrder = Array (); + + $(document).ready( + function() { + aTemplateManager.searchBlocks(); + } + ); +} + +TemplateManager.prototype.onBtnClick = function ($e, $element) { + var $id = $element.id.replace(/_btn$/, ''); + var $block_info = this._blocks[$id]; + var $url = this._editUrl.replace('#BLOCK#', $block_info.block_name + ':' + $block_info.function_name).replace('#EVENT#', 'OnLoadBlock'); + + openSelector('theme-file', $url); + + $e.stopPropagation(); +} + +TemplateManager.prototype.onMouseOver = function ($e, $element) { + $($element).addClass('block-edit-btn-container-over'); + $e.stopPropagation(); +} + +TemplateManager.prototype.onMouseOut = function ($e, $element) { + $($element).removeClass('block-edit-btn-container-over'); + $e.stopPropagation(); +} + +TemplateManager.prototype.searchBlocks = function () { + $('div').each ( + function () { + var $id = $(this).attr('id'); + + if (!$id || $id.match(/parser_block\[.*\].*_btn$/) || !$id.match(/parser_block\[.*\]/)) { + // skip other divs + return true; + } + + TemplateManager.prototype.registerBlock.call(aTemplateManager, this); + } + ); +} + +TemplateManager.prototype.registerBlock = function ($element) { + var $params = $element.getAttribute('params').split(':'); + + this._blocks[$element.id] = { + block_name: $params[0], + function_name: $params[1] + }; + + var $btn = document.getElementById($element.id + '_btn'); + + $($btn).bind( + 'click', + function(ev) { + TemplateManager.prototype.onBtnClick.call(aTemplateManager, ev, this); + } + ); + + $($element).bind( + 'mouseover', + function(ev) { + TemplateManager.prototype.onMouseOver.call(aTemplateManager, ev, this); + } + ); + + $($element).bind( + 'mouseout', + function(ev) { + TemplateManager.prototype.onMouseOut.call(aTemplateManager, ev, this); + } + ); + + this._blockOrder.push($element.id); +} \ No newline at end of file Index: branches/RC/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r11649 -r11661 --- branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11649) +++ branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 11661) @@ -20,8 +20,6 @@ 'OnRecalculatePriorities' => Array ('self' => 'add|edit'), // category ordering 'OnItemBuild' => Array ('self' => true), // always allow to view individual categories (regardless of CATEGORY.VIEW right) 'OnUpdatePreviewBlock' => Array ('self' => true), // for FCKEditor integration - - 'OnSaveBlock' => Array ('self' => true), // saves RenderElements from Front-End ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -763,9 +761,11 @@ */ function _templateFound($template, $theme_id = null) { - if (!defined('DBG_NPARSER_FORCE_COMPILE')) { - $this->Application->InitParser(); - define('DBG_NPARSER_FORCE_COMPILE', 1); + static $init_made = false; + + if (!$init_made) { + $this->Application->InitParser(true); + $init_made = true; } if (!isset($theme_id)) { @@ -1283,7 +1283,7 @@ if ($object->GetDBField('IsSystem') == 1) { if (!$this->_templateFound($object->GetDBField('Template'), $object->GetDBField('ThemeId'))) { - $object->SetError('Template', 'template_file_missing', 'la_err_TemplateFileMissing'); + $object->SetError('Template', 'template_file_missing', 'la_error_TemplateFileMissing'); } } @@ -1847,25 +1847,6 @@ $this->Application->StoreVar('_editor_preview_content_', $string); } - - /** - * Saves changed template block - * - * @param kEvent $event - */ - function OnSaveBlock(&$event) - { - if (!EDITING_MODE) { - $event->status = erSTOP; - echo '0'; - return ; - } - - $template_helper =& $this->Application->recallObject('TemplateHelper'); - /* @var $template_helper TemplateHelper */ - - $event->status = $template_helper->saveBlock($event) ? erSTOP : erFAIL; - } } ?> \ No newline at end of file Index: branches/RC/core/units/structure/structure_config.php =================================================================== diff -u -N -r11635 -r11661 --- branches/RC/core/units/structure/structure_config.php (.../structure_config.php) (revision 11635) +++ branches/RC/core/units/structure/structure_config.php (.../structure_config.php) (revision 11661) @@ -181,6 +181,20 @@ ), ), + 'Radio' => Array( + 'Icons' => Array(1 => 'icon16_folder.gif', 0 => 'icon16_folder-red.gif'), + 'Selector' => 'radio', + 'Fields' => Array( + 'CategoryId' => Array( 'title'=>'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'filter_width' => '20' ), + 'Name' => Array( 'title'=>'la_col_PageTitle', 'data_block' => 'page_browse_td', 'filter_block' => 'grid_like_filter'), + 'Modified_formatted' => Array( 'title'=>'la_col_Modified', 'sort_field' => 'Modified', 'filter_block' => 'grid_date_range_filter' ), + 'Template' => Array( 'title'=>'la_col_TemplateType', 'filter_block' => 'grid_options_filter' ), + 'IsMenu' => Array( 'title'=>'la_col_Visible', 'filter_block' => 'grid_options_filter' ), + 'Path' => Array( 'title'=>'la_col_Path', 'data_block' => 'page_entercat_td', 'filter_block' => 'grid_like_filter' ), + 'IsSystem' => Array( 'title'=>'la_col_System', 'filter_block' => 'grid_options_filter', 'use_phrases'=>1 ), + ), + ), + 'AllPages' => Array( 'Icons' => Array(1 => 'icon16_folder.gif', 0 => 'icon16_folder-red.gif'), 'Fields' => Array( Index: branches/RC/core/kernel/session/session.php =================================================================== diff -u -N -r11648 -r11661 --- branches/RC/core/kernel/session/session.php (.../session.php) (revision 11648) +++ branches/RC/core/kernel/session/session.php (.../session.php) (revision 11661) @@ -921,7 +921,7 @@ } } - function SaveData($params) + function SaveData($params = Array ()) { if (!$this->SetSession()) { // call it here - it may be not set before, because there was no need; if there is a need, it will be set here return;