当前位置: 首页>>代码示例>>PHP>>正文


PHP QQN::NarroContextInfo方法代码示例

本文整理汇总了PHP中QQN::NarroContextInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::NarroContextInfo方法的具体用法?PHP QQN::NarroContextInfo怎么用?PHP QQN::NarroContextInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QQN的用法示例。


在下文中一共展示了QQN::NarroContextInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Save

 public function Save($blnForceInsert = false, $blnForceUpdate = false)
 {
     $this->intSuggestionWordCount = NarroString::WordCount($this->strSuggestionValue);
     $this->intSuggestionCharCount = mb_strlen($this->strSuggestionValue);
     $this->strSuggestionValueMd5 = md5($this->strSuggestionValue);
     if (!isset($this->blnIsImported)) {
         $this->blnIsImported = false;
     }
     if (!$this->__blnRestored || $blnForceInsert) {
         $this->dttCreated = QDateTime::Now();
     } else {
         $this->dttModified = QDateTime::Now();
     }
     parent::Save($blnForceInsert, $blnForceUpdate);
     /**
      * Update all context infos with the has suggestion property
      */
     $arrContextInfo = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->TextId, $this->intTextId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->intLanguageId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, 0)));
     foreach ($arrContextInfo as $objOneContextInfo) {
         $objOneContextInfo->HasSuggestions = 1;
         $objOneContextInfo->Modified = QDateTime::Now();
         try {
             $objOneContextInfo->Save();
         } catch (Exception $objEx) {
             NarroLogger::LogWarn($objEx->getMessage());
         }
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:28,代码来源:NarroSuggestion.class.php

示例2: Form_Create

 protected function Form_Create()
 {
     parent::Form_Create();
     // Instantiate the Meta DataGrid
     $this->dtgNarroContextInfos = new NarroContextInfoDataGrid($this);
     // Style the DataGrid (if desired)
     $this->dtgNarroContextInfos->CssClass = 'datagrid';
     $this->dtgNarroContextInfos->AlternateRowStyle->CssClass = 'alternate';
     // Add Pagination (if desired)
     $this->dtgNarroContextInfos->Paginator = new QPaginator($this->dtgNarroContextInfos);
     $this->dtgNarroContextInfos->ItemsPerPage = __FORM_DRAFTS_FORM_LIST_ITEMS_PER_PAGE__;
     // Use the MetaDataGrid functionality to add Columns for this datagrid
     // Create an Edit Column
     $strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/narro_context_info_edit.php';
     $this->dtgNarroContextInfos->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
     // Create the Other Columns (note that you can use strings for narro_context_info's properties, or you
     // can traverse down QQN::narro_context_info() to display fields that are down the hierarchy)
     $this->dtgNarroContextInfos->MetaAddColumn('ContextInfoId');
     $this->dtgNarroContextInfos->MetaAddColumn(QQN::NarroContextInfo()->Context);
     $this->dtgNarroContextInfos->MetaAddColumn(QQN::NarroContextInfo()->Language);
     $this->dtgNarroContextInfos->MetaAddColumn(QQN::NarroContextInfo()->ValidatorUser);
     $this->dtgNarroContextInfos->MetaAddColumn(QQN::NarroContextInfo()->ValidSuggestion);
     $this->dtgNarroContextInfos->MetaAddColumn('HasSuggestions');
     $this->dtgNarroContextInfos->MetaAddColumn('SuggestionAccessKey');
     $this->dtgNarroContextInfos->MetaAddColumn('SuggestionCommandKey');
     $this->dtgNarroContextInfos->MetaAddColumn('Created');
     $this->dtgNarroContextInfos->MetaAddColumn('Modified');
 }
开发者ID:Jobava,项目名称:narro,代码行数:28,代码来源:NarroContextInfoListFormBase.class.php

示例3: GetTranslation

 /**
  * A translation here consists of the project, file, text, translation, context, plurals, approval, ignore equals
  *
  * @param string $strOriginal the original text
  * @param string $strOriginalAccKey access key for the original text
  * @param string $strTranslation the translated text from the import file (can be empty)
  * @param string $strOriginalAccKey access key for the translated text
  * @param string $strContext the context where the text/translation appears in the file
  * @param string $intPluralForm if this is a plural, what plural form is it (0 singular, 1 plural form 1, and so on)
  * @param string $strComment a comment from the imported file
  *
  * @return string valid suggestion
  */
 protected function GetTranslation($strOriginal, $strContext)
 {
     $objNarroContextInfo = NarroContextInfo::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->Context->ContextMd5, md5($strContext)), QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, md5($strOriginal)), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId), QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId)));
     if ($objNarroContextInfo instanceof NarroContextInfo) {
         return $objNarroContextInfo->ValidSuggestion->SuggestionValue;
     } else {
         return $strOriginal;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:22,代码来源:NarroSvgFileImporter.class.php

示例4: GetTranslations

 /**
  * This function does the opposite of GetAccessKeys
  * @param array $arrTemplate an array with context as keys and original texts as values
  * @return array $arrTranslation an array with context as keys and translations as values
  */
 public function GetTranslations($arrTemplate)
 {
     $arrTranslation = array();
     $arrTranslationObjects = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, 1)), QQ::Expand(QQN::NarroContextInfo()->Context));
     foreach ($arrTranslationObjects as $objNarroContextInfo) {
         $arrTranslation[$objNarroContextInfo->Context->Context] = $this->GetExportedSuggestion($objNarroContextInfo);
         if ($arrTranslation[$objNarroContextInfo->Context->Context] === false) {
             if ($this->blnSkipUntranslated == false) {
                 $arrTranslation[$objNarroContextInfo->Context->Context] = $objNarroContextInfo->Context->Text->TextValue;
             } else {
                 unset($arrTranslation[$objNarroContextInfo->Context->Context]);
             }
         }
         if ($objNarroContextInfo->Context->TextAccessKey) {
             if ($objNarroContextInfo->SuggestionAccessKey && isset($arrTemplate[$objNarroContextInfo->Context->Context]->AccessKeyCtx)) {
                 $arrTranslation[$arrTemplate[$objNarroContextInfo->Context->Context]->AccessKeyCtx] = $objNarroContextInfo->SuggestionAccessKey;
             } elseif (isset($arrTemplate[$objNarroContextInfo->Context->Context]->AccessKeyCtx)) {
                 $arrTranslation[$arrTemplate[$objNarroContextInfo->Context->Context]->AccessKeyCtx] = $objNarroContextInfo->Context->TextAccessKey;
             } else {
                 // is there a access key set in the translation ?
                 if ($objNarroContextInfo->SuggestionAccessKey && strstr($arrTranslation[$objNarroContextInfo->Context->Context], $objNarroContextInfo->SuggestionAccessKey)) {
                     $arrTranslation[$objNarroContextInfo->Context->Context] = $this->ApplySuitableAccessKey($arrTranslation[$objNarroContextInfo->Context->Context], $objNarroContextInfo->SuggestionAccessKey);
                 } elseif ($strTextWithAccKey = $this->ApplySuitableAccessKey($arrTranslation[$objNarroContextInfo->Context->Context])) {
                     $arrTranslation[$objNarroContextInfo->Context->Context] = $strTextWithAccKey;
                 }
             }
         }
         if ($objNarroContextInfo->Context->TextCommandKey) {
             if ($objNarroContextInfo->SuggestionCommandKey && isset($arrTemplate[$objNarroContextInfo->Context->Context]->CommandKeyCtx)) {
                 $arrTranslation[$arrTemplate[$objNarroContextInfo->Context->Context]->CommandKeyCtx] = $objNarroContextInfo->SuggestionCommandKey;
             } else {
                 $arrTranslation[$arrTemplate[$objNarroContextInfo->Context->Context]->CommandKeyCtx] = $objNarroContextInfo->Context->TextCommandKey;
             }
         }
     }
     return $arrTranslation;
 }
