1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29:
30: class Mage_Eav_Helper_Data extends Mage_Core_Helper_Abstract
31: {
32: 33: 34:
35: const XML_PATH_VALIDATOR_DATA_INPUT_TYPES = 'general/validator_data/input_types';
36:
37: protected $_attributesLockedFields = array();
38:
39: protected $_entityTypeFrontendClasses = array();
40:
41: 42: 43: 44: 45:
46: protected function _getDefaultFrontendClasses()
47: {
48: return array(
49: array(
50: 'value' => '',
51: 'label' => Mage::helper('eav')->__('None')
52: ),
53: array(
54: 'value' => 'validate-number',
55: 'label' => Mage::helper('eav')->__('Decimal Number')
56: ),
57: array(
58: 'value' => 'validate-digits',
59: 'label' => Mage::helper('eav')->__('Integer Number')
60: ),
61: array(
62: 'value' => 'validate-email',
63: 'label' => Mage::helper('eav')->__('Email')
64: ),
65: array(
66: 'value' => 'validate-url',
67: 'label' => Mage::helper('eav')->__('URL')
68: ),
69: array(
70: 'value' => 'validate-alpha',
71: 'label' => Mage::helper('eav')->__('Letters')
72: ),
73: array(
74: 'value' => 'validate-alphanum',
75: 'label' => Mage::helper('eav')->__('Letters (a-z, A-Z) or Numbers (0-9)')
76: )
77: );
78: }
79:
80: 81: 82: 83: 84: 85:
86: public function getFrontendClasses($entityTypeCode)
87: {
88: $_defaultClasses = $this->_getDefaultFrontendClasses();
89: if (isset($this->_entityTypeFrontendClasses[$entityTypeCode])) {
90: return array_merge(
91: $_defaultClasses,
92: $this->_entityTypeFrontendClasses[$entityTypeCode]
93: );
94: }
95: $_entityTypeClasses = Mage::app()->getConfig()
96: ->getNode('global/eav_frontendclasses/' . $entityTypeCode);
97: if ($_entityTypeClasses) {
98: foreach ($_entityTypeClasses->children() as $item) {
99: $this->_entityTypeFrontendClasses[$entityTypeCode][] = array(
100: 'value' => (string)$item->value,
101: 'label' => (string)$item->label
102: );
103: }
104: return array_merge(
105: $_defaultClasses,
106: $this->_entityTypeFrontendClasses[$entityTypeCode]
107: );
108: }
109: return $_defaultClasses;
110: }
111:
112: 113: 114: 115: 116: 117:
118: public function getAttributeLockedFields($entityTypeCode)
119: {
120: if (!$entityTypeCode) {
121: return array();
122: }
123: if (isset($this->_attributesLockedFields[$entityTypeCode])) {
124: return $this->_attributesLockedFields[$entityTypeCode];
125: }
126: $_data = Mage::app()->getConfig()->getNode('global/eav_attributes/' . $entityTypeCode);
127: if ($_data) {
128: foreach ($_data->children() as $attribute) {
129: $this->_attributesLockedFields[$entityTypeCode][(string)$attribute->code] =
130: array_keys($attribute->locked_fields->asArray());
131: }
132: return $this->_attributesLockedFields[$entityTypeCode];
133: }
134: return array();
135: }
136:
137: 138: 139: 140: 141:
142: public function getInputTypesValidatorData()
143: {
144: return Mage::getStoreConfig(self::XML_PATH_VALIDATOR_DATA_INPUT_TYPES);
145: }
146: }
147: