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_Edit_Form extends Mage_Adminhtml_Block_Catalog_Category_Abstract
00035 {
00036
00037
00038
00039
00040
00041 protected $_additionalButtons = array();
00042
00043 public function __construct()
00044 {
00045 parent::__construct();
00046 $this->setTemplate('catalog/category/edit/form.phtml');
00047 }
00048
00049 protected function _prepareLayout()
00050 {
00051 $this->setChild('tabs',
00052 $this->getLayout()->createBlock('adminhtml/catalog_category_tabs', 'tabs')
00053 );
00054
00055 if (!$this->getCategory()->isReadonly()) {
00056 $this->setChild('save_button',
00057 $this->getLayout()->createBlock('adminhtml/widget_button')
00058 ->setData(array(
00059 'label' => Mage::helper('catalog')->__('Save Category'),
00060 'onclick' => "categorySubmit('".$this->getSaveUrl()."',true)",
00061 'class' => 'save'
00062 ))
00063 );
00064 }
00065 if (!in_array($this->getCategory()->getId(), $this->getRootIds()) &&
00066 $this->getCategory()->isDeleteable()) {
00067 $this->setChild('delete_button',
00068 $this->getLayout()->createBlock('adminhtml/widget_button')
00069 ->setData(array(
00070 'label' => Mage::helper('catalog')->__('Delete Category'),
00071 'onclick' => "categoryDelete('".$this->getUrl('*/*/delete', array('_current'=>true))."',true)",
00072 'class' => 'delete'
00073 ))
00074 );
00075 }
00076
00077 if (!$this->getCategory()->isReadonly()) {
00078 $this->setChild('reset_button',
00079 $this->getLayout()->createBlock('adminhtml/widget_button')
00080 ->setData(array(
00081 'label' => Mage::helper('catalog')->__('Reset'),
00082 'onclick' => "categoryReset('".$this->getUrl('*/*/edit', array('_current'=>true))."',true)"
00083 ))
00084 );
00085 }
00086
00087 return parent::_prepareLayout();
00088 }
00089
00090
00091
00092
00093
00094
00095 public function getRootIds()
00096 {
00097 $ids = $this->getData('root_ids');
00098 if (is_null($ids)) {
00099 $ids = array();
00100 foreach (Mage::app()->getStores() as $store) {
00101 $ids[] = $store->getRootCategoryId();
00102 }
00103 $this->setData('root_ids', $ids);
00104 }
00105 return $ids;
00106 }
00107
00108 public function getStoreConfigurationUrl()
00109 {
00110 $storeId = (int) $this->getRequest()->getParam('store');
00111 $params = array();
00112
00113 if ($storeId) {
00114 $store = Mage::app()->getStore($storeId);
00115 $params['website'] = $store->getWebsite()->getCode();
00116 $params['store'] = $store->getCode();
00117 }
00118 return $this->getUrl('*/system_store', $params);
00119 }
00120
00121 public function getDeleteButtonHtml()
00122 {
00123 return $this->getChildHtml('delete_button');
00124 }
00125
00126 public function getSaveButtonHtml()
00127 {
00128 if ($this->hasStoreRootCategory()) {
00129 return $this->getChildHtml('save_button');
00130 }
00131 return '';
00132 }
00133
00134 public function getResetButtonHtml()
00135 {
00136 if ($this->hasStoreRootCategory()) {
00137 return $this->getChildHtml('reset_button');
00138 }
00139 return '';
00140 }
00141
00142
00143
00144
00145
00146
00147 public function getAdditionalButtonsHtml()
00148 {
00149 $html = '';
00150 foreach ($this->_additionalButtons as $childName) {
00151 $html .= $this->getChildHtml($childName);
00152 }
00153 return $html;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163 public function addAdditionalButton($alias, $config)
00164 {
00165 $this->setChild($alias . '_button',
00166 $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
00167 $this->_additionalButtons[$alias] = $alias . '_button';
00168 return $this;
00169 }
00170
00171
00172
00173
00174
00175
00176
00177 public function removeAdditionalButton($alias)
00178 {
00179 if (isset($this->_additionalButtons[$alias])) {
00180 $this->unsetChild($this->_additionalButtons[$alias]);
00181 unset($this->_additionalButtons[$alias]);
00182 }
00183
00184 return $this;
00185 }
00186
00187 public function getTabsHtml()
00188 {
00189 return $this->getChildHtml('tabs');
00190 }
00191
00192 public function getHeader()
00193 {
00194 if ($this->hasStoreRootCategory()) {
00195 return $this->getCategoryId() ? $this->getCategoryName() : Mage::helper('catalog')->__('New Category');
00196 }
00197 return Mage::helper('catalog')->__('Set Root Category For Store');
00198 }
00199
00200 public function getDeleteUrl(array $args = array())
00201 {
00202 $params = array('_current'=>true);
00203 $params = array_merge($params, $args);
00204 return $this->getUrl('*/*/delete', $params);
00205 }
00206
00207 public function getProductsJson()
00208 {
00209 $products = $this->getCategory()->getProductsPosition();
00210 if (!empty($products)) {
00211 return Zend_Json::encode($products);
00212 }
00213 return '{}';
00214 }
00215
00216 public function isAjax()
00217 {
00218 return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
00219 }
00220 }