Exemplo n.º 1
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null)
 {
     $page = Mage::getModel('blog/post');
     if (!is_null($identifier) && $identifier !== $page->getId()) {
         $page->setStoreId(Mage::app()->getStore()->getId());
         if (!$page->load($identifier)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     if ($page->getStatus() == 2) {
         return false;
     }
     $page_title = Mage::getSingleton('blog/post')->load($identifier)->getTitle();
     $blog_title = Mage::getStoreConfig('blog/blog/title') . " - ";
     $action->loadLayout();
     if ($storage = Mage::getSingleton('customer/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->getLayout()->getBlock('head')->setTitle($blog_title . $page_title);
     $action->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('blog/blog/layout'));
     $action->renderLayout();
     return true;
 }
Exemplo n.º 2
0
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null, $data)
 {
     $page = Mage::getSingleton('blog/blog');
     if (!is_null($identifier) && $identifier !== $page->getId()) {
         $page->setStoreId(Mage::app()->getStore()->getId());
         if (!$page->load($identifier)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     if ($page->getStatus() == 2) {
         return false;
     }
     $page_title = Mage::getSingleton('blog/blog')->load($identifier)->getTitle();
     $blog_title = Mage::getStoreConfig('blog/blog/title') . " - ";
     $action->loadLayout();
     if ($storage = Mage::getSingleton('customer/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     /*
      if (Mage::getStoreConfig('blog/rss/enable'))
      {
      Mage::helper('blog')->addRss($action->getLayout()->getBlock('head'), Mage::getUrl(Mage::getStoreConfig('blog/blog/route')) . "rss");
      }
     */
     $action->getLayout()->getBlock('head')->setTitle($blog_title . $page_title);
     $action->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('blog/blog/layout'));
     $action->getLayout()->getBlock('post')->setCommentDetails($data['user'], $data['email'], $data['comment']);
     $action->renderLayout();
     return true;
 }
Exemplo n.º 3
0
 /**
  * @see Mage_Core_Controller_Front_Action::renderLayout($output)
  */
 public function renderLayout($output = '')
 {
     //Add main template to to content block
     $mainViewBlock = $this->getLayout()->addBlock(new MageUC_Layout_Controller_Block(), 'main-view');
     $mainViewBlock->assign(get_object_vars($this));
     $this->getLayout()->getBlock('content')->append($mainViewBlock);
     return parent::renderLayout($output);
 }
Exemplo n.º 4
0
 /**
  * Renders CMS page
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer                           $identifier
  *
  * @return bool
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null)
 {
     if (!($catId = Mage::getSingleton('blog/cat')->load($identifier)->getCatId())) {
         return false;
     }
     $pageTitle = Mage::getSingleton('blog/cat')->load($identifier)->getTitle();
     $blogTitle = Mage::getStoreConfig('blog/blog/title') . " - " . $pageTitle;
     $action->loadLayout();
     if ($storage = Mage::getSingleton('customer/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->getLayout()->getBlock('head')->setTitle($blogTitle);
     $action->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('blog/blog/layout'));
     $action->renderLayout();
     return true;
 }
Exemplo n.º 5
0
 /**
  * Renders page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $id = null)
 {
     $model = Mage::getSingleton('manufacturer/manufacturer');
     if (!is_null($id) && $id !== $model->getId()) {
         if (!$model->load($id)) {
             return false;
         }
     }
     if (!$model->getId() or $model->getStatus() != 1) {
         return false;
     }
     //print_r($page->getData());exit;
     /*if ($page->getCustomTheme()) {
           $apply = true;
           $today = Mage::app()->getLocale()->date()->toValue();
           if (($from = $page->getCustomThemeFrom()) && strtotime($from)>$today) {
               $apply = false;
           }
           if ($apply && ($to = $page->getCustomThemeTo()) && strtotime($to)<$today) {
               $apply = false;
           }
           if ($apply) {
               list($package, $theme) = explode('/', $page->getCustomTheme());
               Mage::getSingleton('core/design_package')
                   ->setPackageName($package)
                   ->setTheme($theme);
           }
       }*/
     $action->loadLayout(array('default', 'manufacturer_view'), false, false);
     $action->getLayout()->getUpdate()->addUpdate($model->getLayoutUpdateXml());
     $action->generateLayoutXml()->generateLayoutBlocks();
     if ($storage = Mage::getSingleton('catalog/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     if ($storage = Mage::getSingleton('checkout/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->renderLayout();
     return true;
 }
Exemplo n.º 6
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null)
 {
     if (!($cat_id = Mage::getSingleton('blog/cat')->load($identifier)->getcatId())) {
         return false;
     }
     $page_title = Mage::getSingleton('blog/cat')->load($identifier)->getTitle();
     $blog_title = Mage::getStoreConfig('blog/blog/title') . " - ";
     $action->loadLayout();
     if ($storage = Mage::getSingleton('customer/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->getLayout()->getBlock('head')->setTitle($page_title);
     /*
      if (Mage::getStoreConfig('blog/rss/enable'))
      {
      Mage::helper('blog')->addRss($action->getLayout()->getBlock('head'), Mage::getUrl(Mage::getStoreConfig('blog/blog/route') . "/cat/" .$identifier) . "rss");
      }
     */
     $action->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('blog/blog/layout'));
     $action->renderLayout();
     return true;
 }
Exemplo n.º 7
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null)
 {
     if (!($cat_id = Mage::getSingleton("blog/cat")->load($identifier)->getCatId())) {
         return false;
     }
     $action->loadLayout();
     $layout = $action->getLayout();
     if ($storage = Mage::getSingleton("customer/session")) {
         $layout->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $blogTitle = Mage::getStoreConfig("fontis_blog/blog/title");
     $pageTitle = Mage::getSingleton("blog/cat")->load($identifier)->getTitle();
     if ($head = $layout->getBlock("head")) {
         $head->setTitle($blogTitle . " - " . $pageTitle);
         if (Mage::getStoreConfig("fontis_blog/rss/enabled")) {
             $head->addItem("rss", Mage::getUrl(Mage::helper("blog")->getBlogRoute() . "/cat/" . $identifier) . "rss");
         }
     }
     $layout->getBlock("root")->setTemplate(Mage::getStoreConfig("fontis_blog/blog/layout"));
     $action->renderLayout();
     return true;
 }
Exemplo n.º 8
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = null)
 {
     $page = Mage::getSingleton('cms/page');
     if (!is_null($pageId) && $pageId !== $page->getId()) {
         $page->setStoreId(Mage::app()->getStore()->getId());
         if (!$page->load($pageId)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     if ($page->getCustomTheme()) {
         if (Mage::app()->getLocale()->IsStoreDateInInterval(null, $page->getCustomThemeFrom(), $page->getCustomThemeTo())) {
             list($package, $theme) = explode('/', $page->getCustomTheme());
             Mage::getSingleton('core/design_package')->setPackageName($package)->setTheme($theme);
         }
     }
     $action->getLayout()->getUpdate()->addHandle('default')->addHandle('cms_page');
     $action->addActionLayoutHandles();
     if ($page->getRootTemplate()) {
         $action->getLayout()->helper('page/layout')->applyHandle($page->getRootTemplate());
     }
     $action->loadLayoutUpdates();
     $action->getLayout()->getUpdate()->addUpdate($page->getLayoutUpdateXml());
     $action->generateLayoutXml()->generateLayoutBlocks();
     if ($page->getRootTemplate()) {
         $action->getLayout()->helper('page/layout')->applyTemplate($page->getRootTemplate());
     }
     if ($storage = Mage::getSingleton('catalog/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     if ($storage = Mage::getSingleton('checkout/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->renderLayout();
     return true;
 }
Exemplo n.º 9
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = null)
 {
     $page = AO::getSingleton('cms/page');
     if (!is_null($pageId) && $pageId !== $page->getId()) {
         $page->setStoreId(AO::app()->getStore()->getId());
         if (!$page->load($pageId)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     if ($page->getCustomTheme()) {
         $apply = true;
         $today = AO::app()->getLocale()->date()->toValue();
         if (($from = $page->getCustomThemeFrom()) && strtotime($from) > $today) {
             $apply = false;
         }
         if ($apply && ($to = $page->getCustomThemeTo()) && strtotime($to) < $today) {
             $apply = false;
         }
         if ($apply) {
             list($package, $theme) = explode('/', $page->getCustomTheme());
             AO::getSingleton('core/design_package')->setPackageName($package)->setTheme($theme);
         }
     }
     $action->loadLayout(array('default', 'cms_page'), false, false);
     $action->getLayout()->getUpdate()->addUpdate($page->getLayoutUpdateXml());
     $action->generateLayoutXml()->generateLayoutBlocks();
     if ($storage = AO::getSingleton('catalog/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     if ($storage = AO::getSingleton('checkout/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->renderLayout();
     return true;
 }
Exemplo n.º 10
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = null)
 {
     $page = Mage::getSingleton('cms/page');
     if (!is_null($pageId) && $pageId !== $page->getId()) {
         $page->setStoreId(Mage::app()->getStore()->getId());
         if (!$page->load($pageId)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     //        $customerSession = Mage::getSingleton('customer/session');
     //        if (!$customerSession->authenticate($action)) {
     //            $customerSession->setBeforeAuthUrl(Mage::getBaseUrl().$page->getIdentifier());
     //            return true;
     //        }
     if ($page->getCustomTheme()) {
         $apply = true;
         $today = strtotime('today');
         if (($from = $page->getCustomThemeFrom()) && strtotime($from) > $today) {
             $apply = false;
         }
         if ($apply && ($to = $page->getCustomThemeTo()) && strtotime($to) < $today) {
             $apply = false;
         }
         if ($apply) {
             list($package, $theme) = explode('/', $page->getCustomTheme());
             Mage::getSingleton('core/design_package')->setPackageName($package)->setTheme($theme);
         }
     }
     $action->loadLayout(array('default', 'cms_page'), false, false);
     $action->getLayout()->getUpdate()->addUpdate($page->getLayoutUpdateXml());
     $action->generateLayoutXml()->generateLayoutBlocks();
     $action->renderLayout();
     return true;
 }
 /**
  * Before rendering layout, apply root template (if set)
  * and add various META items
  *
  * @param string $output = ''
  * @return $this
  */
 public function renderLayout($output = '')
 {
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if ($entity = $this->getEntityObject()) {
             $headBlock->addItem('link_rel', $entity->getUrl(), 'rel="canonical"');
         }
     }
     $rootTemplates = array_reverse($this->_rootTemplates);
     foreach ($rootTemplates as $rootTemplate) {
         if ($template = Mage::getStoreConfig('wordpress_blog/layout/' . $rootTemplate)) {
             $this->getLayout()->helper('page/layout')->applyTemplate($template);
             break;
         }
     }
     Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
             $headBlock->setRobots('noindex,nofollow');
         }
     }
     if (count($this->_crumbs) > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
         }
     }
     return parent::renderLayout($output);
 }
Exemplo n.º 12
0
 /**
  * Renders the attribute info page
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  */
 public function renderAllAttributesPage(Mage_Core_Controller_Front_Action $action)
 {
     $action->getLayout()->getUpdate()->addHandle('default')->addHandle('dc_catalog_attributeinfo_all');
     $action->addActionLayoutHandles();
     $action->loadLayoutUpdates();
     //$action->getLayout()->getUpdate()->addUpdate($attributeInfo->getLayoutUpdateXml());
     $action->generateLayoutXml()->generateLayoutBlocks();
     /*if (($attributeInfo->getRootTemplate()) && ('empty' != $attributeInfo->getRootTemplate())) {
           $action->getLayout()->helper('page/layout')
               ->applyTemplate($attributeInfo->getRootTemplate());
       }*/
     // show breadcrumbs
     if (Mage::getStoreConfig('web/default/show_cms_breadcrumbs') && ($breadcrumbs = $action->getLayout()->getBlock('breadcrumbs'))) {
         $breadcrumbs->addCrumb('home', array('label' => Mage::helper('dc_catalog')->__('Home'), 'title' => Mage::helper('dc_catalog')->__('Go to Home Page'), 'link' => Mage::getBaseUrl()));
         $attributeCode = Mage::registry('attribute_code');
         $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
         if (is_array($labels = $attribute->getStoreLabels()) && isset($labels[Mage::app()->getStore()->getId()])) {
             $label = $labels[Mage::app()->getStore()->getId()];
         } else {
             $label = $attribute->getFrontendLabel();
         }
         $breadcrumbs->addCrumb('allvalues', array('label' => Mage::helper('dc_catalog')->__($label . 's')));
     }
     if ($storage = Mage::getSingleton('catalog/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     if ($storage = Mage::getSingleton('checkout/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     $action->renderLayout();
     return true;
 }
Exemplo n.º 13
0
 /**
  * Before rendering layout, apply root template (if set)
  * and add various META items
  *
  * @param string $output = ''
  * @return $this
  */
 public function renderLayout($output = '')
 {
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if ($entity = $this->getEntityObject()) {
             $headBlock->addItem('link_rel', $entity->getCanonicalUrl() ? $entity->getCanonicalUrl() : $entity->getUrl(), 'rel="canonical"');
         }
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Feed"');
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('comments/feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Comments Feed"');
     }
     $rootTemplates = array_reverse($this->_rootTemplates);
     foreach ($rootTemplates as $rootTemplate) {
         if ($template = Mage::getStoreConfig('wordpress/template/' . $rootTemplate)) {
             $this->getLayout()->helper('page/layout')->applyTemplate($template);
             break;
         }
     }
     Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
             $headBlock->setRobots('noindex,nofollow');
         }
     }
     $crumbCount = count($this->_crumbs);
     if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             if (--$crumbCount === 0 && isset($crumb[0]['link'])) {
                 unset($crumb[0]['link']);
             }
             $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
         }
     }
     $this->_renderTitles();
     return parent::renderLayout($output);
 }
Exemplo n.º 14
0
 /**
  * Before rendering layout, apply root template (if set)
  * and add various META items
  *
  * @param string $output = ''
  * @return $this
  */
 public function renderLayout($output = '')
 {
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if ($entity = $this->getEntityObject()) {
             $headBlock->addItem('link_rel', $entity->getCanonicalUrl() ? $entity->getCanonicalUrl() : $entity->getUrl(), 'rel="canonical"');
         }
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Feed"');
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('comments/feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Comments Feed"');
     }
     Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
             $headBlock->setRobots('noindex,nofollow');
         }
     }
     $crumbCount = count($this->_crumbs);
     if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             if (--$crumbCount === 0 && isset($crumb[0]['link'])) {
                 unset($crumb[0]['link']);
             }
             if ($crumb[0]['title']) {
                 $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
             }
         }
     }
     if (count($this->_beforeBodyEndContent) > 0) {
         if ($beforeBodyEnd = $this->getLayout()->getBlock('before_body_end')) {
             $beforeBodyEnd->append($this->getLayout()->createBlock('core/text')->setText(implode("\n", $this->_beforeBodyEndContent)));
         }
     }
     $this->_renderTitles();
     Mage::helper('wordpress/social')->addCodeToHead();
     return parent::renderLayout($output);
 }
Exemplo n.º 15
0
 /**
  * Before rendering layout, apply root template (if set)
  * and add various META items
  *
  * @param string $output = ''
  * @return $this
  */
 public function renderLayout($output = '')
 {
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if ($entity = $this->getEntityObject()) {
             $headBlock->addItem('link_rel', $entity->getCanonicalUrl() ? $entity->getCanonicalUrl() : $entity->getUrl(), 'rel="canonical"');
         }
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Feed"');
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('comments/feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Comments Feed"');
     }
     Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
             $headBlock->setRobots('noindex,nofollow');
         }
     }
     $crumbCount = count($this->_crumbs);
     if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             if (--$crumbCount === 0 && isset($crumb[0]['link'])) {
                 unset($crumb[0]['link']);
             }
             if ($crumb[0]['title']) {
                 $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
             }
         }
     }
     if (count($this->_beforeBodyEndContent) > 0) {
         if ($beforeBodyEnd = $this->getLayout()->getBlock('before_body_end')) {
             $helper = Mage::helper('wordpress');
             $before = '';
             $jsTemplate = '<script type="text/javascript" src="%s"></script>';
             if ($this->_includejQuery) {
                 if ($headBlock = $this->getLayout()->getBlock('head')) {
                     if (strpos(implode(',', array_keys($headBlock->getItems())), 'jquery') === false) {
                         $before .= sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/jquery/jquery.js?ver=1.11.3'));
                         $before .= sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'));
                     }
                     if (strpos(implode(',', array_keys($headBlock->getItems())), 'underscore') === false) {
                         $before .= sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/underscore.min.js?ver=1.6.0'));
                     }
                 }
             }
             $beforeBodyEnd->append($this->getLayout()->createBlock('core/text')->setText($before . implode("\n", $this->_beforeBodyEndContent)));
         }
     }
     $this->_renderTitles();
     Mage::helper('wordpress/social')->addCodeToHead();
     return parent::renderLayout($output);
 }
