/** * 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 = NarroContext::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 NarroContext, given the clauses above $this->DataSource = NarroContext::QueryArray($objConditions, $objClauses); }
/** * Load an array of NarroContext objects, * by Active Index(es) * @param boolean $blnActive * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query * @return NarroContext[] */ public static function LoadArrayByActive($blnActive, $objOptionalClauses = null) { // Call NarroContext::QueryArray to perform the LoadArrayByActive query try { return NarroContext::QueryArray(QQ::Equal(QQN::NarroContext()->Active, $blnActive), $objOptionalClauses); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
$objRssFeed = new QRssFeed(t('Comments on texts'), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, t('Get the latest debates on texts')); } if (isset($objProject) && $objProject instanceof NarroProject) { $strSqlQuery = sprintf('SELECT DISTINCT narro_text_comment.* FROM narro_text_comment, narro_context WHERE narro_text_comment.text_id=narro_context.text_id AND narro_context.active=1 AND narro_context.project_id=%d AND narro_text_comment.language_id=%d ORDER BY created DESC LIMIT 0, 20', $objProject->ProjectId, QApplication::GetLanguageId()); } else { $strSqlQuery = sprintf('SELECT DISTINCT narro_text_comment.* FROM narro_text_comment WHERE narro_text_comment.language_id=%d ORDER BY created DESC LIMIT 0, 20', QApplication::GetLanguageId()); } $objDatabase = QApplication::$Database[1]; $objDbResult = $objDatabase->Query($strSqlQuery); if ($objDbResult) { $arrTextComment = NarroTextComment::InstantiateDbResult($objDbResult); foreach ($arrTextComment as $objTextComment) { if (isset($objProject) && $objProject instanceof NarroProject) { $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->ProjectId, $objProject->ProjectId), QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1))); } else { $arrContext = NarroContext::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContext()->TextId, $objTextComment->TextId), QQ::Equal(QQN::NarroContext()->Active, 1))); } if (count($arrContext)) { $arrProjectLinks = array(); $arrProjects = array(); $strDescription = sprintf(' <span style="font-size:80%%;color:gray;">' . t('%s wrote on %s:') . '</span> <br /> <span style="margin-left:5px;padding:3px;">%s</span>', NarroLink::UserProfile($objTextComment->UserId, '<b>' . $objTextComment->User->RealName . '</b>'), $objTextComment->Created, nl2br($objTextComment->CommentText)); foreach ($arrContext as $objContext) { $arrProjects[$objContext->ProjectId] = $objContext->Project->ProjectName; $strContextLink = __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/' . '#textcomments'; } asort($arrProjects); if (count($arrProjects)) { $strDescription .= sprintf('