Perforce Chronicle 2012.2/486814
API Documentation
|
Validates string for suitability as a CSS class. More...
Public Member Functions | |
__construct () | |
Revise message templates upon instantiation. | |
isValid ($value) | |
Defined by Zend_Validate_Interface. | |
Public Attributes | |
const | ILLEGAL_CHARACTERS = 'illegalCharacters' |
const | INVALID_TYPE = 'invalidType' |
Validates string for suitability as a CSS class.
P4Cms_Validate_CssClass::__construct | ( | ) |
Revise message templates upon instantiation.
{ $message = "Only '-', '_' and alpha-numeric characters are permitted in CSS classes."; $this->_messageTemplates[static::ILLEGAL_CHARACTERS] = $message; $this->_messageTemplates[self::INVALID_TYPE] = 'Invalid type given.'; }
P4Cms_Validate_CssClass::isValid | ( | $ | value | ) |
Defined by Zend_Validate_Interface.
Checks if the given string is a valid CSS class.
string | $value | The value to validate. |
{ $this->_setValue($value); // tolerate empty values if (!isset($value)) { return true; } // ensure that only string values are valid. if (is_numeric($value)) { $value = (string) $value; } if (!is_string($value)) { $this->_error(static::INVALID_TYPE); return false; } // validate permitted characters, but do not complain about unset values if (preg_match("/[^a-z0-9_\- ]/i", $value)) { $this->_error(self::ILLEGAL_CHARACTERS); return false; } return true; }
const P4Cms_Validate_CssClass::ILLEGAL_CHARACTERS = 'illegalCharacters' |
const P4Cms_Validate_CssClass::INVALID_TYPE = 'invalidType' |