/** * @return array - the feed with all the items sorted */ private function getAllEntries($feed) { // collect children messages: (including group handling) $feed['items'] = array(); foreach ($feed['subscriptions'] as &$subscription) { try { $data = $subscription['data'] = $this->feeds->read($subscription['id']); if (is_string($data)) { // error occured $timestamp = time(); if (!isset($feed['items'][$timestamp])) { $feed['items'][$timestamp] = array(); } $feed['items'][$timestamp] = $data; continue; } /* @var $data Zend_Feed_Abstract */ foreach ($data as $item) { @($item->realLink = $item->link()); /* @var $item Zend_Feed_Entry_Abstract */ $item->parentName = $subscription['name']; if ($item instanceof Zend_Feed_Entry_Atom) { $date = $item->updated(); if (!$date) { $date = $item->published(); } if (!$item->realLink()) { $item->realLink = $item->link('alternate'); } } else { if ($item instanceof Zend_Feed_Entry_Rss) { $date = $item->pubDate(); if (!$date) { $date = $data->pubDate() ? $data->pubDate() : date("ddMMyyyy"); } } } if (!$date) { continue; } $timestamp = strtotime($date); $item->date = $timestamp ? $this->getPrintableDate($timestamp) : ''; // using "multi map" with dates as keys to sort the items further // each entry in the map is an array, since there may be more than one item with the same date if (!isset($feed['items'][$timestamp])) { $feed['items'][$timestamp] = array(); } $feed['items'][$timestamp][] = $item; } } catch (FeedReadException $e) { $subscription['data'] = "Feed error: " . $e->getMessage(); } } // purging unneeded data unset($feed['subscriptions']); // sorting the gathered items krsort($feed['items']); return $feed; }