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_XmlConnect_Adminhtml_MobileController
  • Mage_XmlConnect_Block_Adminhtml_History
  • Mage_XmlConnect_Block_Adminhtml_History_Grid
  • Mage_XmlConnect_Block_Adminhtml_Mobile
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Form
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Submission
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Cache
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Images
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Tabs
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Accordion_Themes
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Preview
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Design_Themes
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Flurryanalytics
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_General
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Notification
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Payment
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Settings
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Social
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Submission_History
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tabs
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Addrow
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Color
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Country
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Datetime
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Font
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Image
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Tabs
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Theme
  • Mage_Xmlconnect_Block_Adminhtml_Mobile_Grid
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Grid_Renderer_Bool
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Grid_Renderer_Type
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Preview_Content
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Preview_Tabitems
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Form
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Androidmarket
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tab_Container
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tab_Container_Submission
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Tabs
  • Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
  • Mage_XmlConnect_Block_Adminhtml_Queue
  • Mage_XmlConnect_Block_Adminhtml_Queue_Edit
  • Mage_XmlConnect_Block_Adminhtml_Queue_Edit_Form
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Action
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Application
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Id
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Msgtitle
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Pushtitle
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Status
  • Mage_XmlConnect_Block_Adminhtml_Queue_Grid_Renderer_Template
  • Mage_XmlConnect_Block_Adminhtml_Template
  • Mage_XmlConnect_Block_Adminhtml_Template_Edit
  • Mage_XmlConnect_Block_Adminhtml_Template_Edit_Form
  • Mage_XmlConnect_Block_Adminhtml_Template_Grid
  • Mage_XmlConnect_Block_Adminhtml_Template_Grid_Renderer_Application
  • Mage_XmlConnect_Block_Adminhtml_Template_Grid_Renderer_Name
  • Mage_XmlConnect_Block_Adminhtml_Template_Preview
  • Mage_XmlConnect_Block_Adminhtml_Template_Preview_Form
  • Mage_XmlConnect_Block_Cart
  • Mage_XmlConnect_Block_Cart_Crosssell
  • Mage_XmlConnect_Block_Cart_Info
  • Mage_XmlConnect_Block_Cart_Item_Renderer
  • Mage_XmlConnect_Block_Cart_Item_Renderer_Configurable
  • Mage_XmlConnect_Block_Cart_Item_Renderer_Grouped
  • Mage_XmlConnect_Block_Cart_Paypal_Mecl_Details
  • Mage_XmlConnect_Block_Cart_Paypal_Mecl_Review
  • Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
  • Mage_XmlConnect_Block_Cart_Paypal_Mep_Totals
  • Mage_XmlConnect_Block_Cart_Totals
  • Mage_XmlConnect_Block_Catalog
  • Mage_XmlConnect_Block_Catalog_Category
  • Mage_XmlConnect_Block_Catalog_Category_Info
  • Mage_XmlConnect_Block_Catalog_Filters
  • Mage_XmlConnect_Block_Catalog_Product
  • Mage_XmlConnect_Block_Catalog_Product_Attributes
  • Mage_XmlConnect_Block_Catalog_Product_Gallery
  • Mage_XmlConnect_Block_Catalog_Product_List
  • Mage_XmlConnect_Block_Catalog_Product_Options
  • Mage_XmlConnect_Block_Catalog_Product_Options_Bundle
  • Mage_XmlConnect_Block_Catalog_Product_Options_Configurable
  • Mage_XmlConnect_Block_Catalog_Product_Options_Giftcard
  • Mage_XmlConnect_Block_Catalog_Product_Options_Grouped
  • Mage_XmlConnect_Block_Catalog_Product_Options_Simple
  • Mage_XmlConnect_Block_Catalog_Product_Options_Virtual
  • Mage_XmlConnect_Block_Catalog_Product_Price
  • Mage_XmlConnect_Block_Catalog_Product_Price_Bundle
  • Mage_XmlConnect_Block_Catalog_Product_Price_Default
  • Mage_XmlConnect_Block_Catalog_Product_Price_Giftcard
  • Mage_XmlConnect_Block_Catalog_Product_Related
  • Mage_XmlConnect_Block_Catalog_Product_Review
  • Mage_XmlConnect_Block_Catalog_Product_Review_List
  • Mage_XmlConnect_Block_Catalog_Search
  • Mage_XmlConnect_Block_Catalog_Search_Suggest
  • Mage_XmlConnect_Block_Checkout_Address_Billing
  • Mage_XmlConnect_Block_Checkout_Address_Form
  • Mage_XmlConnect_Block_Checkout_Address_Shipping
  • Mage_XmlConnect_Block_Checkout_Agreements
  • Mage_XmlConnect_Block_Checkout_Order_Review
  • Mage_XmlConnect_Block_Checkout_Order_Review_Info
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Authorizenet
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Ccsave
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Checkmo
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Authorizenet
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Ccsave
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Checkmo
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Free
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Abstract
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Express
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Paypal_Mecl
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Pbridge_Authorizenet
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Pbridge_Paypal_Direct
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Pbridge_Paypaluk_Direct
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Pbridge_Verisign
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Info_Purchaseorder
  • Mage_XmlConnect_Block_Checkout_Payment_Method_List
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Paypal_Direct
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Paypal_Payflow
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Abstract
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Authorizenet
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Paypal
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Paypaluk
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Pbridge_Verisign
  • Mage_XmlConnect_Block_Checkout_Payment_Method_Purchaseorder
  • Mage_XmlConnect_Block_Checkout_Pbridge_Result
  • Mage_XmlConnect_Block_Checkout_Shipping_Method_Available
  • Mage_XmlConnect_Block_Cms_Page
  • Mage_XmlConnect_Block_Configuration
  • Mage_XmlConnect_Block_Customer_Address_Form
  • Mage_XmlConnect_Block_Customer_Address_List
  • Mage_XmlConnect_Block_Customer_Form
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Boolean
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Date
  • Mage_XmlConnect_Block_Customer_Form_Renderer_File
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Image
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Multiline
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Multiselect
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Select
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Text
  • Mage_XmlConnect_Block_Customer_Form_Renderer_Textarea
  • Mage_XmlConnect_Block_Customer_GiftcardCheck
  • Mage_XmlConnect_Block_Customer_Order_Details
  • Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Bundle
  • Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Default
  • Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Downloadable
  • Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Giftcard
  • Mage_XmlConnect_Block_Customer_Order_Item_Renderer_Grouped
  • Mage_XmlConnect_Block_Customer_Order_Items
  • Mage_XmlConnect_Block_Customer_Order_List
  • Mage_XmlConnect_Block_Customer_Order_Totals
  • Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance
  • Mage_XmlConnect_Block_Customer_Order_Totals_Customerbalance_Refunded
  • Mage_XmlConnect_Block_Customer_Order_Totals_Giftcards
  • Mage_XmlConnect_Block_Customer_Order_Totals_Tax
  • Mage_XmlConnect_Block_Customer_Storecredit
  • Mage_XmlConnect_Block_Home
  • Mage_XmlConnect_Block_Review_Form
  • Mage_XmlConnect_Block_Wishlist
  • Mage_XmlConnect_CartController
  • Mage_XmlConnect_CatalogController
  • Mage_XmlConnect_CheckoutController
  • Mage_XmlConnect_CmsController
  • Mage_XmlConnect_ConfigurationController
  • Mage_XmlConnect_Controller_Action
  • Mage_XmlConnect_CustomerController
  • Mage_XmlConnect_Helper_Android
  • Mage_XmlConnect_Helper_Catalog_Category_Image
  • Mage_XmlConnect_Helper_Customer_Form_Renderer
  • Mage_XmlConnect_Helper_Customer_Order
  • Mage_XmlConnect_Helper_Data
  • Mage_XmlConnect_Helper_Image
  • Mage_XmlConnect_Helper_Ipad
  • Mage_XmlConnect_Helper_Iphone
  • Mage_XmlConnect_Helper_Theme
  • Mage_XmlConnect_IndexController
  • Mage_XmlConnect_Model_Adminhtml_System_Config_Backend_Baseurl
  • Mage_XmlConnect_Model_Adminhtml_System_Config_Backend_Currency_Default
  • Mage_XmlConnect_Model_Application
  • Mage_XmlConnect_Model_Catalog_Category_Image
  • Mage_XmlConnect_Model_ConfigData
  • Mage_XmlConnect_Model_History
  • Mage_XmlConnect_Model_Mysql4_Application
  • Mage_XmlConnect_Model_Mysql4_Application_Collection
  • Mage_XmlConnect_Model_Mysql4_Cms_Page_Collection
  • Mage_XmlConnect_Model_Mysql4_ConfigData
  • Mage_XmlConnect_Model_Mysql4_ConfigData_Collection
  • Mage_XmlConnect_Model_Mysql4_Filter_Collection
  • Mage_XmlConnect_Model_Mysql4_History
  • Mage_XmlConnect_Model_Mysql4_History_Collection
  • Mage_XmlConnect_Model_Mysql4_Queue
  • Mage_XmlConnect_Model_Mysql4_Queue_Collection
  • Mage_XmlConnect_Model_Mysql4_Setup
  • Mage_XmlConnect_Model_Mysql4_Template
  • Mage_XmlConnect_Model_Mysql4_Template_Collection
  • Mage_XmlConnect_Model_Observer
  • Mage_XmlConnect_Model_Payment_Method_Paypal_Config
  • Mage_XmlConnect_Model_Payment_Method_Paypal_Mecl
  • Mage_XmlConnect_Model_Payment_Method_Paypal_Mep
  • Mage_XmlConnect_Model_Paypal_Mecl_Checkout
  • Mage_XmlConnect_Model_Paypal_Mep_Checkout
  • Mage_XmlConnect_Model_Preview_Abstract
  • Mage_XmlConnect_Model_Preview_Android
  • Mage_XmlConnect_Model_Preview_Ipad
  • Mage_XmlConnect_Model_Preview_Iphone
  • Mage_XmlConnect_Model_Queue
  • Mage_XmlConnect_Model_Resource_Application
  • Mage_XmlConnect_Model_Resource_Application_Collection
  • Mage_XmlConnect_Model_Resource_Cms_Page_Collection
  • Mage_XmlConnect_Model_Resource_ConfigData
  • Mage_XmlConnect_Model_Resource_ConfigData_Collection
  • Mage_XmlConnect_Model_Resource_Filter_Collection
  • Mage_XmlConnect_Model_Resource_History
  • Mage_XmlConnect_Model_Resource_History_Collection
  • Mage_XmlConnect_Model_Resource_Queue
  • Mage_XmlConnect_Model_Resource_Queue_Collection
  • Mage_XmlConnect_Model_Resource_Setup
  • Mage_XmlConnect_Model_Resource_Template
  • Mage_XmlConnect_Model_Resource_Template_Collection
  • Mage_XmlConnect_Model_Simplexml_Element
  • Mage_XmlConnect_Model_Simplexml_Form
  • Mage_XmlConnect_Model_Simplexml_Form_Abstract
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Checkbox
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Collection
  • Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Date
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Email
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Fieldset
  • Mage_XmlConnect_Model_Simplexml_Form_Element_File
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Image
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Multiline
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Multiselect
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Select
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Text
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Textarea
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Validator
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Validator_Abstract
  • Mage_XmlConnect_Model_Simplexml_Form_Element_Validator_Rule
  • Mage_XmlConnect_Model_Tabs
  • Mage_XmlConnect_Model_Template
  • Mage_XmlConnect_Model_Theme
  • Mage_XmlConnect_Paypal_MeclController
  • Mage_XmlConnect_Paypal_MepController
  • Mage_XmlConnect_PbridgeController
  • Mage_XmlConnect_ReviewController
  • Mage_XmlConnect_WishlistController

