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:  * Widgets Insertion Plugin Config for Editor HTML Element
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Widget
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Widget_Model_Widget_Config extends Varien_Object
 35: {
 36: 
 37:     /**
 38:      * Return config settings for widgets insertion plugin based on editor element config
 39:      *
 40:      * @param Varien_Object $config
 41:      * @return array
 42:      */
 43:     public function getPluginSettings($config)
 44:     {
 45:         $settings = array(
 46:             'widget_plugin_src'   => Mage::getBaseUrl('js').'mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js',
 47:             'widget_images_url'   => $this->getPlaceholderImagesBaseUrl(),
 48:             'widget_placeholders' => $this->getAvailablePlaceholderFilenames(),
 49:             'widget_window_url'   => $this->getWidgetWindowUrl($config)
 50:         );
 51: 
 52:         return $settings;
 53:     }
 54: 
 55:     /**
 56:      * Return Widget placeholders images URL
 57:      *
 58:      * @return string
 59:      */
 60:     public function getPlaceholderImagesBaseUrl()
 61:     {
 62:         return Mage::getDesign()->getSkinUrl('images/widget/');
 63:     }
 64: 
 65:     /**
 66:      * Return Widget placeholders images dir
 67:      *
 68:      * @return string
 69:      */
 70:     public function getPlaceholderImagesBaseDir()
 71:     {
 72:         return Mage::getDesign()->getSkinBaseDir() . DS . 'images' . DS . 'widget';
 73:     }
 74: 
 75:     /**
 76:      * Return list of existing widget image placeholders
 77:      *
 78:      * @return array
 79:      */
 80:     public function getAvailablePlaceholderFilenames()
 81:     {
 82:         $result = array();
 83:         $targetDir = $this->getPlaceholderImagesBaseDir();
 84:         if (is_dir($targetDir) && is_readable($targetDir)) {
 85:             $collection = new Varien_Data_Collection_Filesystem();
 86:             $collection->addTargetDir($targetDir)
 87:                 ->setCollectDirs(false)
 88:                 ->setCollectFiles(true)
 89:                 ->setCollectRecursively(false);
 90:             foreach ($collection as $file) {
 91:                 $result[] = $file->getBasename();
 92:             }
 93:         }
 94: 
 95:         return $result;
 96:     }
 97: 
 98:     /**
 99:      * Return Widgets Insertion Plugin Window URL
100:      *
101:      * @param Varien_Object Editor element config
102:      * @return string
103:      */
104:     public function getWidgetWindowUrl($config)
105:     {
106:         $params = array();
107: 
108:         $skipped = is_array($config->getData('skip_widgets')) ? $config->getData('skip_widgets') : array();
109:         if ($config->hasData('widget_filters')) {
110:             $all = Mage::getModel('widget/widget')->getWidgetsXml();
111:             $filtered = Mage::getModel('widget/widget')->getWidgetsXml($config->getData('widget_filters'));
112:             $reflection = new ReflectionObject($filtered);
113:             foreach ($all as $code => $widget) {
114:                 if (!$reflection->hasProperty($code)) {
115:                     $skipped[] = $widget->getAttribute('type');
116:                 }
117:             }
118:         }
119: 
120:         if (count($skipped) > 0) {
121:             $params['skip_widgets'] = $this->encodeWidgetsToQuery($skipped);
122:         }
123:         return Mage::getSingleton('adminhtml/url')->getUrl('*/widget/index', $params);
124:     }
125: 
126:     /**
127:      * Encode list of widget types into query param
128:      *
129:      * @param array $widgets List of widgets
130:      * @return string Query param value
131:      */
132:     public function encodeWidgetsToQuery($widgets)
133:     {
134:         $widgets = is_array($widgets) ? $widgets : array($widgets);
135:         $param = implode(',', $widgets);
136:         return Mage::helper('core')->urlEncode($param);
137:     }
138: 
139:     /**
140:      * Decode URL query param and return list of widgets
141:      *
142:      * @param string $queryParam Query param value to decode
143:      * @return array Array of widget types
144:      */
145:     public function decodeWidgetsFromQuery($queryParam)
146:     {
147:         $param = Mage::helper('core')->urlDecode($queryParam);
148:         return preg_split('/\s*\,\s*/', $param, 0, PREG_SPLIT_NO_EMPTY);
149:     }
150: 
151: }
152: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0