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 page form element
29: *
30: * @category Mage
31: * @package Mage_XmlConnect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Page
35: extends Varien_Data_Form_Element_Abstract
36: {
37: /**
38: * Init page element
39: *
40: * @param array $attributes
41: */
42: public function __construct($attributes=array())
43: {
44: parent::__construct($attributes);
45: $this->setType('page');
46: }
47:
48: /**
49: * Setting stored data to page element
50: *
51: * @param array $conf
52: */
53: public function initFields($conf)
54: {
55: $this->addElement(new Varien_Data_Form_Element_Text(array(
56: 'name' => $conf['name'] . '[label]',
57: 'class' => 'label onclick_text',
58: )));
59:
60: $this->addElement(new Varien_Data_Form_Element_Select(array(
61: 'name' => $conf['name'] . '[id]',
62: 'values' => $conf['values'],
63: )));
64: }
65:
66: /**
67: * Add form element
68: *
69: * @param Varien_Data_Form_Element_Abstract $element
70: * @param boolean|string $after also can be '^'
71: * @return Varien_Data_Form
72: */
73: public function addElement(Varien_Data_Form_Element_Abstract $element, $after = false)
74: {
75: $element->setId($element->getData('name'));
76: parent::addElement($element, $after);
77: }
78:
79: /**
80: * Getter for Label field
81: * fetching first element as label
82: *
83: * @param string $idSuffix
84: * @return string
85: */
86: public function getLabelHtml($idSuffix = '')
87: {
88: list($label, $element) = $this->getElements();
89: return $label->toHtml();
90: }
91:
92: /**
93: * Getter for second part of rendered field ("selectbox" and "delete button")
94: * fetching second element as <element code>
95: *
96: * @return string
97: */
98: public function getElementHtml()
99: {
100: list($label, $element) = $this->getElements();
101: return $element->toHtml()
102: . '</td><td class="label" style="width: 5em">'
103: . '<button class="scalable save onclick_button" value="−"><span><span><span>'
104: . Mage::helper('xmlconnect')->__('Delete')
105: . '</span></span></span></button>';
106: }
107: }
108: