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 block reference 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_Block
 35:     extends Mage_Adminhtml_Block_Widget
 36: {
 37:     protected $_layoutHandlesXml = null;
 38: 
 39:     protected $_layoutHandleUpdates = array();
 40: 
 41:     protected $_layoutHandleUpdatesXml = null;
 42: 
 43:     protected $_layoutHandle = array();
 44: 
 45:     protected $_blocks = array();
 46: 
 47:     protected $_allowedBlocks = array();
 48: 
 49:     /**
 50:      * Setter
 51:      *
 52:      * @param array $allowedBlocks
 53:      * @return Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Block
 54:      */
 55:     public function setAllowedBlocks($allowedBlocks)
 56:     {
 57:         $this->_allowedBlocks = $allowedBlocks;
 58:         return $this;
 59:     }
 60: 
 61:     /**
 62:      * Add allowed block
 63:      *
 64:      * @param string $block
 65:      * @return Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Block
 66:      */
 67:     public function addAllowedBlock($block)
 68:     {
 69:         $this->_allowedBlocks[] = $block;
 70:         return $this;
 71:     }
 72: 
 73:     /**
 74:      * Getter
 75:      *
 76:      * @return array
 77:      */
 78:     public function getAllowedBlocks()
 79:     {
 80:         return $this->_allowedBlocks;
 81:     }
 82: 
 83:     /**
 84:      * Setter
 85:      * If string given exlopde to array by ',' delimiter
 86:      *
 87:      * @param string|array $layoutHandle
 88:      * @return Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Chooser_Block
 89:      */
 90:     public function setLayoutHandle($layoutHandle)
 91:     {
 92:         if (is_string($layoutHandle)) {
 93:             $layoutHandle = explode(',', $layoutHandle);
 94:         }
 95:         $this->_layoutHandle = array_merge(array('default'), (array)$layoutHandle);
 96:         return $this;
 97:     }
 98: 
 99:     /**
100:      * Getter
101:      *
102:      * @return array
103:      */
104:     public function getLayoutHandle()
105:     {
106:         return $this->_layoutHandle;
107:     }
108: 
109:     /**
110:      * Getter
111:      *
112:      * @return string
113:      */
114:     public function getArea()
115:     {
116:         if (!$this->_getData('area')) {
117:             return Mage_Core_Model_Design_Package::DEFAULT_AREA;
118:         }
119:         return $this->_getData('area');
120:     }
121: 
122:     /**
123:      * Getter
124:      *
125:      * @return string
126:      */
127:     public function getPackage()
128:     {
129:         if (!$this->_getData('package')) {
130:             return Mage_Core_Model_Design_Package::DEFAULT_PACKAGE;
131:         }
132:         return $this->_getData('package');
133:     }
134: 
135:     /**
136:      * Getter
137:      *
138:      * @return string
139:      */
140:     public function getTheme()
141:     {
142:         if (!$this->_getData('theme')) {
143:             return Mage_Core_Model_Design_Package::DEFAULT_THEME;
144:         }
145:         return $this->_getData('theme');
146:     }
147: 
148:     /**
149:      * Prepare html output
150:      *
151:      * @return string
152:      */
153:     protected function _toHtml()
154:     {
155:         $selectBlock = $this->getLayout()->createBlock('core/html_select')
156:             ->setName('block')
157:             ->setClass('required-entry select')
158:             ->setExtraParams('onchange="WidgetInstance.loadSelectBoxByType(\'block_template\','
159:                 .' this.up(\'div.group_container\'), this.value)"')
160:             ->setOptions($this->getBlocks())
161:             ->setValue($this->getSelected());
162:         return parent::_toHtml().$selectBlock->toHtml();
163:     }
164: 
165:     /**
166:      * Retrieve blocks array
167:      *
168:      * @return array
169:      */
170:     public function getBlocks()
171:     {
172:         if (empty($this->_blocks)) {
173:             /* @var $update Mage_Core_Model_Layout_Update */
174:             $update = Mage::getModel('core/layout')->getUpdate();
175:             /* @var $layoutHandles Mage_Core_Model_Layout_Element */
176:             $this->_layoutHandlesXml = $update->getFileLayoutUpdatesXml(
177:                 $this->getArea(),
178:                 $this->getPackage(),
179:                 $this->getTheme());
180:             $this->_collectLayoutHandles();
181:             $this->_collectBlocks();
182:             array_unshift($this->_blocks, array(
183:                 'value' => '',
184:                 'label' => Mage::helper('widget')->__('-- Please Select --')
185:             ));
186:         }
187:         return $this->_blocks;
188:     }
189: 
190:     /**
191:      * Merging layout handles and create xml of merged layout handles
192:      *
193:      */
194:     protected function _collectLayoutHandles()
195:     {
196:         foreach ($this->getLayoutHandle() as $handle) {
197:             $this->_mergeLayoutHandles($handle);
198:         }
199:         $updatesStr = '<'.'?xml version="1.0"?'.'><layout>'.implode('', $this->_layoutHandleUpdates).'</layout>';
200:         $this->_layoutHandleUpdatesXml = simplexml_load_string($updatesStr, 'Varien_Simplexml_Element');
201:     }
202: 
203:     /**
204:      * Adding layout handle that specified in node 'update' to general layout handles
205:      *
206:      * @param string $handle
207:      */
208:     public function _mergeLayoutHandles($handle)
209:     {
210:         foreach ($this->_layoutHandlesXml->{$handle} as $updateXml) {
211:             foreach ($updateXml->children() as $child) {
212:                 if (strtolower($child->getName()) == 'update' && isset($child['handle'])) {
213:                     $this->_mergeLayoutHandles((string)$child['handle']);
214:                 }
215:             }
216:             $this->_layoutHandleUpdates[] = $updateXml->asNiceXml();
217:         }
218:     }
219: 
220: 
221:     /**
222:      * Filter and collect blocks into array
223:      */
224:     protected function _collectBlocks()
225:     {
226:         if ($blocks = $this->_layoutHandleUpdatesXml->xpath('//block/label/..')) {
227:             /* @var $block Mage_Core_Model_Layout_Element */
228:             foreach ($blocks as $block) {
229:                 if ((string)$block->getAttribute('name') && $this->_filterBlock($block)) {
230:                     $helper = Mage::helper(Mage_Core_Model_Layout::findTranslationModuleName($block));
231:                     $this->_blocks[(string)$block->getAttribute('name')] = $helper->__((string)$block->label);
232:                 }
233:             }
234:         }
235:         asort($this->_blocks, SORT_STRING);
236:     }
237: 
238:     /**
239:      * Check whether given block match allowed block types
240:      *
241:      * @param Mage_Core_Model_Layout_Element $block
242:      * @return boolean
243:      */
244:     protected function _filterBlock($block)
245:     {
246:         if (!$this->getAllowedBlocks()) {
247:             return true;
248:         }
249:         if (in_array((string)$block->getAttribute('name'), $this->getAllowedBlocks())) {
250:             return true;
251:         }
252:         return false;
253:     }
254: }
255: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0