Exemplo n.º 16
0
 /**
  * Before rendering layout, apply root template (if set)
  * and add various META items
  *
  * @param string $output = ''
  * @return $this
  */
 public function renderLayout($output = '')
 {
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if ($entity = $this->getEntityObject()) {
             $headBlock->addItem('link_rel', $entity->getCanonicalUrl() ? $entity->getCanonicalUrl() : $entity->getUrl(), 'rel="canonical"');
         }
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Feed"');
         $headBlock->addItem('link_rel', Mage::helper('wordpress')->getUrl('comments/feed/'), 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Comments Feed"');
     }
     $rootTemplates = array_reverse($this->_rootTemplates);
     foreach ($rootTemplates as $rootTemplate) {
         if ($template = Mage::getStoreConfig('wordpress/template/' . $rootTemplate)) {
             $this->getLayout()->helper('page/layout')->applyTemplate($template);
             break;
         }
     }
     Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
     if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
         if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
             $headBlock->setRobots('noindex,nofollow');
         }
     }
     $crumbCount = count($this->_crumbs);
     // determine if contributor or not
     $contributor = false;
     if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             if ($crumbName == 'author') {
                 // we need new breadcrumbs
                 $contributor = true;
             }
         }
     }
     if ($contributor) {
         // get contributor name
         $_old_name = $this->_crumbs['author'];
         // delete old entries
         unset($this->_crumbs['author_nolink']);
         unset($this->_crumbs['author']);
         // im-listening
         $this->_crumbs['im-listening'][0]['link'] = Mage::getBaseUrl() . 'im-listening';
         $this->_crumbs['im-listening'][0]['label'] = 'IM Listening';
         $this->_crumbs['im-listening'][0]['title'] = 'IM Listening';
         $this->_crumbs['contributors'][0]['link'] = Mage::getBaseUrl() . 'im-listening/contributors';
         $this->_crumbs['contributors'][0]['label'] = 'Contributors';
         $this->_crumbs['contributors'][0]['title'] = 'Contributors';
         // current user
         $_user_slug = explode('/', $_old_name[0]['link']);
         $this->_crumbs[$_user_slug[4]][0]['link'] = Mage::getBaseUrl() . 'im-listening/contributors/' . $_user_slug[4];
         $this->_crumbs[$_user_slug[4]][0]['label'] = $_old_name[0]['label'];
         $this->_crumbs[$_user_slug[4]][0]['title'] = $_old_name[0]['title'];
         $this->_crumbs['articles'][0]['link'] = Mage::getBaseUrl() . 'im-listening/contributors/' . $_user_slug[4] . '/all';
         $this->_crumbs['articles'][0]['label'] = 'All Articles';
         $this->_crumbs['articles'][0]['title'] = 'All Articles';
     }
     //		var_dump( $this->_crumbs );
     $urlString = Mage::helper('core/url')->getCurrentUrl();
     $url = Mage::getSingleton('core/url')->parseUrl($urlString);
     if (strpos($url->getPath(), 'im-listening/contributors') == 1 && count($this->_crumbs) == 1) {
         $this->_crumbs['im-listening'][0]['link'] = Mage::getBaseUrl() . 'im-listening';
         $this->_crumbs['im-listening'][0]['label'] = 'IM Listening';
         $this->_crumbs['im-listening'][0]['title'] = 'IM Listening';
         $this->_crumbs['contributors'][0]['link'] = Mage::getBaseUrl() . 'im-listening/contributors';
         $this->_crumbs['contributors'][0]['label'] = 'Contributors';
         $this->_crumbs['contributors'][0]['title'] = 'Contributors';
     }
     if (strpos($url->getPath(), 'im-listening/media') == 1 && count($this->_crumbs) == 1) {
         $this->_crumbs['im-listening'][0]['link'] = Mage::getBaseUrl() . 'im-listening';
         $this->_crumbs['im-listening'][0]['label'] = 'IM Listening';
         $this->_crumbs['im-listening'][0]['title'] = 'IM Listening';
         $this->_crumbs['media'][0]['link'] = Mage::getBaseUrl() . 'im-listening/media';
         $this->_crumbs['media'][0]['label'] = 'Media';
         $this->_crumbs['media'][0]['title'] = 'Media';
     }
     if (strpos($url->getPath(), 'im-listening/stories') == 1 && count($this->_crumbs) == 1) {
         $this->_crumbs['im-listening'][0]['link'] = Mage::getBaseUrl() . 'im-listening';
         $this->_crumbs['im-listening'][0]['label'] = 'IM Listening';
         $this->_crumbs['im-listening'][0]['title'] = 'IM Listening';
         $this->_crumbs['stories'][0]['link'] = Mage::getBaseUrl() . 'im-listening/stories';
         $this->_crumbs['stories'][0]['label'] = 'Stories';
         $this->_crumbs['stories'][0]['title'] = 'Stories';
     }
     if (strpos($url->getPath(), 'im-listening/interviews') == 1 && count($this->_crumbs) == 1) {
         $this->_crumbs['im-listening'][0]['link'] = Mage::getBaseUrl() . 'im-listening';
         $this->_crumbs['im-listening'][0]['label'] = 'IM Listening';
         $this->_crumbs['im-listening'][0]['title'] = 'IM Listening';
         $this->_crumbs['interviews'][0]['link'] = Mage::getBaseUrl() . 'im-listening/interviews';
         $this->_crumbs['interviews'][0]['label'] = 'Interviews';
         $this->_crumbs['interviews'][0]['title'] = 'Interviews';
     }
     // if stories
     // end samuel hack
     if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
         foreach ($this->_crumbs as $crumbName => $crumb) {
             if (--$crumbCount === 0 && isset($crumb[0]['link'])) {
                 unset($crumb[0]['link']);
             }
             $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
         }
     }
     return parent::renderLayout($output);
 }