public function __construct($objParentObject, $strControlId = null) { parent::__construct($objParentObject, $strControlId); $this->blnAutoRenderChildren = true; $this->strTemplate = dirname(__FILE__) . '/' . __CLASS__ . '.tpl.php'; $this->txtSearch = new QTextBox($this); $this->txtSearch->Name = t('Text'); $this->txtSearch->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, 'txtSearch_KeyUp')); $this->txtSearch->SetCustomAttribute('autocomplete', 'off'); $this->btnClear = new QImageButton($this); $this->btnClear->AlternateText = t('Clear'); $this->btnClear->ToolTip = $this->btnClear->AlternateText; $this->btnClear->CssClass = 'clear_button'; $this->btnClear->ImageUrl = __NARRO_IMAGE_ASSETS__ . '/clear.png'; $this->btnClear->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnClear_Click')); $this->lstLanguage = new QListBox($this); $arrLanguages = NarroLanguage::LoadAllActive(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)); foreach ($arrLanguages as $objLanguage) { $this->lstLanguage->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageId, $objLanguage->LanguageCode == QApplication::$TargetLanguage->LanguageCode); } $this->btnSearch = new QImageButton($this); $this->btnSearch->AlternateText = t('Search'); $this->btnSearch->ToolTip = $this->btnSearch->AlternateText; $this->btnSearch->CssClass = 'clear_button'; $this->btnSearch->ImageUrl = __NARRO_IMAGE_ASSETS__ . '/search.png'; $this->btnSearch->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'txtSearch_KeyUp')); $this->dtgSuggestion = new NarroSuggestionDataGrid($this); $this->dtgSuggestion->ShowHeader = false; $this->dtgSuggestion->MetaAddColumn(QQN::NarroSuggestion()->SuggestionValue); $this->dtgSuggestion->AdditionalClauses = array(QQ::LimitInfo(20), QQ::OrderBy(QQN::NarroSuggestion()->Text->TextCharCount)); $this->btnClear_Click(); }
public function __construct($objParentObject, $strControlId = null) { parent::__construct($objParentObject, $strControlId); $this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroHeaderPanel.tpl.php'; $this->strHorizontalAlign = QHorizontalAlign::Right; $this->lstLanguage = new QListBox($this); $this->lstLanguage->AddAction(new QChangeEvent(), new QServerControlAction($this, 'lstLanguage_Change')); $arrLanguages = NarroLanguage::LoadAllActive(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)); foreach ($arrLanguages as $objLanguage) { $this->lstLanguage->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageCode, $objLanguage->LanguageCode == QApplication::$TargetLanguage->LanguageCode); } $this->btnLogout = new QLinkButton($this); $this->btnLogout->Text = '<img src="assets/images/logout.png" alt="' . t('Logout') . '" border="0" title="' . t('Logout') . '" />'; $this->btnLogout->HtmlEntities = false; $this->btnLogout->ToolTip = t('Logout'); $this->btnLogout->SetCustomStyle('vertical-align', 'bottom'); $this->btnLogout->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnLogout_Click')); }
public function __construct(NarroProject $objProject, NarroLanguage $objLanguage, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->objProject = $objProject; $this->objLanguage = $objLanguage; $this->lstLanguage = new QListBox($this); $this->lstLanguage->DisplayStyle = QDisplayStyle::Block; $this->lstLanguage->Instructions = t('Please choose the language from which you will import matching approved translations'); $this->lstLanguage->PreferedRenderMethod = 'RenderWithName'; $this->blnAutoRenderChildren = true; foreach (NarroLanguage::LoadAllActive() as $objLanguage) { $this->lstLanguage->AddItem($objLanguage->LanguageName, $objLanguage->LanguageCode); } }
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/../configuration/prepend.inc.php'; if (!isset($argv)) { exit; } QFirebug::setEnabled(false); if (array_search('--help', $argv) !== false) { echo sprintf("php %s [options]\n" . "--project project id instead of exporting all projects\n" . "--language language code instead of importing all languages\n" . "--disable-plugins disable plugins during import/export\n" . " suggestions, optional, defaults to anonymous\n" . "--exported-suggestion 1 for approved,\n" . " 2 - approved, then most voted,\n" . " 3 - approved, then most recent,\n" . " 4 - approved, most voted, most recent,\n" . " 5 - approved, my suggestion\n" . "--skip-untranslated skip lines that don't have translated texts\n", basename(__FILE__), NarroLanguage::SOURCE_LANGUAGE_CODE); exit; } foreach (NarroProject::LoadArrayByActive(1) as $objProject) { if (in_array('--project', $argv) && $objProject->ProjectId != $argv[array_search('--project', $argv) + 1]) { continue; } foreach (NarroLanguage::LoadAllActive() as $objLanguage) { if (in_array('--language', $argv) && $objLanguage->LanguageCode != $argv[array_search('--language', $argv) + 1]) { continue; } QApplication::$TargetLanguage = $objLanguage; $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($objProject->ProjectId, $objLanguage->LanguageId); if (!$objProjectProgress || $objProjectProgress->Active) { try { $objNarroImporter = new NarroProjectImporter(); $objNarroImporter->SkipUntranslated = (bool) array_search('--skip-untranslated', $argv); NarroPluginHandler::$blnEnablePlugins = !(bool) array_search('--disable-plugins', $argv); if (array_search('--exported-suggestion', $argv)) { $objNarroImporter->ExportedSuggestion = $argv[array_search('--exported-suggestion', $argv) + 1]; } $strSourceLanguage = NarroLanguage::SOURCE_LANGUAGE_CODE; if (array_search('--user', $argv) !== false) {
protected function dtgSuggestions_Create() { $dtgSuggestions = new NarroSuggestionDataGrid($this->tabActivity); $dtgSuggestions->SetCustomStyle('padding', '5px'); $dtgSuggestions->Title = sprintf(t('Translations added by <b>%s</b>'), $this->objUser->RealName); //$dtgSuggestions->SetCustomStyle('margin-left', '15px'); $colText = $dtgSuggestions->MetaAddColumn(QQN::NarroSuggestion()->Text->TextValue); $colText->Name = t('Original text'); $colText->Html = '<?= $_CONTROL->colText_Render($_ITEM); ?>'; $colText->HtmlEntities = false; $colSuggestion = $dtgSuggestions->MetaAddColumn(QQN::NarroSuggestion()->SuggestionValue); $colSuggestion->Name = t('Translated text'); $colSuggestion->Html = '<?= $_CONTROL->colSuggestion_Render($_ITEM); ?>'; $colLanguage = $dtgSuggestions->MetaAddColumn(QQN::NarroSuggestion()->Language->LanguageName); $colLanguage->Name = t('Language'); $colLanguage->Filter = null; foreach (NarroLanguage::LoadAllActive() as $objLanguage) { $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroSuggestion()->LanguageId, $objLanguage->LanguageId)); } $colLanguage->FilterActivate(QApplication::$TargetLanguage->LanguageName); $colLanguage->Html = '<?= $_CONTROL->colLanguage_Render($_ITEM); ?>'; $colCreated = $dtgSuggestions->MetaAddColumn(QQN::NarroSuggestion()->Created); $colCreated->Name = t('Created'); $colCreated->FilterType = QFilterType::None; $colCreated->Html = '<?= $_CONTROL->colCreated_Render($_ITEM); ?>'; $colCreated->HtmlEntities = false; $colCreated->Wrap = false; // Datagrid Paginator $dtgSuggestions->Paginator = new QPaginator($dtgSuggestions); $dtgSuggestions->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); $dtgSuggestions->SortColumnIndex = 3; $dtgSuggestions->SortDirection = true; $dtgSuggestions->AdditionalClauses = array(QQ::Expand(QQN::NarroSuggestion()->Text), QQ::Expand(QQN::NarroSuggestion()->Language)); $dtgSuggestions->AdditionalConditions = QQ::Equal(QQN::NarroSuggestion()->UserId, $this->objUser->UserId); $dtgSuggestions->btnFilter_Click($this->Form->FormId, $dtgSuggestions->FilterButton->ControlId, ''); }
QFirebug::setEnabled(false); if (array_search('--help', $argv) !== false) { echo sprintf("php %s [options]\n" . "--user user id that will be used for the added translations\n" . "--project project id instead of importing all projects\n" . "--language language code instead of importing all languages\n" . "--disable-plugins disable plugins during import/export\n" . "--do-not-clear-logs doesn't clear the logs before starting\n" . " suggestions, optional, defaults to anonymous\n" . "--do-not-check-equal don't check if the translation is equal to the original\n" . " text and don't import it\n" . "--skip-untranslated skip likes that don't have translated texts\n" . "--approve approve the imported suggestions\n" . "--approve-already-approved overwrite translations approved in Narro\n" . "--import-unchanged-files import files marked unchanged after the last import\n" . "--only-suggestions import only suggestions, don't add files, texts\n" . " or contexts\n" . "--no-suggestions do not import suggestions\n", basename(__FILE__), NarroLanguage::SOURCE_LANGUAGE_CODE); exit; } $intProjCnt = NarroProject::CountByActive(1); $intLangCnt = NarroLanguage::CountAllActive(); if (!in_array('--do-not-clear-logs', $argv)) { NarroLog::Truncate(); } $intStartTime = time(); foreach (NarroProject::LoadArrayByActive(1) as $intProjIdx => $objProject) { if (in_array('--project', $argv) && $objProject->ProjectId != $argv[array_search('--project', $argv) + 1]) { continue; } foreach (NarroLanguage::LoadAllActive() as $intLangIdx => $objLanguage) { if (in_array('--language', $argv) && $objLanguage->LanguageCode != $argv[array_search('--language', $argv) + 1]) { continue; } if (in_array('--progress', $argv)) { $strProjectProgress = ''; for ($i = 1; $i < 11; $i++) { if ($intProjIdx * 10 / $intProjCnt <= $i) { $strProjectProgress .= '-'; } else { $strProjectProgress .= '+'; } } $strLanguageProgress = ''; for ($i = 1; $i < 11; $i++) { if ($intLangIdx * 10 / $intLangCnt <= $i) {
public function __construct($objUser, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroUserRolePanel.tpl.php'; $this->objUser = $objUser; // Setup DataGrid Columns $this->colLanguage = new QDataGridColumn(t('Language'), '<?= $_CONTROL->ParentControl->dtgUserRole_LanguageColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName, false))); $this->colLanguage->HtmlEntities = false; $this->colProject = new QDataGridColumn(t('Project'), '<?= $_CONTROL->ParentControl->dtgUserRole_ProjectColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName, false))); $this->colProject->HtmlEntities = false; $this->colRole = new QDataGridColumn(t('Roles'), '<?= $_CONTROL->ParentControl->dtgUserRole_RoleColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName, false))); $this->colRole->HtmlEntities = false; $this->colActions = new QDataGridColumn(t('Actions'), '<?= $_CONTROL->ParentControl->dtgUserRole_ActionsColumn_Render($_ITEM) ?>'); $this->colActions->HtmlEntities = false; // Setup DataGrid $this->dtgUserRole = new NarroDataGrid($this); $this->dtgUserRole->Title = sprintf(t('<b>%s</b>\'s roles'), NarroLink::UserProfile($this->objUser->UserId, $this->objUser->RealName)); $this->dtgUserRole->ShowHeader = true; $this->dtgUserRole->Paginator = new QPaginator($this->dtgUserRole); $this->dtgUserRole->PaginatorAlternate = new QPaginator($this->dtgUserRole); $this->dtgUserRole->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); // Specify Whether or Not to Refresh using Ajax $this->dtgUserRole->UseAjax = QApplication::$UseAjax; // Specify the local databind method this datagrid will use $this->dtgUserRole->SetDataBinder('dtgUserRole_Bind', $this); $this->dtgUserRole->AddColumn($this->colLanguage); $this->dtgUserRole->AddColumn($this->colProject); $this->dtgUserRole->AddColumn($this->colRole); $this->lstLanguage = new QListBox($this); $this->lstLanguage->AddItem('Any'); foreach (NarroLanguage::LoadAllActive(array(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objNarroLanguage) { if (QApplication::HasPermission('Can manage user roles', null, $objNarroLanguage->LanguageId)) { $this->blnCanManageSomeRoles = true; } $this->lstLanguage->AddItem($objNarroLanguage->LanguageName, $objNarroLanguage->LanguageId); } $this->lstLanguage->SelectedValue = QApplication::GetLanguageId(); $this->lstProject = new QListBox($this); $this->lstProject->AddItem('Any'); foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objNarroProject) { if (QApplication::HasPermission('Can manage user roles', $objNarroProject->ProjectId)) { $this->blnCanManageSomeRoles = true; } $this->lstProject->AddItem($objNarroProject->ProjectName, $objNarroProject->ProjectId); } if (!$this->blnCanManageSomeRoles && QApplication::HasPermission('Can manage user roles')) { $this->blnCanManageSomeRoles = true; } if ($this->blnCanManageSomeRoles) { $this->dtgUserRole->AddColumn($this->colActions); } $this->lstRole = new QListBox($this); foreach (NarroRole::LoadAll(array(QQ::OrderBy(QQN::NarroRole()->RoleName))) as $objNarroRole) { if ($objNarroRole->RoleName == 'Administrator' && !QApplication::HasPermission('Administrator')) { continue; } $this->lstRole->AddItem($objNarroRole->RoleName, $objNarroRole->RoleId); } $this->btnAddRole = new QButton($this); $this->btnAddRole->Text = t('Add'); $this->btnAddRole->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnAddRole_Click')); }
protected function GetControlHtml() { $strOutput = $this->lblMessage->Render(false) . '<br /><table style="border: 1px solid #DDDDDD" cellpadding="4" cellspacing="0" width="100%">'; foreach (NarroUser::$AvailablePreferences as $strName => $arrPref) { switch ($arrPref['type']) { case 'number': $txtNumber = new QIntegerTextBox($this); $txtNumber->Name = $strName; $txtNumber->Minimum = 5; $txtNumber->Maximum = 100; $txtNumber->MaxLength = 3; $txtNumber->Width = 50; $txtNumber->Text = $this->objUser->GetPreferenceValueByName($strName); $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtNumber->RenderWithError(false), t($arrPref['description'])); $this->arrControls[$strName] = $txtNumber; break; case 'text': $txtTextPref = new QTextBox($this); $txtTextPref->Name = $strName; $txtTextPref->Text = $this->objUser->GetPreferenceValueByName($strName); if ($strName == 'Special characters') { $strSelect = sprintf('<select onchange="document.getElementById(\'%s\').value+=this.options[this.selectedIndex].value;">', $txtTextPref->ControlId); foreach (NarroDiacriticsPanel::$arrEntities as $strEntityName => $strEntityChar) { $strSelect .= sprintf('<option value=" %s">%s (%s)', $strEntityName, $strEntityChar, $strEntityName); } $strSelect .= '</select>'; $arrPref['description'] = t($arrPref['description']) . $strSelect; $txtTextPref->Width = 400; } elseif ($strName == 'Other languages') { $strSelect = sprintf('<select onchange="document.getElementById(\'%s\').value+= \' \' + this.options[this.selectedIndex].value;">', $txtTextPref->ControlId); foreach (NarroLanguage::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objLanguage) { $strSelect .= sprintf('<option value="%s">%s (%s)', $objLanguage->LanguageCode, t($objLanguage->LanguageName), $objLanguage->LanguageCode); } $strSelect .= '</select>'; $arrPref['description'] = t($arrPref['description']) . $strSelect; $txtTextPref->Width = 400; } $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $txtTextPref->RenderWithError(false), $arrPref['description']); $this->arrControls[$strName] = $txtTextPref; break; case 'option': $lstOption = new QListBox($this); $lstOption->Name = $strName; if ($strName == 'Language') { $arrLanguages = NarroLanguage::LoadAllActive(QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))); foreach ($arrLanguages as $objLanguage) { $lstOption->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageCode, $objLanguage->LanguageCode == $this->objUser->GetPreferenceValueByName($strName)); } } elseif ($strName == 'Application language') { $arrLanguages = NarroLanguage::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))); foreach ($arrLanguages as $objLanguage) { $lstOption->AddItem(t($objLanguage->LanguageName), $objLanguage->LanguageCode, $objLanguage->LanguageCode == $this->objUser->GetPreferenceValueByName($strName)); } } else { foreach ($arrPref['values'] as $strValue) { $lstOption->AddItem(t($strValue), $strValue, $strValue == $this->objUser->GetPreferenceValueByName($strName)); } } $strOutput .= sprintf('<tr class="datagrid_row datagrid_even" style="height:40px"><td>%s:</td><td>%s</td><td style="font-size:-1">%s</td></tr>', t($strName), $lstOption->RenderWithError(false), t($arrPref['description'])); $this->arrControls[$strName] = $lstOption; break; } } $strOutput .= '</table><br />'; $strOutput .= $this->btnCancel->Render(false) . ' ' . $this->btnSave->Render(false); if ($this->txtPreviousUrl) { $strOutput .= ' ' . sprintf(t('Click <a href="%s">here</a> to return to the page you were.'), $this->txtPreviousUrl); } $this->strText = $strOutput; return parent::GetControlHtml(); }