public static function &getInstance() { if (empty(self::$instance)) { self::$instance = new self(); self::$instance->loadPlugins(); } return self::$instance; }
public function __construct() { parent::__construct(); /** * If no title is set, create a generic title based off of the view's name. */ if (empty($this->view->title)) { $title = ucwords($this->front->getView()); Pixelpost_Plugin::executeFilter('filter_title', $title); $this->view->title = $title; } }
} /** * 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 __destruct() { /** * Run the default site-wide filters * * Make a copy of the options we are going to filter, * to make sure that the filters only change the view, not the actual config. */ $site_name = $this->config->site_name; $site_description = $this->config->site_description; Pixelpost_Plugin::executeFilter('filter_site_name', $site_name); Pixelpost_Plugin::executeFilter('filter_site_description', $site_description); $this->view->site_name = $site_name; $this->view->site_description = $site_description; /** * Load the view, either from the controller view, or from the template's view file * * @todo this complex if statement should be moved to a method, or some place out of the way. */ if ($viewPath = $this->viewLoader()) { $this->content = $this->view->fetch($viewPath); } else { /** * No matching View exists, display a 404 error. * @todo Use a Ultralite specific Exception class */ throw new Pixelpost_Exception('File Not Found', 404); } if (!is_null($this->content)) { $this->view->content = $this->content; /** * If no layout is specified, only show the view file * Otherwise load the view inside the layout. */ if (empty($this->layout)) { $result =& $this->content; } else { $result = $this->view->fetch(THMPATH . '/' . $this->config->theme . '/' . $this->layout); } $this->front->setBody($result); } }
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; }