Interfaces

  • Mage_XmlConnect_Model_Simplexml_Form_Element_Renderer_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_XmlConnect
 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:  * XmlConnect Theme model
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Xmlconnect
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_XmlConnect_Model_Theme
 35: {
 36:     /**
 37:      * Current theme file
 38:      *
 39:      * @var string|null
 40:      */
 41:     protected $_file = null;
 42: 
 43:     /**
 44:      * Loaded theme xml object
 45:      *
 46:      * @var SimpleXMLElement|null
 47:      */
 48:     protected $_xml = null;
 49: 
 50:     /**
 51:      * Theme configuration
 52:      *
 53:      * @var array|null
 54:      */
 55:     protected $_conf = null;
 56: 
 57:     /**
 58:      * Load Theme xml from $file
 59:      *
 60:      * @param string $file
 61:      * @throws Mage_Core_Exception
 62:      */
 63:     public function __construct($file)
 64:     {
 65:         $this->_file = $file;
 66:         if (!file_exists($file)) {
 67:             Mage::throwException(Mage::helper('xmlconnect')->__('File doesn\'t exist "%s".', $file));
 68:         }
 69:         if (!is_readable($file)) {
 70:             Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t read file "%s".', $file));
 71:         }
 72:         try {
 73:             $text = file_get_contents($file);
 74:             $this->_xml = simplexml_load_string($text);
 75:         } catch (Exception $e) {
 76:             Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t load XML.'));
 77:         }
 78:         if (empty($this->_xml)) {
 79:             Mage::throwException(Mage::helper('xmlconnect')->__('Invalid XML.'));
 80:         }
 81:         $this->_conf = $this->_xmlToArray($this->_xml->configuration);
 82:         $this->_conf = $this->_conf['configuration'];
 83:         if (!is_array($this->_conf)) {
 84:             Mage::throwException(Mage::helper('xmlconnect')->__('Wrong theme format.'));
 85:         }
 86:     }
 87: 
 88:     /**
 89:      * Get theme xml as array
 90:      *
 91:      * @param array $xml
 92:      * @return array
 93:      */
 94:     protected function _xmlToArray($xml)
 95:     {
 96:         $result = array();
 97:         foreach ($xml as $key => $value) {
 98:             if (count($value)) {
 99:                 $result[$key] = $this->_xmlToArray($value);
100:             } else {
101:                 $result[$key] = (string) $value;
102:             }
103:         }
104:         return $result;
105:     }
106: 
107:     /**
108:      * Get theme file
109:      *
110:      * @return null|string
111:      */
112:     protected function _getThemeFile()
113:     {
114:         return $this->_file;
115:     }
116: 
117:     /**
118:      * Get theme name
119:      *
120:      * @return string
121:      */
122:     public function getName()
123:     {
124:         return (string) $this->_xml->manifest->name;
125:     }
126: 
127:     /**
128:      * Set theme name
129:      *
130:      * @param  $name
131:      * @return Mage_XmlConnect_Model_Theme
132:      */
133:     public function setName($name)
134:     {
135:         $name = trim((string) $name);
136:         $this->_xml->manifest->name = htmlentities($name, ENT_QUOTES, 'UTF-8');
137:         return $this;
138:     }
139: 
140:     /**
141:      * Get theme Label
142:      *
143:      * @return string
144:      */
145:     public function getLabel()
146:     {
147:         return (string) $this->_xml->manifest->label;
148:     }
149: 
150:     /**
151:      * Set theme Label
152:      *
153:      * @param  $label
154:      * @return Mage_XmlConnect_Model_Theme
155:      */
156:     public function setLabel($label)
157:     {
158:         $label = trim((string) $label);
159:         $this->_xml->manifest->label = htmlentities($label, ENT_QUOTES, 'UTF-8');
160:         return $this;
161:     }
162: 
163:     /**
164:      * Generate full file name for custome theme in media
165:      *
166:      * @return string
167:      */
168:     protected function _createThemeName()
169:     {
170:         /** @var $themesHelper Mage_XmlConnect_Helper_Theme */
171:         $themesHelper = Mage::helper('xmlconnect/theme');
172:         /** @var $coreHelper Mage_Core_Helper_Data */
173:         $coreHelper = Mage::helper('core');
174: 
175:         $themeFileName = $themesHelper->getMediaThemePath() . DS .$themesHelper->getCustomThemeName() . '_' . time()
176:             . '_' . $coreHelper->getRandomString(10, 'abcdefghijklmnopqrstuvwxyz0123456789') . '.xml';
177:         return $themeFileName;
178:     }
179: 
180:     /**
181:      * Copy current theme to specified file
182:      *
183:      * @param  $filePath
184:      * @return string new file
185:      */
186:     protected function _createCopy($filePath)
187:     {
188:         $currentThemeFileName = $this->_getThemeFile();
189: 
190:         $ioFile = new Varien_Io_File();
191:         if (!$ioFile->cp($currentThemeFileName, $filePath)) {
192:             Mage::throwException(
193:                 Mage::helper('xmlconnect')->__('Can\'t copy file "%s" to "%s".', $currentThemeFileName, $filePath)
194:             );
195:         } else {
196:             $ioFile->chmod($filePath, 0755);
197:         }
198: 
199:         return $filePath;
200:     }
201: 
202:     /**
203:      * Create a copy of current instance with specified data
204:      *
205:      * @param  $themeName new theme label
206:      * @param  $data theme config array
207:      * @return Mage_XmlConnect_Model_Theme
208:      */
209:     public function createNewTheme($themeName, $data)
210:     {
211:         $filePath = $this->_createThemeName();
212:         $themeFileName = $this->_createCopy($filePath);
213: 
214:         /** @var $themeFileName Mage_XmlConnect_Model_Theme */
215:         $themeFileName = Mage::getModel('xmlconnect/theme', $filePath);
216:         $themeFileName->setLabel($themeName);
217:         $fileName = basename($filePath);
218:         $themeFileName->setName(substr($fileName, 0, -4));
219:         $themeFileName->importAndSaveData($data);
220:         return $themeFileName;
221:     }
222: 
223:     /**
224:      * Load data (flat array) for Varien_Data_Form
225:      *
226:      * @return array
227:      */
228:     public function getFormData()
229:     {
230:         return $this->_flatArray($this->_conf, 'conf');
231:     }
232: 
233:     /**
234:      * Load data (flat array) for Varien_Data_Form
235:      *
236:      * @param array $subtree
237:      * @param string $prefix
238:      * @return array
239:      */
240:     protected function _flatArray($subtree, $prefix = null)
241:     {
242:         $result = array();
243:         foreach ($subtree as $key => $value) {
244:             if (is_null($prefix)) {
245:                 $name = $key;
246:             } else {
247:                 $name = $prefix . '[' . $key . ']';
248:             }
249: 
250:             if (is_array($value)) {
251:                 $result = array_merge($result, $this->_flatArray($value, $name));
252:             } else {
253:                 $result[$name] = $value;
254:             }
255:         }
256:         return $result;
257:     }
258: 
259:     /**
260:      * Validate input Array, recursive
261:      *
262:      * @param array $data
263:      * @param array $xml
264:      * @return array
265:      */
266:     protected function _validateFormInput($data, $xml = null)
267:     {
268:         $root = false;
269:         $result = array();
270:         if (is_null($xml)) {
271:             $root = true;
272:             $data = array('configuration' => $data);
273:             $xml = $this->_xml->configuration;
274:         }
275:         foreach ($xml as $key => $value) {
276:             if (isset($data[$key])) {
277:                 if (is_array($data[$key])) {
278:                     $result[$key] = $this->_validateFormInput($data[$key], $value);
279:                 } else {
280:                     $result[$key] = $data[$key];
281:                 }
282:             }
283:         }
284:         if ($root) {
285:             $result = $result['configuration'];
286:         }
287:         return $result;
288:     }
289: 
290:     /**
291:      * Build XML object recursively from $data array
292:      *
293:      * @param SimpleXMLElement $parent
294:      * @param array $data
295:      * @return null
296:      */
297:     protected function _buildRecursive($parent, $data)
298:     {
299:         foreach ($data as $key=>$value) {
300:             if (is_array($value)) {
301:                 $this->_buildRecursive($parent->addChild($key), $value);
302:             } else {
303:                 $parent->addChild($key, $value);
304:             }
305:         }
306:     }
307: 
308:     /**
309:      * Import data into theme form $data array, and save XML to file
310:      *
311:      * @param array $data
312:      * @return null
313:      */
314:     public function importAndSaveData($data)
315:     {
316:         $xml = new SimpleXMLElement('<theme>'.$this->_xml->manifest->asXML().'</theme>');
317:         $this->_buildRecursive($xml->addChild('configuration'), $this->_validateFormInput($data));
318:         clearstatcache();
319:         if (is_writeable($this->_file)) {
320:             file_put_contents($this->_file, $xml->asXML());
321:         } else {
322:             Mage::throwException(Mage::helper('xmlconnect')->__('Can\'t write to file "%s".', $this->_file));
323:         }
324:     }
325: }
326: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0