Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Catalog_Model_Entity_Product_Attribute_Design_Options_Container
  • Mage_Catalog_Model_Product_Attribute_Source_Inputtype
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Js
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
  • Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
  • Mage_Eav_Helper_Data
  • Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype
  • Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator
  • Mage_Eav_Model_Attribute
  • Mage_Eav_Model_Attribute_Data
  • Mage_Eav_Model_Attribute_Data_Abstract
  • Mage_Eav_Model_Attribute_Data_Boolean
  • Mage_Eav_Model_Attribute_Data_Date
  • Mage_Eav_Model_Attribute_Data_File
  • Mage_Eav_Model_Attribute_Data_Hidden
  • Mage_Eav_Model_Attribute_Data_Image
  • Mage_Eav_Model_Attribute_Data_Multiline
  • Mage_Eav_Model_Attribute_Data_Multiselect
  • Mage_Eav_Model_Attribute_Data_Select
  • Mage_Eav_Model_Attribute_Data_Text
  • Mage_Eav_Model_Attribute_Data_Textarea
  • Mage_Eav_Model_Config
  • Mage_Eav_Model_Convert_Adapter_Entity
  • Mage_Eav_Model_Convert_Adapter_Grid
  • Mage_Eav_Model_Convert_Parser_Abstract
  • Mage_Eav_Model_Entity
  • Mage_Eav_Model_Entity_Abstract
  • Mage_Eav_Model_Entity_Attribute
  • Mage_Eav_Model_Entity_Attribute_Abstract
  • Mage_Eav_Model_Entity_Attribute_Backend_Abstract
  • Mage_Eav_Model_Entity_Attribute_Backend_Array
  • Mage_Eav_Model_Entity_Attribute_Backend_Datetime
  • Mage_Eav_Model_Entity_Attribute_Backend_Default
  • Mage_Eav_Model_Entity_Attribute_Backend_Increment
  • Mage_Eav_Model_Entity_Attribute_Backend_Serialized
  • Mage_Eav_Model_Entity_Attribute_Backend_Store
  • Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
  • Mage_Eav_Model_Entity_Attribute_Backend_Time_Updated
  • Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
  • Mage_Eav_Model_Entity_Attribute_Frontend_Datetime
  • Mage_Eav_Model_Entity_Attribute_Frontend_Default
  • Mage_Eav_Model_Entity_Attribute_Group
  • Mage_Eav_Model_Entity_Attribute_Option
  • Mage_Eav_Model_Entity_Attribute_Set
  • Mage_Eav_Model_Entity_Attribute_Source_Abstract
  • Mage_Eav_Model_Entity_Attribute_Source_Boolean
  • Mage_Eav_Model_Entity_Attribute_Source_Config
  • Mage_Eav_Model_Entity_Attribute_Source_Store
  • Mage_Eav_Model_Entity_Attribute_Source_Table
  • Mage_Eav_Model_Entity_Collection
  • Mage_Eav_Model_Entity_Collection_Abstract
  • Mage_Eav_Model_Entity_Increment_Abstract
  • Mage_Eav_Model_Entity_Increment_Alphanum
  • Mage_Eav_Model_Entity_Increment_Numeric
  • Mage_Eav_Model_Entity_Setup
  • Mage_Eav_Model_Entity_Store
  • Mage_Eav_Model_Entity_Type
  • Mage_Eav_Model_Form
  • Mage_Eav_Model_Form_Element
  • Mage_Eav_Model_Form_Fieldset
  • Mage_Eav_Model_Form_Type
  • Mage_Eav_Model_Mysql4_Config
  • Mage_Eav_Model_Mysql4_Entity_Attribute
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Group
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Option
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Option_Collection
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Set
  • Mage_Eav_Model_Mysql4_Entity_Attribute_Set_Collection
  • Mage_Eav_Model_Mysql4_Entity_Store
  • Mage_Eav_Model_Mysql4_Entity_Type
  • Mage_Eav_Model_Mysql4_Entity_Type_Collection
  • Mage_Eav_Model_Mysql4_Form_Element
  • Mage_Eav_Model_Mysql4_Form_Element_Collection
  • Mage_Eav_Model_Mysql4_Form_Fieldset
  • Mage_Eav_Model_Mysql4_Form_Fieldset_Collection
  • Mage_Eav_Model_Mysql4_Form_Type
  • Mage_Eav_Model_Mysql4_Form_Type_Collection
  • Mage_Eav_Model_Resource_Attribute
  • Mage_Eav_Model_Resource_Attribute_Collection
  • Mage_Eav_Model_Resource_Config
  • Mage_Eav_Model_Resource_Entity_Attribute
  • Mage_Eav_Model_Resource_Entity_Attribute_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Group
  • Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Option
  • Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection
  • Mage_Eav_Model_Resource_Entity_Attribute_Set
  • Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection
  • Mage_Eav_Model_Resource_Entity_Store
  • Mage_Eav_Model_Resource_Entity_Type
  • Mage_Eav_Model_Resource_Entity_Type_Collection
  • Mage_Eav_Model_Resource_Form_Attribute
  • Mage_Eav_Model_Resource_Form_Attribute_Collection
  • Mage_Eav_Model_Resource_Form_Element
  • Mage_Eav_Model_Resource_Form_Element_Collection
  • Mage_Eav_Model_Resource_Form_Fieldset
  • Mage_Eav_Model_Resource_Form_Fieldset_Collection
  • Mage_Eav_Model_Resource_Form_Type
  • Mage_Eav_Model_Resource_Form_Type_Collection
  • Mage_Eav_Model_Resource_Helper_Mysql4