开发者ID:Jobava,项目名称:narro,代码行数:42,代码来源:NarroMozillaIniFileImporter.class.php

示例5: dtgReviews_Create

 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, '');
 }
开发者ID:Jobava,项目名称:narro,代码行数:45,代码来源:NarroUserSuggestionsPanel.class.php

示例6: GetTranslation

 /**
  * A translation here consists of the project, file, text, translation, context, plurals, approval, ignore equals
  *
  * @param string $strOriginal the original text
  * @param string $strOriginalAccKey access key for the original text
  * @param string $strTranslation the translated text from the import file (can be empty)
  * @param string $strOriginalAccKey access key for the translated text
  * @param string $strContext the context where the text/translation appears in the file
  * @param string $intPluralForm if this is a plural, what plural form is it (0 singular, 1 plural form 1, and so on)
  * @param string $strComment a comment from the imported file
  *
  * @return string valid suggestion
  */
 protected function GetTranslation($strOriginal, $strOriginalAccKey = null, $strOriginalAccKeyPrefix = null, $strTranslation, $strTranslationAccKey = null, $strContext, $strComment = null)
 {
     /**
      * The contexts are trimmed at import to avoid useless white space contexts, so we need to trim it when searching for it as well
      */
     $strContext = trim($strContext);
     if ($strContext != '') {
         $objNarroContextInfo = NarroContextInfo::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, 1), QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, 1), QQ::Equal(QQN::NarroContextInfo()->Context->TextAccessKey, $strOriginalAccKey), QQ::Equal(QQN::NarroContextInfo()->Context->ContextMd5, md5($strContext)), QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, md5($strOriginal)), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId)));
     } else {
         $objNarroContextInfo = NarroContextInfo::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, 1), QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, 1), QQ::Equal(QQN::NarroContextInfo()->Context->TextAccessKey, $strOriginalAccKey), QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, md5($strOriginal)), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId)));
     }
     if ($objNarroContextInfo instanceof NarroContextInfo) {
         $this->objCurrentContext = $objNarroContextInfo;
         $strSuggestionValue = $this->GetExportedSuggestion($objNarroContextInfo);
         if ($strSuggestionValue !== false) {
             $arrResult = QApplication::$PluginHandler->ExportSuggestion($strOriginal, $strSuggestionValue, $strContext, $this->objFile, $this->objProject);
             if ($arrResult[1] != '' && $arrResult[0] == $strOriginal && $arrResult[2] == $strContext && $arrResult[3] == $this->objFile && $arrResult[4] == $this->objProject) {
                 $strSuggestionValue = $arrResult[1];
             } else {
                 NarroLogger::LogWarn(sprintf('The plugin "%s" returned an unexpected result while processing the suggestion "%s": %s', QApplication::$PluginHandler->CurrentPluginName, $strSuggestionValue, join(';', $arrResult)));
             }
             if (!is_null($strOriginalAccKey) && !is_null($strOriginalAccKeyPrefix)) {
                 /**
                  * @todo don't export if there's no valid access key
                  */
                 $strTextWithAccKey = NarroString::Replace($objNarroContextInfo->SuggestionAccessKey, $strOriginalAccKeyPrefix . $objNarroContextInfo->SuggestionAccessKey, $strSuggestionValue, 1);
                 return $strTextWithAccKey;
             } else {
                 return $strSuggestionValue;
             }
         } else {
             // NarroLogger::LogDebug(sprintf('No translation found for the text "%s", while searching for context "%s"', $strOriginal, $strContext));
             return '';
         }
     } else {
         NarroLogger::LogError(sprintf('No context found for the text "%s", while searching for context "%s"', $strOriginal, $strContext));
         return '';
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:52,代码来源:NarroGettextPoFileImporter.class.php

示例7: dtrText_Conditions

 protected function dtrText_Conditions($blnReset = false)
 {
     $this->arrConditions = array(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->LanguageId, QApplication::GetLanguageId()), QQ::Equal(QQN::NarroContextInfo()->Context->Active, true), QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, true)));
     if ($blnReset) {
         $this->intMaxRowCount = 0;
     }
     $this->arrClauses = array(QQ::Expand(QQN::NarroContextInfo()->Context), QQ::Expand(QQN::NarroContextInfo()->Context->Text), QQ::Expand(QQN::NarroContextInfo()->Context->File), QQ::Expand(QQN::NarroContextInfo()->Context->Project), QQ::Expand(QQN::NarroContextInfo()->ValidSuggestion));
     if ($this->lstProject->SelectedValue > 0) {
         $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->lstProject->SelectedValue);
     }
     switch ($this->lstFilter->SelectedValue) {
         case self::SHOW_NOT_TRANSLATED:
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, false);
             break;
         case self::SHOW_NOT_APPROVED:
             $this->arrConditions[] = QQ::AndCondition(QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true));
             break;
         case self::SHOW_APPROVED:
             $this->arrConditions[] = QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId);
             break;
         case self::SHOW_APPROVED_AND_NOT_APPROVED:
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true);
             break;
         case self::SHOW_NOT_APPROVED_AND_NOT_TRANSLATED:
             $this->arrConditions[] = QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId);
             break;
         case self::SHOW_NOT_APPROVED_AND_WITHOUT_VOTES:
             $this->arrConditions[] = QQ::Equal(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0);
             break;
         case self::SHOW_NOT_APPROVED_AND_WITH_VOTES:
             $this->arrConditions[] = QQ::NotEqual(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0);
             break;
         case self::SHOW_IDENTICAL_APPROVED:
             $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
             $this->arrClauses[] = QQ::Distinct();
             $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionId), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId));
             break;
         case self::SHOW_IDENTICAL:
             $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
             $this->arrClauses[] = QQ::Distinct();
             $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId));
             break;
         case self::SHOW_ALL:
         default:
     }
     if ($this->txtFile->Text != t('all files') && $this->txtFile->Text != '') {
         if (preg_match("/^'.+'\$/", $this->txtFile->Text)) {
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1));
         } elseif (preg_match('/^".+"$/', $this->txtFile->Text)) {
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1));
         } else {
             $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->File->FilePath, '%' . $this->txtFile->Text . '%');
         }
     }
     if ($this->txtSearch->Text) {
         if (preg_match("/^'.+'\$/", $this->txtSearch->Text)) {
             $strLikeSearch = substr($this->txtSearch->Text, 1, -1);
         } elseif (preg_match('/^".+"$/', $this->txtSearch->Text)) {
             $strLikeSearch = substr($this->txtSearch->Text, 1, -1);
         } else {
             $strLikeSearch = '%' . $this->txtSearch->Text . '%';
         }
         switch ($this->lstSearchIn->SelectedValue) {
             case self::SEARCH_IN_TEXTS:
                 $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch);
                 break;
             case self::SEARCH_IN_TRANSLATIONS:
                 $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
                 $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId()));
                 break;
             case self::SEARCH_IN_AUTHORS:
                 $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
                 $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId()));
                 break;
             case self::SEARCH_IN_CONTEXTS:
                 $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch));
                 break;
             case self::SEARCH_IN_ALL:
             default:
                 $this->arrClauses[] = QQ::Distinct();
                 $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch));
         }
     }
     switch ($this->lstSort->SelectedValue) {
         case self::SORT_TEXT:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextValue, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TEXT_LENGTH:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextWordCount, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TRANSLATION:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->ValidSuggestion->SuggestionValue, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TRANSLATION_DATE:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Modified, $this->lstSortDir->SelectedValue);
             break;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:98,代码来源:NarroTranslatePanel.class.php

