Index: kernel/application.php =================================================================== --- kernel/application.php (revision 12950) +++ kernel/application.php (working copy) @@ -867,11 +867,11 @@ // user can edit cms blocks $editing_mode = $this->GetVar('editing_mode'); define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_BROWSE); - $this->Phrases->setPhraseEditing(); } } safeDefine('EDITING_MODE', ''); // user can't edit anything + $this->Phrases->setPhraseEditing(); if (!$this->RequestProcessed) $this->ProcessRequest(); Index: kernel/languages/phrases_cache.php =================================================================== --- kernel/languages/phrases_cache.php (revision 12950) +++ kernel/languages/phrases_cache.php (working copy) @@ -58,7 +58,7 @@ * * @var string */ - var $_phraseEditTemplate = ''; + var $_phraseEditTemplate = 'regional/phrases_edit'; /** * Use simplified form for phrase editing @@ -81,18 +81,23 @@ */ var $_missingPhrases = Array (); + /** + * Mask for editing link + * + * @var string + */ + var $_editLinkMask = ''; + + /** + * Escape phrase name, before placing it in javascript translation link + * @var unknown_type + */ + var $_escapePhraseName = true; + function PhrasesCache() { parent::kBase(); $this->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'; } /** @@ -102,11 +107,33 @@ function setPhraseEditing() { if (!$this->Application->isAdmin && (EDITING_MODE == EDITING_MODE_CONTENT)) { + // front-end viewed in content mode $this->_editExisting = true; $this->_editMissing = true; $this->_simpleEditingMode = true; $this->_translateHtmlTag = 'span'; } + + $this->_editLinkMask = 'javascript:translate_phrase(\'#LABEL#\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnNew\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; + + if (defined('DEBUG_MODE') && DEBUG_MODE && !$this->Application->GetVar('admin')) { + // admin and front-end while not viewed using content mode (via admin) + $this->_editMissing = defined('DBG_PHRASES') && DBG_PHRASES; + + if (!$this->Application->isAdmin) { + $this->_phraseEditTemplate = 'phrases_edit'; + + $url_params = Array ( + 'm_opener' => 'd', + 'phrases_label' => '#LABEL#', + 'phrases_event' => 'OnNew', + 'pass' => 'm,phrases' + ); + + $this->_escapePhraseName = false; + $this->_editLinkMask = $this->Application->HREF($this->_phraseEditTemplate, '', $url_params); + } + } } function Init($prefix, $special = '') @@ -228,7 +255,7 @@ return ''; } - $original_label = $label; + $original_label = $this->_escapePhraseName ? addslashes($label) : $label; $label = mb_strtoupper($label); $cache_key = ($allow_editing ? '' : 'NE:') . $label; @@ -238,7 +265,7 @@ if ($this->_editExisting && $allow_editing && !array_key_exists($label, $this->_missingPhrases)) { // option to change translation for Labels - $edit_url = 'javascript:translate_phrase(\'' . addslashes($original_label) . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnPrepareUpdate\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; + $edit_url = 'javascript:translate_phrase(\'' . $original_label . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnPrepareUpdate\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; $translated_label = '<' . $this->_translateHtmlTag . ' href="' . $edit_url . '" name="cms-translate-phrase" title="Edit translation">' . $translated_label . '_translateHtmlTag . '>'; if ($this->fromTag) { @@ -274,7 +301,7 @@ $translation = '!' . $label . '!'; if ($this->_editMissing && $allow_editing) { - $edit_url = 'javascript:translate_phrase(\'' . addslashes($original_label) . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnNew\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; + $edit_url = str_replace('#LABEL#', $original_label, $this->_editLinkMask); $translation = '<' . $this->_translateHtmlTag . ' href="' . $edit_url . '" name="cms-translate-phrase" title="Translate">!' . $label . '!_translateHtmlTag . '>'; if ($this->fromTag) {