Пример #1
0
 /**
  * Returns class instance
  *
  * @return FORUM_BOL_PostDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Пример #2
0
 public function searchInTopic($token, $userToken, $topicId, $sortBy = null)
 {
     $posts = $this->postDao->searchInTopic($token, $userToken, $topicId, $sortBy);
     if ($posts) {
         $topic = $this->findTopicById($topicId);
         if (!$topic) {
             return null;
         }
         $groupInfo = $this->getGroupInfo($topic->groupId);
         $forumSection = $this->findSectionById($groupInfo->sectionId);
         $highlight = mb_strlen($token) != 0;
         $parentTopic = array();
         $parentTopic['userId'] = $topic->userId;
         $parentTopic['title'] = $highlight ? $this->highlightSearchWords($topic->title, $token) : $topic->title;
         $parentTopic['topicUrl'] = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topic->id));
         $parentTopic['groupId'] = $topic->groupId;
         $parentTopic['sectionId'] = $groupInfo->sectionId;
         $parentTopic['groupName'] = $groupInfo->name;
         $parentTopic['sectionName'] = $forumSection->name;
         foreach ($posts as $postDto) {
             $formatter = new FORUM_CLASS_ForumSearchResultFormatter();
             $text = strip_tags($postDto->text);
             $postInfo = array('postId' => $postDto->id, 'topicId' => $postDto->topicId, 'userId' => $postDto->userId, 'text' => $formatter->formatResult($text, array($token), $highlight), 'createStamp' => UTIL_DateTime::formatDate($postDto->createStamp), 'postUrl' => $this->getPostUrl($postDto->topicId, $postDto->id));
             $parentTopic['posts'][$postDto->id] = $postInfo;
         }
         return array($parentTopic);
     }
     return null;
 }
Пример #3
0
 public function findTemporaryTopicList($limit)
 {
     $postDao = FORUM_BOL_PostDao::getInstance();
     $query = "SELECT `t`.* FROM `" . $this->getTableName() . "` AS `t`\n            LEFT JOIN `" . $postDao->getTableName() . "` AS `p` ON (`t`.`lastPostId`=`p`.`id`)\n            WHERE `t`.`temp` = 1 AND `p`.`createStamp` < :ts";
     return $this->dbo->queryForList($query, array('ts' => time() - 3600 * 24 * 5));
 }
Пример #4
0
 public function getAttachmentsCountByTopicIdList($topicIds)
 {
     $postDao = FORUM_BOL_PostDao::getInstance();
     $query = "\n            SELECT `p`.`topicId`, COUNT(*) AS `attachments`\n            FROM `" . $this->getTableName() . "` AS `a`\n            LEFT JOIN `" . $postDao->getTableName() . "` AS `p` ON (`a`.`postId`=`p`.`id`)\n            WHERE `p`.`topicId` IN (" . $this->dbo->mergeInClause($topicIds) . ")\n            GROUP BY `topicId`\n        ";
     return $this->dbo->queryForList($query);
 }