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 widget form block
29: *
30: * @category Mage
31: * @package Mage_XmlConnect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form extends Mage_Adminhtml_Block_Widget_Form
35: {
36: /**
37: * Add color chooser to fieldset
38: *
39: * @param Varien_Data_Form_Element_Fieldset $fieldset
40: * @param string $fieldName
41: * @param string $title
42: */
43: protected function addColor($fieldset, $fieldName, $title)
44: {
45: $fieldset->addField($fieldName, 'color', array(
46: 'name' => $fieldName,
47: 'label' => $title,
48: ));
49: }
50:
51: /**
52: * Add image uploader to fieldset
53: *
54: * @param Varien_Data_Form_Element_Fieldset $fieldset
55: * @param string $fieldName
56: * @param string $title
57: * @param string|null $note
58: * @param string $default
59: * @param boolean $required
60: */
61: public function addImage($fieldset, $fieldName, $title, $note = null, $default = '', $required = false)
62: {
63: $fieldset->addField($fieldName, 'image', array(
64: 'name' => $fieldName,
65: 'label' => $title,
66: 'note' => $note,
67: 'default_value' => $default,
68: 'required' => $required,
69: ));
70: }
71:
72: /**
73: * Add font selector to fieldset
74: *
75: * @param Varien_Data_Form_Element_Fieldset $fieldset
76: * @param string $fieldPrefix
77: * @param string $title
78: */
79: public function addFont($fieldset, $fieldPrefix, $title)
80: {
81: $element = $fieldset->addField($fieldPrefix, 'font', array(
82: 'name' => $fieldPrefix,
83: 'label' => $title,
84: ));
85:
86: $element->initFields(array(
87: 'name' => $fieldPrefix,
88: 'fontNames' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontList(),
89: 'fontSizes' => Mage::helper('xmlconnect')->getDeviceHelper()->getFontSizes(),
90: ));
91: }
92:
93: /**
94: * Configure image element type
95: *
96: * @return array
97: */
98: protected function _getAdditionalElementTypes()
99: {
100: $config = Mage::getConfig();
101: return array(
102: 'image' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_image'),
103: 'font' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_font'),
104: 'color' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_color'),
105: 'tabs' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_tabs'),
106: 'theme' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_theme'),
107: 'page' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_page'),
108: 'addrow'=> $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_addrow'),
109: 'datetime' => $config->getBlockClassName('xmlconnect/adminhtml_mobile_form_element_datetime'),
110: );
111: }
112: }
113: