Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Catalog_Block_Seo_Sitemap_Tree_Pager
  • Mage_Page_Block_Html
  • Mage_Page_Block_Html_Breadcrumbs
  • Mage_Page_Block_Html_Footer
  • Mage_Page_Block_Html_Head
  • Mage_Page_Block_Html_Header
  • Mage_Page_Block_Html_Notices
  • Mage_Page_Block_Html_Pager
  • Mage_Page_Block_Html_Topmenu
  • Mage_Page_Block_Html_Welcome
  • Mage_Page_Block_Html_Wrapper
  • Mage_Page_Block_Js_Cookie
  • Mage_Page_Block_Redirect
  • Mage_Page_Helper_Data
  • Mage_Page_Helper_Html
  • Mage_Page_Helper_Layout
  • Mage_Page_Model_Config
  • Mage_Page_Model_Source_Layout
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Page
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Page layout helper
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Page
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Page_Helper_Layout extends Mage_Core_Helper_Abstract
 35: {
 36:     /**
 37:      * Apply page layout handle
 38:      *
 39:      * @param string $pageLayout
 40:      * @return Mage_Page_Helper_Layout
 41:      */
 42:     public function applyHandle($pageLayout)
 43:     {
 44:         $pageLayout = $this->_getConfig()->getPageLayout($pageLayout);
 45: 
 46:         if (!$pageLayout) {
 47:             return $this;
 48:         }
 49: 
 50:         $this->getLayout()
 51:             ->getUpdate()
 52:             ->addHandle($pageLayout->getLayoutHandle());
 53: 
 54:         return $this;
 55:     }
 56: 
 57:     /**
 58:      * Apply page layout template
 59:      * (for old design packages)
 60:      *
 61:      * @param string $pageLayout
 62:      * @return Mage_Page_Helper_Layout
 63:      */
 64:     public function applyTemplate($pageLayout = null)
 65:     {
 66:         if ($pageLayout === null) {
 67:             $pageLayout = $this->getCurrentPageLayout();
 68:         } else {
 69:             $pageLayout = $this->_getConfig()->getPageLayout($pageLayout);
 70:         }
 71: 
 72:         if (!$pageLayout) {
 73:             return $this;
 74:         }
 75: 
 76:         if ($this->getLayout()->getBlock('root') &&
 77:             !$this->getLayout()->getBlock('root')->getIsHandle()) {
 78:                 // If not applied handle
 79:                 $this->getLayout()
 80:                     ->getBlock('root')
 81:                     ->setTemplate($pageLayout->getTemplate());
 82:         }
 83: 
 84:         return $this;
 85:     }
 86: 
 87:     /**
 88:      * Retrieve current applied page layout
 89:      *
 90:      * @return Varien_Object|boolean
 91:      */
 92:     public function getCurrentPageLayout()
 93:     {
 94:         if ($this->getLayout()->getBlock('root') &&
 95:             $this->getLayout()->getBlock('root')->getLayoutCode()) {
 96:             return $this->_getConfig()->getPageLayout($this->getLayout()->getBlock('root')->getLayoutCode());
 97:         }
 98: 
 99:         // All loaded handles
100:         $handles = $this->getLayout()->getUpdate()->getHandles();
101:         // Handles used in page layouts
102:         $pageLayoutHandles = $this->_getConfig()->getPageLayoutHandles();
103:         // Applied page layout handles
104:         $appliedHandles = array_intersect($handles, $pageLayoutHandles);
105: 
106:         if (empty($appliedHandles)) {
107:             return false;
108:         }
109: 
110:         $currentHandle = array_pop($appliedHandles);
111: 
112:         $layoutCode = array_search($currentHandle, $pageLayoutHandles, true);
113: 
114:         return $this->_getConfig()->getPageLayout($layoutCode);
115:     }
116: 
117:     /**
118:      * Retrieve page config
119:      *
120:      * @return Mage_Page_Model_Config
121:      */
122:     protected function _getConfig()
123:     {
124:         return Mage::getSingleton('page/config');
125:     }
126: }
127: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0