public function ChangeDirectory($strPath) { if ($strPath) { $this->objParentFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->Active, 1), QQ::Equal(QQN::NarroFile()->FilePath, $strPath))); } $this->pnlBreadcrumb->Visible = false; $this->pnlBreadcrumb->setElements(NarroLink::ProjectFileList($this->objProject->ProjectId, null, null, '..')); if ($this->objParentFile) { $arrPaths = explode('/', $this->objParentFile->FilePath); $strProgressivePath = ''; if (is_array($arrPaths)) { /** * remove the first part that is empty because paths begin with / * and the last part that will be displayed unlinked */ unset($arrPaths[count($arrPaths) - 1]); unset($arrPaths[0]); foreach ($arrPaths as $intCnt => $strPathPart) { $strProgressivePath .= '/' . $strPathPart; $this->pnlBreadcrumb->addElement(NarroLink::ProjectFileList($this->objProject->ProjectId, $strProgressivePath, null, $strPathPart)); } } } if ($this->objParentFile instanceof NarroFile) { $this->pnlBreadcrumb->addElement($this->objParentFile->FileName); $this->pnlBreadcrumb->Visible = true; } }
/** * 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'); } }
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; }
/** * 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 = NarroFile::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 NarroFile, given the clauses above $this->DataSource = NarroFile::QueryArray($objConditions, $objClauses); }
/** * 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 (($objNarroFile = NarroFile::LoadByFilePathProjectId($this->txtFilePath->Text, $this->lstProject->SelectedValue)) && $objNarroFile->FileId != $this->mctNarroFile->NarroFile->FileId) { $blnToReturn = false; $this->txtFilePath->Warning = QApplication::Translate("Already in Use"); $this->lstProject->Warning = QApplication::Translate("Already in Use"); } if (($objNarroFile = NarroFile::LoadByFileNameParentId($this->txtFileName->Text, $this->lstParent->SelectedValue)) && $objNarroFile->FileId != $this->mctNarroFile->NarroFile->FileId) { $blnToReturn = false; $this->txtFileName->Warning = QApplication::Translate("Already in Use"); $this->lstParent->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 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'); } }
public function MarkUnusedContextsAsInactive() { if (count($this->arrContextId)) { NarroFile::GetDatabase()->NonQuery(sprintf('UPDATE narro_context SET active=1 WHERE project_id=%d AND file_id=%d AND context_id IN (%s)', $this->objProject->ProjectId, $this->objFile->FileId, join(',', $this->arrContextId))); NarroFile::GetDatabase()->NonQuery(sprintf('UPDATE narro_context SET active=0 WHERE project_id=%d AND file_id=%d AND context_id NOT IN (%s)', $this->objProject->ProjectId, $this->objFile->FileId, join(',', $this->arrContextId))); } }
/** * 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; } }
public function ExportFromDirectory() { // NarroLogger::LogDebug(sprintf('Starting to export in directory "%s"', $this->strTranslationPath)); /** * get the file list with complete paths */ $arrFiles = $this->ListDir($this->strTemplatePath); $intTotalFilesToProcess = count($arrFiles); if ($intTotalFilesToProcess == 1 && pathinfo($arrFiles[0], PATHINFO_EXTENSION) == 'xpi') { return $this->ExportToXpi($arrFiles[0]); } if ($intTotalFilesToProcess > __MAXIMUM_FILE_COUNT_TO_EXPORT__) { NarroLogger::LogError(sprintf('Too many files to process: %d. The maximum number of files to export is set in the configuration file at %d', $intTotalFilesToProcess, __MAXIMUM_FILE_COUNT_TO_EXPORT__)); return false; } // NarroLogger::LogDebug(sprintf('Starting to process %d files', $intTotalFilesToProcess)); $arrDirectories = array(); NarroProgress::SetProgress(0, $this->objProject->ProjectId, 'export', $intTotalFilesToProcess); if (is_array($arrFiles)) { foreach ($arrFiles as $intFileNo => $strFileToExport) { $arrFileParts = explode('/', str_replace($this->strTemplatePath, '', $strFileToExport)); $strFileName = $arrFileParts[count($arrFileParts) - 1]; unset($arrFileParts[count($arrFileParts) - 1]); unset($arrFileParts[0]); $strPath = ''; $intParentId = null; $arrDirectories = array(); foreach ($arrFileParts as $intPos => $strDir) { $strPath = $strPath . '/' . $strDir; if (!isset($arrDirectories[$strPath])) { if (!is_null($intParentId)) { $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strDir), QQ::Equal(QQN::NarroFile()->TypeId, NarroFileType::Folder), QQ::Equal(QQN::NarroFile()->ParentId, $intParentId))); } else { $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strDir), QQ::Equal(QQN::NarroFile()->TypeId, NarroFileType::Folder), QQ::IsNull(QQN::NarroFile()->ParentId))); } if (!$objFile instanceof NarroFile) { NarroLogger::LogWarn(sprintf('Could not find folder "%s" with parent id "%d" in the database.', $strDir, $intParentId)); continue; } $arrDirectories[$strPath] = $objFile->FileId; } $intParentId = $arrDirectories[$strPath]; } $strTranslatedFileToExport = str_replace($this->strTemplatePath, $this->strTranslationPath, $strFileToExport); if (!file_exists(dirname($strTranslatedFileToExport))) { if (!mkdir(dirname($strTranslatedFileToExport), 0777, true)) { NarroLogger::LogWarn(sprintf('Failed to create the parent directories for the file %s', $strFileToExport)); return false; } NarroUtils::RecursiveChmod(dirname($strTranslatedFileToExport)); } $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strFileName), QQ::Equal(QQN::NarroFile()->ParentId, $intParentId), QQ::Equal(QQN::NarroFile()->Active, 1))); if (!$objFile instanceof NarroFile) { continue; } // NarroLogger::LogDebug(sprintf('Exporting file "%s" using template "%s"', $objFile->FileName, $strTranslatedFileToExport)); $intTime = time(); $this->ExportFile($objFile, $strFileToExport, $strTranslatedFileToExport); $intElapsedTime = time() - $intTime; // NarroLogger::LogDebug(sprintf('Processed file "%s" in %d seconds, %d files left', str_replace($this->strTemplatePath, '', $strFileToExport), $intElapsedTime, (count($arrFiles) - $intFileNo - 1))); NarroImportStatistics::$arrStatistics['Exported files']++; NarroProgress::SetProgress((int) ceil($intFileNo * 100 / $intTotalFilesToProcess), $this->objProject->ProjectId, 'export'); } } return true; }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objFile) { $objObject->objFile = NarroFile::GetSoapObjectFromObject($objObject->objFile, false); } else { if (!$blnBindRelatedObjects) { $objObject->intFileId = null; } } if ($objObject->objLanguage) { $objObject->objLanguage = NarroLanguage::GetSoapObjectFromObject($objObject->objLanguage, false); } else { if (!$blnBindRelatedObjects) { $objObject->intLanguageId = null; } } return $objObject; }
/** * Counts all associated NarroFilesAsProject * @return int */ public function CountNarroFilesAsProject() { if (is_null($this->intProjectId)) { return 0; } return NarroFile::CountByProjectId($this->intProjectId); }