public function __construct($objParentObject, $strControlId = null, NarroContextInfo $objContextInfo) { parent::__construct($objParentObject, $strControlId); $this->objContextInfo = $objContextInfo; $this->lblIndex = new QLabel($this); $this->lblIndex->CssClass = 'index'; $this->lblIndex->HtmlEntities = false; $this->lblMessage = new QLabel($this); $this->lblMessage->CssClass = 'message'; $this->lblMessage->HtmlEntities = false; $this->chkChanged = new QCheckBox($this); $this->chkChanged->DisplayStyle = QDisplayStyle::None; $this->txtTranslation = new QTextBox($this); $this->txtTranslation->ActionParameter = $objContextInfo->ContextInfoId; $this->txtTranslation->TextMode = QTextMode::MultiLine; $this->txtTranslation->CssClass = 'translation_box'; $this->txtTranslation->CrossScripting = QCrossScripting::Allow; $this->txtTranslation->Rows = 1; $this->txtTranslation->ReadOnly = !QApplication::HasPermissionForThisLang('Can suggest'); $this->txtTranslation->Width = '100%'; $this->txtTranslation->DisplayStyle = QDisplayStyle::Block; if ($this->txtTranslation->ReadOnly) { $this->txtTranslation->ToolTip = t('Sign in to add translations'); } else { $this->txtTranslation->ToolTip = t('Enter your translation here'); } if ($this->objContextInfo->Context->TextAccessKey) { $this->txtAccessKey = new QTextBox($this); $this->txtAccessKey->ToolTip = sprintf(t('Access key (original access key: %s)'), $this->objContextInfo->Context->TextAccessKey); $this->txtAccessKey->TextMode = QTextMode::SingleLine; $this->txtAccessKey->Name = t('Access key'); $this->txtAccessKey->Instructions = sprintf(t('This is the letter that appears underlined in menus and buttons and you can use Alt + this letter to select, e.g. <b>%s</b>'), NarroString::Replace($this->objContextInfo->Context->TextAccessKey, sprintf('<u>%s</u>', $this->objContextInfo->Context->TextAccessKey), $this->objContextInfo->Context->Text->TextValue, 1)); $this->txtAccessKey->Columns = 5; $this->txtAccessKey->MaxLength = 10; $this->txtAccessKey->Text = $this->objContextInfo->SuggestionAccessKey; } if ($this->objContextInfo->Context->TextCommandKey) { $this->txtCommandKey = new QTextBox($this); $this->txtCommandKey->ToolTip = sprintf(t('Command key (original command key: %s)'), $this->objContextInfo->Context->TextCommandKey); $this->txtCommandKey->TextMode = QTextMode::SingleLine; $this->txtCommandKey->Name = t('Command key'); $this->txtCommandKey->Instructions = sprintf(t('This is the letter that appears in menus and buttons after the text and you can use Ctrl + this letter to select, e.g. <b>%s Ctrl+%s</b>'), NarroString::Replace($this->objContextInfo->Context->TextAccessKey, sprintf('<u>%s</u>', $this->objContextInfo->Context->TextAccessKey), $this->objContextInfo->Context->Text->TextValue, 1), $this->objContextInfo->Context->TextCommandKey); $this->txtCommandKey->Columns = 5; $this->txtCommandKey->MaxLength = 10; $this->txtCommandKey->Text = $this->objContextInfo->SuggestionCommandKey; } if ($objContextInfo->ValidSuggestionId) { $this->txtTranslation->Text = $objContextInfo->ValidSuggestion->SuggestionValue; } $this->txtTranslation->Columns = 50; $this->btnCopy = new QButton($this); $this->btnCopy->Text = t('Copy'); $this->btnCopy->DisplayStyle = QDisplayStyle::None; $this->btnCopy->TabIndex = -1; $this->btnCopy->CssClass = $this->btnCopy->CssClass . ' copy'; $this->btnCopy->Display = QApplication::HasPermissionForThisLang('Can suggest'); $this->lblText = new QLabel($this); $this->lblText->Width = '100%'; $this->lblText->TagName = 'pre'; $this->lblText->CssClass = 'originalText'; $this->lblText->Text = NarroString::ShowLeadingAndTrailingSpaces(NarroString::HtmlEntities($this->objContextInfo->Context->Text->TextValue)); $this->lblText->HtmlEntities = false; $this->lblText->Text = str_replace("\n", '<span class="newline_block" title="Enter"> </span><br />', $this->lblText->Text); $this->btnHelp_Create(); $this->btnSave = new QButton($this); $this->btnSave->Text = t('Save'); $this->btnSave->CssClass = $this->btnSave->CssClass . ' save'; $this->btnSave->Display = QApplication::HasPermissionForThisLang('Can suggest'); if (QApplication::$User->GetPreferenceValueByName('Automatically save translations') == 'Yes') { $this->btnSave->DisplayStyle = QDisplayStyle::None; $this->btnSave->TabIndex = -1; } $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click')); $this->btnKeepUntranslated_Create(); $this->lblContextInfo_Create(); $this->txtTranslation->AddAction(new QFocusEvent(), new QJavaScriptAction(sprintf('ctx_editor_focus("%s", "%s", "%s", "%s", "%s", "%s")', $this->ControlId, $this->txtTranslation->ControlId, $this->btnCopy->ControlId, $this->btnHelp->ControlId, $this->lblContextInfo->ControlId, $this->chkChanged->ControlId))); $this->txtTranslation->AddAction(new QChangeEvent(), new QJavaScriptAction(sprintf('jQuery("#%s").attr("checked", true);', $this->chkChanged->ControlId))); if (QApplication::$User->GetPreferenceValueByName('Automatically save translations') == 'Yes') { $this->txtTranslation->AddAction(new QFocusEvent(), new QAjaxControlAction($this, 'txtTranslation_Focus')); } $this->btnCopy->AddAction(new QClickEvent(), new QJavaScriptAction(sprintf('if (jQuery("#%s").attr("alt") == "%s") {jQuery("#%s").val(jQuery("#%s").text());jQuery("#%s").attr("alt", "%s");jQuery("#%s").attr("checked", "true");} else {jQuery("#%s").val("");jQuery("#%s").attr("alt", "%s");jQuery("#%s").attr("checked", "");}', $this->btnCopy->ControlId, t('Copy'), $this->txtTranslation->ControlId, $this->lblText->ControlId, $this->btnCopy->ControlId, t('Clear'), $this->chkChanged->ControlId, $this->txtTranslation->ControlId, $this->btnCopy->ControlId, t('Copy'), $this->chkChanged->ControlId))); if ($this->objContextInfo->HasSuggestions && is_null($this->objContextInfo->ValidSuggestionId)) { $this->dtgTranslation_Create(); } $this->strTemplate = dirname(__FILE__) . '/' . __CLASS__ . '.tpl.php'; if ($this->txtTranslation->ReadOnly) { $this->btnHelp_Click($this->Form->FormId, $this->btnHelp->ControlId, ''); } }