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_Create extends Mage_Adminhtml_Block_Widget_Button
00035 {
00036
00037
00038
00039
00040
00041 protected $_config = null;
00042
00043
00044
00045
00046
00047
00048 public function getConfig()
00049 {
00050 if (is_null($this->_config)) {
00051 $this->_config = new Varien_Object();
00052 }
00053
00054 return $this->_config;
00055 }
00056
00057 protected function _beforeToHtml()
00058 {
00059 $this->setId('create_attribute_' . $this->getConfig()->getGroupId())
00060 ->setOnClick($this->getJsObjectName() . '.create();')
00061 ->setType('button')
00062 ->setClass('add')
00063 ->setLabel(Mage::helper('adminhtml')->__('Create New Attribute'));
00064
00065 $this->getConfig()
00066 ->setUrl($this->getUrl(
00067 '*/catalog_product_attribute/new',
00068 array(
00069 'group' => $this->getConfig()->getGroupId(),
00070 'tab' => $this->getConfig()->getTabId(),
00071 'store' => $this->getConfig()->getStoreId(),
00072 'product' => $this->getConfig()->getProductId(),
00073 'set' => $this->getConfig()->getAttributeSetId(),
00074 'type' => $this->getConfig()->getTypeId(),
00075 'popup' => 1
00076 )
00077 ));
00078
00079 return parent::_beforeToHtml();
00080 }
00081
00082 protected function _toHtml()
00083 {
00084 $html = parent::_toHtml();
00085 $html .= Mage::helper('adminhtml/js')->getScript(
00086 "var {$this->getJsObjectName()} = new Product.Attributes('{$this->getId()}');\n"
00087 . "{$this->getJsObjectName()}.setConfig(" . Zend_Json::encode($this->getConfig()->getData()) . ");\n"
00088 );
00089
00090 return $html;
00091 }
00092
00093 public function getJsObjectName()
00094 {
00095 return $this->getId() . 'JsObject';
00096 }
00097 }