1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Eav
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Entity/Attribute/Model - attribute selection source abstract
30: *
31: * @category Mage
32: * @package Mage_Eav
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: abstract class Mage_Eav_Model_Entity_Attribute_Source_Abstract
36: implements Mage_Eav_Model_Entity_Attribute_Source_Interface
37: {
38: /**
39: * Reference to the attribute instance
40: *
41: * @var Mage_Eav_Model_Entity_Attribute_Abstract
42: */
43: protected $_attribute;
44:
45: /**
46: * Options array
47: *
48: * @var array
49: */
50: protected $_options = null;
51:
52: /**
53: * Set attribute instance
54: *
55: * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
56: * @return Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
57: */
58: public function setAttribute($attribute)
59: {
60: $this->_attribute = $attribute;
61: return $this;
62: }
63:
64: /**
65: * Get attribute instance
66: *
67: * @return Mage_Eav_Model_Entity_Attribute_Abstract
68: */
69: public function getAttribute()
70: {
71: return $this->_attribute;
72: }
73:
74: /**
75: * Get a text for option value
76: *
77: * @param string|integer $value
78: * @return string|bool
79: */
80: public function getOptionText($value)
81: {
82: $options = $this->getAllOptions();
83: // Fixed for tax_class_id and custom_design
84: if (sizeof($options) > 0) foreach($options as $option) {
85: if (isset($option['value']) && $option['value'] == $value) {
86: return isset($option['label']) ? $option['label'] : $option['value'];
87: }
88: } // End
89: if (isset($options[$value])) {
90: return $options[$value];
91: }
92: return false;
93: }
94:
95: public function getOptionId($value)
96: {
97: foreach ($this->getAllOptions() as $option) {
98: if (strcasecmp($option['label'], $value)==0 || $option['value'] == $value) {
99: return $option['value'];
100: }
101: }
102: return null;
103: }
104:
105: /**
106: * Add Value Sort To Collection Select
107: *
108: * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
109: * @param string $dir direction
110: * @return Mage_Eav_Model_Entity_Attribute_Source_Abstract
111: */
112: public function addValueSortToCollection($collection, $dir = Varien_Data_Collection::SORT_ORDER_DESC) {
113: return $this;
114: }
115:
116: /**
117: * Retrieve flat column definition
118: *
119: * @return array
120: */
121: public function getFlatColums()
122: {
123: return array();
124: }
125:
126: /**
127: * Retrieve Indexes(s) for Flat
128: *
129: * @return array
130: */
131: public function getFlatIndexes()
132: {
133: return array();
134: }
135:
136: /**
137: * Retrieve Select For Flat Attribute update
138: *
139: * @param int $store
140: * @return Varien_Db_Select|null
141: */
142: public function getFlatUpdateSelect($store)
143: {
144: return null;
145: }
146: }
147: