public function getExamples()
 {
     global $wgVersion;
     // attempt to find a valid feed name
     // if none available, just use an example value
     $availableFeeds = array_keys(FeaturedFeeds::getFeeds(false));
     $feed = reset($availableFeeds);
     if (!$feed) {
         $feed = 'featured';
     }
     if (version_compare($wgVersion, '1.19alpha', '>=')) {
         return array("api.php?action=featuredfeed&feed={$feed}" => "Retrieve feed ``{$feed}'");
     } else {
         return array("Retrieve feed `{$feed}'", "    api.php?action=featuredfeed&feed={$feed}");
     }
 }
Esempio n. 2
0
 public function execute($par = '')
 {
     global $wgMemc;
     $this->setHeaders();
     $out = $this->getOutput();
     $parts = explode('/', $par);
     if (count($parts) != 3) {
         $out->showErrorPage('error', 'ffeed-no-feed');
         return;
     }
     list($feedName, $date, $langCode) = $parts;
     $feeds = FeaturedFeeds::getFeeds($langCode);
     if (!isset($feeds[$feedName])) {
         $out->showErrorPage('error', 'ffeed-feed-not-found', array($feedName));
         return;
     }
     $feed = $feeds[$feedName];
     $timestamp = wfTimestamp(TS_UNIX, $date);
     if (!$timestamp) {
         $out->showErrorPage('error', 'ffeed-invalid-timestamp');
         return;
     }
     $date = FeaturedFeeds::startOfDay($timestamp);
     // First, search in the general cache
     foreach ($feed->getFeedItems() as $item) {
         if ($item->getRawDate() == $date) {
             $this->displayItem($item);
             return;
         }
     }
     $key = wfMemcKey('featured', $feedName, $date, $feed->getLanguage()->getCode(), FeaturedFeedItem::CACHE_VERSION);
     $item = $wgMemc->get($key);
     if (!$item) {
         $item = $feed->getFeedItem($date);
         if ($item) {
             $wgMemc->set($key, $item, 3600 * 24);
         }
     }
     if ($item) {
         $this->displayItem($item);
     } else {
         $out->showErrorPage('error', 'ffeed-entry-not-found', array($this->getLanguage()->date($date)));
     }
 }
Esempio n. 3
0
 /**
  * @return array
  */
 public function getFeedItems()
 {
     $this->init();
     if ($this->items === false) {
         $this->items = array();
         for ($i = 1 - $this->options['limit']; $i <= 0; $i++) {
             $timestamp = FeaturedFeeds::todaysStart() + $i * 24 * 3600;
             $item = $this->getFeedItem($timestamp);
             if ($item) {
                 $this->items[] = $item;
             }
         }
     }
     return $this->items;
 }