*/ class Fishpig_Wordpress_MiscController extends Mage_Core_Controller_Front_Action { /** * Set the post password and redirect to the referring page * */ public function applyPostPasswordAction() { $password = $this->getRequest()->getPost('post_password'); Mage::getSingleton('wordpress/session')->setPostPassword($password); $this->_redirectReferer(); } /** * Forward requests to the WordPress installation * */ public function forwardAction() { $queryString = $_SERVER['QUERY_STRING']; $forwardTo = rtrim(Mage::helper('wordpress')->getWpOption('siteurl'), '/') . '/index.php?' . $queryString; $this->_redirectUrl($forwardTo); } /** * Forward requests for images * */ public function forwardFileAction() { $url = rtrim(Mage::helper('wordpress')->getWpOption('siteurl'), '/'); $forwardTo = $url . '/' . ltrim($this->getRequest()->getParam('uri'), '/'); $this->_redirectUrl($forwardTo); } /** * Display the blog robots.txt file * */ public function robotsAction() { $this->getResponse()->setHeader('Content-Type', 'text/plain;charset=utf8'); $this->getResponse()->setBody( $this->getLayout()->createBlock('core/template')->setTemplate('wordpress/robots.phtml')->toHtml() ); } /** * XML Sitemap action * */ public function sitemapAction() { if (Mage::getStoreConfigFlag('wordpress_blog/xml_sitemap/enabled')) { try { $sitemap = Mage::getSingleton('wordpress/sitemap_xml') ->load() ->generate(); $this->getResponse() ->setHeader('Content-Type','text/xml') ->setBody($sitemap->getXml()); } catch (Exception $e) { Mage::helper('wordpress')->log($e->getMessage()); $this->_forward('noRoute'); } } else { $this->_forward('noRoute'); } } /** * Display the RSS Feed * */ public function rssAction() { if (Mage::getStoreConfigFlag('wordpress_blog/rss_feed/enabled')) { $this->getResponse() ->setHeader('Content-Type', 'application/rss+xml; charset=' . Mage::helper('wordpress')->getWpOption('blog_charset'), true) ->setBody($this->getLayout()->createBlock('wordpress/feed_home')->toHtml()); } else { $this->_forward('noRoute'); } } /** * Redirect the user to the WordPress Admin * */ public function wpAdminAction() { return $this->_redirectTo(Mage::helper('wordpress')->getAdminUrl()); } /** * Forces a redirect to the given URL * * @param string $url * @return bool */ protected function _redirectTo($url) { return $this->getResponse()->setRedirect($url)->sendResponse(); } }