public function DisplayInProjectListInProgressColumn(NarroProject $objProject, $strText = '') { $strExportText = ''; if ($objProject->ProjectType != NarroProjectType::Mozilla) { return array($objProject, ''); } $objCache = new NarroCache(__CLASS__, QApplication::GetLanguageId()); $objData = $objCache->GetData(); if (!$objData) { $strJson = @file_get_contents($this->strUrl); if ($strJson) { $objData = json_decode($strJson); if ($objData) { $objCache->SaveData($objData); } } } if (is_array($objData->items)) { foreach ($objData->items as $objItem) { if ($objItem->id == sprintf('%s/%s', $objProject->GetPreferenceValueByName('Code name on mozilla l10n dashboard'), QApplication::$TargetLanguage->LanguageCode)) { $strWarning = $objItem->warnings ? sprintf('%d warnings', $objItem->warnings) : ''; $strMissing = $objItem->missing ? sprintf('%d missing', $objItem->missing) : ''; $strExportText = sprintf('<a title="Visit the Mozilla l10n dashboard" target="_blank" href="https://l10n-stage-sj.mozilla.org/dashboard/compare?run=%d">%s</a>', $objItem->runid, join(', ', array($objItem->result, $strMissing, $strWarning))); break; } } } return array($objProject, $strExportText); }
protected function SetupNarroProject($intProjectId) { // Lookup Object PK information from Query String (if applicable) if ($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), t('Add project')); } }
public function Save($blnForceInsert = false, $blnForceUpdate = false) { $mixResult = parent::Save($blnForceInsert, $blnForceUpdate); foreach (NarroProject::LoadAll() as $objProject) { $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($objProject->ProjectId, $this->LanguageId); if (!$objProjectProgress) { $objProject->CountAllTextsByLanguage($this->LanguageId); } } return $mixResult; }
protected function SetupNarroProject($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); if (!$this->objProject) { QApplication::Redirect(NarroLink::ProjectList()); return false; } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); return true; } }
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->lstProject = new QListBox($this); $this->lstProject->DisplayStyle = QDisplayStyle::Block; $this->lstProject->Instructions = t('Please choose the project from which you will import matching approved translations'); $this->lstProject->PreferedRenderMethod = 'RenderWithName'; $this->blnAutoRenderChildren = true; foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objProject) { $this->lstProject->AddItem($objProject->ProjectName, $objProject->ProjectId); } }
protected function RepositorySetup() { NarroProject::RegisterPreference('SVN commit path', false, 0, 'text', 'The url to commit this project to SVN.', ''); NarroProject::RegisterPreference('Username for SVN', false, 0, 'text', '', ''); $this->objProject->SetPreferenceValueByName('SVN commit path', $this->txtRepositoryUrl->Text); $this->objProject->SetPreferenceValueByName('Username for SVN', $this->txtUsername->Text); $this->objProject->Save(); $this->strSSHKey = sprintf('%s/svn_%d_%s_%d', __TMP_PATH__, QApplication::$User->UserId, QApplication::$TargetLanguage->LanguageCode, $this->objProject->ProjectId); $strProcLogFile = __TMP_PATH__ . '/' . $this->objProject->ProjectId . '-' . QApplication::$TargetLanguage->LanguageCode . '-svn.log'; copy($this->fileSSHPrivateKey->File, $this->strSSHKey); chmod($this->strSSHKey, 0600); $mixProcess = NarroUtils::Exec(sprintf('svn checkout %s %s_svn', escapeshellarg($this->txtRepositoryUrl->Text), $this->strSSHKey), $arrOutput, $arrError, $intRetVal, false, array('SVN_SSH' => sprintf('ssh -o StrictHostKeyChecking=no -l %s -p 22 -i %s', escapeshellarg($this->txtUsername->Text), escapeshellarg($this->strSSHKey)), 'HOME' => __TMP_PATH__), __TMP_PATH__, true); if ($intRetVal == 0) { NarroUtils::RecursiveCopy($this->objProject->DefaultTranslationPath, $this->strSSHKey . '_svn'); $mixProcess = NarroUtils::Exec('svn add -q ./*', $arrOutput, $arrError, $intRetVal, false, array('SVN_SSH' => sprintf('ssh -o StrictHostKeyChecking=no -l %s -p 22 -i %s', escapeshellarg($this->txtUsername->Text), escapeshellarg($this->strSSHKey)), 'HOME' => __TMP_PATH__), $this->strSSHKey . '_svn', true); return $intRetVal; } else { return $intRetVal; } }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this NarroProjectMetaControl * @param integer $intProjectId primary key value * @param QMetaControlCreateType $intCreateType rules governing NarroProject object creation - defaults to CreateOrEdit * @return NarroProjectMetaControl */ public static function Create($objParentObject, $intProjectId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intProjectId)) { $objNarroProject = NarroProject::Load($intProjectId); // NarroProject was found -- return it! if ($objNarroProject) { return new NarroProjectMetaControl($objParentObject, $objNarroProject); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a NarroProject object with PK arguments: ' . $intProjectId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new NarroProjectMetaControl($objParentObject, new NarroProject()); }
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * 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)) {
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; }
protected function dtgReviews_Create() { $dtgReviews = new NarroContextInfoDataGrid($this->tabActivity); $dtgReviews->SetCustomStyle('padding', '5px'); $dtgReviews->Title = sprintf(t('Translations approved by <b>%s</b>'), $this->objUser->RealName); $colText = $dtgReviews->MetaAddColumn(QQN::NarroContextInfo()->ValidSuggestion->Text->TextValue); $colText->Name = t('Original text'); $colText->Html = '<?= $_CONTROL->colText_Render($_ITEM); ?>'; $colText->HtmlEntities = false; $colSuggestion = $dtgReviews->MetaAddColumn(QQN::NarroContextInfo()->ValidSuggestion->SuggestionValue); $colSuggestion->Name = t('Approved translation'); $colSuggestion->Html = '<?= $_CONTROL->colSuggestion_Render($_ITEM); ?>'; $colProject = $dtgReviews->MetaAddColumn(QQN::NarroContextInfo()->Context->Project->ProjectName); $colProject->Name = t('Project'); $colProject->Filter = null; foreach (NarroProject::LoadArrayByActive(1) as $objProject) { $colProject->FilterAddListItem($objProject->ProjectName, QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $objProject->ProjectId)); } $colProject->Html = '<?= $_CONTROL->colProject_Render($_ITEM); ?>'; $colProject->HtmlEntities = false; $colLanguage = $dtgReviews->MetaAddColumn(QQN::NarroContextInfo()->Language->LanguageName); $colLanguage->Name = t('Language'); $colLanguage->Filter = null; foreach (NarroLanguage::LoadAllActive() as $objLanguage) { $colLanguage->FilterAddListItem($objLanguage->LanguageName, QQ::Equal(QQN::NarroContextInfo()->LanguageId, $objLanguage->LanguageId)); } $colLanguage->FilterActivate(QApplication::$TargetLanguage->LanguageName); $colLanguage->Html = '<?= $_CONTROL->colLanguage_Render($_ITEM); ?>'; $colModified = $dtgReviews->MetaAddColumn(QQN::NarroContextInfo()->Modified); $colModified->Name = t('Approved'); $colModified->FilterType = QFilterType::None; $colModified->Html = '<?= $_CONTROL->colModified_Render($_ITEM); ?>'; $colModified->HtmlEntities = false; $colModified->Wrap = false; // Datagrid Paginator $dtgReviews->Paginator = new QPaginator($dtgReviews); $dtgReviews->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page'); // Specify Whether or Not to Refresh using Ajax $dtgReviews->UseAjax = true; $dtgReviews->SortColumnIndex = 4; $dtgReviews->SortDirection = true; $dtgReviews->AdditionalClauses = array(QQ::Expand(QQN::NarroContextInfo()->ValidSuggestion), QQ::Expand(QQN::NarroContextInfo()->Language)); $dtgReviews->AdditionalConditions = QQ::AndCondition(QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId), QQ::Equal(QQN::NarroContextInfo()->ValidatorUserId, $this->objUser->UserId)); $dtgReviews->btnFilter_Click($this->Form->FormId, $dtgReviews->FilterButton->ControlId, ''); }
public function btnTest_Click() { NarroProject::RegisterPreference('Mercurial commit path', false, 0, 'text', 'The url to commit this project to mercurial.', ''); NarroProject::RegisterPreference('Username for Mercurial', false, 0, 'text', '', ''); $this->objProject->SetPreferenceValueByName('Mercurial commit path', $this->txtRepositoryUrl->Text); $this->objProject->SetPreferenceValueByName('Username for Mercurial', $this->txtUsername->Text); $this->objProject->Save(); $strSSHKey = sprintf('%s/mercurial_%d_%s_%d', __TMP_PATH__, QApplication::$User->UserId, QApplication::$TargetLanguage->LanguageCode, $this->objProject->ProjectId); $strProcLogFile = __TMP_PATH__ . '/' . $this->objProject->ProjectId . '-' . QApplication::$TargetLanguage->LanguageCode . '-mercurial.log'; copy($this->fileSSHPrivateKey->File, $strSSHKey); chmod($strSSHKey, 0600); file_put_contents($strSSHKey . '_hgrc', sprintf("[paths]\n" . "default = %s\n" . "\n" . "[ui]\n" . "ssh = ssh -i %s -o StrictHostKeyChecking=no -l %s\n" . "username = %s\n", $this->txtRepositoryUrl->Text, $strSSHKey, $this->txtUsername->Text, $this->txtCommitUsername->Text)); $mixProcess = exec(sprintf('export HOME=%s;export HGRCPATH=%s; hg clone %s %s_mercurial;cd %s_mercurial; cp -f -R %s/* .; hg addremove; hg diff -w --nodates > %s_diff; hg commit -m "%s" %s; hg outgoing', __TMP_PATH__, $strSSHKey . '_hgrc', escapeshellarg($this->txtRepositoryUrl->Text), $strSSHKey, $strSSHKey, escapeshellarg($this->objProject->DefaultTranslationPath), $strSSHKey, escapeshellarg($this->txtCommitMessage->Text), $this->pnlPatchViewer && count($this->pnlPatchViewer->SelectedFiles) ? join(" ", $this->pnlPatchViewer->SelectedFiles) : ""), $arrOutput); $this->lblOutput->Text = join("\n", $arrOutput); $this->Form->RemoveControl($this->pnlPatchViewer->ControlId); $this->pnlPatchViewer = new NarroPatchViewerPanel($strSSHKey . '_diff', $this); unlink($strSSHKey); unlink($strSSHKey . '_hgrc'); unlink($strSSHKey . '_diff'); NarroUtils::RecursiveDelete($strSSHKey . '_mercurial'); $this->btnCommit->Display = true; $this->chkForce->Display = true; }
/** * Refresh this MetaControl with Data from the local NarroFile object. * @param boolean $blnReload reload NarroFile from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objNarroFile->Reload(); } if ($this->lblFileId) { if ($this->blnEditMode) { $this->lblFileId->Text = $this->objNarroFile->FileId; } } if ($this->txtFileName) { $this->txtFileName->Text = $this->objNarroFile->FileName; } if ($this->lblFileName) { $this->lblFileName->Text = $this->objNarroFile->FileName; } if ($this->txtFilePath) { $this->txtFilePath->Text = $this->objNarroFile->FilePath; } if ($this->lblFilePath) { $this->lblFilePath->Text = $this->objNarroFile->FilePath; } if ($this->txtFileMd5) { $this->txtFileMd5->Text = $this->objNarroFile->FileMd5; } if ($this->lblFileMd5) { $this->lblFileMd5->Text = $this->objNarroFile->FileMd5; } if ($this->lstParent) { $this->lstParent->RemoveAllItems(); $this->lstParent->AddItem(QApplication::Translate('- Select One -'), null); $objParentArray = NarroFile::LoadAll(); if ($objParentArray) { foreach ($objParentArray as $objParent) { $objListItem = new QListItem($objParent->__toString(), $objParent->FileId); if ($this->objNarroFile->Parent && $this->objNarroFile->Parent->FileId == $objParent->FileId) { $objListItem->Selected = true; } $this->lstParent->AddItem($objListItem); } } } if ($this->lblParentId) { $this->lblParentId->Text = $this->objNarroFile->Parent ? $this->objNarroFile->Parent->__toString() : null; } if ($this->lstType) { $this->lstType->SelectedValue = $this->objNarroFile->TypeId; } if ($this->lblTypeId) { $this->lblTypeId->Text = $this->objNarroFile->TypeId ? NarroFileType::$NameArray[$this->objNarroFile->TypeId] : null; } 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->objNarroFile->Project && $this->objNarroFile->Project->ProjectId == $objProject->ProjectId) { $objListItem->Selected = true; } $this->lstProject->AddItem($objListItem); } } } if ($this->lblProjectId) { $this->lblProjectId->Text = $this->objNarroFile->Project ? $this->objNarroFile->Project->__toString() : null; } if ($this->chkActive) { $this->chkActive->Checked = $this->objNarroFile->Active; } if ($this->lblActive) { $this->lblActive->Text = $this->objNarroFile->Active ? QApplication::Translate('Yes') : QApplication::Translate('No'); } if ($this->calCreated) { $this->calCreated->DateTime = $this->objNarroFile->Created; } if ($this->lblCreated) { $this->lblCreated->Text = sprintf($this->objNarroFile->Created) ? $this->objNarroFile->Created->qFormat($this->strCreatedDateTimeFormat) : null; } if ($this->calModified) { $this->calModified->DateTime = $this->objNarroFile->Modified; } if ($this->lblModified) { $this->lblModified->Text = sprintf($this->objNarroFile->Modified) ? $this->objNarroFile->Modified->qFormat($this->strModifiedDateTimeFormat) : null; } if ($this->txtHeader) { $this->txtHeader->Text = $this->objNarroFile->Header; } if ($this->lblHeader) { $this->lblHeader->Text = $this->objNarroFile->Header; } }
/** * 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; } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { foreach ($this->arrControls as $strName => $objControl) { switch (NarroProject::$AvailablePreferences[$strName]['type']) { case 'number': $this->objProject->SetPreferenceValueByName($strName, $objControl->Text); break; case 'text': $this->objProject->SetPreferenceValueByName($strName, $objControl->Text); break; case 'option': $this->objProject->SetPreferenceValueByName($strName, $objControl->SelectedValue); break; } } try { $this->objProject->Save(); $this->objProject = NarroProject::Load($this->objProject->ProjectId); $this->objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->objProject->ProjectId, QApplication::GetLanguageId()); $this->lblMessage->Text = t('Your preferences were saved successfuly.'); $this->lblMessage->ForeColor = 'green'; } catch (Exception $objEx) { $this->lblMessage->Text = t('An error occurred while trying to save your preferences.'); $this->lblMessage->ForeColor = 'red'; } }
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; }
/** * Refresh this MetaControl with Data from the local NarroContext object. * @param boolean $blnReload reload NarroContext from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objNarroContext->Reload(); } if ($this->lblContextId) { if ($this->blnEditMode) { $this->lblContextId->Text = $this->objNarroContext->ContextId; } } 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->objNarroContext->Text && $this->objNarroContext->Text->TextId == $objText->TextId) { $objListItem->Selected = true; } $this->lstText->AddItem($objListItem); } } } if ($this->lblTextId) { $this->lblTextId->Text = $this->objNarroContext->Text ? $this->objNarroContext->Text->__toString() : null; } if ($this->txtTextAccessKey) { $this->txtTextAccessKey->Text = $this->objNarroContext->TextAccessKey; } if ($this->lblTextAccessKey) { $this->lblTextAccessKey->Text = $this->objNarroContext->TextAccessKey; } if ($this->txtTextCommandKey) { $this->txtTextCommandKey->Text = $this->objNarroContext->TextCommandKey; } if ($this->lblTextCommandKey) { $this->lblTextCommandKey->Text = $this->objNarroContext->TextCommandKey; } 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->objNarroContext->Project && $this->objNarroContext->Project->ProjectId == $objProject->ProjectId) { $objListItem->Selected = true; } $this->lstProject->AddItem($objListItem); } } } if ($this->lblProjectId) { $this->lblProjectId->Text = $this->objNarroContext->Project ? $this->objNarroContext->Project->__toString() : null; } if ($this->txtContext) { $this->txtContext->Text = $this->objNarroContext->Context; } if ($this->lblContext) { $this->lblContext->Text = $this->objNarroContext->Context; } if ($this->txtContextMd5) { $this->txtContextMd5->Text = $this->objNarroContext->ContextMd5; } if ($this->lblContextMd5) { $this->lblContextMd5->Text = $this->objNarroContext->ContextMd5; } if ($this->txtComment) { $this->txtComment->Text = $this->objNarroContext->Comment; } if ($this->lblComment) { $this->lblComment->Text = $this->objNarroContext->Comment; } if ($this->txtCommentMd5) { $this->txtCommentMd5->Text = $this->objNarroContext->CommentMd5; } if ($this->lblCommentMd5) { $this->lblCommentMd5->Text = $this->objNarroContext->CommentMd5; } 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->objNarroContext->File && $this->objNarroContext->File->FileId == $objFile->FileId) { $objListItem->Selected = true; } $this->lstFile->AddItem($objListItem); } } } if ($this->lblFileId) { $this->lblFileId->Text = $this->objNarroContext->File ? $this->objNarroContext->File->__toString() : null; } if ($this->calCreated) { $this->calCreated->DateTime = $this->objNarroContext->Created; } if ($this->lblCreated) { $this->lblCreated->Text = sprintf($this->objNarroContext->Created) ? $this->objNarroContext->Created->qFormat($this->strCreatedDateTimeFormat) : null; } if ($this->calModified) { $this->calModified->DateTime = $this->objNarroContext->Modified; } if ($this->lblModified) { $this->lblModified->Text = sprintf($this->objNarroContext->Modified) ? $this->objNarroContext->Modified->qFormat($this->strModifiedDateTimeFormat) : null; } if ($this->chkActive) { $this->chkActive->Checked = $this->objNarroContext->Active; } if ($this->lblActive) { $this->lblActive->Text = $this->objNarroContext->Active ? QApplication::Translate('Yes') : QApplication::Translate('No'); } }
/////////////////////// // Setup Error Handling /////////////////////// if (array_key_exists('SERVER_PROTOCOL', $_SERVER)) { set_error_handler('QcodoHandleError', error_reporting()); set_exception_handler('QcodoHandleException'); } spl_autoload_register(array('QApplication', 'Autoload')); QApplication::Initialize(); QApplication::InitializeDatabaseConnections(); QApplication::$EncodingType = 'UTF-8'; NarroUser::GetDatabase()->NonQuery("SET NAMES 'utf8'"); NarroUser::RegisterPreference('Items per page', 'number', t('How many items are displayed per page'), 10); NarroUser::RegisterPreference('Font size', 'option', t('The application font size'), 'medium', array('x-small', 'small', 'medium', 'large', 'x-large')); NarroUser::RegisterPreference('Language', 'option', t('The language you are translating to'), QApplication::QueryString('l'), array(QApplication::QueryString('l'))); NarroUser::RegisterPreference('Application language', 'option', t('The language you want to see Narro in'), isset(QApplication::$TargetLanguage) ? QApplication::$TargetLanguage->LanguageCode : NarroLanguage::SOURCE_LANGUAGE_CODE, array(isset(QApplication::$TargetLanguage) ? QApplication::$TargetLanguage->LanguageCode : NarroLanguage::SOURCE_LANGUAGE_CODE)); NarroUser::RegisterPreference('Special characters', 'text', t('Characters that are not on your keyboard, separated by spaces'), '$€'); NarroUser::RegisterPreference('Automatically save translations', 'option', t('Save translations when moving to the next text to translate'), 'No', array('Yes', 'No')); NarroUser::RegisterPreference('Launch imports and exports in background', 'option', t('Launch imports and exports in background'), 'Yes', array('Yes', 'No')); NarroUser::RegisterPreference('Load more texts while scrolling', 'option', t('Whether to load more content if you reach the bottom of the page'), 'No', array('Yes', 'No')); if (!isset($argv)) { QApplication::SessionOverride(); QApplication::InitializeSession(); } QApplication::InitializeUser(); QApplication::InitializeLanguage(); NarroProject::RegisterPreference('Export translators and reviewers in the file header as a comment', false, 0, 'option', '', 'No', array('Yes', 'No')); QApplication::InitializeLogging(); QApplication::InitializeTranslationEngine(); QApplication::$PluginHandler = new NarroPluginHandler(dirname(__FILE__) . '/../includes/narro/plugins'); }
/** * 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 (($objNarroProject = NarroProject::LoadByProjectName($this->txtProjectName->Text)) && $objNarroProject->ProjectId != $this->mctNarroProject->NarroProject->ProjectId) { $blnToReturn = false; $this->txtProjectName->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; }
/** * 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; } }
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" . "--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 .= '+'; }
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; }
* * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/configuration/prepend.inc.php'; QApplication::$TargetLanguage = NarroLanguage::Load(QApplication::QueryString('l')); if (QApplication::QueryString('p')) { $objProject = NarroProject::Load(QApplication::QueryString('p')); } switch (QApplication::QueryString('t')) { case 'suggestion': if (isset($objProject) && $objProject instanceof NarroProject) { $strCacheId = sprintf('rssfeed_suggestion_%d_%d', $objProject->ProjectId, QApplication::QueryString('l')); } else { $strCacheId = sprintf('rssfeed_suggestion_%d', QApplication::QueryString('l')); } if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) { if (isset($objProject) && $objProject instanceof NarroProject) { $objRssFeed = new QRssFeed(sprintf(t('Translations for %s'), $objProject->ProjectName), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s for %s'), t(QApplication::$TargetLanguage->LanguageName), $objProject->ProjectName)); } else { $objRssFeed = new QRssFeed(sprintf(t('Translations for all projects'), t(QApplication::$TargetLanguage->LanguageName)), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s'), t(QApplication::$TargetLanguage->LanguageName))); } if (isset($objProject) && $objProject instanceof NarroProject) {
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objText) { $objObject->objText = NarroText::GetSoapObjectFromObject($objObject->objText, false); } else { if (!$blnBindRelatedObjects) { $objObject->intTextId = null; } } if ($objObject->objProject) { $objObject->objProject = NarroProject::GetSoapObjectFromObject($objObject->objProject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intProjectId = null; } } if ($objObject->objFile) { $objObject->objFile = NarroFile::GetSoapObjectFromObject($objObject->objFile, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFileId = null; } } if ($objObject->dttCreated) { $objObject->dttCreated = $objObject->dttCreated->qFormat(QDateTime::FormatSoap); } if ($objObject->dttModified) { $objObject->dttModified = $objObject->dttModified->qFormat(QDateTime::FormatSoap); } return $objObject; }
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')); }
$strTargetLanguage = $argv[array_search('--translation-lang', $argv) + 1]; } if (array_search('--user', $argv) !== false) { $intUserId = $argv[array_search('--user', $argv) + 1]; } $objUser = NarroUser::LoadByUserId($intUserId); if (!$objUser instanceof NarroUser) { NarroLogger::LogInfo(sprintf('User id=%s does not exist in the database, will try to use the anonymous user.', $intUserId)); $objUser = NarroUser::LoadAnonymousUser(); if (!$objUser instanceof NarroUser) { NarroLogger::LogInfo(sprintf('The anonymous user id=%s does not exist in the database.', $intUserId)); return false; } } 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));
public function dtgProjectList_Bind() { if ($this->txtSearch->Text != '') { $arrConditions[] = QQ::Like(QQN::NarroProject()->ProjectName, sprintf('%%%s%%', $this->txtSearch->Text)); } else { $arrConditions[] = QQ::All(); } if (QApplication::HasPermissionForThisLang('Can manage project')) { $arrConditions[] = QQ::All(); } else { $arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->Active, 1), QQ::Equal(QQN::NarroProject()->Active, 1)); } // Setup the $objClauses Array $objClauses = array(QQ::Expand(QQN::NarroProject()->NarroProjectProgressAsProject, QQ::Equal(QQN::NarroProject()->NarroProjectProgressAsProject->LanguageId, QApplication::GetLanguageId()))); // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgProjectList->TotalItemCount = NarroProject::QueryCount(QQ::AndCondition($arrConditions), $objClauses); // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->dtgProjectList->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgProjectList->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all NarroProjectProgress objects, given the clauses above $this->dtgProjectList->DataSource = NarroProject::QueryArray(QQ::AndCondition($arrConditions), $objClauses); }
/** * Default / simple DataBinder for this Meta DataGrid. This can easily be overridden * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). */ public function MetaDataBinder() { $objConditions = $this->Conditions; if (null !== $this->conAdditionalConditions) { $objConditions = QQ::AndCondition($this->conAdditionalConditions, $objConditions); } // Setup the $objClauses Array $objClauses = array(); if (null !== $this->clsAdditionalClauses) { $objClauses = $this->clsAdditionalClauses; } // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = NarroProject::QueryCount($objConditions); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from NarroProject, given the clauses above $this->DataSource = NarroProject::QueryArray($objConditions, $objClauses); }
public function lstProject_Create() { $this->lstProject = new QListBox($this); $this->lstProject->AddItem(t('all projects')); foreach (NarroProject::LoadArrayByActive(1, array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objProject) { $this->lstProject->AddItem($objProject->ProjectName, $objProject->ProjectId); } $this->lstProject->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'btnSearch_Click', $this->objWaitIcon)); if (QApplication::QueryString('p') > 0) { $this->lstProject->SelectedValue = QApplication::QueryString('p'); } }
/** * 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; } }
/** * Counts all associated NarroProjectsAsProjectCategory * @return int */ public function CountNarroProjectsAsProjectCategory() { if (is_null($this->intProjectCategoryId)) { return 0; } return NarroProject::CountByProjectCategoryId($this->intProjectCategoryId); }