Index: branches/RC/core/kernel/languages/phrases_cache.php =================================================================== diff -u -r10580 -r11430 --- branches/RC/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 10580) +++ branches/RC/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 11430) @@ -17,7 +17,7 @@ var $LanguageId = null; var $fromTag = false; - + function PhrasesCache() { parent::kBase(); @@ -115,10 +115,10 @@ function GetPhrase($label) { - if (!isset($this->LanguageId)) return 'impossible case'; + 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 (ereg("^!.+!$", $label) > 0) { $label = substr($label, 1, -1); //cut exclamation marks @@ -147,6 +147,23 @@ } } + + if (defined('DEBUG_MODE') && DEBUG_MODE && + (($this->Application->IsAdmin() && constOn('DBG_PHRASES_EDIT_ADMIN')) || (!$this->Application->IsAdmin() && constOn('DBG_PHRASES_EDIT_FRONT')) ) ) { + // 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')) { + // link to popup when using popups (only in admin) + $edit_url = 'javascript:translate_phrase(\''.addslashes($translated_label).'\', \''.$edit_tpl.'\');'; + } + 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 ); + } + $translated_label = '!'.$translated_label.'!'; + } + return $translated_label; } Index: branches/RC/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -r9408 -r11430 --- branches/RC/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 9408) +++ branches/RC/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 11430) @@ -10,14 +10,26 @@ function CheckPermission(&$event) { if (!$this->Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - if ($event->Name == 'OnNew' || $event->Name == 'OnCreate') { + if ($event->Name == 'OnNew' || $event->Name == 'OnCreate' || $event->Name == 'OnPrepareUpdate' || $event->Name == 'OnUpdate') { return true; } } + + return parent::CheckPermission($event); } + function mapPermissions() + { + parent::mapPermissions(); + $permissions = Array ( + 'OnItemBuild' => Array('self' => true, 'subitem' => true), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + /** * Forces new label in case if issued from get link * @@ -53,6 +65,26 @@ } } + function OnPrepareUpdate(&$event) + { + $language_id = $this->Application->GetVar('m_lang'); + $label = $this->Application->GetVar('phrases_label'); + + $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; + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $this->Conn->GetOne($sql)); +// $event->redirect = false; + } + + function OnUpdate(&$event) + { + parent::OnUpdate($event); + +// $event->redirect = + } + /** * Forces create to use live table *