示例8: sprintf

 if (isset($objProject) && $objProject instanceof NarroProject) {
     $strCacheId = sprintf('rssfeed_context_info_changes_%d_%d', $objProject->ProjectId, QApplication::QueryString('l'));
 } else {
     $strCacheId = sprintf('rssfeed_context_info_changes_%d', QApplication::QueryString('l'));
 }
 if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) {
     $objRssFeed = new QRssFeed(sprintf(t('Context changes in %s'), t(QApplication::$TargetLanguage->LanguageName)), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest context information changes in %s'), t(QApplication::$TargetLanguage->LanguageName)));
     $objRssFeed->PubDate = new QDateTime(QDateTime::Now);
     $objRssFeed->Language = strtolower(str_replace('_', '-', QApplication::$TargetLanguage->LanguageCode));
     $strDescription = '';
     if (isset($objProject) && $objProject instanceof NarroProject) {
         $objCondition = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->LanguageId, QApplication::GetLanguageId()), QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $objProject->ProjectId));
     } else {
         $objCondition = QQ::Equal(QQN::NarroContextInfo()->LanguageId, QApplication::GetLanguageId());
     }
     foreach (NarroContextInfo::QueryArray($objCondition, array(QQ::OrderBy(QQN::NarroContextInfo()->Modified, 0), QQ::LimitInfo(20, 0))) as $intKey => $objNarroContextInfo) {
         $strContextLink = sprintf(__HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . NarroLink::Translate($objNarroContextInfo->Context->ProjectId, '', 0, '', 0, 0, 10, 0, $objNarroContextInfo->ContextInfoId));
         $strProjectLink = sprintf(__HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . NarroLink::ProjectTextList($objNarroContextInfo->Context->ProjectId, NarroTranslatePanel::SHOW_ALL, ''));
         $strUserLink = __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . NarroLink::UserProfile($objNarroContextInfo->ValidatorUserId);
         if (isset($objProject) && $objProject instanceof NarroProject) {
             $strItemName = '';
         } else {
             $strItemName = $objNarroContextInfo->Context->Project->ProjectName . ' :: ';
         }
         $objItem = new QRssItem($strItemName . (strlen($objNarroContextInfo->Context->Text->TextValue) > 124 ? substr($objNarroContextInfo->Context->Text->TextValue, 0, 124) . '...' : $objNarroContextInfo->Context->Text->TextValue), $strContextLink);
         $objItem->Description = sprintf('<p>' . t('Project') . ': <a href="%s">%s</a></p>', $strProjectLink, $objNarroContextInfo->Context->Project->ProjectName) . sprintf('<p>' . t('Context') . ': <a href="%s">%s</a></p>', $strContextLink, NarroString::HtmlEntities($objNarroContextInfo->Context->Context)) . sprintf('<p>' . t('Original text') . ': %s</p>', $objNarroContextInfo->Context->TextAccessKey ? NarroString::Replace($objNarroContextInfo->Context->TextAccessKey, '<u>' . $objNarroContextInfo->Context->TextAccessKey . '</u>', NarroString::HtmlEntities($objNarroContextInfo->Context->Text->TextValue), 1) : NarroString::HtmlEntities($objNarroContextInfo->Context->Text->TextValue)) . ($objNarroContextInfo->ValidSuggestionId ? sprintf('<p>' . t('Approved suggestion') . ': %s</p>', $objNarroContextInfo->Context->TextAccessKey ? NarroString::Replace($objNarroContextInfo->SuggestionAccessKey, '<u>' . $objNarroContextInfo->SuggestionAccessKey . '</u>', NarroString::HtmlEntities($objNarroContextInfo->ValidSuggestion->SuggestionValue), 1) : NarroString::HtmlEntities($objNarroContextInfo->ValidSuggestion->SuggestionValue)) : '') . ($objNarroContextInfo->HasSuggestions ? sprintf(t('The text has %s suggestions'), NarroSuggestion::QueryCount(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestion()->TextId, $objNarroContextInfo->Context->TextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, QApplication::GetLanguageId())))) : t('The text has no suggestions')) . ($objNarroContextInfo->ValidSuggestionId && $objNarroContextInfo->ValidatorUserId != NarroUser::ANONYMOUS_USER_ID ? sprintf('<p>' . t('Approved by') . ': <a href="%s">%s</a>', $strUserLink, $objNarroContextInfo->ValidSuggestionId ? $objNarroContextInfo->ValidatorUser->RealName : '') : '');
         $objItem->PubDate = new QDateTime($objNarroContextInfo->Modified);
         $objItem->Author = $objNarroContextInfo->ValidSuggestionId ? $objNarroContextInfo->ValidatorUser->RealName : '';
         $objRssFeed->AddItem($objItem);
         $strDescription = '';
     }
