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


PHP Thread::newFromRow方法代码示例

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


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

示例1: createFeedItem

 private function createFeedItem($row)
 {
     global $wgOut;
     $thread = Thread::newFromRow($row);
     $linker = new Linker();
     $titleStr = $thread->subject();
     $completeText = $thread->root()->getContent();
     $completeText = $wgOut->parse($completeText);
     $threadTitle = clone $thread->topmostThread()->title();
     $threadTitle->setFragment('#' . $thread->getAnchorName());
     $titleUrl = $threadTitle->getFullURL();
     $timestamp = $thread->created();
     $user = $thread->author()->getName();
     // Grab the title for the superthread, if one exists.
     $stTitle = null;
     if ($thread->hasSuperThread()) {
         $stTitle = clone $thread->topmostThread()->title();
         $stTitle->setFragment('#' . $thread->superthread()->getAnchorName());
     }
     // Prefix content with a quick description
     $userLink = $linker->userLink($thread->author()->getId(), $user);
     $talkpageLink = $linker->link($thread->getTitle());
     $superthreadLink = $linker->link($stTitle);
     $description = wfMsgExt($thread->hasSuperThread() ? 'lqt-feed-reply-intro' : 'lqt-feed-new-thread-intro', array('parse', 'replaceafter'), array($talkpageLink, $userLink, $superthreadLink));
     $completeText = $description . $completeText;
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:ApiFeedLQTThreads.php

示例2: createFeedItem

 private function createFeedItem($row)
 {
     $thread = Thread::newFromRow($row);
     $titleStr = $thread->subject();
     $completeText = $thread->root()->getContent();
     $completeText = $this->getOutput()->parse($completeText);
     $threadTitle = clone $thread->topmostThread()->title();
     $threadTitle->setFragment('#' . $thread->getAnchorName());
     $titleUrl = $threadTitle->getFullURL();
     $timestamp = $thread->created();
     $user = $thread->author()->getName();
     // Prefix content with a quick description
     $userLink = Linker::userLink($thread->author()->getId(), $user);
     $talkpageLink = Linker::link($thread->getTitle());
     if ($thread->hasSuperThread()) {
         $stTitle = clone $thread->topmostThread()->title();
         $stTitle->setFragment('#' . $thread->superthread()->getAnchorName());
         $superthreadLink = Linker::link($stTitle);
         $description = wfMessage('lqt-feed-reply-intro')->rawParams($talkpageLink, $userLink, $superthreadLink)->params($user)->parseAsBlock();
     } else {
         // Third param is unused
         $description = wfMessage('lqt-feed-new-thread-intro')->rawParams($talkpageLink, $userLink, '')->params($user)->parseAsBlock();
     }
     $completeText = $description . $completeText;
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:26,代码来源:ApiFeedLQTThreads.php

示例3: loadFromResult

 static function loadFromResult($res, $db, $bulkLoad = false)
 {
     $rows = array();
     $threads = array();
     foreach ($res as $row) {
         $rows[] = $row;
         if (!$bulkLoad) {
             $threads[$row->thread_id] = Thread::newFromRow($row);
         }
     }
     if (!$bulkLoad) {
         return $threads;
     }
     return Thread::bulkLoad($rows);
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:15,代码来源:Threads.php

示例4: bulkLoad

 static function bulkLoad($rows)
 {
     // Preload subthreads
     $top_thread_ids = array();
     $all_thread_rows = $rows;
     $pageIds = array();
     $linkBatch = new LinkBatch();
     $userIds = array();
     $loadEditorsFor = array();
     $dbr = wfGetDB(DB_SLAVE);
     if (!is_array(self::$replyCacheById)) {
         self::$replyCacheById = array();
     }
     // Build a list of threads for which to pull replies, and page IDs to pull data for.
     //  Also, pre-initialise the reply cache.
     foreach ($rows as $row) {
         if ($row->thread_ancestor) {
             $top_thread_ids[] = $row->thread_ancestor;
         } else {
             $top_thread_ids[] = $row->thread_id;
         }
         // Grab page data while we're here.
         if ($row->thread_root) {
             $pageIds[] = $row->thread_root;
         }
         if ($row->thread_summary_page) {
             $pageIds[] = $row->thread_summary_page;
         }
         if (!isset(self::$replyCacheById[$row->thread_id])) {
             self::$replyCacheById[$row->thread_id] = array();
         }
     }
     $all_thread_ids = $top_thread_ids;
     // Pull replies to the threads provided, and as above, pull page IDs to pull data for,
     //  pre-initialise the reply cache, and stash the row object for later use.
     if (count($top_thread_ids)) {
         $res = $dbr->select('thread', '*', array('thread_ancestor' => $top_thread_ids, 'thread_type != ' . $dbr->addQuotes(Threads::TYPE_DELETED)), __METHOD__);
         foreach ($res as $row) {
             // Grab page data while we're here.
             if ($row->thread_root) {
                 $pageIds[] = $row->thread_root;
             }
             if ($row->thread_summary_page) {
                 $pageIds[] = $row->thread_summary_page;
             }
             $all_thread_rows[] = $row;
             $all_thread_ids[$row->thread_id] = $row->thread_id;
         }
     }
     // Pull thread reactions
     if (count($all_thread_ids)) {
         $res = $dbr->select('thread_reaction', '*', array('tr_thread' => $all_thread_ids), __METHOD__);
         foreach ($res as $row) {
             $thread_id = $row->tr_thread;
             $user = $row->tr_user_text;
             $info = array('type' => $row->tr_type, 'user-id' => $row->tr_user, 'user-name' => $row->tr_user_text, 'value' => $row->tr_value);
             $type = $info['type'];
             $user = $info['user-name'];
             if (!isset(self::$reactionCacheById[$thread_id])) {
                 self::$reactionCacheById[$thread_id] = array();
             }
             if (!isset(self::$reactionCacheById[$thread_id][$type])) {
                 self::$reactionCacheById[$thread_id][$type] = array();
             }
             self::$reactionCacheById[$thread_id][$type][$user] = $info;
         }
     }
     // Preload page data (restrictions, and preload Article object with everything from
     //  the page table. Also, precache the title and article objects for pulling later.
     $articlesById = array();
     if (count($pageIds)) {
         // Pull restriction info. Needs to come first because otherwise it's done per
         //  page by loadPageData.
         $restrictionRows = array_fill_keys($pageIds, array());
         $res = $dbr->select('page_restrictions', '*', array('pr_page' => $pageIds), __METHOD__);
         foreach ($res as $row) {
             $restrictionRows[$row->pr_page][] = $row;
         }
         $res = $dbr->select('page', '*', array('page_id' => $pageIds), __METHOD__);
         foreach ($res as $row) {
             $t = Title::newFromRow($row);
             if (isset($restrictionRows[$t->getArticleId()])) {
                 $t->loadRestrictionsFromRows($restrictionRows[$t->getArticleId()], $row->page_restrictions);
             }
             $article = new Article($t);
             $article->loadPageData($row);
             self::$titleCacheById[$t->getArticleId()] = $t;
             $articlesById[$article->getId()] = $article;
             if (count(self::$titleCacheById) > 10000) {
                 self::$titleCacheById = array();
             }
         }
     }
     // For every thread we have a row object for, load a Thread object, add the user and
     //  user talk pages to a link batch, cache the relevant user id/name pair, and
     //  populate the reply cache.
     foreach ($all_thread_rows as $row) {
         $thread = Thread::newFromRow($row, null);
         if (isset($articlesById[$thread->rootId])) {
             $thread->root = $articlesById[$thread->rootId];
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:Thread.php

示例5: renderThread

 protected function renderThread($row, $params, &$entry)
 {
     // Set up OutputPage
     $out = $this->getOutput();
     $oldOutputText = $out->getHTML();
     $out->clearHTML();
     // Setup
     $thread = Thread::newFromRow($row);
     $article = $thread->root();
     if (!$article) {
         return;
     }
     $title = $article->getTitle();
     $user = $this->getUser();
     $request = $this->getRequest();
     $view = new LqtView($out, $article, $title, $user, $request);
     // Parameters
     $view->threadNestingLevel = $params['renderlevel'];
     $renderpos = $params['renderthreadpos'];
     $rendercount = $params['renderthreadcount'];
     $options = array();
     if (isset($params['rendermaxthreadcount'])) {
         $options['maxCount'] = $params['rendermaxthreadcount'];
     }
     if (isset($params['rendermaxdepth'])) {
         $options['maxDepth'] = $params['rendermaxdepth'];
     }
     if (isset($params['renderstartrepliesat'])) {
         $options['startAt'] = $params['renderstartrepliesat'];
     }
     $view->showThread($thread, $renderpos, $rendercount, $options);
     $result = $out->getHTML();
     $out->clearHTML();
     $out->addHTML($oldOutputText);
     $entry['content'] = $result;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:36,代码来源:ApiQueryLQTThreads.php

示例6: dumpThreadData

 static function dumpThreadData($writer, &$out, $row, $title)
 {
     // Is it a thread
     if (empty($row->thread_id) || $row->thread_type >= 2) {
         return true;
     }
     $thread = Thread::newFromRow($row);
     $threadInfo = "\n";
     $attribs = array();
     $attribs['ThreadSubject'] = $thread->subject();
     if ($thread->hasSuperThread()) {
         if ($thread->superThread()->title()) {
             $attribs['ThreadParent'] = $thread->superThread()->title()->getPrefixedText();
         }
         if ($thread->topmostThread()->title()) {
             $attribs['ThreadAncestor'] = $thread->topmostThread()->title()->getPrefixedText();
         }
     }
     $attribs['ThreadPage'] = $thread->getTitle()->getPrefixedText();
     $attribs['ThreadID'] = $thread->id();
     if ($thread->hasSummary() && $thread->summary()) {
         $attribs['ThreadSummaryPage'] = $thread->summary()->getTitle()->getPrefixedText();
     }
     $attribs['ThreadAuthor'] = $thread->author()->getName();
     $attribs['ThreadEditStatus'] = self::$editedStati[$thread->editedness()];
     $attribs['ThreadType'] = self::$threadTypes[$thread->type()];
     $attribs['ThreadSignature'] = $thread->signature();
     foreach ($attribs as $key => $value) {
         $threadInfo .= "\t" . Xml::element($key, null, $value) . "\n";
     }
     $out .= UtfNormal::cleanUp(Xml::tags('DiscussionThreading', null, $threadInfo) . "\n");
     return true;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:33,代码来源:Hooks.php


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