/**
  *
  * @param int $date
  * @return FeaturedFeedItem
  */
 public function getFeedItem($date)
 {
     self::$parserOptions->setTimestamp($date);
     self::$parserOptions->setUserLang($this->language);
     $titleText = self::$parser->transformMsg($this->page, self::$parserOptions);
     $title = Title::newFromText($titleText);
     if (!$title) {
         return false;
     }
     $rev = Revision::newFromTitle($title);
     if (!$rev) {
         return false;
         // page does not exist
     }
     $text = $rev->getText();
     if (!$text) {
         return false;
     }
     $text = self::$parser->parse($text, $title, self::$parserOptions)->getText();
     $url = SpecialPage::getTitleFor('FeedItem', $this->name . '/' . wfTimestamp(TS_MW, $date) . '/' . $this->language->getCode())->getFullURL();
     return new FeaturedFeedItem(self::$parser->transformMsg($this->entryName, self::$parserOptions), wfExpandUrl($url), $text, $date);
 }
Example #2
0
 /**
  * ParserOptions are constructed before we determined the language, so fix it
  *
  * @param $lang Language
  */
 public function setParserLanguage($lang)
 {
     $this->parserOptions->setTargetLanguage($lang);
     $this->parserOptions->setUserLang($lang);
 }
Example #3
0
 /**
  * Get parser options suitable for rendering the primary article wikitext
  * @param $canonical boolean Determines that the generated options must not depend on user preferences (see bug 14404)
  * @return mixed ParserOptions object or boolean false
  */
 public function getParserOptions($canonical = false)
 {
     global $wgUser, $wgLanguageCode;
     if (!$this->mParserOptions || $canonical) {
         $user = !$canonical ? $wgUser : new User();
         $parserOptions = new ParserOptions($user);
         $parserOptions->setTidy(true);
         $parserOptions->enableLimitReport();
         if ($canonical) {
             $parserOptions->setUserLang($wgLanguageCode);
             # Must be set explicitely
             return $parserOptions;
         }
         $this->mParserOptions = $parserOptions;
     }
     // Clone to allow modifications of the return value without affecting cache
     return clone $this->mParserOptions;
 }