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_Eav 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 /** 00029 * Entity/Attribute/Model - attribute selection source abstract 00030 * 00031 * @category Mage 00032 * @package Mage_Eav 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 abstract class Mage_Eav_Model_Entity_Attribute_Source_Abstract implements Mage_Eav_Model_Entity_Attribute_Source_Interface 00036 { 00037 /** 00038 * Reference to the attribute instance 00039 * 00040 * @var Mage_Eav_Model_Entity_Attribute_Abstract 00041 */ 00042 protected $_attribute; 00043 00044 /** 00045 * Options array 00046 * 00047 * @var array 00048 */ 00049 protected $_options; 00050 00051 /** 00052 * Set attribute instance 00053 * 00054 * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute 00055 * @return Mage_Eav_Model_Entity_Attribute_Frontend_Abstract 00056 */ 00057 public function setAttribute($attribute) 00058 { 00059 $this->_attribute = $attribute; 00060 return $this; 00061 } 00062 00063 /** 00064 * Get attribute instance 00065 * 00066 * @return Mage_Eav_Model_Entity_Attribute_Abstract 00067 */ 00068 public function getAttribute() 00069 { 00070 return $this->_attribute; 00071 } 00072 00073 /** 00074 * Get a text for option value 00075 * 00076 * @param string|integer $value 00077 * @return string 00078 */ 00079 public function getOptionText($value) 00080 { 00081 $options = $this->getAllOptions(); 00082 // Fixed for tax_class_id and custom_design 00083 if (sizeof($options) > 0) foreach($options as $option) { 00084 if (isset($option['value']) && $option['value'] == $value) { 00085 return $option; 00086 } 00087 } // End 00088 if (isset($options[$value])) { 00089 return $options[$value]; 00090 } 00091 return false; 00092 } 00093 00094 public function getOptionId($value) 00095 { 00096 foreach ($this->getAllOptions() as $option) { 00097 if (strcasecmp($option['label'], $value)==0 || $option['value'] == $value) { 00098 return $option['value']; 00099 } 00100 } 00101 return null; 00102 } 00103 00104 /** 00105 * Add Value Sort To Collection Select 00106 * 00107 * @param Mage_Eav_Model_Entity_Collection_Abstract $collection 00108 * @param string $dir direction 00109 * @return Mage_Eav_Model_Entity_Attribute_Source_Abstract 00110 */ 00111 public function addValueSortToCollection($collection, $dir = 'asc') { 00112 return $this; 00113 } 00114 00115 /** 00116 * Retrieve Column(s) for Flat 00117 * 00118 * @return array 00119 */ 00120 public function getFlatColums() 00121 { 00122 return array(); 00123 } 00124 00125 /** 00126 * Retrieve Indexes(s) for Flat 00127 * 00128 * @return array 00129 */ 00130 public function getFlatIndexes() 00131 { 00132 return array(); 00133 } 00134 00135 /** 00136 * Retrieve Select For Flat Attribute update 00137 * 00138 * @param int $store 00139 * @return Varien_Db_Select|null 00140 */ 00141 public function getFlatUpdateSelect($store) 00142 { 00143 return null; 00144 } 00145 }