コード例 #1
0
ファイル: ChangesFeed.php プロジェクト: whysasse/kmwiki
 /**
  * Generates feed's content
  *
  * @param ChannelFeed $feed ChannelFeed subclass object (generally the one returned
  *   by getFeedObject())
  * @param ResultWrapper $rows ResultWrapper object with rows in recentchanges table
  * @param int $lastmod Timestamp of the last item in the recentchanges table (only
  *   used for the cache key)
  * @param FormOptions $opts As in SpecialRecentChanges::getDefaultOptions()
  * @return null|bool True or null
  */
 public function execute($feed, $rows, $lastmod, $opts)
 {
     global $wgLang, $wgRenderHashAppend;
     if (!FeedUtils::checkFeedOutput($this->format)) {
         return null;
     }
     $optionsHash = md5(serialize($opts->getAllValues())) . $wgRenderHashAppend;
     $timekey = wfMemcKey($this->type, $this->format, $wgLang->getCode(), $optionsHash, 'timestamp');
     $key = wfMemcKey($this->type, $this->format, $wgLang->getCode(), $optionsHash);
     FeedUtils::checkPurge($timekey, $key);
     /**
      * Bumping around loading up diffs can be pretty slow, so where
      * possible we want to cache the feed output so the next visitor
      * gets it quick too.
      */
     $cachedFeed = $this->loadFromCache($lastmod, $timekey, $key);
     if (is_string($cachedFeed)) {
         wfDebug("RC: Outputting cached feed\n");
         $feed->httpHeaders();
         echo $cachedFeed;
     } else {
         wfDebug("RC: rendering new feed and caching it\n");
         ob_start();
         self::generateFeed($rows, $feed);
         $cachedFeed = ob_get_contents();
         ob_end_flush();
         $this->saveToCache($cachedFeed, $timekey, $key);
     }
     return true;
 }
コード例 #2
0
 /**
  * Actually output a feed.
  * @param ChannelFeed $feed Feed object.
  * @param $res Result of sql query
  */
 private function makeFeed($feed, $res)
 {
     global $wgGNSMcommentNamespace;
     $feed->outHeader();
     foreach ($res as $row) {
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         if (!$title) {
             $feed->outFooter();
             return;
         }
         // @todo FIXME: Under what circumstance would cl_timestamp not be set?
         // possibly worth an exception if that happens.
         $pubDate = isset($row->cl_timestamp) ? $row->cl_timestamp : wfTimestampNow();
         $feedItem = new FeedSMItem($title, $pubDate, $this->getKeywords($title), $wgGNSMcommentNamespace);
         $feed->outItem($feedItem);
     }
     $feed->outFooter();
 }
コード例 #3
0
ファイル: ChangesFeed.php プロジェクト: claudinec/galan-wiki
 /**
  * Generate the feed items given a row from the database, printing the feed.
  * @param object $rows DatabaseBase resource with recentchanges rows
  * @param ChannelFeed $feed
  */
 public static function generateFeed($rows, &$feed)
 {
     $items = self::buildItems($rows);
     $feed->outHeader();
     foreach ($items as $item) {
         $feed->outItem($item);
     }
     $feed->outFooter();
 }