Interfaces

  • Mage_Eav_Model_Entity_Attribute_Backend_Interface
  • Mage_Eav_Model_Entity_Attribute_Frontend_Interface
  • Mage_Eav_Model_Entity_Attribute_Interface
  • Mage_Eav_Model_Entity_Attribute_Source_Interface
  • Mage_Eav_Model_Entity_Increment_Interface
  • Mage_Eav_Model_Entity_Interface

Exceptions

  • Mage_Eav_Exception
  • Mage_Eav_Model_Entity_Attribute_Exception
  • Overview
  • Package
  • Class
  • Tree
  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:  * EAV Attribute Abstract Data Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Eav
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Eav_Model_Attribute_Data_Abstract
 36: {
 37:     /**
 38:      * Attribute instance
 39:      *
 40:      * @var Mage_Eav_Model_Attribute
 41:      */
 42:     protected $_attribite;
 43: 
 44:     /**
 45:      * Entity instance
 46:      *
 47:      * @var Mage_Core_Model_Abstract
 48:      */
 49:     protected $_entity;
 50: 
 51:     /**
 52:      * Request Scope name
 53:      *
 54:      * @var string
 55:      */
 56:     protected $_requestScope;
 57: 
 58:     /**
 59:      * Scope visibility flag
 60:      *
 61:      * @var boolean
 62:      */
 63:     protected $_requestScopeOnly    = true;
 64: 
 65:     /**
 66:      * Is AJAX request flag
 67:      *
 68:      * @var boolean
 69:      */
 70:     protected $_isAjax              = false;
 71: 
 72:     /**
 73:      * Array of full extracted data
 74:      * Needed for depends attributes
 75:      *
 76:      * @var array
 77:      */
 78:     protected $_extractedData       = array();
 79: 
 80:     /**
 81:      * Mage_Core_Model_Locale FORMAT
 82:      *
 83:      * @var string
 84:      */
 85:     protected $_dateFilterFormat;
 86: 
 87:     /**
 88:      * Set attribute instance
 89:      *
 90:      * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
 91:      * @return Mage_Eav_Model_Attribute_Data_Abstract
 92:      */
 93:     public function setAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 94:     {
 95:         $this->_attribite = $attribute;
 96:         return $this;
 97:     }
 98: 
 99:     /**
100:      * Return Attribute instance
101:      *
102:      * @throws Mage_Core_Exception
103:      * @return Mage_Eav_Model_Attribute
104:      */
105:     public function getAttribute()
106:     {
107:         if (!$this->_attribite) {
108:             Mage::throwException(Mage::helper('eav')->__('Attribute object is undefined'));
109:         }
110:         return $this->_attribite;
111:     }
112: 
113:     /**
114:      * Set Request scope
115:      *
116:      * @param string $scope
117:      * @return string
118:      */
119:     public function setRequestScope($scope)
120:     {
121:         $this->_requestScope = $scope;
122:         return $this;
123:     }
124: 
125:     /**
126:      * Set scope visibility
127:      * Search value only in scope or search value in scope and global
128:      *
129:      * @param boolean $flag
130:      * @return Mage_Eav_Model_Attribute_Data_Abstract
131:      */
132:     public function setRequestScopeOnly($flag)
133:     {
134:         $this->_requestScopeOnly = (bool)$flag;
135:         return $this;
136:     }
137: 
138:     /**
139:      * Set entity instance
140:      *
141:      * @param Mage_Core_Model_Abstract $entity
142:      * @return Mage_Eav_Model_Attribute_Data_Abstract
143:      */
144:     public function setEntity(Mage_Core_Model_Abstract $entity)
145:     {
146:         $this->_entity = $entity;
147:         return $this;
148:     }
149: 
150:     /**
151:      * Returns entity instance
152:      *
153:      * @return Mage_Core_Model_Abstract
154:      */
155:     public function getEntity()
156:     {
157:         if (!$this->_entity) {
158:             Mage::throwException(Mage::helper('eav')->__('Entity object is undefined'));
159:         }
160:         return $this->_entity;
161:     }
162: 
163:     /**
164:      * Set array of full extracted data
165:      *
166:      * @param array $data
167:      * @return Mage_Eav_Model_Attribute_Data_Abstract
168:      */
169:     public function setExtractedData(array $data)
170:     {
171:         $this->_extractedData = $data;
172:         return $this;
173:     }
174: 
175:     /**
176:      * Return extracted data
177:      *
178:      * @param string $index
179:      * @return mixed
180:      */
181:     public function getExtractedData($index = null)
182:     {
183:         if (!is_null($index)) {
184:             if (isset($this->_extractedData[$index])) {
185:                 return $this->_extractedData[$index];
186:             }
187:             return null;
188:         }
189:         return $this->_extractedData;
190:     }
191: 
192:     /**
193:      * Apply attribute input filter to value
194:      *
195:      * @param string $value
196:      * @return string
197:      */
198:     protected function _applyInputFilter($value)
199:     {
200:         if ($value === false) {
201:             return false;
202:         }
203: 
204:         $filter = $this->_getFormFilter();
205:         if ($filter) {
206:             $value = $filter->inputFilter($value);
207:         }
208: 
209:         return $value;
210:     }
211: 
212:     /**
213:      * Return Data Form Input/Output Filter
214:      *
215:      * @return Varien_Data_Form_Filter_Interface|false
216:      */
217:     protected function _getFormFilter()
218:     {
219:         $filterCode = $this->getAttribute()->getInputFilter();
220:         if ($filterCode) {
221:             $filterClass = 'Varien_Data_Form_Filter_' . ucfirst($filterCode);
222:             if ($filterCode == 'date') {
223:                 $filter = new $filterClass($this->_dateFilterFormat(), Mage::app()->getLocale()->getLocale());
224:             } else {
225:                 $filter = new $filterClass();
226:             }
227:             return $filter;
228:         }
229:         return false;
230:     }
231: 
232:     /**
233:      * Get/Set/Reset date filter format
234:      *
235:      * @param string|null|false $format
236:      * @return Mage_Eav_Model_Attribute_Data_Abstract|string
237:      */
238:     protected function _dateFilterFormat($format = null)
239:     {
240:         if (is_null($format)) {
241:             // get format
242:             if (is_null($this->_dateFilterFormat)) {
243:                 $this->_dateFilterFormat = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT;
244:             }
245:             return Mage::app()->getLocale()->getDateFormat($this->_dateFilterFormat);
246:         } else if ($format === false) {
247:             // reset value
248:             $this->_dateFilterFormat = null;
249:             return $this;
250:         }
251: 
252:         $this->_dateFilterFormat = $format;
253:         return $this;
254:     }
255: 
256:     /**
257:      * Apply attribute output filter to value
258:      *
259:      * @param string $value
260:      * @return string
261:      */
262:     protected function _applyOutputFilter($value)
263:     {
264:         $filter = $this->_getFormFilter();
265:         if ($filter) {
266:             $value = $filter->outputFilter($value);
267:         }
268: 
269:         return $value;
270:     }
271: 
272:     /**
273:      * Validate value by attribute input validation rule
274:      *
275:      * @param string $value
276:      * @return string
277:      */
278:     protected function _validateInputRule($value)
279:     {
280:         // skip validate empty value
281:         if (empty($value)) {
282:             return true;
283:         }
284: 
285:         $label         = $this->getAttribute()->getStoreLabel();
286:         $validateRules = $this->getAttribute()->getValidateRules();
287: 
288:         if (!empty($validateRules['input_validation'])) {
289:             switch ($validateRules['input_validation']) {
290:                 case 'alphanumeric':
291:                     $validator = new Zend_Validate_Alnum(true);
292:                     $validator->setMessage(
293:                         Mage::helper('eav')->__('"%s" invalid type entered.', $label),
294:                         Zend_Validate_Alnum::INVALID
295:                     );
296:                     $validator->setMessage(
297:                         Mage::helper('eav')->__('"%s" has not only alphabetic and digit characters.', $label),
298:                         Zend_Validate_Alnum::NOT_ALNUM
299:                     );
300:                     $validator->setMessage(
301:                         Mage::helper('eav')->__('"%s" is an empty string.', $label),
302:                         Zend_Validate_Alnum::STRING_EMPTY
303:                     );
304:                     if (!$validator->isValid($value)) {
305:                         return $validator->getMessages();
306:                     }
307:                     break;
308:                 case 'numeric':
309:                     $validator = new Zend_Validate_Digits();
310:                     $validator->setMessage(
311:                         Mage::helper('eav')->__('"%s" invalid type entered.', $label),
312:                         Zend_Validate_Digits::INVALID
313:                     );
314:                     $validator->setMessage(
315:                         Mage::helper('eav')->__('"%s" contains not only digit characters.', $label),
316:                         Zend_Validate_Digits::NOT_DIGITS
317:                     );
318:                     $validator->setMessage(
319:                         Mage::helper('eav')->__('"%s" is an empty string.', $label),
320:                         Zend_Validate_Digits::STRING_EMPTY
321:                     );
322:                     if (!$validator->isValid($value)) {
323:                         return $validator->getMessages();
324:                     }
325:                     break;
326:                 case 'alpha':
327:                     $validator = new Zend_Validate_Alpha(true);
328:                     $validator->setMessage(
329:                         Mage::helper('eav')->__('"%s" invalid type entered.', $label),
330:                         Zend_Validate_Alpha::INVALID
331:                     );
332:                     $validator->setMessage(
333:                         Mage::helper('eav')->__('"%s" has not only alphabetic characters.', $label),
334:                         Zend_Validate_Alpha::NOT_ALPHA
335:                     );
336:                     $validator->setMessage(
337:                         Mage::helper('eav')->__('"%s" is an empty string.', $label),
338:                         Zend_Validate_Alpha::STRING_EMPTY
339:                     );
340:                     if (!$validator->isValid($value)) {
341:                         return $validator->getMessages();
342:                     }
343:                     break;
344:                 case 'email':
345:         /**
346:         $this->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
347:         $this->__("Invalid type given. String expected")
348:         $this->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
349:         $this->__("'%value%' does not match the expected structure for a DNS hostname")
350:         $this->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
351:         $this->__("'%value%' does not appear to be a valid local network name")
352:         $this->__("'%value%' does not appear to be a valid URI hostname")
353:         $this->__("'%value%' appears to be an IP address, but IP addresses are not allowed")
354:         $this->__("'%value%' appears to be a local network name but local network names are not allowed")
355:         $this->__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
356:         $this->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
357:         */
358:                     $validator = new Zend_Validate_EmailAddress();
359:                     $validator->setMessage(
360:                         Mage::helper('eav')->__('"%s" invalid type entered.', $label),
361:                         Zend_Validate_EmailAddress::INVALID
362:                     );
363:                     $validator->setMessage(
364:                         Mage::helper('eav')->__('"%s" is not a valid email address.', $label),
365:                         Zend_Validate_EmailAddress::INVALID_FORMAT
366:                     );
367:                     $validator->setMessage(
368:                         Mage::helper('eav')->__('"%s" is not a valid hostname.', $label),
369:                         Zend_Validate_EmailAddress::INVALID_HOSTNAME
370:                     );
371:                     $validator->setMessage(
372:                         Mage::helper('eav')->__('"%s" is not a valid hostname.', $label),
373:                         Zend_Validate_EmailAddress::INVALID_MX_RECORD
374:                     );
375:                     $validator->setMessage(
376:                         Mage::helper('eav')->__('"%s" is not a valid hostname.', $label),
377:                         Zend_Validate_EmailAddress::INVALID_MX_RECORD
378:                     );
379:                     $validator->setMessage(
380:                         Mage::helper('eav')->__('"%s" is not a valid email address.', $label),
381:                         Zend_Validate_EmailAddress::DOT_ATOM
382:                     );
383:                     $validator->setMessage(
384:                         Mage::helper('eav')->__('"%s" is not a valid email address.', $label),
385:                         Zend_Validate_EmailAddress::QUOTED_STRING
386:                     );
387:                     $validator->setMessage(
388:                         Mage::helper('eav')->__('"%s" is not a valid email address.', $label),
389:                         Zend_Validate_EmailAddress::INVALID_LOCAL_PART
390:                     );
391:                     $validator->setMessage(
392:                         Mage::helper('eav')->__('"%s" exceeds the allowed length.', $label),
393:                         Zend_Validate_EmailAddress::LENGTH_EXCEEDED
394:                     );
395:                     $validator->setMessage(
396:                         Mage::helper('customer')->__("'%value%' appears to be an IP address, but IP addresses are not allowed"),
397:                         Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED
398:                     );
399:                     $validator->setMessage(
400:                         Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"),
401:                         Zend_Validate_Hostname::UNKNOWN_TLD
402:                     );
403:                     $validator->setMessage(
404:                         Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"),
405:                         Zend_Validate_Hostname::INVALID_DASH
406:                     );
407:                     $validator->setMessage(
408:                         Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"),
409:                         Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA
410:                     );
411:                     $validator->setMessage(
412:                         Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"),
413:                         Zend_Validate_Hostname::UNDECIPHERABLE_TLD
414:                     );
415:                     $validator->setMessage(
416:                         Mage::helper('customer')->__("'%value%' does not appear to be a valid local network name"),
417:                         Zend_Validate_Hostname::INVALID_LOCAL_NAME
418:                     );
419:                     $validator->setMessage(
420:                         Mage::helper('customer')->__("'%value%' appears to be a local network name but local network names are not allowed"),
421:                         Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED
422:                     );
423:                     $validator->setMessage(
424:                         Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"),
425:                         Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE
426:                     );
427:                     if (!$validator->isValid($value)) {
428:                         return array_unique($validator->getMessages());
429:                     }
430:                     break;
431:                 case 'url':
432:                     $parsedUrl = parse_url($value);
433:                     if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
434:                         return array(Mage::helper('eav')->__('"%s" is not a valid URL.', $label));
435:                     }
436:                     $validator = new Zend_Validate_Hostname();
437:                     if (!$validator->isValid($parsedUrl['host'])) {
438:                         return array(Mage::helper('eav')->__('"%s" is not a valid URL.', $label));
439:                     }
440:                     break;
441:                 case 'date':
442:                     $validator = new Zend_Validate_Date(Varien_Date::DATE_INTERNAL_FORMAT);
443:                     $validator->setMessage(
444:                         Mage::helper('eav')->__('"%s" invalid type entered.', $label),
445:                         Zend_Validate_Date::INVALID
446:                     );
447:                     $validator->setMessage(
448:                         Mage::helper('eav')->__('"%s" is not a valid date.', $label),
449:                         Zend_Validate_Date::INVALID_DATE
450:                     );
451:                     $validator->setMessage(
452:                         Mage::helper('eav')->__('"%s" does not fit the entered date format.', $label),
453:                         Zend_Validate_Date::FALSEFORMAT
454:                     );
455:                     if (!$validator->isValid($value)) {
456:                        return array_unique($validator->getMessages());
457:                     }
458: 
459:                     break;
460:             }
461:         }
462:         return true;
463:     }
464: 
465:     /**
466:      * Set is AJAX Request flag
467:      *
468:      * @param boolean $flag
469:      * @return Mage_Eav_Model_Attribute_Data_Abstract
470:      */
471:     public function setIsAjaxRequest($flag = true)
472:     {
473:         $this->_isAjax = (bool)$flag;
474:         return $this;
475:     }
476: 
477:     /**
478:      * Return is AJAX Request
479:      *
480:      * @return boolean
481:      */
482:     public function getIsAjaxRequest()
483:     {
484:         return $this->_isAjax;
485:     }
486: 
487:     /**
488:      * Return Original Attribute value from Request
489:      *
490:      * @param Zend_Controller_Request_Http $request
491:      * @return mixed
492:      */
493:     protected function _getRequestValue(Zend_Controller_Request_Http $request)
494:     {
495:         $attrCode  = $this->getAttribute()->getAttributeCode();
496:         if ($this->_requestScope) {
497:             if (strpos($this->_requestScope, '/') !== false) {
498:                 $params = $request->getParams();
499:                 $parts = explode('/', $this->_requestScope);
500:                 foreach ($parts as $part) {
501:                     if (isset($params[$part])) {
502:                         $params = $params[$part];
503:                     } else {
504:                         $params = array();
505:                     }
506:                 }
507:             } else {
508:                 $params = $request->getParam($this->_requestScope);
509:             }
510: 
511:             if (isset($params[$attrCode])) {
512:                 $value = $params[$attrCode];
513:             } else {
514:                 $value = false;
515:             }
516: 
517:             if (!$this->_requestScopeOnly && $value === false) {
518:                 $value = $request->getParam($attrCode, false);
519:             }
520:         } else {
521:             $value = $request->getParam($attrCode, false);
522:         }
523:         return $value;
524:     }
525: 
526:     /**
527:      * Extract data from request and return value
528:      *
529:      * @param Zend_Controller_Request_Http $request
530:      * @return array|string
531:      */
532:     abstract public function extractValue(Zend_Controller_Request_Http $request);
533: 
534:     /**
535:      * Validate data
536:      *
537:      * @param array|string $value
538:      * @throws Mage_Core_Exception
539:      * @return boolean
540:      */
541:     abstract public function validateValue($value);
542: 
543:     /**
544:      * Export attribute value to entity model
545:      *
546:      * @param array|string $value
547:      * @return Mage_Eav_Model_Attribute_Data_Abstract
548:      */
549:     abstract public function compactValue($value);
550: 
551:     /**
552:      * Restore attribute value from SESSION to entity model
553:      *
554:      * @param array|string $value
555:      * @return Mage_Eav_Model_Attribute_Data_Abstract
556:      */
557:     abstract public function restoreValue($value);
558: 
559:     /**
560:      * Return formated attribute value from entity model
561:      *
562:      * @param string $format
563:      * @return string|array
564:      */
565:     abstract public function outputValue($format = Mage_Eav_Model_Attribute_Data::OUTPUT_FORMAT_TEXT);
566: }
567: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0