开发者ID:Jobava,项目名称:narro,代码行数:31,代码来源:rss.php

示例9: UpdateProjectProgress

 protected function UpdateProjectProgress($intLanguageId, $strColumn, $intValue)
 {
     $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->ProjectId, $intLanguageId);
     $blnChanged = false;
     if (!$objProjectProgress instanceof NarroProjectProgress) {
         $objProjectProgress = new NarroProjectProgress();
         $objProjectProgress->LanguageId = $intLanguageId;
         $objProjectProgress->ProjectId = $this->ProjectId;
         $objProjectProgress->TotalTextCount = 0;
         $objProjectProgress->ApprovedTextCount = 0;
         $objProjectProgress->FuzzyTextCount = 0;
         $objProjectProgress->ProgressPercent = 0;
         $objProjectProgress->Active = $this->Active;
         $objProjectProgress->LastModified = QDateTime::Now();
         $blnChanged = true;
     }
     // Nothing changed
     if (!$blnChanged && $objProjectProgress->{$strColumn} == $intValue) {
         return true;
     }
     $objProjectProgress->{$strColumn} = $intValue;
     if ($objProjectProgress->TotalTextCount) {
         $objProjectProgress->ProgressPercent = floor($objProjectProgress->ApprovedTextCount * 100 / $objProjectProgress->TotalTextCount);
     } else {
         $objProjectProgress->ProgressPercent = 0;
     }
     $objLastContextInfo = NarroContextInfo::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->intProjectId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, true), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $intLanguageId)), QQ::OrderBy(QQN::NarroContextInfo()->Modified, 0));
     if ($objLastContextInfo) {
         $objProjectProgress->LastModified = $objLastContextInfo->Modified;
     }
     $objProjectProgress->Save();
     return true;
 }
开发者ID:Jobava,项目名称:narro,代码行数:33,代码来源:NarroProject.class.php

示例10: GetContextInfoArray

 protected function GetContextInfoArray()
 {
     $this->arrContextInfo = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId)), array(QQ::Expand(QQN::NarroContextInfo()->Context->Text), QQ::LimitInfo(500)));
 }
开发者ID:Jobava,项目名称:narro,代码行数:4,代码来源:NarroFileImporter.class.php

示例11: GetTranslation

 /**
  * A translation here consists of the project, file, text, translation, context, plurals, approval, ignore equals
  *
  * @param string $strOriginal the original text
  * @param string $strOriginalAccKey access key for the original text
  * @param string $strTranslation the translated text from the import file (can be empty)
  * @param string $strOriginalAccKey access key for the translated text
  * @param string $strContext the context where the text/translation appears in the file
  * @param string $intPluralForm if this is a plural, what plural form is it (0 singular, 1 plural form 1, and so on)
  * @param string $strComment a comment from the imported file
  *
  * @return string valid suggestion
  */
 protected function GetTranslation($strOriginal, $strOriginalAccKey = null, $strOriginalAccKeyPrefix = null, $strTranslation, $strTranslationAccKey = null, $strContext, $strComment = null)
 {
     $objNarroContextInfo = NarroContextInfo::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->Context->ContextMd5, md5(trim($strContext))), QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, md5($strOriginal)), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId)));
     if ($objNarroContextInfo instanceof NarroContextInfo) {
         $strSuggestionValue = $this->GetExportedSuggestion($objNarroContextInfo);
         $arrResult = QApplication::$PluginHandler->ExportSuggestion($strOriginal, $strSuggestionValue, $strContext, $this->objFile, $this->objProject);
         if ($arrResult[1] != '' && $arrResult[0] == $strOriginal && $arrResult[2] == $strContext && $arrResult[3] == $this->objFile && $arrResult[4] == $this->objProject) {
             $strSuggestionValue = $arrResult[1];
         } else {
             NarroLogger::LogWarn(sprintf('The plugin "%s" returned an unexpected result while processing the suggestion "%s": %s', QApplication::$PluginHandler->CurrentPluginName, $strTranslation, $strTranslation));
         }
         if (!is_null($strOriginalAccKey) && !is_null($strOriginalAccKeyPrefix)) {
             /**
              * @todo don't export if there's no valid access key
              */
             $strTextWithAccKey = NarroString::Replace($objNarroContextInfo->SuggestionAccessKey, $strOriginalAccKeyPrefix . $objNarroContextInfo->SuggestionAccessKey, $strSuggestionValue, 1);
             return $strTextWithAccKey;
         } else {
             return $strSuggestionValue;
         }
     } else {
         /**
          * leave it untranslated
          */
         return $strOriginal;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:40,代码来源:NarroDumbGettextPoFileImporter.class.php

示例12: ExportFile

 public function ExportFile($strTemplateFile, $strTranslatedFile)
 {
     $hndTranslatedFile = @fopen($strTranslatedFile, 'w');
     if (!$hndTranslatedFile) {
         throw new Exception(sprintf('Can\'t open file "%s" for writing', $strTranslatedFile));
     }
     $intTotalToProcess = NarroUtils::CountFileLines($strTemplateFile);
     /**
      * get all the texts and contexts from the template file, including the file line
      */
     $arrTexts = $this->FileToArray($strTemplateFile, $this->objSourceLanguage->LanguageCode, true);
     // NarroLogger::LogDebug(sprintf('Starting to process file "%s" (%d texts), the result is written to "%s".', $strTemplateFile, $intTotalToProcess, $strTranslatedFile));
     $intFileLineNr = 0;
     foreach ($arrTexts as $strContext => $arrTextInfo) {
         $strText = $arrTextInfo[0];
         $strTextAccKey = $arrTextInfo[1];
         $strTextAccKeyPrefix = $arrTextInfo[2];
         $strFileLine = $arrTextInfo[3];
         $intFileLineNr++;
         $arrColumn = preg_split('/\\t/', $strFileLine);
         /**
          * Unset a number before language code
          */
         $arrColumn[8] = '';
         /**
          * create a copy for the translated line, we'll just replace lang code, the number on column 8 and the text with the translation
          */
         $arrTranslatedColumn = $arrColumn;
         $arrTranslatedColumn[8] = 0;
         $arrTranslatedColumn[9] = 'ro';
         $objNarroContextInfo = $this->GetContextInfo($strText, $strContext);
         if (!$objContextInfo) {
             // NarroLogger::LogDebug('No context info found, trying database');
             $objContextInfo = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId), QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, md5($strText)), QQ::Equal(QQN::NarroContextInfo()->Context->ContextMd5, md5($strContext))));
         }
         /**
          * the original texts are used if no suggestion is found, so we export only approved texts
          */
         if ($objNarroContextInfo instanceof NarroContextInfo) {
             $strSuggestionValue = $this->GetExportedSuggestion($objNarroContextInfo);
         } else {
             // NarroLogger::LogDebug('No context info found, skipping');
             continue;
         }
         if (!isset($strSuggestionValue) || !$strSuggestionValue) {
             continue;
         }
         if ($objNarroContextInfo->Context->TextAccessKey != '') {
             if ($objNarroContextInfo->ValidSuggestionId && $objNarroContextInfo->SuggestionAccessKey != '') {
                 $strSuggestionValue = NarroString::Replace($objNarroContextInfo->SuggestionAccessKey, $strTextAccKeyPrefix . $objNarroContextInfo->SuggestionAccessKey, $strSuggestionValue, 1);
             } else {
                 $strSuggestionValue = $strTextAccKeyPrefix . $strSuggestionValue;
             }
         }
         $arrTranslatedColumn[10] = str_replace(array("\n", "\r"), array("", ""), $strSuggestionValue);
         preg_match_all('/\\\\"/', $strText, $arrEscOrigMatches);
         preg_match_all('/\\\\"/', $strSuggestionValue, $arrEscTransMatches);
         if (isset($arrEscOrigMatches[0]) && count($arrEscTransMatches[0]) % 2 != 0) {
             NarroLogger::LogWarn(sprintf('Warning! The translated text "%s" has unclosed double quotes.', $strSuggestionValue));
             continue;
         }
         fwrite($hndTranslatedFile, join("\t", $arrColumn));
         fwrite($hndTranslatedFile, join("\t", $arrTranslatedColumn));
     }
     fclose($hndTranslatedFile);
     if (filesize($strTranslatedFile) == 0) {
         unlink($strTranslatedFile);
     } else {
         chmod($strTranslatedFile, 0666);
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:71,代码来源:NarroOpenOfficeSdfFileImporter.class.php

示例13: ExportFile

 public function ExportFile($strTemplateFile, $strTranslatedFile)
 {
     $strTemplateContents = file_get_contents($strTemplateFile);
     if (!$strTemplateContents) {
         NarroLogger::LogWarn(sprintf('Found a empty template (%s), copying the original', $strTemplateFile));
         copy($strTemplateFile, $strTranslatedFile);
         chmod($strTranslatedFile, 0666);
         return false;
     }
     if (strstr($strTemplateContents, '#define MOZ_LANGPACK_CONTRIBUTORS')) {
         $strTemplateContents = preg_replace('/^#\\s+#define MOZ_LANGPACK_CONTRIBUTORS.*$/m', '#define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Joe Solon</em:contributor> <em:contributor>Suzy Solon</em:contributor>', $strTemplateContents);
     }
     $arrTemplateContents = explode("\n", $strTemplateContents);
     $strComment = '';
     foreach ($arrTemplateContents as $intPos => $strLine) {
         if (preg_match('/^#define\\s+([^\\s]+)\\s+(.+)$/s', trim($strLine), $arrMatches)) {
             $arrTemplate[trim($arrMatches[1])] = trim($arrMatches[2]);
             $arrTemplateLines[trim($arrMatches[1])] = $arrMatches[0];
             $arrTemplateComment[trim($arrMatches[1])] = $strComment;
             $strComment = '';
         } elseif (trim($strLine) != '' && $strLine[0] != '#') {
             // NarroLogger::LogDebug(sprintf('Skipped line "%s" from the template "%s".', $strLine, $this->objFile->FileName));
         } elseif ($strLine[0] == '#') {
             $strComment .= "\n" . $strLine;
         }
     }
     $strTranslateContents = '';
     if (count($arrTemplate) < 1) {
         return false;
     }
     $arrTranslationObjects = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, 1)));
     foreach ($arrTranslationObjects as $objNarroContextInfo) {
         if ($objNarroContextInfo->ValidSuggestionId > 0) {
             $arrTranslation[$objNarroContextInfo->Context->Context] = $this->GetExportedSuggestion($objNarroContextInfo);
             if ($arrTranslation[$objNarroContextInfo->Context->Context] === false) {
                 $arrTranslation[$objNarroContextInfo->Context->Context] = $objNarroContextInfo->Context->Text->TextValue;
             }
             if ($objNarroContextInfo->Context->TextAccessKey) {
                 if ($objNarroContextInfo->SuggestionAccessKey) {
                     $strAccessKey = $objNarroContextInfo->SuggestionAccessKey;
                 } else {
                     $strAccessKey = $objNarroContextInfo->Context->TextAccessKey;
                 }
                 $arrTranslation[$objNarroContextInfo->Context->Context] = preg_replace('/' . $strAccessKey . '/', '&' . $strAccessKey, $arrTranslation[$objNarroContextInfo->Context->Context], 1);
                 NarroImportStatistics::$arrStatistics['Texts that have access keys']++;
             } else {
                 NarroImportStatistics::$arrStatistics["Texts that don't have access keys"]++;
             }
         } else {
             // NarroLogger::LogDebug(sprintf('In file "%s", the context "%s" does not have a valid suggestion.', $this->objFile->FileName, $objNarroContextInfo->Context->Context));
             NarroImportStatistics::$arrStatistics['Texts without valid suggestions']++;
             NarroImportStatistics::$arrStatistics['Texts kept as original']++;
         }
     }
     $strTranslateContents = $strTemplateContents;
     foreach ($arrTemplate as $strKey => $strOriginalText) {
         if (isset($arrTranslation[$strKey])) {
             $arrResult = QApplication::$PluginHandler->ExportSuggestion($strOriginalText, $arrTranslation[$strKey], $strKey, $this->objFile, $this->objProject);
             if ($arrResult[1] != '' && $arrResult[0] == $strOriginalText && $arrResult[2] == $strKey && $arrResult[3] == $this->objFile && $arrResult[4] == $this->objProject) {
                 $arrTranslation[$strKey] = $arrResult[1];
             } else {
                 NarroLogger::LogWarn(sprintf('The plugin "%s" returned an unexpected result while processing the suggestion "%s": %s', QApplication::$PluginHandler->CurrentPluginName, $arrTranslation[$strKey], var_export($arrResult, true)));
             }
             if (strstr($strTranslateContents, sprintf('#define %s %s', $strKey, $strOriginalText))) {
                 $strTranslateContents = str_replace(sprintf('#define %s %s', $strKey, $strOriginalText), sprintf('#define %s %s', $strKey, $arrTranslation[$strKey]), $strTranslateContents);
             } else {
                 NarroLogger::LogWarn(sprintf('Can\'t find "%s" in the file "%s"'), $strKey . $strGlue . $strOriginalText, $this->objFile->FileName);
             }
             if (strstr($arrTranslation[$strKey], "\n")) {
                 NarroLogger::LogWarn(sprintf('Skpping translation "%s" because it has a newline in it'), $arrTranslation[$strKey]);
                 continue;
             }
         } else {
             // NarroLogger::LogDebug(sprintf('Couldn\'t find the key "%s" in the translations, using the original text.', $strKey, $this->objFile->FileName));
             NarroImportStatistics::$arrStatistics['Texts kept as original']++;
             if ($this->blnSkipUntranslated == true) {
             }
             if ($this->blnSkipUntranslated == true) {
                 if (isset($arrTemplateComment[$strKey]) && $arrTemplateComment[$strKey] != '') {
                     $strTranslateContents = str_replace($arrTemplateComment[$strKey] . "\n", "\n", $strTranslateContents);
                     $strTranslateContents = str_replace(sprintf("#define %s %s\n", $strKey, $strOriginalText), '', $strTranslateContents);
                 }
             }
         }
     }
     if (file_exists($strTranslatedFile) && !is_writable($strTranslatedFile) && !unlink($strTranslatedFile)) {
         NarroLogger::LogError(sprintf('Can\'t delete the file "%s"', $strTranslatedFile));
     }
     if (!file_put_contents($strTranslatedFile, $strTranslateContents)) {
         NarroLogger::LogError(sprintf('Can\'t write to file "%s"', $strTranslatedFile));
     }
     @chmod($strTranslatedFile, 0666);
 }
开发者ID:Jobava,项目名称:narro,代码行数:93,代码来源:NarroMozillaIncFileImporter.class.php

示例14: CountByFileName

 public static function CountByFileName($strFileName, $intFilter, $objExtraCondition = null)
 {
     if (!is_object($objExtraCondition)) {
         $objExtraCondition = QQ::All();
     }
     if (trim($strFileName) == '') {
         $objSearchCondition = QQ::All();
     } elseif (preg_match("/^'.*'\$/", $strFileName)) {
         $objSearchCondition = QQ::Equal(QQN::NarroContextInfo()->Context->File->FileName, substr($strFileName, 1, -1));
     } else {
         $objSearchCondition = QQ::Like(QQN::NarroContextInfo()->Context->File->FileName, '%' . $strFileName . '%');
     }
     switch ($intFilter) {
         case NarroTextListForm::SHOW_UNTRANSLATED_TEXTS:
             $objFilterCondition = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, 0);
             break;
         case NarroTextListForm::SHOW_APPROVED_TEXTS:
             $objFilterCondition = QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId);
             break;
         case NarroTextListForm::SHOW_TEXTS_THAT_REQUIRE_APPROVAL:
             $objFilterCondition = QQ::AndCondition(QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, 1));
             break;
         default:
             // no filters
             $objFilterCondition = QQ::All();
     }
     $intContextCount = NarroContextInfo::QueryCount(QQ::AndCondition($objSearchCondition, $objFilterCondition, $objExtraCondition), array(QQ::GroupBy(QQN::NarroContextInfo()->ContextId)));
     return $intContextCount;
 }
