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_Connect
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: * Abstract for extension info tabs
29: *
30: * @category Mage
31: * @package Mage_Connect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: abstract class Mage_Connect_Block_Adminhtml_Extension_Custom_Edit_Tab_Abstract
35: extends Mage_Adminhtml_Block_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: /**
39: * TODO
40: */
41: protected $_addRowButtonHtml;
42:
43: /**
44: * TODO
45: */
46: protected $_removeRowButtonHtml;
47:
48: /**
49: * TODO
50: */
51: protected $_addFileDepButtonHtml;
52:
53: /**
54: * TODO
55: */
56: public function __construct()
57: {
58: parent::__construct();
59: $this->setData(Mage::getSingleton('connect/session')->getCustomExtensionPackageFormData());
60: }
61:
62: /**
63: * TODO remove ???
64: */
65: public function initForm()
66: {
67: return $this;
68: }
69:
70: /**
71: * TODO
72: */
73: public function getValue($key, $default='')
74: {
75: $value = $this->getData($key);
76: return htmlspecialchars($value ? $value : $default);
77: }
78:
79: /**
80: * TODO
81: */
82: public function getSelected($key, $value)
83: {
84: return $this->getData($key)==$value ? 'selected="selected"' : '';
85: }
86:
87: /**
88: * TODO
89: */
90: public function getChecked($key)
91: {
92: return $this->getData($key) ? 'checked="checked"' : '';
93: }
94:
95: /**
96: * TODO
97: */
98: public function getAddRowButtonHtml($container, $template, $title='Add')
99: {
100: if (!isset($this->_addRowButtonHtml[$container])) {
101: $this->_addRowButtonHtml[$container] = $this->getLayout()
102: ->createBlock('adminhtml/widget_button')
103: ->setType('button')
104: ->setClass('add')
105: ->setLabel($this->__($title))
106: ->setOnClick("addRow('".$container."', '".$template."')")
107: ->toHtml();
108: }
109: return $this->_addRowButtonHtml[$container];
110: }
111:
112: /**
113: * TODO
114: */
115: public function getRemoveRowButtonHtml($selector='span')
116: {
117: if (!$this->_removeRowButtonHtml) {
118: $this->_removeRowButtonHtml = $this->getLayout()
119: ->createBlock('adminhtml/widget_button')
120: ->setType('button')
121: ->setClass('delete')
122: ->setLabel($this->__('Remove'))
123: ->setOnClick("removeRow(this, '".$selector."')")
124: ->toHtml();
125: }
126: return $this->_removeRowButtonHtml;
127: }
128:
129: public function getAddFileDepsRowButtonHtml($selector='span', $filesClass='files')
130: {
131: if (!$this->_addFileDepButtonHtml) {
132: $this->_addFileDepButtonHtml = $this->getLayout()
133: ->createBlock('adminhtml/widget_button')
134: ->setType('button')
135: ->setClass('add')
136: ->setLabel($this->__('Add files'))
137: ->setOnClick("showHideFiles(this, '".$selector."', '".$filesClass."')")
138: ->toHtml();
139: }
140: return $this->_addFileDepButtonHtml;
141:
142: }
143:
144: /**
145: * Get Tab Label
146: *
147: * @return string
148: */
149: public function getTabLabel()
150: {
151: return '';
152: }
153:
154: /**
155: * Get Tab Title
156: *
157: * @return string
158: */
159: public function getTabTitle()
160: {
161: return '';
162: }
163:
164: public function canShowTab()
165: {
166: return true;
167: }
168:
169: public function isHidden()
170: {
171: return false;
172: }
173: }
174: