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 page groups (predefined layouts group) to display on
 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_Tab_Main_Layout
 35:     extends Mage_Adminhtml_Block_Template implements Varien_Data_Form_Element_Renderer_Interface
 36: {
 37:     /**
 38:      * @var Varien_Data_Form_Element_Abstract
 39:      */
 40:     protected $_element = null;
 41: 
 42:     /**
 43:      * Internal constructor
 44:      */
 45:     protected function _construct()
 46:     {
 47:         parent::_construct();
 48:         $this->setTemplate('widget/instance/edit/layout.phtml');
 49:     }
 50: 
 51:     /**
 52:      * Render given element (return html of element)
 53:      *
 54:      * @return string
 55:      */
 56:     public function render(Varien_Data_Form_Element_Abstract $element)
 57:     {
 58:         $this->setElement($element);
 59:         return $this->toHtml();
 60:     }
 61: 
 62:     /**
 63:      * Setter
 64:      *
 65:      * @param Varien_Data_Form_Element_Abstract $element
 66:      * @return
 67:      */
 68:     public function setElement(Varien_Data_Form_Element_Abstract $element)
 69:     {
 70:         $this->_element = $element;
 71:         return $this;
 72:     }
 73: 
 74:     /**
 75:      * Getter
 76:      *
 77:      * @return Varien_Data_Form_Element_Abstract
 78:      */
 79:     public function getElement()
 80:     {
 81:         return $this->_element;
 82:     }
 83: 
 84:     /**
 85:      * Generate url to get categories chooser by ajax query
 86:      *
 87:      * @return string
 88:      */
 89:     public function getCategoriesChooserUrl()
 90:     {
 91:         return $this->getUrl('*/*/categories', array('_current' => true));
 92:     }
 93: 
 94:     /**
 95:      * Generate url to get products chooser by ajax query
 96:      *
 97:      * @return string
 98:      */
 99:     public function getProductsChooserUrl()
100:     {
101:         return $this->getUrl('*/*/products', array('_current' => true));
102:     }
103: 
104:     /**
105:      * Generate url to get reference block chooser by ajax query
106:      *
107:      * @return string
108:      */
109:     public function getBlockChooserUrl()
110:     {
111:         return $this->getUrl('*/*/blocks', array('_current' => true));
112:     }
113: 
114:     /**
115:      * Generate url to get template chooser by ajax query
116:      *
117:      * @return string
118:      */
119:     public function getTemplateChooserUrl()
120:     {
121:         return $this->getUrl('*/*/template', array('_current' => true));
122:     }
123: 
124:     /**
125:      * Create and return html of select box Display On
126:      *
127:      * @return string
128:      */
129:     public function getDisplayOnSelectHtml()
130:     {
131:         $selectBlock = $this->getLayout()->createBlock('core/html_select')
132:             ->setName('widget_instance[{{id}}][page_group]')
133:             ->setId('widget_instance[{{id}}][page_group]')
134:             ->setClass('required-entry page_group_select select')
135:             ->setExtraParams("onchange=\"WidgetInstance.displayPageGroup(this.value+\'_{{id}}\')\"")
136:             ->setOptions($this->_getDisplayOnOptions());
137:         return $selectBlock->toHtml();
138:     }
139: 
140:     /**
141:      * Retrieve Display On options array.
142:      * - Categories (anchor and not anchor)
143:      * - Products (product types depend on configuration)
144:      * - Generic (predefined) pages (all pages and single layout update)
145:      *
146:      * @return array
147:      */
148:     protected function _getDisplayOnOptions()
149:     {
150:         $options = array();
151:         $options[] = array(
152:             'value' => '',
153:             'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('-- Please Select --'))
154:         );
155:         $options[] = array(
156:             'label' => Mage::helper('widget')->__('Categories'),
157:             'value' => array(
158:                 array(
159:                     'value' => 'anchor_categories',
160:                     'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Anchor Categories'))
161:                 ),
162:                 array(
163:                     'value' => 'notanchor_categories',
164:                     'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Non-Anchor Categories'))
165:                 )
166:             )
167:         );
168:         foreach (Mage_Catalog_Model_Product_Type::getTypes() as $typeId => $type) {
169:             $productsOptions[] = array(
170:                'value' => $typeId.'_products',
171:                'label' => $this->helper('core')->jsQuoteEscape($type['label'])
172:             );
173:         }
174:         array_unshift($productsOptions, array(
175:             'value' => 'all_products',
176:             'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('All Product Types'))
177:         ));
178:         $options[] = array(
179:             'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Products')),
180:             'value' => $productsOptions
181:         );
182:         $options[] = array(
183:             'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Generic Pages')),
184:             'value' => array(
185:                 array(
186:                     'value' => 'all_pages',
187:                     'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('All Pages'))
188:                 ),
189:                 array(
190:                     'value' => 'pages',
191:                     'label' => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Specified Page'))
192:                 )
193:             )
194:         );
195:         return $options;
196:     }
197: 
198:     /**
199:      * Generate array of parameters for every container type to create html template
200:      *
201:      * @return array
202:      */
203:     public function getDisplayOnContainers()
204:     {
205:         $container = array();
206:         $container['anchor'] = array(
207:             'label' => 'Categories',
208:             'code' => 'categories',
209:             'name' => 'anchor_categories',
210:             'layout_handle' => 'default,catalog_category_layered',
211:             'is_anchor_only' => 1,
212:             'product_type_id' => ''
213:         );
214:         $container['notanchor'] = array(
215:             'label' => 'Categories',
216:             'code' => 'categories',
217:             'name' => 'notanchor_categories',
218:             'layout_handle' => 'default,catalog_category_default',
219:             'is_anchor_only' => 0,
220:             'product_type_id' => ''
221:         );
222:         $container['all_products'] = array(
223:             'label' => 'Products',
224:             'code' => 'products',
225:             'name' => 'all_products',
226:             'layout_handle' => 'default,catalog_product_view',
227:             'is_anchor_only' => '',
228:             'product_type_id' => ''
229:         );
230:         foreach (Mage_Catalog_Model_Product_Type::getTypes() as $typeId => $type) {
231:             $container[$typeId] = array(
232:                 'label' => 'Products',
233:                 'code' => 'products',
234:                 'name' => $typeId . '_products',
235:                 'layout_handle' => 'default,catalog_product_view,PRODUCT_TYPE_'.$typeId,
236:                 'is_anchor_only' => '',
237:                 'product_type_id' => $typeId
238:             );
239:         }
240:         return $container;
241:     }
242: 
243:     /**
244:      * Retrieve layout select chooser html
245:      *
246:      * @return string
247:      */
248:     public function getLayoutsChooser()
249:     {
250:         $layouts = $this->getLayout()
251:             ->createBlock('widget/adminhtml_widget_instance_edit_chooser_layout')
252:             ->setSelectName('widget_instance[{{id}}][pages][layout_handle]')
253:             ->setArea($this->getWidgetInstance()->getArea())
254:             ->setPackage($this->getWidgetInstance()->getPackage())
255:             ->setTheme($this->getWidgetInstance()->getTheme());
256:         return $layouts->toHtml();
257:     }
258: 
259:     /**
260:      * Retrieve add layout button html
261:      *
262:      * @return string
263:      */
264:     public function getAddLayoutButtonHtml()
265:     {
266:         $button = $this->getLayout()->createBlock('adminhtml/widget_button')
267:             ->setData(array(
268:                 'label'     => Mage::helper('widget')->__('Add Layout Update'),
269:                 'onclick'   => 'WidgetInstance.addPageGroup({})',
270:                 'class'     => 'add'
271:             ));
272:         return $button->toHtml();
273:     }
274: 
275:     /**
276:      * Retrieve remove layout button html
277:      *
278:      * @return string
279:      */
280:     public function getRemoveLayoutButtonHtml()
281:     {
282:         $button = $this->getLayout()->createBlock('adminhtml/widget_button')
283:             ->setData(array(
284:                 'label'     => $this->helper('core')->jsQuoteEscape(Mage::helper('widget')->__('Remove Layout Update')),
285:                 'onclick'   => 'WidgetInstance.removePageGroup(this)',
286:                 'class'     => 'delete'
287:             ));
288:         return $button->toHtml();
289:     }
290: 
291:     /**
292:      * Prepare and retrieve page groups data of widget instance
293:      *
294:      * @return array
295:      */
296:     public function getPageGroups()
297:     {
298:         $widgetInstance = $this->getWidgetInstance();
299:         $pageGroups = array();
300:         if ($widgetInstance->getPageGroups()) {
301:             foreach ($widgetInstance->getPageGroups() as $pageGroup) {
302:                 $pageGroups[] = array(
303:                     'page_id' => $pageGroup['page_id'],
304:                     'group' => $pageGroup['page_group'],
305:                     'block' => $pageGroup['block_reference'],
306:                     'for_value'   => $pageGroup['page_for'],
307:                     'layout_handle' => $pageGroup['layout_handle'],
308:                     $pageGroup['page_group'].'_entities' => $pageGroup['entities'],
309:                     'template' => $pageGroup['page_template']
310:                 );
311:             }
312:         }
313:         return $pageGroups;
314:     }
315: }
316: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0