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_Category_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
00035 {
00036
00037
00038
00039
00040
00041 protected $_attributeTabBlock = 'adminhtml/catalog_category_tab_attributes';
00042
00043
00044
00045
00046
00047 public function __construct()
00048 {
00049 parent::__construct();
00050 $this->setId('category_info_tabs');
00051 $this->setDestElementId('category_tab_content');
00052 $this->setTitle(Mage::helper('catalog')->__('Category Data'));
00053 $this->setTemplate('widget/tabshoriz.phtml');
00054 }
00055
00056
00057
00058
00059
00060
00061 public function getCategory()
00062 {
00063 return Mage::registry('current_category');
00064 }
00065
00066
00067
00068
00069
00070
00071 public function getCatalogHelper()
00072 {
00073 return Mage::helper('adminhtml/catalog');
00074 }
00075
00076
00077
00078
00079
00080
00081 public function getAttributeTabBlock()
00082 {
00083 if ($block = $this->getCatalogHelper()->getCategoryAttributeTabBlock()) {
00084 return $block;
00085 }
00086 return $this->_attributeTabBlock;
00087 }
00088
00089
00090
00091
00092
00093
00094 protected function _prepareLayout()
00095 {
00096 $categoryAttributes = $this->getCategory()->getAttributes();
00097 $attributeSetId = $this->getCategory()->getDefaultAttributeSetId();
00098 $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
00099 ->setAttributeSetFilter($attributeSetId)
00100 ->load();
00101 $defaultGroupId = 0;
00102 foreach ($groupCollection as $group) {
00103
00104 if ($defaultGroupId == 0 or $group->getIsDefault()) {
00105 $defaultGroupId = $group->getId();
00106 }
00107 }
00108
00109 foreach ($groupCollection as $group) {
00110
00111 $attributes = array();
00112 foreach ($categoryAttributes as $attribute) {
00113
00114 if ($attribute->isInGroup($attributeSetId, $group->getId())) {
00115 $attributes[] = $attribute;
00116 }
00117 }
00118
00119
00120 if (!$attributes) {
00121 continue;
00122 }
00123
00124 $active = $defaultGroupId == $group->getId();
00125 $block = $this->getLayout()->createBlock($this->getAttributeTabBlock(), '')
00126 ->setGroup($group)
00127 ->setAttributes($attributes)
00128 ->setAddHiddenFields($active)
00129 ->toHtml();
00130 $this->addTab('group_' . $group->getId(), array(
00131 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
00132 'content' => $block,
00133 'active' => $active
00134 ));
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 $this->addTab('products', array(
00144 'label' => Mage::helper('catalog')->__('Category Products'),
00145 'content' => $this->getLayout()->createBlock('adminhtml/catalog_category_tab_product', 'category.product.grid')->toHtml(),
00146 ));
00147
00148
00149 Mage::dispatchEvent('adminhtml_catalog_category_tabs', array(
00150 'tabs' => $this
00151 ));
00152
00153
00154
00155
00156 if (Mage::app()->getConfig()->getModuleConfig('Mage_GoogleOptimizer')->is('active', true)
00157 && Mage::helper('googleoptimizer')->isOptimizerActive($this->getCategory()->getStoreId())) {
00158 $this->addTab('googleoptimizer', array(
00159 'label' => Mage::helper('googleoptimizer')->__('Category View Optimization'),
00160 'content' => $this->getLayout()->createBlock('googleoptimizer/adminhtml_catalog_category_edit_tab_googleoptimizer')->toHtml(),
00161 ));
00162 }
00163
00164
00165
00166
00167
00168 return parent::_prepareLayout();
00169 }
00170 }