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_Widget_Adminhtml_Widget_InstanceController
  • Mage_Widget_Adminhtml_WidgetController
  • Mage_Widget_Block_Adminhtml_Widget_Form
  • Mage_Widget_Block_Adminhtml_Widget_Instance
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Block
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Layout
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Template
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Form
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main_Layout
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Properties
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Settings
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tabs
  • Mage_Widget_Block_Adminhtml_Widget_Instance_Grid
  • Mage_Widget_Block_Adminhtml_Widget_Options
  • Mage_Widget_Helper_Data
  • Mage_Widget_Model_Mysql4_Widget
  • Mage_Widget_Model_Mysql4_Widget_Instance
  • Mage_Widget_Model_Mysql4_Widget_Instance_Collection
  • Mage_Widget_Model_Observer
  • Mage_Widget_Model_Resource_Widget
  • Mage_Widget_Model_Resource_Widget_Instance
  • Mage_Widget_Model_Resource_Widget_Instance_Collection
  • Mage_Widget_Model_Template_Filter
  • Mage_Widget_Model_Widget
  • Mage_Widget_Model_Widget_Config
  • Mage_Widget_Model_Widget_Instance

Interfaces

  • Mage_Widget_Block_Interface
  • 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_Widget
 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:  * Widget Instance layouts chooser
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Widget
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Layout
 35:     extends Mage_Adminhtml_Block_Widget
 36: {
 37:     protected $_layoutHandles = array();
 38: 
 39:     /**
 40:      * layout handles wildcar patterns
 41:      *
 42:      * @var array
 43:      */
 44:     protected $_layoutHandlePatterns = array(
 45:         '^default$',
 46:         '^catalog_category_*',
 47:         '^catalog_product_*',
 48:         '^PRODUCT_*'
 49:     );
 50: 
 51:     /**
 52:      * Constructor
 53:      */
 54:     protected function _construct()
 55:     {
 56:         parent::_construct();
 57:     }
 58: 
 59:     /**
 60:      * Add not allowed layout handle pattern
 61:      *
 62:      * @param string $pattern
 63:      * @return Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Layout
 64:      */
 65:     public function addLayoutHandlePattern($pattern)
 66:     {
 67:         $this->_layoutHandlePatterns[] = $pattern;
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * Getter
 73:      *
 74:      * @return array
 75:      */
 76:     public function getLayoutHandlePatterns()
 77:     {
 78:         return $this->_layoutHandlePatterns;
 79:     }
 80: 
 81:     /**
 82:      * Getter
 83:      *
 84:      * @return string
 85:      */
 86:     public function getArea()
 87:     {
 88:         if (!$this->_getData('area')) {
 89:             return Mage_Core_Model_Design_Package::DEFAULT_AREA;
 90:         }
 91:         return $this->_getData('area');
 92:     }
 93: 
 94:     /**
 95:      * Getter
 96:      *
 97:      * @return string
 98:      */
 99:     public function getPackage()
100:     {
101:         if (!$this->_getData('package')) {
102:             return Mage_Core_Model_Design_Package::DEFAULT_PACKAGE;
103:         }
104:         return $this->_getData('package');
105:     }
106: 
107:     /**
108:      * Getter
109:      *
110:      * @return string
111:      */
112:     public function getTheme()
113:     {
114:         if (!$this->_getData('theme')) {
115:             return Mage_Core_Model_Design_Package::DEFAULT_THEME;
116:         }
117:         return $this->_getData('theme');
118:     }
119: 
120:     /**
121:      * Prepare html output
122:      *
123:      * @return string
124:      */
125:     protected function _toHtml()
126:     {
127:         $selectBlock = $this->getLayout()->createBlock('core/html_select')
128:             ->setName($this->getSelectName())
129:             ->setId('layout_handle')
130:             ->setClass('required-entry select')
131:             ->setExtraParams("onchange=\"WidgetInstance.loadSelectBoxByType(\'block_reference\', " .
132:                             "this.up(\'div.pages\'), this.value)\"")
133:             ->setOptions($this->getLayoutHandles(
134:                 $this->getArea(),
135:                 $this->getPackage(),
136:                 $this->getTheme()));
137:         return parent::_toHtml().$selectBlock->toHtml();
138:     }
139: 
140:     /**
141:      * Retrieve layout handles
142:      *
143:      * @param string $area
144:      * @param string $package
145:      * @param string $theme
146:      * @return array
147:      */
148:     public function getLayoutHandles($area, $package, $theme)
149:     {
150:         if (empty($this->_layoutHandles)) {
151:             /* @var $update Mage_Core_Model_Layout_Update */
152:             $update = Mage::getModel('core/layout')->getUpdate();
153:             $this->_layoutHandles[''] = Mage::helper('widget')->__('-- Please Select --');
154:             $this->_collectLayoutHandles($update->getFileLayoutUpdatesXml($area, $package, $theme));
155:         }
156:         return $this->_layoutHandles;
157:     }
158: 
159:     /**
160:      * Filter and collect layout handles into array
161:      *
162:      * @param Mage_Core_Model_Layout_Element $layoutHandles
163:      */
164:     protected function _collectLayoutHandles($layoutHandles)
165:     {
166:         if ($layoutHandlesArr = $layoutHandles->xpath('/*/*/label/..')) {
167:             foreach ($layoutHandlesArr as $node) {
168:                 if ($this->_filterLayoutHandle($node->getName())) {
169:                     $helper = Mage::helper(Mage_Core_Model_Layout::findTranslationModuleName($node));
170:                     $this->_layoutHandles[$node->getName()] = $this->helper('core')->jsQuoteEscape(
171:                         $helper->__((string)$node->label)
172:                     );
173:                 }
174:             }
175:             asort($this->_layoutHandles, SORT_STRING);
176:         }
177:     }
178: 
179:     /**
180:      * Check if given layout handle allowed (do not match not allowed patterns)
181:      *
182:      * @param string $layoutHandle
183:      * @return boolean
184:      */
185:     protected function _filterLayoutHandle($layoutHandle)
186:     {
187:         $wildCard = '/('.implode(')|(', $this->getLayoutHandlePatterns()).')/';
188:         if (preg_match($wildCard, $layoutHandle)) {
189:             return false;
190:         }
191:         return true;
192:     }
193: }
194: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0