开发者ID:Jobava,项目名称:narro,代码行数:29,代码来源:NarroContextInfo.class.php

示例15: ExportFile

 public function ExportFile($strTemplateFile, $strTranslatedFile)
 {
     $arrSourceKey = $this->FileAsArray($strTemplateFile);
     $intElapsedTime = time() - $intTime;
     if ($intElapsedTime > 0) {
         // NarroLogger::LogDebug(sprintf('Preprocessing %s took %d seconds.', $this->objFile->FileName, $intElapsedTime));
     }
     // NarroLogger::LogDebug(sprintf('Found %d contexts in file %s.', count($arrSourceKey), $this->objFile->FileName));
     if (is_array($arrSourceKey)) {
         $arrTranslationObjects = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->FileId, $this->objFile->FileId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->objTargetLanguage->LanguageId), QQ::Equal(QQN::NarroContextInfo()->Context->Active, 1)));
         foreach ($arrTranslationObjects as $objNarroContextInfo) {
             $strTranslation = $this->GetExportedSuggestion($objNarroContextInfo);
             if (isset($arrSourceKey[$objNarroContextInfo->Context->Context])) {
                 $arrSourceKey[$objNarroContextInfo->Context->Context]->Value = $strTranslation;
             } else {
                 if ($this->blnSkipUntranslated == false) {
                     $arrSourceKey[$objNarroContextInfo->Context->Context]->Value = $objNarroContextInfo->Context->Text->TextValue;
                 } else {
                     unset($arrTranslation[$objNarroContextInfo->Context->Context]);
                 }
             }
         }
         $hndTranslationFile = fopen($strTranslatedFile, 'w');
         foreach ($arrSourceKey as $strContext => $objEntity) {
             /* @var $objEntity NarroFileEntity */
             fwrite($hndTranslationFile, $objEntity->Key . "\n");
             fwrite($hndTranslationFile, $objEntity->Comment . "\n");
             fwrite($hndTranslationFile, $objEntity->Value . "\n\n");
         }
         fclose($hndTranslationFile);
         NarroUtils::Chmod($strTranslatedFile, 0666);
         return true;
     } else {
         NarroLogger::LogWarn(sprintf('Found a empty template (%s), copying the original', $strTemplateFile));
         copy($strTemplateFile, $strTranslatedFile);
         NarroUtils::Chmod($strTranslatedFile, 0666);
         return false;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:39,代码来源:NarroSrtFileImporter.class.php


注:本文中的QQN::NarroContextInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。