/** * Process Posts * * Run the posts through the Plugin system, and apply any * necessary data before sending the array to the view. * * @param array & $posts (optional) if not specified, the function will process $this->posts. * @return void */ public function processPosts(&$posts = null) { if ($posts === null) { $posts =& $this->posts; } // Tack on image data to the posts array foreach ($posts as $key => $post) { $posts[$key]->id = (int) $posts[$key]->id; $posts[$key]->permalink = $this->config->url . 'post/' . $post->id; $image_info = getimagesize('content/images/' . $post->filename); $posts[$key]->width = $image_info[0]; $posts[$key]->height = $image_info[1]; $posts[$key]->type = $image_info['mime']; $posts[$key]->uri = $this->config->url . 'content/images/' . $post->filename; $image_info = getimagesize('content/images/thumb_' . $post->filename); $posts[$key]->thumb_width = $image_info[0]; $posts[$key]->thumb_height = $image_info[1]; $posts[$key]->thumb_type = $image_info['mime']; $posts[$key]->thumb_uri = $this->config->url . 'content/images/thumb_' . $post->filename; } /** * Allow any plugins to modify to adjust the posts before we apply the filters: */ Pixelpost_Plugin::executeAction('hook_posts', $posts, $this->front->getController(), $this->front->getAction()); foreach ($posts as $key => $post) { Pixelpost_Plugin::executeFilter('filter_permalink', $posts[$key]->permalink); Pixelpost_Plugin::executeFilter('filter_title', $posts[$key]->title); Pixelpost_Plugin::executeFilter('filter_description', $posts[$key]->description); Pixelpost_Plugin::executeFilter('filter_filename', $posts[$key]->filename); Pixelpost_Plugin::executeFilter('filter_published', $posts[$key]->published); } }
} /** * Initialize Page */ $front = Model_Front::getInstance(); /** * Initialize Timezone */ if (!empty($config->timezone)) { date_default_timezone_set($config->timezone); } $config->current_time = date("Y-m-d H:i:s", time()); /** * Initialize Plugin Hooks */ Pixelpost_Plugin::executeAction('hook_init'); /** * Helper Functions */ /** * Turn register globals off. * * @return null Will return null if register_globals PHP directive was disabled */ function unregister_globals() { if (!ini_get('register_globals')) { return; } if (isset($_REQUEST['GLOBALS'])) { die('GLOBALS overwrite attempt detected');
public function rssAction() { /** * If this method is being auto-run by index(), * we don't need to run it here. */ if ($this->feed_type == 'rss') { $this->indexAction(); } /** * Transmit the RSS feed using the XML content type */ @header('Content-Type: text/xml; charset=utf-8'); /** * Initialize the feed array */ $this->feed = array(); /** * Feed Header Information */ $this->feed['rss']['channel']['title'] = $this->config->site_name; $this->feed['rss']['channel']['link'] = $this->config->url; $this->feed['rss']['channel']['description'] = $this->config->site_description; $this->feed['rss']['channel']['language'] = str_replace('_', '-', strtolower($this->config->locale)); if (isset($this->config->copyright)) { $this->feed['rss']['channel']['copyright'] = $this->config->copyright; } $this->feed['rss']['channel']['pubDate'] = date(DATE_RSS, time()); $this->feed['rss']['channel']['generator'] = "Ultralite"; $this->feed['rss']['channel']['atom:link'][0] = null; $this->feed['rss']['channel']['atom:link']['0_attr'] = array('rel' => 'self', 'type' => 'application/rss+xml', 'href' => $this->config->url . 'feed'); /** * Feed Pagination - Next: */ if ($this->config->feed_pagination && Pixelpost_Uri::$page > 1) { // Add the current page to the rel=self link: $this->feed['rss']['channel']['atom:link']['0_attr']['href'] .= '/page/' . Pixelpost_Uri::$page; $this->feed['rss']['channel']['atom:link'][1] = null; $this->feed['rss']['channel']['atom:link']['1_attr'] = array('rel' => 'previous', 'href' => $this->config->url . 'feed'); if (Pixelpost_Uri::$page - 1 != 1) { $this->feed['rss']['channel']['atom:link']['1_attr']['href'] .= '/page/' . (Pixelpost_Uri::$page - 1); } } /** * Feed Pagination - Previous: */ if ($this->config->feed_pagination && Pixelpost_Uri::$page < Pixelpost_Uri::$total_pages) { $this->feed['rss']['channel']['atom:link'][2] = null; $this->feed['rss']['channel']['atom:link']['2_attr'] = array('rel' => 'next', 'href' => $this->config->url . 'feed/page/' . (Pixelpost_Uri::$page + 1)); } /** * Include the feed icon, if it exists: */ if (file_exists(THMPATH . "/{$this->config->theme}/images/feed_icon.png")) { // $image = getimagesize(THMPATH."/{$this->config->theme}/images/feed_icon.png"); $this->feed['rss']['channel']['image']['title'] = $this->config->site_name; $this->feed['rss']['channel']['image']['link'] = $this->config->url; $this->feed['rss']['channel']['image']['url'] = "{$this->config->url}content/themes/{$this->config->theme}/images/feed_icon.png"; // $this->feed['rss']['channel']['image']['width'] = $image[0]; // $this->feed['rss']['channel']['image']['height'] = $image[1]; $this->feed['rss']['channel']['atom:icon'] = "{$this->config->url}content/themes/{$this->config->theme}/images/feed_icon.png"; } /** * Allow any plugins to add/remove tags from the <channel> section of the RSS feed: */ Pixelpost_Plugin::executeAction('hook_rss_channel', $this->feed['rss']['channel']); /** * Feed Items */ $this->feed['rss']['channel']['item'] = array(); foreach ($this->posts as $id => $post) { $this->feed['rss']['channel']['item'][$id] = array('title' => $post->title, 'link' => $post->permalink, 'description' => "<p><a href=\"{$post->permalink}\"><img src=\"{$post->uri}\" alt=\"{$post->title}\" width=\"{$post->width}\" height=\"{$post->height}\" /></a></p>{$post->description}", 'pubDate' => date(DATE_RSS, strtotime($post->published)), 'guid' => $post->permalink); /** * Allow any plugins to add/remove tags from each of the <item> tags in the RSS feed: */ Pixelpost_Plugin::executeAction('hook_rss_item', $this->feed['rss']['channel']['item'][$id], $post); } /** * Feed Attributes and Namespaces */ $this->feed['rss_attr'] = array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'); /** * Allow any plugins to add/remove tags from the entire this->feed array: */ Pixelpost_Plugin::executeAction('hook_rss_feed', $this->feed); /** * Sent the Values out to the view */ $this->view->feed = $this->feed; $this->view->posts = $this->posts; }