示例#1
0
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->pnlTab = new QTabs($this);
     $pnlDummy = new QPanel($this->pnlTab);
     $pnlDummy = new QPanel($this->pnlTab);
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders = array(NarroLink::ProjectList(t('Projects')), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_ALL, '', 0, 0, 10, 0, 0, t('Translate')), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')));
     /**
      * Do not show the langauge tab if only two languages are active (source and target
      * Unless the user is an administrator and might want to set another one active
      */
     if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
         $this->pnlLanguageTab = new QTabs($this->pnlTab);
         $pnlDummy = new QPanel($this->pnlLanguageTab);
         $arrLangHeaders[] = t('List');
         if (QApplication::HasPermissionForThisLang('Can add language')) {
             $this->pnlLanguageEdit = new NarroLanguageEditPanel($this->pnlLanguageTab, NarroLanguage::Load(QApplication::QueryString('lid')));
             $arrLangHeaders[] = QApplication::QueryString('lid') ? t('Edit') : t('Add');
         }
         $this->pnlLanguageTab->Headers = $arrLangHeaders;
         $this->pnlLanguageTab->Selected = 1;
         $arrHeaders[] = t('Languages');
         $this->pnlTab->Selected = count($arrHeaders) - 1;
     }
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserList('', t('Users'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles'));
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::Log('', t('Application Log'));
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
示例#2
0
文件: users.php 项目: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->pnlTab = new QTabs($this);
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::ProjectList(t('Projects'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate'));
     if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::LanguageList(t('Languages'));
     }
     $this->pnlUserList = new NarroUserListPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserList('', t('Users'));
     $this->pnlTab->Selected = count($arrHeaders) - 1;
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles'));
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::Log('', t('Application Log'));
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
 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();
 }
示例#4
0
文件: projects.php 项目: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->pnlTab = new QTabs($this);
     /**
      * Create the project list panel and set the filter from the url.
      * The filter is used to show only projects of a given status based on their progress
      * (finished, empty, in progress).
      */
     $this->pnlProjectList = new NarroProjectListPanel($this->pnlTab);
     $this->pnlTop = new NarroTopPanel(date(sprintf('Y-m-%d 00:00:00', date('d') - date('N') + 1)), $this);
     $pnlDummy = new QPanel($this->pnlTab);
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders = array(t('Projects'), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')), NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')));
     /**
      * Do not show the langauge tab if only two languages are active (source and target
      * Unless the user is an administrator and might want to set another one active
      */
     if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::LanguageList(t('Languages'));
     }
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserList('', t('Users'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles'));
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::Log('', t('Application Log'));
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
 public function btnExport_Click($strFormId, $strControlId, $strParameter)
 {
     if (!$this->fileToUpload->Display) {
         $this->fileToUpload->Display = true;
         return false;
     }
     $objFileImporter = NarroFileType::GetFileImporter($this->objFile->TypeId);
     $objFileImporter->User = QApplication::$User;
     $objFileImporter->Project = $this->objFile->Project;
     $objFileImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode(NarroLanguage::SOURCE_LANGUAGE_CODE);
     $objFileImporter->TargetLanguage = QApplication::$TargetLanguage;
     $objFileImporter->File = $this->objFile;
     $strTempFileName = tempnam(__TMP_PATH__, QApplication::$TargetLanguage->LanguageCode);
     if (file_exists($this->fileToUpload->File)) {
         $objFileImporter->ExportFile($this->fileToUpload->File, $strTempFileName);
         unlink($this->fileToUpload->File);
     } else {
         $objFileImporter->ExportFile($this->objFile->Project->DefaultTemplatePath . $this->objFile->FilePath, $strTempFileName);
     }
     ob_clean();
     header(sprintf('Content-Disposition: attachment; filename="%s"', $this->objFile->FileName));
     readfile($strTempFileName);
     unlink($strTempFileName);
     exit;
 }
示例#6
0
文件: review.php 项目: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     if (QApplication::QueryString('p') == 0) {
         $this->pnlMainTab = new QTabs($this);
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::ProjectList(t('Projects'));
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate'));
         $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab);
         $arrHeaders[] = t('Review');
         $this->pnlMainTab->Selected = count($arrHeaders) - 1;
         if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
             $pnlDummy = new QPanel($this->pnlMainTab);
             $arrHeaders[] = NarroLink::LanguageList(t('Languages'));
         }
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::UserList('', t('Users'));
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles'));
         if (QApplication::HasPermissionForThisLang('Administrator')) {
             $pnlDummy = new QPanel($this->pnlMainTab);
             $arrHeaders[] = NarroLink::Log('', t('Application Log'));
         }
         $this->pnlMainTab->Headers = $arrHeaders;
     } else {
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::Project($this->objProject->ProjectId, t('Overview'));
         if ($this->objProject instanceof NarroProject && QApplication::HasPermissionForThisLang('Can edit project', $this->objProject->ProjectId)) {
             $pnlDummy = new QPanel($this->pnlMainTab);
             $arrHeaders[] = NarroLink::ProjectEdit($this->objProject->ProjectId, t('Edit'));
         }
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::Translate($this->objProject->ProjectId, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate'));
         $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab);
         $arrHeaders[] = t('Review');
         $this->pnlMainTab->Selected = count($arrHeaders) - 1;
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::ProjectFileList($this->objProject->ProjectId, '', '', t('Files'));
         $pnlDummy = new QPanel($this->pnlMainTab);
         $arrHeaders[] = NarroLink::ProjectLanguages($this->objProject->ProjectId, t('Languages'));
         if (QApplication::HasPermissionForThisLang('Can import project', $this->objProject->ProjectId)) {
             $pnlDummy = new QPanel($this->pnlMainTab);
             $arrHeaders[] = NarroLink::ProjectImport($this->objProject->ProjectId, t('Import'));
         }
         if (QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) {
             $pnlDummy = new QPanel($this->pnlMainTab);
             $arrHeaders[] = NarroLink::ProjectExport($this->objProject->ProjectId, t('Export'));
         }
         $this->pnlMainTab->Headers = $arrHeaders;
     }
 }
示例#7
0
文件: role.php 项目: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->pnlTab = new QTabPanel($this);
     $this->pnlTab->UseAjax = false;
     $this->pnlRoleTab = new QTabPanel($this->pnlTab);
     $this->pnlRoleEdit = new NarroRoleEditPanel($this->pnlRoleTab, NarroRole::Load(QApplication::QueryString('rid')));
     $this->pnlRoleTab->addTab(new QPanel($this->pnlRoleTab), t('List'), NarroLink::RoleList());
     $this->pnlRoleTab->addTab($this->pnlRoleEdit, QApplication::QueryString('lid') ? t('Edit') : t('Add'));
     $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Projects'), NarroLink::ProjectList());
     $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Translate'), NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_ALL, '', 0, 0, 10, 0, 0));
     $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Languages'), NarroLink::LanguageList());
     $this->pnlTab->addTab(new QPanel($this->pnlTab), t('Users'), NarroLink::UserList());
     $this->pnlTab->addTab($this->pnlRoleTab, t('Roles'));
     $this->pnlTab->SelectedTab = 4;
     $this->pnlRoleTab->SelectedTab = 1;
     $this->pnlTab = new QTabs($this);
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::ProjectList(t('Projects'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate'));
     if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::LanguageList(t('Languages'));
     }
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserList('', t('Users'));
     $this->pnlRoleTab = new QTabs($this->pnlTab);
     new QPanel($this->pnlRoleTab);
     $arrRoleHeaders[] = NarroLink::RoleList(0, '', t('List'));
     if (QApplication::HasPermissionForThisLang('Can add role')) {
         $pnlDummy = new NarroRoleEditPanel($this->pnlRoleTab, NarroRole::Load(QApplication::QueryString('rid')));
         $arrRoleHeaders[] = NarroLink::RoleEdit(null, t('Add'));
         $this->pnlRoleTab->Selected = count($arrRoleHeaders) - 1;
     }
     $this->pnlRoleTab->Headers = $arrRoleHeaders;
     $arrHeaders[] = t('Roles');
     $this->pnlTab->Selected = count($arrHeaders) - 1;
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::Log('', t('Application Log'));
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
示例#8
0
 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 btnImport_Click($strFormId, $strControlId, $strParameter)
 {
     if (!$this->fileToUpload->Display) {
         $this->fileToUpload->Display = true;
         return false;
     }
     $objFileImporter = NarroFileType::GetFileImporter($this->objNarroFile->TypeId);
     $objFileImporter->User = QApplication::$User;
     $objFileImporter->Project = $this->objNarroFile->Project;
     $objFileImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode(NarroLanguage::SOURCE_LANGUAGE_CODE);
     $objFileImporter->TargetLanguage = QApplication::$TargetLanguage;
     $objFileImporter->CheckEqual = true;
     $objFileImporter->File = $this->objNarroFile;
     $objFileImporter->OnlySuggestions = !QApplication::HasPermissionForThisLang('Can approve', $this->objNarroFile->ProjectId);
     $objFileImporter->ApproveAlreadyApproved = QApplication::HasPermissionForThisLang('Can approve', $this->objNarroFile->ProjectId);
     $objFileImporter->Approve = QApplication::HasPermissionForThisLang('Can approve', $this->objNarroFile->ProjectId);
     $strTempFileName = tempnam(__TMP_PATH__, QApplication::$TargetLanguage->LanguageCode);
     $objFileImporter->ImportFile($this->objNarroFile->Project->DefaultTemplatePath . $this->objNarroFile->FilePath, $this->fileToUpload->File);
 }
 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);
     }
 }
 public function __construct($objNarroProject = null, $objParentObject, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // Call SetupNarroProject to either Load/Edit Existing or Create New
     $this->SetupNarroProject($objNarroProject);
     // Create/Setup Controls for NarroProject's Data Fields
     $this->lblMessage_Create();
     $this->lstProjectCategory_Create();
     $this->lstProjectCategory->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId);
     $this->txtProjectName_Create();
     $this->txtProjectName->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId);
     $this->lstProjectType_Create();
     $this->lstProjectType->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId);
     $this->txtProjectDescription_Create();
     $this->txtProjectDescription->Enabled = QApplication::HasPermission('Can edit project', $this->objProject->ProjectId);
     $this->txtActive_Create();
     if (count(NarroProject::$AvailablePreferences) && $this->objProject->ProjectId) {
         $this->pnlPreferences = new NarroProjectPreferencesPanel($this->objProject, $this);
     }
     if (QApplication::HasPermission('Can import project', $this->objProject->ProjectId)) {
         $this->pnlTextsSource = new NarroProjectTextSourcePanel($this->objProject, NarroLanguage::LoadByLanguageCode(NarroLanguage::SOURCE_LANGUAGE_CODE), $this);
     }
     // Create/Setup ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References
     // Create/Setup Button Action controls
     $this->btnSave_Create();
     $this->btnReset_Create();
     $this->btnCancel_Create();
     $this->btnDelete_Create();
     $this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroProjectEditPanel.tpl.php';
 }
 /**
  * Refresh this MetaControl with Data from the local NarroSuggestion object.
  * @param boolean $blnReload reload NarroSuggestion from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroSuggestion->Reload();
     }
     if ($this->lblSuggestionId) {
         if ($this->blnEditMode) {
             $this->lblSuggestionId->Text = $this->objNarroSuggestion->SuggestionId;
         }
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroSuggestion->User && $this->objNarroSuggestion->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroSuggestion->User ? $this->objNarroSuggestion->User->__toString() : null;
     }
     if ($this->lstText) {
         $this->lstText->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstText->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objTextArray = NarroText::LoadAll();
         if ($objTextArray) {
             foreach ($objTextArray as $objText) {
                 $objListItem = new QListItem($objText->__toString(), $objText->TextId);
                 if ($this->objNarroSuggestion->Text && $this->objNarroSuggestion->Text->TextId == $objText->TextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstText->AddItem($objListItem);
             }
         }
     }
     if ($this->lblTextId) {
         $this->lblTextId->Text = $this->objNarroSuggestion->Text ? $this->objNarroSuggestion->Text->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroSuggestion->Language && $this->objNarroSuggestion->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroSuggestion->Language ? $this->objNarroSuggestion->Language->__toString() : null;
     }
     if ($this->txtSuggestionValue) {
         $this->txtSuggestionValue->Text = $this->objNarroSuggestion->SuggestionValue;
     }
     if ($this->lblSuggestionValue) {
         $this->lblSuggestionValue->Text = $this->objNarroSuggestion->SuggestionValue;
     }
     if ($this->txtSuggestionValueMd5) {
         $this->txtSuggestionValueMd5->Text = $this->objNarroSuggestion->SuggestionValueMd5;
     }
     if ($this->lblSuggestionValueMd5) {
         $this->lblSuggestionValueMd5->Text = $this->objNarroSuggestion->SuggestionValueMd5;
     }
     if ($this->txtSuggestionCharCount) {
         $this->txtSuggestionCharCount->Text = $this->objNarroSuggestion->SuggestionCharCount;
     }
     if ($this->lblSuggestionCharCount) {
         $this->lblSuggestionCharCount->Text = $this->objNarroSuggestion->SuggestionCharCount;
     }
     if ($this->txtSuggestionWordCount) {
         $this->txtSuggestionWordCount->Text = $this->objNarroSuggestion->SuggestionWordCount;
     }
     if ($this->lblSuggestionWordCount) {
         $this->lblSuggestionWordCount->Text = $this->objNarroSuggestion->SuggestionWordCount;
     }
     if ($this->chkHasComments) {
         $this->chkHasComments->Checked = $this->objNarroSuggestion->HasComments;
     }
     if ($this->lblHasComments) {
         $this->lblHasComments->Text = $this->objNarroSuggestion->HasComments ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkIsImported) {
         $this->chkIsImported->Checked = $this->objNarroSuggestion->IsImported;
     }
     if ($this->lblIsImported) {
         $this->lblIsImported->Text = $this->objNarroSuggestion->IsImported ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroSuggestion->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroSuggestion->Created) ? $this->objNarroSuggestion->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroSuggestion->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroSuggestion->Modified) ? $this->objNarroSuggestion->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
 }
示例#13
0
 public static function InitializeLanguage()
 {
     global $argv;
     if (strstr($_SERVER['REQUEST_URI'], '_devtools')) {
         return false;
     }
     if (strstr($_SERVER['REQUEST_URI'], 'image.php')) {
         return false;
     }
     if (strstr($_SERVER['REQUEST_URI'], 'profile.php')) {
         return false;
     }
     QApplication::$SourceLanguage = NarroLanguage::LoadByLanguageCode(__SOURCE_LANGUAGE_CODE__);
     // language passed through the l parameter
     if (@$_REQUEST['l']) {
         QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode(@$_REQUEST['l']);
     } elseif (isset($argv) && ($strLanguage = $argv[array_search('--translation-lang', $argv) + 1])) {
         QApplication::$TargetLanguage = NarroLanguage::LoadByLanguageCode($strLanguage);
     } else {
         if (QApplication::$User->UserId != NarroUser::ANONYMOUS_USER_ID) {
             $objGuessedLanguage = NarroLanguage::LoadByLanguageCode(QApplication::$User->GetPreferenceValueByName('Language'));
             if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) {
                 $objGuessedLanguage = null;
             }
         }
         if (!$objGuessedLanguage) {
             $objGuessedLanguage = QApplication::GetBrowserLanguage();
             if (!$objGuessedLanguage instanceof NarroLanguage || !$objGuessedLanguage->Active) {
                 $objGuessedLanguage = null;
             }
         }
         if (!$objGuessedLanguage) {
             $objGuessedLanguage = NarroLanguage::QuerySingle(QQ::Equal(QQN::NarroLanguage()->Active, true));
         }
         if (!$objGuessedLanguage) {
             die('There are no active languages in the database.');
         } else {
             if (!isset($_REQUEST['openid_mode']) && !isset($argv)) {
                 QApplication::Redirect(sprintf('projects.php?l=%s', $objGuessedLanguage->LanguageCode));
                 exit;
             } else {
                 QApplication::$TargetLanguage = $objGuessedLanguage;
             }
         }
     }
     if (QApplication::$TargetLanguage->Active == false && !isset($argv)) {
         die(sprintf('The language %s is not active. Please ask the administrator to activate or check your URL if this is not the language you wanted.', QApplication::$TargetLanguage->LanguageName));
     }
 }
示例#14
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     if ($objObject->objProject) {
         $objObject->objProject = NarroProject::GetSoapObjectFromObject($objObject->objProject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intProjectId = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->dttDate) {
         $objObject->dttDate = $objObject->dttDate->qFormat(QDateTime::FormatSoap);
     }
     return $objObject;
 }
示例#15
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objText) {
         $objObject->objText = NarroText::GetSoapObjectFromObject($objObject->objText, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intTextId = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     if ($objObject->dttCreated) {
         $objObject->dttCreated = $objObject->dttCreated->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttModified) {
         $objObject->dttModified = $objObject->dttModified->qFormat(QDateTime::FormatSoap);
     }
     return $objObject;
 }
 /**
  * Refresh this MetaControl with Data from the local NarroUserRole object.
  * @param boolean $blnReload reload NarroUserRole from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroUserRole->Reload();
     }
     if ($this->lblUserRoleId) {
         if ($this->blnEditMode) {
             $this->lblUserRoleId->Text = $this->objNarroUserRole->UserRoleId;
         }
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroUserRole->User && $this->objNarroUserRole->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroUserRole->User ? $this->objNarroUserRole->User->__toString() : null;
     }
     if ($this->lstRole) {
         $this->lstRole->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstRole->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objRoleArray = NarroRole::LoadAll();
         if ($objRoleArray) {
             foreach ($objRoleArray as $objRole) {
                 $objListItem = new QListItem($objRole->__toString(), $objRole->RoleId);
                 if ($this->objNarroUserRole->Role && $this->objNarroUserRole->Role->RoleId == $objRole->RoleId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstRole->AddItem($objListItem);
             }
         }
     }
     if ($this->lblRoleId) {
         $this->lblRoleId->Text = $this->objNarroUserRole->Role ? $this->objNarroUserRole->Role->__toString() : null;
     }
     if ($this->lstProject) {
         $this->lstProject->RemoveAllItems();
         $this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
         $objProjectArray = NarroProject::LoadAll();
         if ($objProjectArray) {
             foreach ($objProjectArray as $objProject) {
                 $objListItem = new QListItem($objProject->__toString(), $objProject->ProjectId);
                 if ($this->objNarroUserRole->Project && $this->objNarroUserRole->Project->ProjectId == $objProject->ProjectId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstProject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblProjectId) {
         $this->lblProjectId->Text = $this->objNarroUserRole->Project ? $this->objNarroUserRole->Project->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroUserRole->Language && $this->objNarroUserRole->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroUserRole->Language ? $this->objNarroUserRole->Language->__toString() : null;
     }
 }
 public function btnTmx_Click($strFormId, $strControlId, $intLanguageId)
 {
     set_time_limit(0);
     $objLanguage = NarroLanguage::Load($intLanguageId);
     if (!$objLanguage) {
         return false;
     }
     header("Pragma: public");
     // required
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: private", false);
     // required for certain browsers
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"" . sprintf('%s %s.tmx', preg_replace('/^[a-z]/i', '_', __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__), $objLanguage->LanguageName) . "\";");
     ob_clean();
     $strXml = NarroLanguage::GetTmx(QQ::Equal(QQN::NarroText()->NarroSuggestionAsText->LanguageId, $intLanguageId));
     header("Content-Length: " . strlen($strXml));
     echo $strXml;
     exit;
 }
示例#18
0
文件: log.php 项目: Jobava/narro
 protected function Form_Create()
 {
     parent::Form_Create();
     if (!QApplication::HasPermissionForThisLang('Administrator')) {
         QApplication::Redirect(NarroLink::ProjectList());
     }
     $this->pnlTab = new QTabs($this);
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::ProjectList(t('Projects'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::Review(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review'));
     if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) {
         $pnlDummy = new QPanel($this->pnlTab);
         $arrHeaders[] = NarroLink::LanguageList(t('Languages'));
     }
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::UserList('', t('Users'));
     $pnlDummy = new QPanel($this->pnlTab);
     $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles'));
     if (QApplication::HasPermissionForThisLang('Administrator')) {
         $this->pnlLog = new QPanel($this->pnlTab);
         $this->pnlLog->AutoRenderChildren = true;
         $btnClearLog = new QButton($this->pnlLog);
         $btnClearLog->Text = t('Clear the log');
         $btnClearLog->AddAction(new QClickEvent(), new QConfirmAction(t('Are you sure you want to delete all the logged messages?')));
         $btnClearLog->AddAction(new QClickEvent(), new QAjaxAction('btnClearLog_Click'));
         $this->dtgLog = new NarroLogDataGrid($this->pnlLog);
         // Datagrid Paginator
         $this->dtgLog->Paginator = new QPaginator($this->dtgLog);
         $this->dtgLog->PaginatorAlternate = new QPaginator($this->dtgLog);
         $this->dtgLog->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page');
         $this->dtgLog->SortColumnIndex = 0;
         $this->dtgLog->SortDirection = 1;
         $colDate = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Date);
         $colDate->OrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId);
         $colDate->ReverseOrderByClause = QQ::OrderBy(QQN::NarroLog()->LogId, 0);
         if (QApplication::HasPermission('Administrator')) {
             $colLanguage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Language->LanguageName);
             $colLanguage->Filter = null;
             $colLanguage->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->LanguageId));
             foreach (NarroLanguage::LoadAll(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)) as $objLanguage) {
                 $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroLog()->LanguageId, $objLanguage->LanguageId));
             }
         } else {
             $this->dtgLog->AdditionalConditions = QQ::Equal(QQN::NarroLog()->LanguageId, QApplication::GetLanguageId());
         }
         $colProject = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Project->ProjectName);
         $colProject->Filter = null;
         $colProject->FilterAddListItem(t('-Not set-'), QQ::IsNull(QQN::NarroLog()->ProjectId));
         foreach (NarroProject::LoadAll(QQ::OrderBy(QQN::NarroProject()->ProjectName)) as $objProject) {
             $colProject->FilterAddListItem($objProject->ProjectName, QQ::Equal(QQN::NarroLog()->ProjectId, $objProject->ProjectId));
         }
         $colUser = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->User->Username);
         $colUser->Html = '<?=(($_ITEM->UserId)?NarroLink::UserProfile($_ITEM->UserId, $_ITEM->User->Username):"")?>';
         $colUser->HtmlEntities = false;
         $colPriority = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Priority);
         $colPriority->Name = 'P';
         $colPriority->Width = 16;
         $colPriority->FilterBoxSize = 1;
         $colPriority->HtmlEntities = false;
         $colMessage = $this->dtgLog->MetaAddColumn(QQN::NarroLog()->Message);
         $colMessage->HtmlEntities = false;
         $colMessage->Html = '<?=$_FORM->dtgLog_colMessage_Render($_ITEM)?>';
         $arrHeaders[] = NarroLink::Log('', t('Application Log'));
         $this->pnlTab->Selected = count($arrHeaders) - 1;
     }
     $this->pnlTab->Headers = $arrHeaders;
 }
示例#19
0
 public function Save($blnForceInsert = false, $blnForceUpdate = false)
 {
     $blnNew = !$this->__blnRestored || $blnForceInsert;
     $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->intProjectId, QApplication::GetLanguageId());
     if (is_array($this->arrPreferences)) {
         foreach ($this->arrPreferences as $strName => $strValue) {
             if (self::$AvailablePreferences[$strName]['global'] == false) {
                 if ($objProjectProgress) {
                     $objProjectProgress->SetPreferenceValueByName($strName, $strValue);
                 }
             } else {
                 $arrGlobalPreferences[$strName] = $strValue;
             }
         }
     }
     if (isset($arrGlobalPreferences)) {
         $this->strData = serialize($arrGlobalPreferences);
     }
     if ($objProjectProgress) {
         $objProjectProgress->Save();
     }
     $mixResult = parent::Save($blnForceInsert, $blnForceUpdate);
     if ($blnNew) {
         if (!file_exists(__IMPORT_PATH__ . '/' . $this->ProjectId)) {
             @mkdir(__IMPORT_PATH__ . '/' . $this->ProjectId, 0777, true);
             NarroUtils::RecursiveChmod(__IMPORT_PATH__ . '/' . $this->ProjectId);
         }
         if (!file_exists($this->DefaultTemplatePath)) {
             @mkdir($this->DefaultTemplatePath, 0777, true);
             NarroUtils::RecursiveChmod($this->DefaultTemplatePath);
         }
         foreach (NarroLanguage::LoadAll() as $objLanguage) {
             $objProjectProgress = new NarroProjectProgress();
             $objProjectProgress->LanguageId = $objLanguage->LanguageId;
             $objProjectProgress->ProjectId = $this->ProjectId;
             $objProjectProgress->Active = $this->Active;
             $objProjectProgress->TotalTextCount = 0;
             $objProjectProgress->ApprovedTextCount = 0;
             $objProjectProgress->FuzzyTextCount = 0;
             $objProjectProgress->ProgressPercent = 0;
             $objProjectProgress->Active = $this->Active;
             $objProjectProgress->LastModified = QDateTime::Now();
             $objProjectProgress->Save();
             if (!file_exists($this->DefaultTranslationPath)) {
                 @mkdir($this->DefaultTranslationPath, 0777, true);
             }
             NarroUtils::RecursiveChmod($this->DefaultTranslationPath, 0666, 0777);
         }
     }
     return $mixResult;
 }
 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, '');
 }
 /**
  * Refresh this MetaControl with Data from the local NarroProjectProgress object.
  * @param boolean $blnReload reload NarroProjectProgress from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroProjectProgress->Reload();
     }
     if ($this->lblProjectProgressId) {
         if ($this->blnEditMode) {
             $this->lblProjectProgressId->Text = $this->objNarroProjectProgress->ProjectProgressId;
         }
     }
     if ($this->lstProject) {
         $this->lstProject->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objProjectArray = NarroProject::LoadAll();
         if ($objProjectArray) {
             foreach ($objProjectArray as $objProject) {
                 $objListItem = new QListItem($objProject->__toString(), $objProject->ProjectId);
                 if ($this->objNarroProjectProgress->Project && $this->objNarroProjectProgress->Project->ProjectId == $objProject->ProjectId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstProject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblProjectId) {
         $this->lblProjectId->Text = $this->objNarroProjectProgress->Project ? $this->objNarroProjectProgress->Project->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroProjectProgress->Language && $this->objNarroProjectProgress->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroProjectProgress->Language ? $this->objNarroProjectProgress->Language->__toString() : null;
     }
     if ($this->chkActive) {
         $this->chkActive->Checked = $this->objNarroProjectProgress->Active;
     }
     if ($this->lblActive) {
         $this->lblActive->Text = $this->objNarroProjectProgress->Active ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->calLastModified) {
         $this->calLastModified->DateTime = $this->objNarroProjectProgress->LastModified;
     }
     if ($this->lblLastModified) {
         $this->lblLastModified->Text = sprintf($this->objNarroProjectProgress->LastModified) ? $this->objNarroProjectProgress->LastModified->qFormat($this->strLastModifiedDateTimeFormat) : null;
     }
     if ($this->txtTotalTextCount) {
         $this->txtTotalTextCount->Text = $this->objNarroProjectProgress->TotalTextCount;
     }
     if ($this->lblTotalTextCount) {
         $this->lblTotalTextCount->Text = $this->objNarroProjectProgress->TotalTextCount;
     }
     if ($this->txtFuzzyTextCount) {
         $this->txtFuzzyTextCount->Text = $this->objNarroProjectProgress->FuzzyTextCount;
     }
     if ($this->lblFuzzyTextCount) {
         $this->lblFuzzyTextCount->Text = $this->objNarroProjectProgress->FuzzyTextCount;
     }
     if ($this->txtApprovedTextCount) {
         $this->txtApprovedTextCount->Text = $this->objNarroProjectProgress->ApprovedTextCount;
     }
     if ($this->lblApprovedTextCount) {
         $this->lblApprovedTextCount->Text = $this->objNarroProjectProgress->ApprovedTextCount;
     }
     if ($this->txtProgressPercent) {
         $this->txtProgressPercent->Text = $this->objNarroProjectProgress->ProgressPercent;
     }
     if ($this->lblProgressPercent) {
         $this->lblProgressPercent->Text = $this->objNarroProjectProgress->ProgressPercent;
     }
     if ($this->txtData) {
         $this->txtData->Text = $this->objNarroProjectProgress->Data;
     }
     if ($this->lblData) {
         $this->lblData->Text = $this->objNarroProjectProgress->Data;
     }
 }
示例#22
0
 private function CreateNarroTemplate($intProjectId)
 {
     $strPoFile = __DOCROOT__ . __SUBDIRECTORY__ . '/locale/' . $this->objSourceLanguage->LanguageCode . '/narro.po';
     NarroLogger::LogInfo(sprintf('Building a narro gettext template in %s.', $strPoFile));
     $arrPermissions = NarroPermission::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroPermission()->PermissionName)));
     NarroLogger::LogInfo(sprintf('Found %d permission names to localize.', count($arrPermissions)));
     $arrRoles = NarroRole::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroRole()->RoleName)));
     NarroLogger::LogInfo(sprintf('Found %d role names to localize.', count($arrRoles)));
     $allFiles = NarroUtils::ListDirectory(realpath(dirname(__FILE__) . '/../../..'), null, '/.*\\/drafts\\/.*|.*\\/data\\/.*|.*\\/examples\\/.*|.*\\/qcubed_generated\\/.*/');
     NarroLogger::LogInfo(sprintf('Found %d php files to search for localizable messages.', count($allFiles)));
     foreach ($allFiles as $strFileName) {
         if (pathinfo($strFileName, PATHINFO_EXTENSION) != 'php') {
             continue;
         }
         $strFile = file_get_contents($strFileName);
         $strShortPath = str_ireplace(realpath(__DOCROOT__ . __SUBDIRECTORY__) . '/', '', $strFileName);
         if (strpos($strShortPath, 'data') === 0) {
             continue;
         }
         if (strpos($strShortPath, 'includes/qcubed_generated') === 0) {
             continue;
         }
         $strFile = str_replace("\\'", "&&&escapedsimplequote&&&", $strFile);
         $strFile = str_replace('\\"', "&&&escapeddoublequote&&&", $strFile);
         if ($strFile) {
             preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\']([^\']{2,})[\']\\s*\\)/', $strFile, $arrMatches);
             if (isset($arrMatches[2])) {
                 foreach ($arrMatches[2] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = '#. ';
                         foreach ($arrFullMatches[0] as $strFullMatch) {
                             if (trim($strFullMatch)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
                             }
                         }
                     }
                 }
             }
             preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\\"]([^\\"]{2,})[\\"]\\s*\\)/', $strFile, $arrMatches);
             if (isset($arrMatches[2])) {
                 foreach ($arrMatches[2] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = '#. ';
                         foreach ($arrFullMatches[0] as $strFullMatch) {
                             if (trim($strFullMatch)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
                             }
                         }
                     }
                 }
             }
             preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\']([^\']{2,})[\']\\s*,\\s*[\']([^\']{2,})[\']\\s*,\\s*([^\\)]+)\\s*\\)/', $strFile, $arrMatches);
             if (isset($arrMatches[2])) {
                 foreach ($arrMatches[2] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $arrMessages[md5($strText)]['plural'] = $arrMatches[3][$intMatchNo];
                         $strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = '#. ';
                         foreach ($arrFullMatches[0] as $strFullMatch) {
                             if (trim($strFullMatch)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
                             }
                         }
                     }
                 }
             }
             preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\\"]([^\\"]{2,})[\\"]\\s*,\\s*[\\"]([^\\"]{2,})[\\"]\\s*,\\s*([^\\)]+)\\s*\\)/', $strFile, $arrMatches);
             if (isset($arrMatches[2])) {
                 foreach ($arrMatches[2] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $arrMessages[md5($strText)]['plural'] = $arrMatches[3][$intMatchNo];
                         $strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = '#. ';
                         foreach ($arrFullMatches[0] as $strFullMatch) {
                             if (trim($strFullMatch)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
                             }
                         }
                     }
                 }
             }
             preg_match_all('/NarroApp::RegisterPreference\\(\\s*\'([^\']+)\'\\s*,\\s*\'[^\']+\'\\s*,\\s*\'([^\']+)\'\\s*,\\s*/', $strFile, $arrMatches);
             if (isset($arrMatches[1])) {
                 foreach ($arrMatches[1] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $strSearchText = $arrMatches[0][$intMatchNo];
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = "#. Preference name\n";
                         foreach ($arrFullMatches[0] as $strLine) {
                             if (isset($strLine) && trim($strLine)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strLine) . "\n";
                             }
                         }
                     }
                 }
                 foreach ($arrMatches[2] as $intMatchNo => $strText) {
                     if (trim($strText) != '') {
                         $strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
                         $arrMessages[md5($strText)]['text'] = $strText;
                         $arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
                         $strSearchText = $arrMatches[0][$intMatchNo];
                         preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                         $arrMessages[md5($strText)]['context'] = "#. Preference description\n";
                         foreach ($arrFullMatches[0] as $strLine) {
                             if (isset($strLine) && trim($strLine)) {
                                 $arrMessages[md5($strText)]['context'] .= trim($strLine) . "\n";
                             }
                         }
                     }
                 }
             }
             if (preg_match_all('/t\\(\\$[a-zA-Z]+\\-\\>LanguageName/', $strFile, $arrMatches)) {
                 if (!isset($arrLanguages)) {
                     $arrLanguages = NarroLanguage::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroLanguage()->LanguageName)));
                 }
                 $strLangContext = '#. ';
                 foreach ($arrMatches as $intMatchNo => $arrVal) {
                     $strSearchText = $arrMatches[0][$intMatchNo];
                     preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                     foreach ($arrFullMatches[0] as $strLine) {
                         if (isset($strLine) && trim($strLine)) {
                             $strLangContext .= trim($strLine) . "\n";
                         }
                     }
                 }
                 if (is_array($arrLanguages)) {
                     foreach ($arrLanguages as $objLanguage) {
                         $arrMessages[md5($objLanguage->LanguageName)]['text'] = $objLanguage->LanguageName;
                         $arrMessages[md5($objLanguage->LanguageName)]['files'][$strShortPath] = $strShortPath;
                         $arrMessages[md5($objLanguage->LanguageName)]['context'] = $strLangContext;
                     }
                 }
             }
             if (preg_match_all('/t\\(\\$[a-zA-Z]+\\-\\>RoleName/', $strFile, $arrMatches)) {
                 $strLangContext = '#. ';
                 foreach ($arrMatches as $intMatchNo => $arrVal) {
                     $strSearchText = $arrMatches[0][$intMatchNo];
                     preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                     foreach ($arrFullMatches[0] as $strLine) {
                         if (isset($strLine) && trim($strLine)) {
                             $strLangContext .= trim($strLine) . "\n";
                         }
                     }
                 }
                 if (is_array($arrRoles)) {
                     foreach ($arrRoles as $objRole) {
                         $arrMessages[md5($objRole->RoleName)]['text'] = $objRole->RoleName;
                         $arrMessages[md5($objRole->RoleName)]['files'][$strShortPath] = $strShortPath;
                         $arrMessages[md5($objRole->RoleName)]['context'] = $strLangContext;
                     }
                 }
             }
             if (preg_match_all('/t\\(\\$[a-zA-Z]+\\-\\>PermissionName/', $strFile, $arrMatches)) {
                 $strLangContext = '#. ';
                 foreach ($arrMatches as $intMatchNo => $arrVal) {
                     $strSearchText = $arrMatches[0][$intMatchNo];
                     preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
                     foreach ($arrFullMatches[0] as $strLine) {
                         if (isset($strLine) && trim($strLine)) {
                             $strLangContext .= trim($strLine) . "\n";
                         }
                     }
                 }
                 if (is_array($arrPermissions)) {
                     foreach ($arrPermissions as $objPermission) {
                         $arrMessages[md5($objPermission->PermissionName)]['text'] = $objPermission->PermissionName;
                         $arrMessages[md5($objPermission->PermissionName)]['files'][$strShortPath] = $strShortPath;
                         $arrMessages[md5($objPermission->PermissionName)]['context'] = $strLangContext;
                     }
                 }
             }
         }
     }
     $strPoHeader = '#, fuzzy' . "\n" . 'msgid ""' . "\n" . 'msgstr ""' . "\n" . '"Project-Id-Version: Narro ' . NARRO_VERSION . "\n" . '"Report-Msgid-Bugs-To: alexxed@gmail.com\\n"' . "\n" . '"POT-Creation-Date: ' . date('Y-d-m H:iO') . '\\n"' . "\n" . '"PO-Revision-Date: ' . date('Y-d-m H:iO') . '\\n"' . "\n" . '"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"' . "\n" . '"Language-Team: LANGUAGE <*****@*****.**>\\n"' . "\n" . '"MIME-Version: 1.0\\n"' . "\n" . '"Content-Type: text/plain; charset=UTF-8\\n"' . "\n" . '"Content-Transfer-Encoding: 8bit\\n"' . "\n" . '"Plural-Forms: nplurals=2; plural=n != 1;\\n"' . "\n" . '"X-Generator: Narro\\n"' . "\n";
     $hndFile = fopen($strPoFile, 'w');
     if (!$hndFile) {
         NarroLogger::LogError(sprintf('Error while opening the po file "%s" for writing.', $strPoFile));
     }
     fputs($hndFile, $strPoHeader);
     // Obtain a list of columns
     foreach ($arrMessages as $key => $row) {
         $texts[$key] = $row['text'];
     }
     //array_multisort($texts, SORT_ASC, SORT_STRING, $arrMessages);
     foreach ($arrMessages as $intKey => $arrMsgData) {
         if (isset($arrMsgData['plural'])) {
             fputs($hndFile, sprintf("#: %s\nmsgid \"%s\"\nmsgid_plural \"%s\"\nmsgstr[0] \"\"\nmsgstr[1] \"\"\n\n", join(' ', array_values($arrMsgData['files'])), str_replace(array('"', "\n"), array('\\"', '\\n'), $arrMsgData['text']), str_replace(array('"', "\n"), array('\\"', '\\n'), $arrMsgData['plural'])));
         } else {
             if (!isset($arrMsgData['files'])) {
                 print_r($arrMsgData);
             } else {
                 fputs($hndFile, sprintf("%s\n#: %s\nmsgid \"%s\"\nmsgstr \"\"\n\n", isset($arrMsgData['context']) ? str_replace("\n", "\n#. ", trim($arrMsgData['context'])) . '' : '', join(' ', array_values($arrMsgData['files'])), str_replace(array('"', "\n"), array('\\"', '\\n'), $arrMsgData['text'])));
             }
         }
     }
     fclose($hndFile);
     NarroUtils::Chmod($strPoFile, 0666);
     NarroLogger::LogInfo('Wrote a new Narro template file in ' . $strPoFile);
 }
 /**
  * Refresh this MetaControl with Data from the local NarroContextInfo object.
  * @param boolean $blnReload reload NarroContextInfo from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroContextInfo->Reload();
     }
     if ($this->lblContextInfoId) {
         if ($this->blnEditMode) {
             $this->lblContextInfoId->Text = $this->objNarroContextInfo->ContextInfoId;
         }
     }
     if ($this->lstContext) {
         $this->lstContext->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstContext->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objContextArray = NarroContext::LoadAll();
         if ($objContextArray) {
             foreach ($objContextArray as $objContext) {
                 $objListItem = new QListItem($objContext->__toString(), $objContext->ContextId);
                 if ($this->objNarroContextInfo->Context && $this->objNarroContextInfo->Context->ContextId == $objContext->ContextId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstContext->AddItem($objListItem);
             }
         }
     }
     if ($this->lblContextId) {
         $this->lblContextId->Text = $this->objNarroContextInfo->Context ? $this->objNarroContextInfo->Context->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroContextInfo->Language && $this->objNarroContextInfo->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroContextInfo->Language ? $this->objNarroContextInfo->Language->__toString() : null;
     }
     if ($this->lstValidatorUser) {
         $this->lstValidatorUser->RemoveAllItems();
         $this->lstValidatorUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objValidatorUserArray = NarroUser::LoadAll();
         if ($objValidatorUserArray) {
             foreach ($objValidatorUserArray as $objValidatorUser) {
                 $objListItem = new QListItem($objValidatorUser->__toString(), $objValidatorUser->UserId);
                 if ($this->objNarroContextInfo->ValidatorUser && $this->objNarroContextInfo->ValidatorUser->UserId == $objValidatorUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstValidatorUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblValidatorUserId) {
         $this->lblValidatorUserId->Text = $this->objNarroContextInfo->ValidatorUser ? $this->objNarroContextInfo->ValidatorUser->__toString() : null;
     }
     if ($this->lstValidSuggestion) {
         $this->lstValidSuggestion->RemoveAllItems();
         $this->lstValidSuggestion->AddItem(QApplication::Translate('- Select One -'), null);
         $objValidSuggestionArray = NarroSuggestion::LoadAll();
         if ($objValidSuggestionArray) {
             foreach ($objValidSuggestionArray as $objValidSuggestion) {
                 $objListItem = new QListItem($objValidSuggestion->__toString(), $objValidSuggestion->SuggestionId);
                 if ($this->objNarroContextInfo->ValidSuggestion && $this->objNarroContextInfo->ValidSuggestion->SuggestionId == $objValidSuggestion->SuggestionId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstValidSuggestion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblValidSuggestionId) {
         $this->lblValidSuggestionId->Text = $this->objNarroContextInfo->ValidSuggestion ? $this->objNarroContextInfo->ValidSuggestion->__toString() : null;
     }
     if ($this->chkHasSuggestions) {
         $this->chkHasSuggestions->Checked = $this->objNarroContextInfo->HasSuggestions;
     }
     if ($this->lblHasSuggestions) {
         $this->lblHasSuggestions->Text = $this->objNarroContextInfo->HasSuggestions ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->txtSuggestionAccessKey) {
         $this->txtSuggestionAccessKey->Text = $this->objNarroContextInfo->SuggestionAccessKey;
     }
     if ($this->lblSuggestionAccessKey) {
         $this->lblSuggestionAccessKey->Text = $this->objNarroContextInfo->SuggestionAccessKey;
     }
     if ($this->txtSuggestionCommandKey) {
         $this->txtSuggestionCommandKey->Text = $this->objNarroContextInfo->SuggestionCommandKey;
     }
     if ($this->lblSuggestionCommandKey) {
         $this->lblSuggestionCommandKey->Text = $this->objNarroContextInfo->SuggestionCommandKey;
     }
     if ($this->calCreated) {
         $this->calCreated->DateTime = $this->objNarroContextInfo->Created;
     }
     if ($this->lblCreated) {
         $this->lblCreated->Text = sprintf($this->objNarroContextInfo->Created) ? $this->objNarroContextInfo->Created->qFormat($this->strCreatedDateTimeFormat) : null;
     }
     if ($this->calModified) {
         $this->calModified->DateTime = $this->objNarroContextInfo->Modified;
     }
     if ($this->lblModified) {
         $this->lblModified->Text = sprintf($this->objNarroContextInfo->Modified) ? $this->objNarroContextInfo->Modified->qFormat($this->strModifiedDateTimeFormat) : null;
     }
 }
示例#24
0
 public static function LoadByUserId($intUserId, $objOptionalClauses = null)
 {
     $objUser = NarroUser::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroUser()->UserId, $intUserId)), QQ::ExpandAsArray(QQN::NarroUser()->NarroUserRoleAsUser));
     if (!$objUser instanceof NarroUser) {
         return false;
     }
     foreach ($objUser->_NarroUserRoleAsUserArray as $objRole) {
         /* @var $objRole NarroUserRole */
         $arrRolePermission = NarroRolePermission::LoadArrayByRoleId($objRole->RoleId, QQ::Expand(QQN::NarroRolePermission()->Permission));
         foreach ($arrRolePermission as $objRolePermission) {
             $objUser->arrPermissions[$objRolePermission->Permission->PermissionName . '-' . $objRole->LanguageId . '-' . $objRole->ProjectId] = $objRolePermission;
         }
     }
     if (isset($objUser->Preferences['Language'])) {
         $objLanguage = NarroLanguage::LoadByLanguageCode($objUser->Preferences['Language']);
         if ($objLanguage instanceof NarroLanguage) {
             $objUser->Language = $objLanguage;
         } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
             $objUser->Language = QApplication::$TargetLanguage;
         }
     } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
         $objUser->Language = QApplication::$TargetLanguage;
     }
     return $objUser;
 }
 /**
  * Refresh this MetaControl with Data from the local NarroFileProgress object.
  * @param boolean $blnReload reload NarroFileProgress from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroFileProgress->Reload();
     }
     if ($this->lblFileProgressId) {
         if ($this->blnEditMode) {
             $this->lblFileProgressId->Text = $this->objNarroFileProgress->FileProgressId;
         }
     }
     if ($this->lstFile) {
         $this->lstFile->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstFile->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objFileArray = NarroFile::LoadAll();
         if ($objFileArray) {
             foreach ($objFileArray as $objFile) {
                 $objListItem = new QListItem($objFile->__toString(), $objFile->FileId);
                 if ($this->objNarroFileProgress->File && $this->objNarroFileProgress->File->FileId == $objFile->FileId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstFile->AddItem($objListItem);
             }
         }
     }
     if ($this->lblFileId) {
         $this->lblFileId->Text = $this->objNarroFileProgress->File ? $this->objNarroFileProgress->File->__toString() : null;
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroFileProgress->Language && $this->objNarroFileProgress->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroFileProgress->Language ? $this->objNarroFileProgress->Language->__toString() : null;
     }
     if ($this->txtFileMd5) {
         $this->txtFileMd5->Text = $this->objNarroFileProgress->FileMd5;
     }
     if ($this->lblFileMd5) {
         $this->lblFileMd5->Text = $this->objNarroFileProgress->FileMd5;
     }
     if ($this->txtHeader) {
         $this->txtHeader->Text = $this->objNarroFileProgress->Header;
     }
     if ($this->lblHeader) {
         $this->lblHeader->Text = $this->objNarroFileProgress->Header;
     }
     if ($this->txtTotalTextCount) {
         $this->txtTotalTextCount->Text = $this->objNarroFileProgress->TotalTextCount;
     }
     if ($this->lblTotalTextCount) {
         $this->lblTotalTextCount->Text = $this->objNarroFileProgress->TotalTextCount;
     }
     if ($this->txtApprovedTextCount) {
         $this->txtApprovedTextCount->Text = $this->objNarroFileProgress->ApprovedTextCount;
     }
     if ($this->lblApprovedTextCount) {
         $this->lblApprovedTextCount->Text = $this->objNarroFileProgress->ApprovedTextCount;
     }
     if ($this->txtFuzzyTextCount) {
         $this->txtFuzzyTextCount->Text = $this->objNarroFileProgress->FuzzyTextCount;
     }
     if ($this->lblFuzzyTextCount) {
         $this->lblFuzzyTextCount->Text = $this->objNarroFileProgress->FuzzyTextCount;
     }
     if ($this->txtProgressPercent) {
         $this->txtProgressPercent->Text = $this->objNarroFileProgress->ProgressPercent;
     }
     if ($this->lblProgressPercent) {
         $this->lblProgressPercent->Text = $this->objNarroFileProgress->ProgressPercent;
     }
     if ($this->chkExport) {
         $this->chkExport->Checked = $this->objNarroFileProgress->Export;
     }
     if ($this->lblExport) {
         $this->lblExport->Text = $this->objNarroFileProgress->Export ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
 }
示例#26
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objUser) {
         $objObject->objUser = NarroUser::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     if ($objObject->objRole) {
         $objObject->objRole = NarroRole::GetSoapObjectFromObject($objObject->objRole, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intRoleId = null;
         }
     }
     if ($objObject->objProject) {
         $objObject->objProject = NarroProject::GetSoapObjectFromObject($objObject->objProject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intProjectId = null;
         }
     }
     if ($objObject->objLanguage) {
         $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLanguageId = null;
         }
     }
     return $objObject;
 }
示例#27
0
 }
 QApplication::$User = $objUser;
 $objProject = NarroProject::Load($intProjectId);
 if (!$objProject instanceof NarroProject) {
     NarroLogger::LogInfo(sprintf('Project with id=%s does not exist in the database.', $intProjectId));
     return false;
 }
 $objLanguage = NarroLanguage::LoadByLanguageCode($strTargetLanguage);
 if (!$objLanguage instanceof NarroLanguage) {
     NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strTargetLanguage));
     return false;
 }
 QApplication::$TargetLanguage = $objLanguage;
 $objNarroImporter->TargetLanguage = $objLanguage;
 NarroLogger::LogInfo(sprintf('Target language is %s', $objNarroImporter->TargetLanguage->LanguageName));
 $objNarroImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode($strSourceLanguage);
 if (!$objNarroImporter->SourceLanguage instanceof NarroLanguage) {
     NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strSourceLanguage));
     return false;
 }
 NarroLogger::LogInfo(sprintf('Source language is %s', $objNarroImporter->SourceLanguage->LanguageName));
 $objNarroImporter->Project = $objProject;
 $objNarroImporter->User = $objUser;
 if (array_search('--template-directory', $argv) !== false) {
     $objNarroImporter->TemplatePath = $argv[array_search('--template-directory', $argv) + 1];
 } else {
     $objNarroImporter->TemplatePath = $objNarroImporter->Project->DefaultTemplatePath;
 }
 if (array_search('--translation-directory', $argv) !== false) {
     $objNarroImporter->TranslationPath = $argv[array_search('--translation-directory', $argv) + 1];
 } else {
示例#28
0
 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'));
 }
 /**
  * Refresh this MetaControl with Data from the local NarroLog object.
  * @param boolean $blnReload reload NarroLog from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objNarroLog->Reload();
     }
     if ($this->lblLogId) {
         if ($this->blnEditMode) {
             $this->lblLogId->Text = $this->objNarroLog->LogId;
         }
     }
     if ($this->lstLanguage) {
         $this->lstLanguage->RemoveAllItems();
         $this->lstLanguage->AddItem(QApplication::Translate('- Select One -'), null);
         $objLanguageArray = NarroLanguage::LoadAll();
         if ($objLanguageArray) {
             foreach ($objLanguageArray as $objLanguage) {
                 $objListItem = new QListItem($objLanguage->__toString(), $objLanguage->LanguageId);
                 if ($this->objNarroLog->Language && $this->objNarroLog->Language->LanguageId == $objLanguage->LanguageId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstLanguage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblLanguageId) {
         $this->lblLanguageId->Text = $this->objNarroLog->Language ? $this->objNarroLog->Language->__toString() : null;
     }
     if ($this->lstProject) {
         $this->lstProject->RemoveAllItems();
         $this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
         $objProjectArray = NarroProject::LoadAll();
         if ($objProjectArray) {
             foreach ($objProjectArray as $objProject) {
                 $objListItem = new QListItem($objProject->__toString(), $objProject->ProjectId);
                 if ($this->objNarroLog->Project && $this->objNarroLog->Project->ProjectId == $objProject->ProjectId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstProject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblProjectId) {
         $this->lblProjectId->Text = $this->objNarroLog->Project ? $this->objNarroLog->Project->__toString() : null;
     }
     if ($this->lstUser) {
         $this->lstUser->RemoveAllItems();
         $this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
         $objUserArray = NarroUser::LoadAll();
         if ($objUserArray) {
             foreach ($objUserArray as $objUser) {
                 $objListItem = new QListItem($objUser->__toString(), $objUser->UserId);
                 if ($this->objNarroLog->User && $this->objNarroLog->User->UserId == $objUser->UserId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstUser->AddItem($objListItem);
             }
         }
     }
     if ($this->lblUserId) {
         $this->lblUserId->Text = $this->objNarroLog->User ? $this->objNarroLog->User->__toString() : null;
     }
     if ($this->txtMessage) {
         $this->txtMessage->Text = $this->objNarroLog->Message;
     }
     if ($this->lblMessage) {
         $this->lblMessage->Text = $this->objNarroLog->Message;
     }
     if ($this->txtPriority) {
         $this->txtPriority->Text = $this->objNarroLog->Priority;
     }
     if ($this->lblPriority) {
         $this->lblPriority->Text = $this->objNarroLog->Priority;
     }
     if ($this->calDate) {
         $this->calDate->DateTime = $this->objNarroLog->Date;
     }
     if ($this->lblDate) {
         $this->lblDate->Text = sprintf($this->objNarroLog->Date) ? $this->objNarroLog->Date->qFormat($this->strDateDateTimeFormat) : null;
     }
 }
 /**
  * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  */
 protected function Form_Validate()
 {
     // By default, we report the result of validation from the parent
     $blnToReturn = parent::Form_Validate();
     // Custom Validation Rules
     // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
     // Check for records that may violate Unique Clauses
     if (($objNarroLanguage = NarroLanguage::LoadByLanguageName($this->txtLanguageName->Text)) && $objNarroLanguage->LanguageId != $this->mctNarroLanguage->NarroLanguage->LanguageId) {
         $blnToReturn = false;
         $this->txtLanguageName->Warning = QApplication::Translate("Already in Use");
     }
     if (($objNarroLanguage = NarroLanguage::LoadByLanguageCode($this->txtLanguageCode->Text)) && $objNarroLanguage->LanguageId != $this->mctNarroLanguage->NarroLanguage->LanguageId) {
         $blnToReturn = false;
         $this->txtLanguageCode->Warning = QApplication::Translate("Already in Use");
     }
     $blnFocused = false;
     foreach ($this->GetErrorControls() as $objControl) {
         // Set Focus to the top-most invalid control
         if (!$blnFocused) {
             $objControl->Focus();
             $blnFocused = true;
         }
         // Blink on ALL invalid controls
         $objControl->Blink();
     }
     return $blnToReturn;
 }