1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_XmlConnect_Block_Adminhtml_Mobile_Edit_Tab_Content
35: extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: protected $_pages;
39:
40: 41: 42: 43:
44: public function __construct()
45: {
46: parent::__construct();
47: $this->setShowGlobalIcon(true);
48: }
49:
50: 51: 52: 53: 54: 55:
56: protected function _addPage($fieldset, $fieldPrefix)
57: {
58: $element = $fieldset->addField($fieldPrefix, 'page', array(
59: 'name' => $fieldPrefix,
60: ));
61: $element->initFields(array(
62: 'name' => $fieldPrefix,
63: 'values' => $this->_pages,
64: ));
65: }
66:
67: 68: 69: 70: 71: 72:
73: protected function _prepareForm()
74: {
75: $model = Mage::helper('xmlconnect')->getApplication();
76: $conf = $model->getConf();
77: $form = new Varien_Data_Form();
78: $this->setForm($form);
79:
80: $pages = Mage::getResourceModel('xmlconnect/cms_page_collection')->toOptionIdArray();
81: $dummy = array(array( 'value' => '', 'label' => '' ));
82: $this->_pages = array_merge($dummy, $pages);
83:
84: $fieldset = $form->addFieldset('cms_pages', array('legend' => $this->__('Pages')));
85: $this->_addElementTypes($fieldset);
86:
87: $fieldset->addField('page_row_add', 'addrow', array(
88: 'onclick' => 'insertNewTableRow(this)',
89: 'options' => $this->_pages,
90: 'class' => ' scalable save ',
91: 'label' => $this->__('Label'),
92: 'before_element_html' => $this->__('Get Content from CMS Page').'</td><td class="label">',
93: ));
94:
95: if (!empty($conf['native']['pages'])) {
96: foreach ($conf['native']['pages'] as $key=>$dummy) {
97: $this->_addPage($fieldset, 'conf[native][pages]['.$key.']');
98: }
99: }
100:
101: $data = $model->getFormData();
102: $data['page_row_add'] = $this->__('Add Page');
103: $form->setValues($data);
104: return parent::_prepareForm();
105: }
106:
107: 108: 109: 110: 111:
112: public function getTabLabel()
113: {
114: return $this->__('Content');
115: }
116:
117: 118: 119: 120: 121:
122: public function getTabTitle()
123: {
124: return $this->__('Content');
125: }
126:
127: 128: 129: 130: 131:
132: public function canShowTab()
133: {
134: return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication();
135: }
136:
137: 138: 139: 140: 141:
142: public function isHidden()
143: {
144: return false;
145: }
146: }
147: