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_Websites extends Mage_Adminhtml_Block_Store_Switcher
00035 {
00036 protected $_storeFromHtml;
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setTemplate('catalog/product/edit/websites.phtml');
00042 }
00043
00044
00045
00046
00047
00048
00049 public function getProduct()
00050 {
00051 return Mage::registry('product');
00052 }
00053
00054 public function getStoreId()
00055 {
00056 return $this->getProduct()->getStoreId();
00057 }
00058
00059 public function getProductId()
00060 {
00061 return $this->getProduct()->getId();
00062 }
00063
00064 public function getWebsites()
00065 {
00066 return $this->getProduct()->getWebsiteIds();
00067 }
00068
00069 public function hasWebsite($websiteId)
00070 {
00071 return in_array($websiteId, $this->getProduct()->getWebsiteIds());
00072 }
00073
00074
00075
00076
00077
00078
00079 public function isReadonly()
00080 {
00081 return $this->getProduct()->getWebsitesReadonly();
00082 }
00083
00084 public function getStoreName($storeId)
00085 {
00086 return Mage::app()->getStore($storeId)->getName();
00087 }
00088
00089 public function getChooseFromStoreHtml($storeTo)
00090 {
00091 if (!$this->_storeFromHtml) {
00092 $this->_storeFromHtml = '<select name="copy_to_stores[__store_identifier__]" disabled>';
00093 $this->_storeFromHtml.= '<option value="0">'.Mage::helper('catalog')->__('Default Values').'</option>';
00094 foreach ($this->getWebsiteCollection() as $_website) {
00095 if (!$this->hasWebsite($_website->getId())) {
00096 continue;
00097 }
00098 $this->_storeFromHtml .= '<optgroup label="' . $_website->getName() . '"></optgroup>';
00099 foreach ($this->getGroupCollection($_website) as $_group) {
00100 $this->_storeFromHtml .= '<optgroup label=" ' . $_group->getName() . '">';
00101 foreach ($this->getStoreCollection($_group) as $_store) {
00102 $this->_storeFromHtml .= '<option value="' . $_store->getId() . '"> ' . $_store->getName() . '</option>';
00103 }
00104 }
00105 $this->_storeFromHtml .= '</optgroup>';
00106 }
00107 $this->_storeFromHtml.= '</select>';
00108 }
00109 return str_replace('__store_identifier__', $storeTo->getId(), $this->_storeFromHtml);
00110 }
00111 }