Esempio n. 1
0
 /**
  * Format the rows (generated by SpecialRecentchanges or SpecialRecentchangeslinked)
  * as an RSS/Atom feed.
  */
 public function execute()
 {
     $config = $this->getConfig();
     $this->params = $this->extractRequestParams();
     if (!$config->get('Feed')) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     $feedClasses = $config->get('FeedClasses');
     if (!isset($feedClasses[$this->params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     $this->getMain()->setCacheMode('public');
     if (!$this->getMain()->getParameter('smaxage')) {
         // bug 63249: This page gets hit a lot, cache at least 15 seconds.
         $this->getMain()->setCacheMaxAge(15);
     }
     $feedFormat = $this->params['feedformat'];
     $specialClass = $this->params['target'] !== null ? 'SpecialRecentchangeslinked' : 'SpecialRecentchanges';
     $formatter = $this->getFeedObject($feedFormat, $specialClass);
     // Parameters are passed via the request in the context… :(
     $context = new DerivativeContext($this);
     $context->setRequest(new DerivativeRequest($this->getRequest(), $this->params, $this->getRequest()->wasPosted()));
     // The row-getting functionality should be factored out of ChangesListSpecialPage too…
     $rc = new $specialClass();
     $rc->setContext($context);
     $rows = $rc->getRows();
     $feedItems = $rows ? ChangesFeed::buildItems($rows) : array();
     ApiFormatFeedWrapper::setResult($this->getResult(), $formatter, $feedItems);
 }
Esempio n. 2
0
 public function execute()
 {
     global $wgFeedClasses, $wgSitename, $wgServer;
     try {
         $params = $this->extractRequestParams();
         $fauxReqArr = array("action" => "query", "list" => "activityfeed");
         $fauxReq = new FauxRequest($fauxReqArr);
         $module = new ApiMain($fauxReq);
         $module->execute();
         $data = $module->getResultData();
         $feedItems = array();
         foreach ((array) $data["query"]["activityfeed"] as $info) {
             $feedItems[] = $this->createFeedItem($info);
         }
         $feed = new $wgFeedClasses[$params["feedformat"]]("{$wgSitename} - activity feed", "", $wgServer);
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     } catch (Exception $e) {
         $this->getMain()->setCacheMaxAge(0);
         $feedFormat = isset($params["feedformat"]) ? $params["feedformat"] : "rss";
         $feed = new $wgFeedClasses[$feedFormat]("{$wgSitename} - error - activity feed", "", $wgServer);
         if ($e instanceof UsageException) {
             $errorCode = $e->getCodeString();
         } else {
             $errorCode = "internal_api_error";
         }
         $errorText = $e->getMessage();
         $feedItems[] = new FeedItem("Error ({$errorCode})", $errorText, "", "", "");
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     }
 }
Esempio n. 3
0
 public function execute()
 {
     $params = $this->extractRequestParams();
     global $wgFeed, $wgFeedClasses, $wgSitename, $wgLanguageCode;
     if (!$wgFeed) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     if (!isset($wgFeedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     global $wgMiserMode;
     if ($params['showsizediff'] && $wgMiserMode) {
         $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled');
     }
     $msg = wfMessage('Contributions')->inContentLanguage()->text();
     $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
     $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL();
     $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText();
     $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'showSizeDiff' => $params['showsizediff']));
     $feedItems = array();
     if ($pager->getNumRows() > 0) {
         foreach ($pager->mResult as $row) {
             $feedItems[] = $this->feedItem($row);
         }
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
 /**
  * Format the rows (generated by SpecialRecentchanges or SpecialRecentchangeslinked)
  * as an RSS/Atom feed.
  */
 public function execute()
 {
     global $wgFeed, $wgFeedClasses;
     $this->params = $this->extractRequestParams();
     if (!$wgFeed) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     if (!isset($wgFeedClasses[$this->params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     $this->getMain()->setCacheMode('public');
     if (!$this->getMain()->getParameter('smaxage')) {
         // bug 63249: This page gets hit a lot, cache at least 15 seconds.
         $this->getMain()->setCacheMaxAge(15);
     }
     $feedFormat = $this->params['feedformat'];
     $specialClass = $this->params['target'] !== null ? 'SpecialRecentchangeslinked' : 'SpecialRecentchanges';
     $formatter = $this->getFeedObject($feedFormat, $specialClass);
     // Everything is passed implicitly via $wgRequest… :(
     // The row-getting functionality should maybe be factored out of ChangesListSpecialPage too…
     $rc = new $specialClass();
     $rows = $rc->getRows();
     $feedItems = $rows ? ChangesFeed::buildItems($rows) : array();
     ApiFormatFeedWrapper::setResult($this->getResult(), $formatter, $feedItems);
 }
Esempio n. 5
0
 /**
  * Make a nested call to the API to request items in the last $hours.
  * Wrap the result as an RSS/Atom feed.
  */
 public function execute()
 {
     global $wgFeedClasses;
     $params = $this->extractRequestParams();
     $db = wfGetDB(DB_SLAVE);
     $feedTitle = self::createFeedTitle($params);
     $feedClass = $wgFeedClasses[$params['feedformat']];
     $feedItems = array();
     $feedUrl = Title::newMainPage()->getFullURL();
     $tables = array('thread');
     $fields = array($db->tableName('thread') . ".*");
     $conds = $this->getConditions($params, $db);
     $options = array('LIMIT' => 200, 'ORDER BY' => 'thread_created DESC');
     $res = $db->select($tables, $fields, $conds, __METHOD__, $options);
     foreach ($res as $row) {
         $feedItems[] = $this->createFeedItem($row);
     }
     $feed = new $feedClass($feedTitle, '', $feedUrl);
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
 public function execute()
 {
     $params = $this->extractRequestParams();
     $config = $this->getConfig();
     if (!$config->get('Feed')) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     $feedClasses = $config->get('FeedClasses');
     if (!isset($feedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     if ($params['showsizediff'] && $this->getConfig()->get('MiserMode')) {
         $this->dieUsage('Size difference is disabled in Miser Mode', 'sizediffdisabled');
     }
     $msg = wfMessage('Contributions')->inContentLanguage()->text();
     $feedTitle = $config->get('Sitename') . ' - ' . $msg . ' [' . $config->get('LanguageCode') . ']';
     $feedUrl = SpecialPage::getTitleFor('Contributions', $params['user'])->getFullURL();
     $target = $params['user'] == 'newbies' ? 'newbies' : Title::makeTitleSafe(NS_USER, $params['user'])->getText();
     $feed = new $feedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $pager = new ContribsPager($this->getContext(), array('target' => $target, 'namespace' => $params['namespace'], 'year' => $params['year'], 'month' => $params['month'], 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'newOnly' => $params['newonly'], 'showSizeDiff' => $params['showsizediff']));
     $feedLimit = $this->getConfig()->get('FeedLimit');
     if ($pager->getLimit() > $feedLimit) {
         $pager->setLimit($feedLimit);
     }
     $feedItems = array();
     if ($pager->getNumRows() > 0) {
         $count = 0;
         $limit = $pager->getLimit();
         foreach ($pager->mResult as $row) {
             // ContribsPager selects one more row for navigation, skip that row
             if (++$count > $limit) {
                 break;
             }
             $item = $this->feedItem($row);
             if ($item !== null) {
                 $feedItems[] = $item;
             }
         }
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
Esempio n. 7
0
 /**
  * Format the rows (generated by SpecialRecentchanges or SpecialRecentchangeslinked)
  * as an RSS/Atom feed.
  */
 public function execute()
 {
     $this->params = $this->extractRequestParams();
     $config = $this->getConfig();
     if (!$config->get('Feed')) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     $feedClasses = $config->get('FeedClasses');
     if (!isset($feedClasses[$this->params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     $this->getMain()->setCacheMode('public');
     if (!$this->getMain()->getParameter('smaxage')) {
         // bug 63249: This page gets hit a lot, cache at least 15 seconds.
         $this->getMain()->setCacheMaxAge(15);
     }
     $feedFormat = $this->params['feedformat'];
     $formatter = $this->getFeedObject($feedFormat);
     $feedItems = $this->getItems();
     ApiFormatFeedWrapper::setResult($this->getResult(), $formatter, $feedItems);
 }
Esempio n. 8
0
 public function execute()
 {
     wfProfileIn(__METHOD__);
     $params = $this->extractRequestParams();
     global $wgFeedClasses;
     if (!isset($wgFeedClasses[$params['feedformat']])) {
         wfProfileOut(__METHOD__);
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     $language = isset($params['language']) ? $params['language'] : false;
     if ($language !== false && !Language::isValidCode($language)) {
         $language = false;
     }
     $feeds = FeaturedFeeds::getFeeds($language);
     $ourFeed = $feeds[$params['feed']];
     $feedClass = new $wgFeedClasses[$params['feedformat']]($ourFeed->title, $ourFeed->description, wfExpandUrl(Title::newMainPage()->getFullURL()));
     ApiFormatFeedWrapper::setResult($this->getResult(), $feedClass, $ourFeed->getFeedItems());
     // Cache stuff in squids
     $this->getMain()->setCacheMode('public');
     $this->getMain()->setCacheMaxAge(FeaturedFeeds::getMaxAge());
     wfProfileOut(__METHOD__);
 }
Esempio n. 9
0
 public function execute()
 {
     $feedformat = null;
     extract($this->extractRequestParams());
     // limit to 1 day
     $startTime = wfTimestamp(TS_MW, time() - intval(1 * 86400));
     // Prepare nested request
     $params = new FauxRequest(array('action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'general', 'list' => 'watchlist', 'wlprop' => 'user|comment|timestamp', 'wlstart' => $startTime, 'wllimit' => 50));
     // Execute
     $module = new ApiMain($params);
     $module->execute();
     // Get data array
     $data = $module->getResultData();
     $feedItems = array();
     foreach ($data['query']['watchlist'] as $info) {
         $feedItems[] = $this->createFeedItem($info);
     }
     global $wgFeedClasses, $wgSitename, $wgContLanguageCode;
     $feedTitle = $wgSitename . ' - ' . wfMsgForContent('watchlist') . ' [' . $wgContLanguageCode . ']';
     $feedUrl = SpecialPage::getTitleFor('Watchlist')->getFullUrl();
     $feed = new $wgFeedClasses[$feedformat]($feedTitle, htmlspecialchars(wfMsgForContent('watchlist')), $feedUrl);
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
Esempio n. 10
0
 /**
  * Returns the version information of this file, plus it includes
  * the versions for all files that are not callable proper API modules
  */
 public function getVersion()
 {
     $vers = array();
     $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n    http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/";
     $vers[] = __CLASS__ . ': $Id: ApiMain.php 50834 2009-05-20 20:10:47Z catrope $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
Esempio n. 11
0
 /**
  * Returns the version information of this file, plus it includes
  * the versions for all files that are not callable proper API modules
  */
 public function getVersion()
 {
     $vers = array();
     $vers[] = 'MediaWiki ' . SpecialVersion::getVersion();
     $vers[] = __CLASS__ . ': $Id: ApiMain.php 24494 2007-07-31 17:53:37Z yurik $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
Esempio n. 12
0
 /**
  * Make a nested call to the API to request watchlist items in the last $hours.
  * Wrap the result as an RSS/Atom feed.
  */
 public function execute()
 {
     global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode;
     try {
         $params = $this->extractRequestParams();
         if (!$wgFeed) {
             $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
         }
         if (!isset($wgFeedClasses[$params['feedformat']])) {
             $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
         }
         // limit to the number of hours going from now back
         $endTime = wfTimestamp(TS_MW, time() - intval($params['hours'] * 60 * 60));
         // Prepare parameters for nested request
         $fauxReqArr = array('action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'general', 'list' => 'watchlist', 'wlprop' => 'title|user|comment|timestamp', 'wldir' => 'older', 'wlend' => $endTime, 'wllimit' => min(50, $wgFeedLimit));
         if ($params['wlowner'] !== null) {
             $fauxReqArr['wlowner'] = $params['wlowner'];
         }
         if ($params['wltoken'] !== null) {
             $fauxReqArr['wltoken'] = $params['wltoken'];
         }
         if ($params['wlexcludeuser'] !== null) {
             $fauxReqArr['wlexcludeuser'] = $params['wlexcludeuser'];
         }
         if ($params['wlshow'] !== null) {
             $fauxReqArr['wlshow'] = $params['wlshow'];
         }
         if ($params['wltype'] !== null) {
             $fauxReqArr['wltype'] = $params['wltype'];
         }
         // Support linking to diffs instead of article
         if ($params['linktodiffs']) {
             $this->linkToDiffs = true;
             $fauxReqArr['wlprop'] .= '|ids';
         }
         // Support linking directly to sections when possible
         // (possible only if section name is present in comment)
         if ($params['linktosections']) {
             $this->linkToSections = true;
         }
         // Check for 'allrev' parameter, and if found, show all revisions to each page on wl.
         if ($params['allrev']) {
             $fauxReqArr['wlallrev'] = '';
         }
         // Create the request
         $fauxReq = new FauxRequest($fauxReqArr);
         // Execute
         $module = new ApiMain($fauxReq);
         $module->execute();
         // Get data array
         $data = $module->getResultData();
         $feedItems = array();
         foreach ((array) $data['query']['watchlist'] as $info) {
             $feedItems[] = $this->createFeedItem($info);
         }
         $msg = wfMessage('watchlist')->inContentLanguage()->text();
         $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
         $feedUrl = SpecialPage::getTitleFor('Watchlist')->getFullURL();
         $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     } catch (Exception $e) {
         // Error results should not be cached
         $this->getMain()->setCacheMaxAge(0);
         // @todo FIXME: Localise  brackets
         $feedTitle = $wgSitename . ' - Error - ' . wfMessage('watchlist')->inContentLanguage()->text() . ' [' . $wgLanguageCode . ']';
         $feedUrl = SpecialPage::getTitleFor('Watchlist')->getFullURL();
         $feedFormat = isset($params['feedformat']) ? $params['feedformat'] : 'rss';
         $msg = wfMessage('watchlist')->inContentLanguage()->escaped();
         $feed = new $wgFeedClasses[$feedFormat]($feedTitle, $msg, $feedUrl);
         if ($e instanceof UsageException) {
             $errorCode = $e->getCodeString();
         } else {
             // Something is seriously wrong
             $errorCode = 'internal_api_error';
         }
         $errorText = $e->getMessage();
         $feedItems[] = new FeedItem("Error ({$errorCode})", $errorText, '', '', '');
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     }
 }
Esempio n. 13
0
 public function getVersion()
 {
     $vers = array();
     $vers[] = __CLASS__ . ': $Id: ApiMain.php 17987 2006-11-29 05:45:03Z nickj $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
Esempio n. 14
0
 /**
  * Returns the version information of this file, plus it includes
  * the versions for all files that are not callable proper API modules
  */
 public function getVersion()
 {
     $vers = array();
     $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n    http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/";
     $vers[] = __CLASS__ . ': $Id: ApiMain.php 69990 2010-07-27 08:44:08Z tstarling $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
Esempio n. 15
0
 /**
  * Returns the version information of this file, plus it includes
  * the versions for all files that are not callable proper API modules
  */
 public function getVersion()
 {
     $vers = array();
     $vers[] = 'MediaWiki ' . SpecialVersion::getVersion();
     $vers[] = __CLASS__ . ': $Id: ApiMain.php 31484 2008-03-03 05:46:20Z brion $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
 public function execute()
 {
     $params = $this->extractRequestParams();
     //HINT: includes/api/ApiFeedContributions.php
     //HINT: includes/api/ApiFeedWatchlist.php
     global $wgSitename, $wgLanguageCode, $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry, $wgFeed, $wgFeedClasses;
     if (!$wgFeed) {
         $this->dieUsage('Syndication feeds are not available', 'feed-unavailable');
     }
     if (!isset($wgFeedClasses[$params['feedformat']])) {
         $this->dieUsage('Invalid subscription feed type', 'feed-invalid');
     }
     $msg = wfMessage('specialextendedsearch')->inContentLanguage()->text();
     $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
     $feedUrl = SpecialPage::getTitleFor('SpecialExtendedSearch')->getFullURL();
     $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars($msg), $feedUrl);
     $feedItems = array();
     try {
         $oSearchService = SearchService::getInstance();
         $oSearchRequest = new BsSearchRequest('apifeed');
         $oSearchRequestMW = new SearchRequestMW($oSearchRequest);
         $oSearchOptions = new SearchOptions($oSearchRequestMW);
         // Prepare search input
         $sSearchString = $params['q'];
         $sSearchString = urldecode($sSearchString);
         $sSearchString = BsSearchService::preprocessSearchInput($sSearchString);
         $sSearchString = BsSearchService::sanitzeSearchString($sSearchString);
         // Make solr query suitable for autocomplete
         $aSolrQuery = $oSearchOptions->getSolrQuery();
         //$sSearchString = 'titleWord:("'.$params['q'].'") OR titleWord:('.$params['q'].') OR titleReverse:(*'.$params['q'].'*) OR textWord:("'.$params['q'].'") OR textWord:('.$params['q'].') OR textReverse:(*'.$params['q'].'*)';
         $sSearchString = 'titleWord:(' . $sSearchString . ') OR titleWord:(' . $sSearchString . '*) OR titleReverse:(*' . $sSearchString . '*) OR textWord:(' . $sSearchString . ') OR textReverse:(*' . $sSearchString . '*)';
         $aSearchOptions = $aSolrQuery['searchOptions'];
         $aSearchOptions['facet'] = 'off';
         $aSearchOptions['hl'] = 'on';
         $aSearchOptions['hl.fl'] = 'textWord, textReverse';
         $aSearchOptions['hl.snippets'] = 3;
         // params are query, offset, limit, params
         $aHits = $oSearchService->search($sSearchString, 0, 25, $aSearchOptions);
         foreach ($aHits->response->docs as $doc) {
             if ($doc->namespace != '999') {
                 $oTitle = Title::makeTitle($doc->namespace, $doc->title);
             } else {
                 continue;
             }
             if (!$oTitle->userCan('read')) {
                 continue;
             }
             $oHighlightData = $aHits->highlighting->{$doc->uid};
             if (isset($oHighlightData->textWord)) {
                 $aHighlightsnippets = $oHighlightData->textWord;
             } else {
                 if (isset($oHighlightData->textReverse)) {
                     $aHighlightsnippets = $oHighlightData->textReverse;
                 }
             }
             $sTextFragment = '';
             foreach ($aHighlightsnippets as $sFrag) {
                 $sFrag = strip_tags($sFrag, '<em>');
                 if (empty($sFrag)) {
                     continue;
                 }
                 $sTextFragment .= "{$sFrag}<br />";
             }
             $feedItems[] = new FeedItem($doc->title, $sTextFragment, $oTitle->getFullURL());
         }
     } catch (Exception $e) {
         $this->dieUsage($e->getMessage(), 'feed-invalid');
     }
     ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
 }
Esempio n. 17
0
 /**
  * Make a nested call to the API to request watchlist items in the last $hours.
  * Wrap the result as an RSS/Atom feed.
  */
 public function execute()
 {
     global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgContLanguageCode;
     try {
         $params = $this->extractRequestParams();
         // limit to the number of hours going from now back
         $endTime = wfTimestamp(TS_MW, time() - intval($params['hours'] * 60 * 60));
         $dbr = wfGetDB(DB_SLAVE);
         // Prepare parameters for nested request
         $fauxReqArr = array('action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'general', 'list' => 'watchlist', 'wlprop' => 'title|user|comment|timestamp', 'wldir' => 'older', 'wlend' => $dbr->timestamp($endTime), 'wllimit' => 50 > $wgFeedLimit ? $wgFeedLimit : 50);
         // Check for 'allrev' parameter, and if found, show all revisions to each page on wl.
         if (!is_null($params['allrev'])) {
             $fauxReqArr['wlallrev'] = '';
         }
         // Create the request
         $fauxReq = new FauxRequest($fauxReqArr);
         // Execute
         $module = new ApiMain($fauxReq);
         $module->execute();
         // Get data array
         $data = $module->getResultData();
         $feedItems = array();
         foreach ((array) $data['query']['watchlist'] as $info) {
             $feedItems[] = $this->createFeedItem($info);
         }
         $feedTitle = $wgSitename . ' - ' . wfMsgForContent('watchlist') . ' [' . $wgContLanguageCode . ']';
         $feedUrl = SpecialPage::getTitleFor('Watchlist')->getFullUrl();
         $feed = new $wgFeedClasses[$params['feedformat']]($feedTitle, htmlspecialchars(wfMsgForContent('watchlist')), $feedUrl);
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     } catch (Exception $e) {
         // Error results should not be cached
         $this->getMain()->setCacheMaxAge(0);
         $feedTitle = $wgSitename . ' - Error - ' . wfMsgForContent('watchlist') . ' [' . $wgContLanguageCode . ']';
         $feedUrl = SpecialPage::getTitleFor('Watchlist')->getFullUrl();
         $feedFormat = isset($params['feedformat']) ? $params['feedformat'] : 'rss';
         $feed = new $wgFeedClasses[$feedFormat]($feedTitle, htmlspecialchars(wfMsgForContent('watchlist')), $feedUrl);
         if ($e instanceof UsageException) {
             $errorCode = $e->getCodeString();
         } else {
             // Something is seriously wrong
             $errorCode = 'internal_api_error';
         }
         $errorText = $e->getMessage();
         $feedItems[] = new FeedItem("Error ({$errorCode})", $errorText, "", "", "");
         ApiFormatFeedWrapper::setResult($this->getResult(), $feed, $feedItems);
     }
 }
Esempio n. 18
0
 /**
  * Returns the version information of this file, plus it includes
  * the versions for all files that are not callable proper API modules
  */
 public function getVersion()
 {
     $vers = array();
     $vers[] = 'MediaWiki ' . SpecialVersion::getVersion();
     $vers[] = __CLASS__ . ': $Id: ApiMain.php,v 1.1.1.1 2009/11/04 00:04:42 vu Exp $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }