00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Catalog fieldset element renderer 00029 * 00030 * @category Mage 00031 * @package Mage_Adminhtml 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element 00035 { 00036 /** 00037 * Initialize block template 00038 */ 00039 protected function _construct() 00040 { 00041 $this->setTemplate('catalog/form/renderer/fieldset/element.phtml'); 00042 } 00043 00044 /** 00045 * Retrieve data object related with form 00046 * 00047 * @return Mage_Catalog_Model_Product || Mage_Catalog_Model_Category 00048 */ 00049 public function getDataObject() 00050 { 00051 return $this->getElement()->getForm()->getDataObject(); 00052 } 00053 00054 /** 00055 * Retireve associated with element attribute object 00056 * 00057 * @return Mage_Catalog_Model_Resource_Eav_Attribute 00058 */ 00059 public function getAttribute() 00060 { 00061 return $this->getElement()->getEntityAttribute(); 00062 } 00063 00064 /** 00065 * Retrieve associated attribute code 00066 * 00067 * @return string 00068 */ 00069 public function getAttributeCode() 00070 { 00071 return $this->getAttribute()->getAttributeCode(); 00072 } 00073 00074 /** 00075 * Check "Use default" checkbox display availability 00076 * 00077 * @return bool 00078 */ 00079 public function canDisplayUseDefault() 00080 { 00081 if ($attribute = $this->getAttribute()) { 00082 if (!$attribute->isScopeGlobal() 00083 && $this->getDataObject() 00084 && $this->getDataObject()->getId() 00085 && $this->getDataObject()->getStoreId()) { 00086 return true; 00087 } 00088 } 00089 return false; 00090 } 00091 00092 /** 00093 * Check default value usage fact 00094 * 00095 * @return bool 00096 */ 00097 public function usedDefault() 00098 { 00099 $devaultValue = $this->getDataObject()->getAttributeDefaultValue($this->getAttribute()->getAttributeCode()); 00100 return is_null($devaultValue); 00101 } 00102 00103 /** 00104 * Disable field in default value using case 00105 * 00106 * @return Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element 00107 */ 00108 public function checkFieldDisable() 00109 { 00110 if ($this->canDisplayUseDefault() && $this->usedDefault()) { 00111 $this->getElement()->setDisabled(true); 00112 } 00113 return $this; 00114 } 00115 00116 /** 00117 * Retrieve label of attribute scope 00118 * 00119 * GLOBAL | WEBSITE | STORE 00120 * 00121 * @return string 00122 */ 00123 public function getScopeLabel() 00124 { 00125 $html = ''; 00126 $attribute = $this->getElement()->getEntityAttribute(); 00127 if (!$attribute || Mage::app()->isSingleStoreMode() || $attribute->getFrontendInput()=='gallery') { 00128 return $html; 00129 } 00130 if ($attribute->isScopeGlobal()) { 00131 $html.= '[GLOBAL]'; 00132 } 00133 elseif ($attribute->isScopeWebsite()) { 00134 $html.= '[WEBSITE]'; 00135 } 00136 elseif ($attribute->isScopeStore()) { 00137 $html.= '[STORE VIEW]'; 00138 } 00139 00140 return $html; 00141 } 00142 00143 /** 00144 * Retrieve element label html 00145 * 00146 * @return string 00147 */ 00148 public function getElementLabelHtml() 00149 { 00150 return $this->getElement()->getLabelHtml(); 00151 } 00152 00153 /** 00154 * Retrieve element html 00155 * 00156 * @return string 00157 */ 00158 public function getElementHtml() 00159 { 00160 return $this->getElement()->getElementHtml(); 00161 } 00162 }