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
00035 class Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Form
00036 {
00037
00038
00039
00040
00041
00042 public function getCategory()
00043 {
00044 return Mage::registry('current_category');
00045 }
00046
00047
00048
00049
00050
00051 public function __construct() {
00052 parent::__construct();
00053 $this->setShowGlobalIcon(true);
00054 }
00055
00056
00057
00058
00059
00060
00061 protected function _prepareForm() {
00062 $group = $this->getGroup();
00063 $attributes = $this->getAttributes();
00064
00065 $form = new Varien_Data_Form();
00066 $form->setHtmlIdPrefix('group_' . $group->getId());
00067 $form->setDataObject($this->getCategory());
00068
00069 $fieldset = $form->addFieldset('fieldset_group_' . $group->getId(), array(
00070 'legend' => Mage::helper('catalog')->__($group->getAttributeGroupName())
00071 ));
00072
00073 if ($this->getAddHiddenFields()) {
00074 if (!$this->getCategory()->getId()) {
00075
00076 if ($this->getRequest()->getParam('parent')) {
00077 $fieldset->addField('path', 'hidden', array(
00078 'name' => 'path',
00079 'value' => $this->getRequest()->getParam('parent')
00080 ));
00081 }
00082 else {
00083 $fieldset->addField('path', 'hidden', array(
00084 'name' => 'path',
00085 'value' => 1
00086 ));
00087 }
00088 }
00089 else {
00090 $fieldset->addField('id', 'hidden', array(
00091 'name' => 'id',
00092 'value' => $this->getCategory()->getId()
00093 ));
00094 $fieldset->addField('path', 'hidden', array(
00095 'name' => 'path',
00096 'value' => $this->getCategory()->getPath()
00097 ));
00098 }
00099 }
00100
00101 $this->_setFieldset($attributes, $fieldset);
00102
00103 foreach ($attributes as $attribute) {
00104
00105 if ($attribute->getAttributeCode() == 'url_key') {
00106 if ($this->getCategory()->getLevel() == 1) {
00107 $fieldset->removeField('url_key');
00108 $fieldset->addField('url_key', 'hidden', array(
00109 'name' => 'url_key',
00110 'value' => $this->getCategory()->getUrlKey()
00111 ));
00112 }
00113 }
00114 }
00115
00116 if ($this->getCategory()->hasLockedAttributes()) {
00117 foreach ($this->getCategory()->getLockedAttributes() as $attribute) {
00118 if ($element = $form->getElement($attribute)) {
00119 $element->setReadonly(true, true);
00120 }
00121 }
00122 }
00123
00124 $form->addValues($this->getCategory()->getData());
00125
00126 $form->setFieldNameSuffix('general');
00127 $this->setForm($form);
00128
00129 return parent::_prepareForm();
00130 }
00131
00132
00133
00134
00135
00136
00137 protected function _getAdditionalElementTypes()
00138 {
00139 return array(
00140 'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_category_helper_image')
00141 );
00142 }
00143 }