Index: branches/5.0.x/admin/system_presets/simple/settings.php =================================================================== diff -u -r12265 -r12298 --- branches/5.0.x/admin/system_presets/simple/settings.php (.../settings.php) (revision 12265) +++ branches/5.0.x/admin/system_presets/simple/settings.php (.../settings.php) (revision 12298) @@ -1,8 +1,7 @@ Application->GetTopmostWid($this->Prefix); $session_name = rtrim($this->getPrefixSpecial().'_selected_ids_'.$wid, '_'); @@ -2030,7 +2030,7 @@ } return $ret; - } + }*/ /** * Returns import/export process percent @@ -2159,7 +2159,7 @@ WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $page_id; $template = strtolower( $this->Conn->GetOne($sql) ); - $url_params = Array ('m_cat_id' => $page_id, 'no_amp' => 1, 'editing_mode' => EDITING_MODE_CMS, 'pass' => 'm'); + $url_params = Array ('m_cat_id' => $page_id, 'no_amp' => 1, 'editing_mode' => EDITING_MODE_CONTENT, 'pass' => 'm'); $preview_url = $this->Application->HREF($template, '_FRONT_END_', $url_params, 'index.php'); $preview_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $preview_url); } Index: branches/5.0.x/themes/default2009/platform/elements/side_boxes/mailing_list.elm.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/platform/elements/side_boxes/mailing_list.elm.tpl (.../mailing_list.elm.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/platform/elements/side_boxes/mailing_list.elm.tpl (.../mailing_list.elm.tpl) (revision 12298) @@ -1,21 +1,21 @@ - - - - -
-img/s.gif" alt="" width="1" height="5" border="0" />
- -
-
- -
-
- -
- " /> - " /> -   - - - -
+ + + + +
+img/s.gif" alt="" width="1" height="5" border="0" />
+ +
+
+ +
+
+ +
+ + +   + + + +
Index: branches/5.0.x/core/kernel/db/dbitem.php =================================================================== diff -u -r12294 -r12298 --- branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12294) +++ branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12298) @@ -1,6 +1,6 @@ FieldValues) && defined('DEBUG_MODE') && DEBUG_MODE) { + $this->Application->Debugger->appendTrace(); + }*/ + return $this->FieldValues[$name]; } Index: branches/5.0.x/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 12117) +++ branches/5.0.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 12298) @@ -1,6 +1,6 @@ Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - if ($event->Name == 'OnNew' || $event->Name == 'OnCreate' || $event->Name == 'OnPrepareUpdate' || $event->Name == 'OnUpdate') { + $allow_events = Array ('OnCreate', 'OnUpdate'); + + if (in_array($event->Name, $allow_events)) { return true; } } - - return parent::CheckPermission($event); } function mapPermissions() { parent::mapPermissions(); - $permissions = Array ( - 'OnItemBuild' => Array('self' => true, 'subitem' => true), - ); + $permissions = Array ( + 'OnItemBuild' => Array('self' => true, 'subitem' => true), + 'OnNew' => Array('self' => true, 'subitem' => true), + 'OnPrepareUpdate' => Array('self' => true, 'subitem' => true), + ); + $this->permMapping = array_merge($this->permMapping, $permissions); } @@ -66,12 +69,12 @@ parent::OnNew($event); $label = $this->Application->GetVar('phrases_label'); - $object =& $event->getObject( $label ? Array('live_table'=>true, 'skip_autoload' => true) : Array('skip_autoload' => true) ); + $object =& $event->getObject( $label ? Array('live_table' => true, 'skip_autoload' => true) : Array('skip_autoload' => true) ); if ($label) { - $object->SetDBField('Phrase',$label); + $object->SetDBField('Phrase', $label); // phrase is created in language, used to display phrases - $object->SetDBField('LanguageId', $this->Application->Phrases->LanguageId); - $object->SetDBField('PhraseType',1); + $object->SetDBField('LanguageId', $this->Application->GetVar('m_lang')); + $object->SetDBField('PhraseType', 1); $primary_language = $this->Application->GetDefaultLanguageId(); $live_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); @@ -81,16 +84,22 @@ } $last_module = $this->Application->GetVar('last_module'); - if($last_module) $object->SetDBField('Module', $last_module); + if ($last_module) { + $object->SetDBField('Module', $last_module); + } - if($event->Special == 'export' || $event->Special == 'import') - { + if ($event->Special == 'export' || $event->Special == 'import') { $object->SetDBField('PhraseType', '|0|1|2|'); $modules = $this->Conn->GetCol('SELECT Name FROM '.TABLE_PREFIX.'Modules'); $object->SetDBField('Module', '|'.implode('|', $modules).'|' ); } } + /** + * Prepares existing phrase editing + * + * @param kEvent $event + */ function OnPrepareUpdate(&$event) { $language_id = $this->Application->GetVar('m_lang'); @@ -99,9 +108,12 @@ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); $label_idfield = $this->Application->getUnitOption($event->Prefix, 'IDField'); - $sql = 'SELECT '.$label_idfield.' FROM '.$table_name.' WHERE Phrase = '.$this->Conn->qstr($label).' AND LanguageId = '.$language_id; + $sql = 'SELECT ' . $label_idfield . ' + FROM ' . $table_name . ' + WHERE Phrase = '.$this->Conn->qstr($label).' AND LanguageId = '.$language_id; $this->Application->SetVar($event->getPrefixSpecial() . '_id', $this->Conn->GetOne($sql)); -// $event->redirect = false; + + $event->redirect = false; } /** Index: branches/5.0.x/themes/default2009/platform/elements/html_head.elm.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/platform/elements/html_head.elm.tpl (.../html_head.elm.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/platform/elements/html_head.elm.tpl (.../html_head.elm.tpl) (revision 12298) @@ -27,5 +27,5 @@ , - var aMultiLanguageSelector = new MultiLanguageSelector({}, ); + var aMultiLanguageSelector = new MultiLanguageSelector({}, ); Index: branches/5.0.x/core/units/phrases/phrase_tp.php =================================================================== diff -u --- branches/5.0.x/core/units/phrases/phrase_tp.php (revision 0) +++ branches/5.0.x/core/units/phrases/phrase_tp.php (revision 12298) @@ -0,0 +1,30 @@ +Application->GetVar('simple_mode'); + $phrases_label = $this->Application->GetVar('phrases_label'); + + return $simple_mode || !$phrases_label; + } + } \ No newline at end of file Index: branches/5.0.x/themes/default2009/platform/elements/side_boxes/login.elm.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/platform/elements/side_boxes/login.elm.tpl (.../login.elm.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/platform/elements/side_boxes/login.elm.tpl (.../login.elm.tpl) (revision 12298) @@ -100,7 +100,7 @@ @@ -84,7 +84,7 @@ - +
Index: branches/5.0.x/core/kernel/nparser/nparser.php =================================================================== diff -u -r12277 -r12298 --- branches/5.0.x/core/kernel/nparser/nparser.php (.../nparser.php) (revision 12277) +++ branches/5.0.x/core/kernel/nparser/nparser.php (.../nparser.php) (revision 12298) @@ -1,6 +1,6 @@ CONTENT_OF_DESIGN: ' . $prepend; + if (EDITING_MODE == EDITING_MODE_DESIGN) { + $decorate = true; - if (EDITING_MODE == EDITING_MODE_INSIDES) { - $decorate = true; + if ($is_template) { + // content inside pair RenderElement tag } - } - else { - if (strpos($block_params['name'], '__capture_') === 0) { - // capture tag (usually inside pair RenderElement) -// $prepend = 'CAPTURE: ' . $prepend; - - if (EDITING_MODE == EDITING_MODE_INSIDES) { - $decorate = true; - } - } - elseif (array_key_exists('content', $block_params)) { - // pair RenderElement (on template, were it's used) -// $prepend = 'PAIR_RENDER_ELEMENT: ' . $prepend; - - if (EDITING_MODE == EDITING_MODE_DESIGN) { - $decorate = true; - } - } else { - // non-pair RenderElement -// $prepend = 'SINGLE_RENDER_ELEMENT: ' . $prepend; - - if (EDITING_MODE == EDITING_MODE_INSIDES) { - $decorate = true; + if (strpos($block_params['name'], '__capture_') === 0) { + // capture tag (usually inside pair RenderElement) } - - if (array_key_exists('layout_view', $block_params) && $block_params['layout_view'] && (EDITING_MODE == EDITING_MODE_LAYOUT)) { - $decorate = true; + elseif (array_key_exists('content', $block_params)) { + // pair RenderElement (on template, were it's used) + $design = true; } } } @@ -584,6 +563,14 @@ $block_name = $block_params['name']; $function_name = $is_template ? $block_name : $this->Elements[$block_name]; + $block_title = ''; + if (array_key_exists($function_name, $this->Application->Parser->ElementLocations)) { + $element_location = $this->Application->Parser->ElementLocations[$function_name]; + + $block_title .= $element_location['template'] . '.tpl'; + $block_title .= ' (' . $element_location['start_pos'] . ' - ' . $element_location['end_pos'] . ')'; + } + // ensure unique id for every div (used from print lists) $container_num = 1; $container_id = 'parser_block[' . $function_name . ']'; @@ -597,14 +584,24 @@ // prepare parameter string $param_string = $block_name . ':' . $function_name; + if ($design) { + $btn_text = 'Edit design'; + $btn_class = 'cms-edit-design-btn'; + $btn_container_class = 'block-edit-design-btn-container'; + } + else { + $btn_text = 'Edit block'; + $btn_class = 'cms-edit-block-btn'; + $btn_container_class = 'block-edit-block-btn-container'; + } $block_editor = ' -
-
+
+
-
Edit
+
' . $btn_text . '
%s Index: branches/5.0.x/core/units/phrases/phrases_config.php =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 12117) +++ branches/5.0.x/core/units/phrases/phrases_config.php (.../phrases_config.php) (revision 12298) @@ -1,6 +1,6 @@ Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), 'EventHandlerClass' => Array ('class' => 'PhrasesEventHandler', 'file' => 'phrases_event_handler.php', 'build_event' => 'OnBuild'), - 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), + 'TagProcessorClass' => Array ('class' => 'PhraseTagProcessor', 'file' => 'phrase_tp.php', 'build_event' => 'OnBuild'), 'AutoLoad' => true, Index: branches/5.0.x/core/kernel/constants.php =================================================================== diff -u -r12294 -r12298 --- branches/5.0.x/core/kernel/constants.php (.../constants.php) (revision 12294) +++ branches/5.0.x/core/kernel/constants.php (.../constants.php) (revision 12298) @@ -1,6 +1,6 @@ CheckUserPermission($user, 'CATEGORY.MODIFY', 0, 0)) { // user can edit cms blocks $editing_mode = $this->GetVar('editing_mode'); - define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_CMS); + define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_BROWSE); + $this->Phrases->setPhraseEditing(); } } @@ -1955,9 +1956,9 @@ exit; } - function Phrase($label) + function Phrase($label, $allow_editing = true) { - return $this->Phrases->GetPhrase($label); + return $this->Phrases->GetPhrase($label, $allow_editing); } /** Index: branches/5.0.x/core/admin_templates/incs/cms.css =================================================================== diff -u -r12230 -r12298 --- branches/5.0.x/core/admin_templates/incs/cms.css (.../cms.css) (revision 12230) +++ branches/5.0.x/core/admin_templates/incs/cms.css (.../cms.css) (revision 12298) @@ -16,7 +16,7 @@ padding: 5px; } -div.cms-section-properties-btn, div.cms-edit-btn, div.cms-save-layout-btn { +div.cms-section-properties-btn, div.cms-edit-btn, div.cms-edit-block-btn, div.cms-edit-design-btn { padding: 2px 5px; font-family: Arial, Verdana; font-size: 13px; @@ -59,25 +59,70 @@ filter: alpha(opacity=50); } -/* === Styles for "Save Layout" button === */ -div.cms-save-layout-btn { - float: left; - position: absolute; +div.cms-edit-block-btn { + margin-left: -10px; + border: 2px solid #FF6E00; + background-color: #FFCC00; + display: none; +} +div.cms-edit-design-btn { margin-left: -10px; + border: 2px solid #006E00; + background-color: #00CC00; + /*opacity: 0.5; + filter: alpha(opacity=50);*/ + display: none; +} + +/* === Styles for "Save" and "Cancel" buttons (for layout) === */ +div.cms-layout-btn-container { + position: absolute; + margin-top: -10px; + margin-left: -10px; + display: none; + z-index: 99; +} + +div.cms-save-layout-btn, div.cms-cancel-layout-btn { + float: left; + padding: 2px 5px; + font-family: Arial, Verdana; + font-size: 13px; + font-weight: normal; + width: auto; + color: black; + cursor: pointer; + -moz-border-radius: 10px; +} + +div.cms-save-layout-btn { border: 2px solid #A1D0A1; background-color: #CCFF00; } +div.cms-cancel-layout-btn { + border: 2px solid #FF0000; + background-color: #FF6A5D; +} + +div.cms-cancel-layout-btn { + margin-left: 4px; +} + /* === Styles for Template Editor === */ -div.block-edit-btn-container { +div.block-edit-block-btn-container, div.block-edit-design-btn-container { border: 1px dashed transparent; } -div.block-edit-btn-container-over { +div.block-edit-block-btn-container-over { border-color: #FF6E00; } +div.block-edit-design-btn-container-over { + border-color: #006E00; +} + /* === Styles for element moving/sorting in theme === */ div.movable-area { min-height: 200px; @@ -86,4 +131,26 @@ .move-helper { border: 3px dashed #666; /*width: auto !important;*/ +} + +/* === Styles for phrase translation links === */ +span[name='cms-translate-phrase'] { + text-decoration: none; + border: 1px dashed transparent; + padding: 3px; + +} + +span[name='cms-translate-phrase']:hover { + border-color: #FF6E00; +} + +span[name='cms-translate-phrase'] .cms-btn-text { + font-size: 9px; +} + +span[name='cms-translate-phrase'] .cms-edit-btn { + display: none; + opacity: 1; + filter: alpha(opacity=0); } \ No newline at end of file Index: branches/5.0.x/core/admin_templates/js/script.js =================================================================== diff -u -r12230 -r12298 --- branches/5.0.x/core/admin_templates/js/script.js (.../script.js) (revision 12230) +++ branches/5.0.x/core/admin_templates/js/script.js (.../script.js) (revision 12298) @@ -538,9 +538,14 @@ ); } -function translate_phrase($label, $template) { +function translate_phrase($label, $template, $options) { set_hidden_field('phrases_label', $label); - open_popup('phrases', 'OnNew', $template); + + if ($options.simple_mode !== undefined) { + set_hidden_field('simple_mode', $options.simple_mode ? 1 : 0); + } + + open_popup('phrases', $options.event === undefined ? 'OnNew' : $options.event, $template); } function direct_edit($prefix_special, $url) { Index: branches/5.0.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -r12267 -r12298 --- branches/5.0.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12267) +++ branches/5.0.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12298) @@ -1,6 +1,6 @@ 'm,c,content', @@ -1169,7 +1169,7 @@
-
Edit '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
+
Edit content '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'
'; @@ -1334,7 +1334,7 @@ $ret = '' . "\n"; $ret .= '' . "\n"; - if (EDITING_MODE == EDITING_MODE_LAYOUT) { + if (EDITING_MODE == EDITING_MODE_DESIGN) { $ret .= ' '; @@ -1362,35 +1362,39 @@ $this_url = $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', 'no_amp' => 1)); $ret .= "var aTemplateManager = new TemplateManager('" . $edit_template_url . "', '" . $this_url . "', '" . $save_layout_url . "', " . (int)EDITING_MODE . ");\n"; - $ret .= "var \$modal_windows = " . ($this->Application->ConfigValue('UseModalWindows') ? 'true' : 'false') . ";\n"; - $ret .= "var main_title = '" . addslashes( $this->Application->ConfigValue('Site_Name') ) . "';" . "\n"; - $ret .= "var base_url = '" . $this->Application->BaseURL() . "';" . "\n"; - $ret .= 'TB.closeHtml = \'close
\';' . "\n"; + if (EDITING_MODE != EDITING_MODE_BROWSE) { + $ret .= "var \$modal_windows = " . ($this->Application->ConfigValue('UseModalWindows') ? 'true' : 'false') . ";\n"; + $ret .= "var main_title = '" . addslashes( $this->Application->ConfigValue('Site_Name') ) . "';" . "\n"; + $ret .= "var base_url = '" . $this->Application->BaseURL() . "';" . "\n"; + $ret .= 'TB.closeHtml = \'close
\';' . "\n"; - $url_params = Array('m_theme' => '', 'pass' => 'm', 'm_opener' => 'r', 'no_amp' => 1); - $browse_url = $this->Application->HREF('catalog/catalog', ADMIN_DIRECTORY, $url_params, 'index.php'); - $browse_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $browse_url); + $url_params = Array('m_theme' => '', 'pass' => 'm', 'm_opener' => 'r', 'no_amp' => 1); + $browse_url = $this->Application->HREF('catalog/catalog', ADMIN_DIRECTORY, $url_params, 'index.php'); + $browse_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $browse_url); - $ret .= ' - var topmost = window.top; + $ret .= ' + var topmost = window.top; - topmost.document.title = document.title + \' - '.$this->Application->Phrase('la_AdministrativeConsole').'\'; - t = \''.$this->Application->GetVar('t').'\'; + topmost.document.title = document.title + \' - '.$this->Application->Phrase('la_AdministrativeConsole', false).'\'; + t = \''.$this->Application->GetVar('t').'\'; - if (window.parent.frames["menu"] != undefined) { - if ( $.isFunction(window.parent.frames["menu"].SyncActive) ) { - window.parent.frames["menu"].SyncActive("' . $browse_url . '"); + if (window.parent.frames["menu"] != undefined) { + if ( $.isFunction(window.parent.frames["menu"].SyncActive) ) { + window.parent.frames["menu"].SyncActive("' . $browse_url . '"); + } } - } - '; + '; + } $ret .= '' . "\n"; - // add form, so admin scripts could work - $ret .= '
- - - '; + if (EDITING_MODE != EDITING_MODE_BROWSE) { + // add form, so admin scripts could work + $ret .= '
+ + + '; + } return $ret; } @@ -1412,48 +1416,79 @@ $page =& $this->_getPage($params); - if (!$page->isLoaded()) { + if (!$page->isLoaded() || (($display_mode != 'end') && (EDITING_MODE == EDITING_MODE_BROWSE))) { // when "EditingScripts" tag is not used, make sure, that scripts are also included return $this->EditingScripts($params); } // show "EditPage" button only for pages, that exists in structure if ($display_mode != 'end') { - $url_params = Array( - 'pass' => 'm,c', - 'm_opener' => 'd', - 'c_id' => $page->GetID(), - 'c_mode' => 't', - 'c_event' => 'OnEdit', - 'front' => 1, - '__URLENCODE__' => 1, - '__NO_REWRITE__'=> 1, - 'escape' => 1, - 'index_file' => 'index.php', - ); + $edit_btn = ''; - $edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params); + if (EDITING_MODE == EDITING_MODE_CONTENT) { + $url_params = Array( + 'pass' => 'm,c', + 'm_opener' => 'd', + 'c_id' => $page->GetID(), + 'c_mode' => 't', + 'c_event' => 'OnEdit', + 'front' => 1, + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'escape' => 1, + 'index_file' => 'index.php', + ); - $edit_btn = ''; + $edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params); - if (EDITING_MODE == EDITING_MODE_LAYOUT) { $edit_btn .= ' -
+
-
Save Layout
+
Section Properties
' . "\n"; - } + } elseif (EDITING_MODE == EDITING_MODE_DESIGN) { + $url_params = Array( + 'pass' => 'm,theme', + 'm_opener' => 'd', + 'theme_id' => $this->Application->GetVar('m_theme'), + 'theme_mode' => 't', + 'theme_event' => 'OnEdit', + 'theme-file_id' => $this->_getThemeFileId(), + 'front' => 1, + '__URLENCODE__' => 1, + '__NO_REWRITE__'=> 1, + 'escape' => 1, + 'index_file' => 'index.php', + ); - $edit_btn .= ' -
-
- + $edit_url = $this->Application->HREF('themes/file_edit', '/admin', $url_params); + + $edit_btn .= ' +
+
+
+ +
+
Save changes
+
+
+
+ +
+
Cancel
+
-
Section Properties
-
' . "\n"; +
+
+ +
+
Section Template
+
' . "\n"; + } + if ($display_mode == 'start') { // button with border around the page $edit_code .= '
' . $edit_btn . '
'; @@ -1480,6 +1515,26 @@ return $edit_code; } + function _getThemeFileId() + { + $template = $this->Application->GetVar('t'); + + if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->IsAdmin()) { + $cms_handler =& $this->Application->recallObject($this->Prefix . '_EventHandler'); + /* @var $cms_handler CategoriesEventHandler */ + + $template = ltrim($cms_handler->GetDesignTemplate(), '/'); + } + + $file_path = dirname($template) == '.' ? '' : '/' . dirname($template); + $file_name = basename($template); + + $sql = 'SELECT FileId + FROM ' . TABLE_PREFIX . 'ThemeFiles + WHERE (FilePath = ' . $this->Conn->qstr($file_path) . ') AND (FileName = ' . $this->Conn->qstr($file_name . '.tpl') . ')'; + return $this->Conn->GetOne($sql); + } + /** * Builds cached menu version * Index: branches/5.0.x/themes/default2009/platform/elements/side_boxes/search.elm.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/platform/elements/side_boxes/search.elm.tpl (.../search.elm.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/platform/elements/side_boxes/search.elm.tpl (.../search.elm.tpl) (revision 12298) @@ -33,7 +33,7 @@
- " />
+
Index: branches/5.0.x/themes/default2009/index.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/index.tpl (.../index.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/index.tpl (.../index.tpl) (revision 12298) @@ -1,58 +1,58 @@ - - - - - - - - - - -
-
- -
-
- -
-
- -
-
- -
-
-
- - - - -
-
- -
-
- - - - - - - -
-
- - - -
-
-
- - - - + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + + + +
+
+ +
+
+ + + + + + + +
+
+ + + +
+
+
+ + + + \ No newline at end of file Index: branches/5.0.x/core/admin_templates/languages/phrase_edit.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/core/admin_templates/languages/phrase_edit.tpl (.../phrase_edit.tpl) (revision 12117) +++ branches/5.0.x/core/admin_templates/languages/phrase_edit.tpl (.../phrase_edit.tpl) (revision 12298) @@ -13,10 +13,20 @@ submit_event('phrases',''); } ) ); - a_toolbar.AddButton( new ToolBarButton('cancel', '', function() { - cancel_edit('phrases','OnCancelEdit','',''); + + a_toolbar.AddButton( + new ToolBarButton( + 'cancel', + '', + function() { + + window_close(); + + cancel_edit('phrases', 'OnCancelEdit', '', ''); + } - ) ); + ) + ); a_toolbar.AddButton( new ToolBarButton('reset_edit', '', function() { reset_form('phrases', 'OnReset', ''); @@ -50,30 +60,49 @@ -
- - "> - - - - + + - - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + +
+
+ - +
+ \ No newline at end of file Index: branches/5.0.x/core/admin_templates/regional/phrases_edit.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/core/admin_templates/regional/phrases_edit.tpl (.../phrases_edit.tpl) (revision 12117) +++ branches/5.0.x/core/admin_templates/regional/phrases_edit.tpl (.../phrases_edit.tpl) (revision 12298) @@ -1,5 +1,4 @@ - @@ -14,10 +13,20 @@ submit_event('phrases',''); } ) ); - a_toolbar.AddButton( new ToolBarButton('cancel', '', function() { - submit_event('phrases','OnCancel'); + + a_toolbar.AddButton( + new ToolBarButton( + 'cancel', + '', + function() { + + window_close(); + + cancel_edit('phrases', 'OnCancelEdit', '', ''); + } - ) ); + ) + ); a_toolbar.AddButton( new ToolBarButton('reset_edit', '', function() { reset_form('phrases', 'OnReset', ''); @@ -51,33 +60,46 @@ -
- - "> - - - - + + - - - - - + + + - - - + + + - - - + + + + + + + + - + + + + + + + + + + + + + +
+
+ - +
Index: branches/5.0.x/core/kernel/languages/phrases_cache.php =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12117) +++ branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12298) @@ -1,6 +1,6 @@ Conn =& $this->Application->GetADODBConnection(); + + if (defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->IsAdmin()) { + // only has effect in admin, because on front-end phrases are translated in "Content Mode" + $this->_editMissing = defined('DBG_PHRASES') && DBG_PHRASES; + } + + // now we use admin phrase editing template even on front-end + $this->_phraseEditTemplate = 'regional/phrases_edit'; + $this->_usePopups = $this->Application->ConfigValue('UsePopups'); } + /** + * Sets phrase editing mode, that corresponds current editing mode + * + */ + function setPhraseEditing() + { + if (!$this->Application->IsAdmin() && (EDITING_MODE == EDITING_MODE_CONTENT)) { + $this->_editExisting = true; + $this->_editMissing = true; + $this->_simpleEditingMode = true; + $this->_translateHtmlTag = 'span'; + } + } + function Init($prefix, $special = '') { if (constOn('IS_INSTALL')) { @@ -62,11 +127,13 @@ function GetCachedIds() { - $query = sprintf("SELECT PhraseList, ConfigVariables FROM %s WHERE Template = %s", - TABLE_PREFIX.'PhraseCache', - $this->Conn->Qstr(md5($this->Application->GetVar('t').$this->Application->GetVar('m_theme').$this->Application->GetVar('m_lang')))); - $res = $this->Conn->GetRow($query); + $cache_key = md5($this->Application->GetVar('t') . $this->Application->GetVar('m_theme') . $this->Application->GetVar('m_lang')); + $sql = 'SELECT PhraseList, ConfigVariables + FROM ' . TABLE_PREFIX . 'PhraseCache + WHERE Template = ' . $this->Conn->qstr($cache_key); + $res = $this->Conn->GetRow($sql); + if ($res && $res['ConfigVariables']) { $this->Application->OriginalConfigCacheIds = explode(',', $res['ConfigVariables']); $this->Application->ConfigCacheIds = $this->Application->OriginalConfigCacheIds; @@ -77,16 +144,20 @@ function LoadPhrases($ids) { - if ( !is_array($ids) || !implode('', $ids) ) return; - $query = sprintf("SELECT Translation,UPPER(Phrase) AS Phrase FROM %s WHERE LanguageId = %s AND PhraseId IN (%s)", - TABLE_PREFIX.'Phrase', - $this->LanguageId, - join(',', $ids)); - $this->Phrases = $this->Conn->GetCol($query,'Phrase'); + if ( !is_array($ids) || !implode('', $ids) ) { + return; + } + + $sql = 'SELECT Translation, UPPER(Phrase) AS Phrase + FROM ' . TABLE_PREFIX . 'Phrase + WHERE (LanguageId = ' . $this->LanguageId . ') AND PhraseId IN (' . implode(',', $ids) . ')'; + $this->Phrases = $this->Conn->GetCol($sql, 'Phrase'); + /*foreach($phrases as $phrase => $tanslation) { $this->AddCachedPhrase(mb_strtoupper($phrase), $tanslation); }*/ + $this->Ids = $ids; $this->OriginalIds = $ids; } @@ -125,90 +196,100 @@ } } - function GetPhrase($label) + function GetPhrase($label, $allow_editing = true) { - if (!isset($this->LanguageId)) return 'impossible case'; - //actually possible when custom field contains references to language labels and its being rebuilt in OnAfterConfigRead - //which is triggered by Sections rebuild, which in turn read all the configs and all of that happens BEFORE seeting the language... + if (!isset($this->LanguageId)) { + //actually possible when custom field contains references to language labels and its being rebuilt in OnAfterConfigRead + //which is triggered by Sections rebuild, which in turn read all the configs and all of that happens BEFORE seeting the language... + return 'impossible case'; + } - if (ereg("^!.+!$", $label) > 0) - { + if (ereg("^!.+!$", $label) > 0) { $label = substr($label, 1, -1); //cut exclamation marks } - if( strlen($label) == 0 ) return ''; + if (strlen($label) == 0) { + return ''; + } $original_label = $label; $label = mb_strtoupper($label); - if(isset($this->Phrases[$label])) { + + if (array_key_exists($label, $this->Phrases)) { $translated_label = $this->Phrases[$label]; - // debug mode is checked directly to improve performance - if (defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PHRASES_HIGHLIGHT')) { - if (!$this->Application->isDebugMode()) return $translated_label; - if ($this->Application->IsAdmin()) { - $sql = 'SELECT Module - FROM '.TABLE_PREFIX.'Phrase - WHERE (LanguageId = '.$this->LanguageId.') AND (Phrase = '.$this->Conn->qstr($label).')'; - $this->Application->Debugger->appendHTML('Phrase: '.$label.'; Module: '.$this->Conn->GetOne($sql).''); -// $translated_label = $translated_label.' [m: '.$this->Conn->GetOne($sql).'; l: '.$label.']'; - } - else { - // highlight text created via translated phrase (used to detect if text on screen is phrase or not) - $translated_label = ''.$translated_label.' '.$original_label.''; - } - - } - - if (defined('DEBUG_MODE') && DEBUG_MODE && - (($this->Application->IsAdmin() && constOn('DBG_PHRASES_EDIT_ADMIN')) || (!$this->Application->IsAdmin() && constOn('DBG_PHRASES_EDIT_FRONT')) ) ) { + if ($this->_editExisting && $allow_editing) { // option to change translation for Labels - list($edit_tpl, $index_file) = $this->Application->IsAdmin() ? Array('regional/phrases_edit', 'index.php') : Array('phrases_edit', 'index.php'); - - if ($this->Application->IsAdmin() && $this->Application->ConfigValue('UsePopups')) { + if ($this->_usePopups) { // link to popup when using popups (only in admin) - $edit_url = 'javascript:translate_phrase(\''.addslashes($translated_label).'\', \''.$edit_tpl.'\');'; + $edit_url = 'javascript:translate_phrase(\'' . addslashes($original_label) . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnPrepareUpdate\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; } else { // direct link, when not using popups OR on frontend - $edit_url = $this->Application->HREF($edit_tpl,'',Array('m_opener'=>'d','phrases_label'=>$original_label,'phrases_event'=>'OnPrepareUpdate', 'pass'=>'all,phrases'), $index_file ); + $url_params = Array( + 'm_opener' => 'd', + 'phrases_label' => $original_label, + 'phrases_event' => 'OnPrepareUpdate', + 'simple_mode' => $this->_simpleEditingMode ? 1 : 0, + 'pass' => 'all,phrases' + ); + + $edit_url = $this->Application->HREF($this->_phraseEditTemplate, '', $url_params, 'index.php'); } - $translated_label = '!'.$translated_label.'!'; + + $translated_label = '<' . $this->_translateHtmlTag . ' href="' . $edit_url . '" name="cms-translate-phrase" title="Edit translation">' . $translated_label . '_translateHtmlTag . '>'; + + if ($this->fromTag) { + $translated_label = $this->escapeTagReserved($translated_label); + } } return $translated_label; } - $this->LoadPhraseByLabel($label, $original_label); + $this->LoadPhraseByLabel($label, $original_label, $allow_editing); + return $this->GetPhrase($label); } - function LoadPhraseByLabel($label, $original_label) + function LoadPhraseByLabel($label, $original_label, $allow_editing = true) { - $query = sprintf("SELECT PhraseId, Translation FROM %s WHERE LanguageId = %s AND UPPER(Phrase) = UPPER(%s)", - TABLE_PREFIX.'Phrase', - $this->LanguageId, - $this->Conn->qstr($label)); - $res = $this->Conn->GetRow($query); - if ($res === false || count($res) == 0) - { - $translation = '!'.$label.'!'; - if($this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - list($edit_tpl, $index_file) = $this->Application->IsAdmin() ? Array('regional/phrases_edit', 'index.php') : Array('phrases_edit', 'index.php'); + $sql = 'SELECT PhraseId, Translation + FROM ' . TABLE_PREFIX . 'Phrase + WHERE (LanguageId = ' . $this->LanguageId . ') AND (UPPER(Phrase) = UPPER(' . $this->Conn->qstr($label) . '))'; + $res = $this->Conn->GetRow($sql); - if ($this->Application->IsAdmin() && $this->Application->ConfigValue('UsePopups')) { + if ($res === false || count($res) == 0) { + $translation = '!' . $label . '!'; + + if ($this->_editMissing && $allow_editing) { + if ($this->_usePopups) { // link to popup when using popups (only in admin) - $edit_url = 'javascript:translate_phrase(\''.addslashes($original_label).'\', \''.$edit_tpl.'\');'; + $edit_url = 'javascript:translate_phrase(\'' . addslashes($original_label) . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnNew\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; } else { // direct link, when not using popups OR on frontend - $edit_url = $this->Application->HREF($edit_tpl,'',Array('m_opener'=>'d','phrases_label'=>$original_label,'phrases_event'=>'OnNew', 'pass'=>'all,phrases'), $index_file ); + $url_params = Array ( + 'm_opener' => 'd', + 'phrases_label' => $original_label, + 'phrases_event' => 'OnNew', + 'simple_mode' => $this->_simpleEditingMode ? 1 : 0, + 'pass' => 'all,phrases' + ); + + $edit_url = $this->Application->HREF($this->_phraseEditTemplate, '', $url_params, 'index.php'); } - $translation = '!'.$label.'!'; - if($this->fromTag) $translation = $this->escapeTagReserved($translation); + $translation = '<' . $this->_translateHtmlTag . ' href="' . $edit_url . '" class="cms-translate-phrase" title="Translate">!' . $label . '!_translateHtmlTag . '>'; + + if ($this->fromTag) { + $translation = $this->escapeTagReserved($translation); + } } - $this->AddCachedPhrase($label, $translation); //add it as already cached, as long as we dont need to cache not found phrase + + // add it as already cached, as long as we dont need to cache not found phrase + $this->AddCachedPhrase($label, $translation); + return false; } @@ -259,6 +340,7 @@ $i++; } $this->fromTag = false; + return preg_replace($language_tags, $values, $text); } @@ -276,7 +358,4 @@ return str_replace($reserved,$replacement,$text); } -} - - -?> \ No newline at end of file +} \ No newline at end of file Index: branches/5.0.x/themes/default2009/platform/designs/default_design.des.tpl =================================================================== diff -u -r12117 -r12298 --- branches/5.0.x/themes/default2009/platform/designs/default_design.des.tpl (.../default_design.des.tpl) (revision 12117) +++ branches/5.0.x/themes/default2009/platform/designs/default_design.des.tpl (.../default_design.des.tpl) (revision 12298) @@ -54,7 +54,7 @@
- +

- !" /> +