00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Form
00035 {
00036 protected function _prepareForm()
00037 {
00038 if ($group = $this->getGroup()) {
00039 $form = new Varien_Data_Form();
00040
00041
00042
00043
00044 $form->setDataObject(Mage::registry('product'));
00045
00046 $fieldset = $form->addFieldset('group_fields'.$group->getId(),
00047 array('legend'=>Mage::helper('catalog')->__($group->getAttributeGroupName()))
00048 );
00049
00050 $attributes = $this->getGroupAttributes();
00051
00052 $this->_setFieldset($attributes, $fieldset, array('gallery'));
00053
00054 if ($tierPrice = $form->getElement('tier_price')) {
00055 $tierPrice->setRenderer(
00056 $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
00057 );
00058 }
00059
00060
00061
00062
00063 if (!$form->getElement('media_gallery')
00064 && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
00065 $headerBar = $this->getLayout()->createBlock(
00066 'adminhtml/catalog_product_edit_tab_attributes_create'
00067 );
00068
00069 $headerBar->getConfig()
00070 ->setTabId('group_' . $group->getId())
00071 ->setGroupId($group->getId())
00072 ->setStoreId($form->getDataObject()->getStoreId())
00073 ->setAttributeSetId($form->getDataObject()->getAttributeSetId())
00074 ->setTypeId($form->getDataObject()->getTypeId())
00075 ->setProductId($form->getDataObject()->getId());
00076
00077 $fieldset->setHeaderBar(
00078 $headerBar->toHtml()
00079 );
00080 }
00081
00082 if ($form->getElement('meta_description')) {
00083 $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
00084 }
00085
00086 $values = Mage::registry('product')->getData();
00087
00088
00089
00090 if (!Mage::registry('product')->getId()) {
00091 foreach ($attributes as $attribute) {
00092 if (!isset($values[$attribute->getAttributeCode()])) {
00093 $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
00094 }
00095 }
00096 }
00097
00098 if (Mage::registry('product')->hasLockedAttributes()) {
00099 foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
00100 if ($element = $form->getElement($attribute)) {
00101 $element->setReadonly(true, true);
00102 }
00103 }
00104 }
00105
00106 Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
00107
00108 $form->addValues($values);
00109 $form->setFieldNameSuffix('product');
00110 $this->setForm($form);
00111 }
00112 }
00113
00114 protected function _getAdditionalElementTypes()
00115 {
00116 $result = array(
00117 'price' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_price'),
00118 'gallery' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_gallery'),
00119 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_image'),
00120 'boolean' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_boolean')
00121 );
00122
00123 $response = new Varien_Object();
00124 $response->setTypes(array());
00125 Mage::dispatchEvent('adminhtml_catalog_product_edit_element_types', array('response'=>$response));
00126
00127 foreach ($response->getTypes() as $typeName=>$typeClass) {
00128 $result[$typeName] = $typeClass;
00129 }
00130
00131 return $result;
00132 }
00133 }