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:
35: class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
36: {
37: 38: 39: 40: 41:
42: protected function _prepareForm()
43: {
44: parent::_prepareForm();
45: $attributeObject = $this->getAttributeObject();
46:
47: $form = $this->getForm();
48:
49: $fieldset = $form->getElement('base_fieldset');
50:
51: $frontendInputElm = $form->getElement('frontend_input');
52: $additionalTypes = array(
53: array(
54: 'value' => 'price',
55: 'label' => Mage::helper('catalog')->__('Price')
56: ),
57: array(
58: 'value' => 'media_image',
59: 'label' => Mage::helper('catalog')->__('Media Image')
60: )
61: );
62: if ($attributeObject->getFrontendInput() == 'gallery') {
63: $additionalTypes[] = array(
64: 'value' => 'gallery',
65: 'label' => Mage::helper('catalog')->__('Gallery')
66: );
67: }
68:
69: $response = new Varien_Object();
70: $response->setTypes(array());
71: Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
72: $_disabledTypes = array();
73: $_hiddenFields = array();
74: foreach ($response->getTypes() as $type) {
75: $additionalTypes[] = $type;
76: if (isset($type['hide_fields'])) {
77: $_hiddenFields[$type['value']] = $type['hide_fields'];
78: }
79: if (isset($type['disabled_types'])) {
80: $_disabledTypes[$type['value']] = $type['disabled_types'];
81: }
82: }
83: Mage::register('attribute_type_hidden_fields', $_hiddenFields);
84: Mage::register('attribute_type_disabled_types', $_disabledTypes);
85:
86: $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
87: $frontendInputElm->setValues($frontendInputValues);
88:
89: $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
90:
91: $scopes = array(
92: Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
93: Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
94: Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
95: );
96:
97: if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
98: unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
99: }
100:
101: $fieldset->addField('is_global', 'select', array(
102: 'name' => 'is_global',
103: 'label' => Mage::helper('catalog')->__('Scope'),
104: 'title' => Mage::helper('catalog')->__('Scope'),
105: 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'),
106: 'values'=> $scopes
107: ), 'attribute_code');
108:
109: $fieldset->addField('apply_to', 'apply', array(
110: 'name' => 'apply_to[]',
111: 'label' => Mage::helper('catalog')->__('Apply To'),
112: 'values' => Mage_Catalog_Model_Product_Type::getOptions(),
113: 'mode_labels' => array(
114: 'all' => Mage::helper('catalog')->__('All Product Types'),
115: 'custom' => Mage::helper('catalog')->__('Selected Product Types')
116: ),
117: 'required' => true
118: ), 'frontend_class');
119:
120: $fieldset->addField('is_configurable', 'select', array(
121: 'name' => 'is_configurable',
122: 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'),
123: 'values' => $yesnoSource,
124: ), 'apply_to');
125:
126:
127: $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
128:
129: $fieldset->addField('is_searchable', 'select', array(
130: 'name' => 'is_searchable',
131: 'label' => Mage::helper('catalog')->__('Use in Quick Search'),
132: 'title' => Mage::helper('catalog')->__('Use in Quick Search'),
133: 'values' => $yesnoSource,
134: ));
135:
136: $fieldset->addField('is_visible_in_advanced_search', 'select', array(
137: 'name' => 'is_visible_in_advanced_search',
138: 'label' => Mage::helper('catalog')->__('Use in Advanced Search'),
139: 'title' => Mage::helper('catalog')->__('Use in Advanced Search'),
140: 'values' => $yesnoSource,
141: ));
142:
143: $fieldset->addField('is_comparable', 'select', array(
144: 'name' => 'is_comparable',
145: 'label' => Mage::helper('catalog')->__('Comparable on Front-end'),
146: 'title' => Mage::helper('catalog')->__('Comparable on Front-end'),
147: 'values' => $yesnoSource,
148: ));
149:
150: $fieldset->addField('is_filterable', 'select', array(
151: 'name' => 'is_filterable',
152: 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"),
153: 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
154: 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
155: 'values' => array(
156: array('value' => '0', 'label' => Mage::helper('catalog')->__('No')),
157: array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')),
158: array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')),
159: ),
160: ));
161:
162: $fieldset->addField('is_filterable_in_search', 'select', array(
163: 'name' => 'is_filterable_in_search',
164: 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"),
165: 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
166: 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
167: 'values' => $yesnoSource,
168: ));
169:
170: $fieldset->addField('is_used_for_promo_rules', 'select', array(
171: 'name' => 'is_used_for_promo_rules',
172: 'label' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'),
173: 'title' => Mage::helper('catalog')->__('Use for Promo Rule Conditions'),
174: 'values' => $yesnoSource,
175: ));
176:
177: $fieldset->addField('position', 'text', array(
178: 'name' => 'position',
179: 'label' => Mage::helper('catalog')->__('Position'),
180: 'title' => Mage::helper('catalog')->__('Position in Layered Navigation'),
181: 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'),
182: 'class' => 'validate-digits',
183: ));
184:
185: $fieldset->addField('is_wysiwyg_enabled', 'select', array(
186: 'name' => 'is_wysiwyg_enabled',
187: 'label' => Mage::helper('catalog')->__('Enable WYSIWYG'),
188: 'title' => Mage::helper('catalog')->__('Enable WYSIWYG'),
189: 'values' => $yesnoSource,
190: ));
191:
192: $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array(
193: 'name' => 'is_html_allowed_on_front',
194: 'label' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'),
195: 'title' => Mage::helper('catalog')->__('Allow HTML Tags on Frontend'),
196: 'values' => $yesnoSource,
197: ));
198: if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) {
199: $attributeObject->setIsHtmlAllowedOnFront(1);
200: }
201:
202: $fieldset->addField('is_visible_on_front', 'select', array(
203: 'name' => 'is_visible_on_front',
204: 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
205: 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
206: 'values' => $yesnoSource,
207: ));
208:
209: $fieldset->addField('used_in_product_listing', 'select', array(
210: 'name' => 'used_in_product_listing',
211: 'label' => Mage::helper('catalog')->__('Used in Product Listing'),
212: 'title' => Mage::helper('catalog')->__('Used in Product Listing'),
213: 'note' => Mage::helper('catalog')->__('Depends on design theme'),
214: 'values' => $yesnoSource,
215: ));
216: $fieldset->addField('used_for_sort_by', 'select', array(
217: 'name' => 'used_for_sort_by',
218: 'label' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'),
219: 'title' => Mage::helper('catalog')->__('Used for Sorting in Product Listing'),
220: 'note' => Mage::helper('catalog')->__('Depends on design theme'),
221: 'values' => $yesnoSource,
222: ));
223:
224: $form->getElement('apply_to')->setSize(5);
225:
226: if ($applyTo = $attributeObject->getApplyTo()) {
227: $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo);
228: $form->getElement('apply_to')->setValue($applyTo);
229: } else {
230: $form->getElement('apply_to')->addClass('no-display ignore-validate');
231: }
232:
233:
234: $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
235: ->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')
236: ->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')
237: ->addFieldMap("frontend_input", 'frontend_input_type')
238: ->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')
239: ->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')
240: );
241:
242: Mage::dispatchEvent('adminhtml_catalog_product_attribute_edit_prepare_form', array(
243: 'form' => $form,
244: 'attribute' => $attributeObject
245: ));
246:
247: return $this;
248: }
249:
250: 251: 252: 253: 254:
255: protected function _getAdditionalElementTypes()
256: {
257: return array(
258: 'apply' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_apply'),
259: );
260: }
261: }
262: