Ejemplo n.º 1
0
 public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false)
 {
     // Get the Database Object for this Class
     $objDatabase = NarroTextComment::GetDatabase();
     $strQuery = NarroTextComment::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
     $objCache = new QCache('qquery/narrotextcomment', $strQuery);
     $cacheData = $objCache->GetData();
     if (!$cacheData || $blnForceUpdate) {
         $objDbResult = $objQueryBuilder->Database->Query($strQuery);
         $arrResult = NarroTextComment::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
         $objCache->SaveData(serialize($arrResult));
     } else {
         $arrResult = unserialize($cacheData);
     }
     return $arrResult;
 }
Ejemplo n.º 2
0
Archivo: rss.php Proyecto: Jobava/narro
 }
 if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) {
     if (isset($objProject) && $objProject instanceof NarroProject) {
         $objRssFeed = new QRssFeed(sprintf(t('Comments on texts from %s'), $objProject->ProjectName), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest debates on texts from the project %s'), $objProject->ProjectName));
     } else {
         $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;