コード例 #1
0
ファイル: NarroTextGen.class.php プロジェクト: Jobava/narro
 /**
  * Load all NarroTexts
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return NarroText[]
  */
 public static function LoadAll($objOptionalClauses = null)
 {
     if (func_num_args() > 1) {
         throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
     }
     // Call NarroText::QueryArray to perform the LoadAll query
     try {
         return NarroText::QueryArray(QQ::All(), $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
コード例 #2
0
//                    }
//                }
//
//                $objSuggestion->Save();
//            }
//        }
$intDuplicateTextsDeleted = 0;
foreach (NarroText::LoadAll() as $intVal => $objText) {
    if ($objText->TextValueMd5 == md5($objText->TextValue)) {
        continue;
    }
    try {
        $objText->Save();
    } catch (Exception $objEx) {
        if (strstr($objEx->getMessage(), 'Duplicate')) {
            $arrDuplicateTexts = NarroText::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroText()->TextValue, $objText->TextValue), QQ::NotEqual(QQN::NarroText()->TextId, $objText->TextId)));
            error_log(sprintf('Found duplicates for "%s": %d', $objText->TextValue, count($arrDuplicateTexts)));
            foreach ($arrDuplicateTexts as $objDuplicateText) {
                if ($objText->TextValue !== $objDuplicateText->TextValue) {
                    continue;
                }
                foreach (NarroTextComment::LoadArrayByTextId($objDuplicateText->TextId) as $objTextComment) {
                    error_log('Moving text comment');
                    $objTextComment->TextId = $objText->TextId;
                    $objTextComment->Save();
                }
                foreach (NarroSuggestion::LoadArrayByTextId($objDuplicateText->TextId) as $objSuggestion) {
                    error_log('Moving text from suggestion');
                    $arrDuplicateSuggestions = NarroSuggestion::QueryArray(QQ::AndCondition(QQ::NotEqual(QQN::NarroSuggestion()->SuggestionId, $objSuggestion->SuggestionId), QQ::Equal(QQN::NarroSuggestion()->SuggestionValue, $objSuggestion->SuggestionValue), QQ::Equal(QQN::NarroSuggestion()->TextId, $objText->TextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, $objSuggestion->LanguageId)));
                    if (count($arrDuplicateSuggestions)) {
                        error_log(sprintf('Found duplicates for "%s": %d', $objSuggestion->SuggestionValue, count($arrDuplicateSuggestions)));
コード例 #3
0
 /**
  * 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 = NarroText::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 NarroText, given the clauses above
     $this->DataSource = NarroText::QueryArray($objConditions, $objClauses);
 }