Source for file DottedPairValidatorRule.class.php

Documentation is available at DottedPairValidatorRule.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."utilities/FieldSetValidator/rules/RegexValidatorRule.class.php");
  4.  
  5. /**
  6. * The DottedPairValidatorRule checks to see if a string is of a "module.action"
  7. * dotted-pair format.
  8. *
  9. * @package harmoni.actions
  10. *
  11. * @copyright Copyright &copy; 2005, Middlebury College
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  13. *
  14. * @version $Id: DottedPairValidatorRule.class.php,v 1.8 2007/09/04 20:25:29 adamfranco Exp $
  15. */
  16.  
  17. class DottedPairValidatorRule
  18. extends RegexValidatorRule
  19. {
  20. /**
  21. * the constructor
  22. *
  23. * @access public
  24. * @return void
  25. ***/
  26. function DottedPairValidatorRule() {
  27. $this->_regex = "^[[:alnum:]_-]+\.([[:alnum:]_-]+)|\*$"; // matches a dotted-pair for modules.actions
  28. }
  29. /**
  30. * This is a static method to return an already-created instance of a validator
  31. * rule. There are at most about a hundred unique rule objects in use durring
  32. * any given execution cycle, but rule objects are instantiated hundreds of
  33. * thousands of times.
  34. *
  35. * This method follows a modified Singleton pattern
  36. *
  37. * @return object ValidatorRule
  38. * @access public
  39. * @static
  40. * @since 3/28/05
  41. */
  42. function getRule () {
  43. // Because there is no way in PHP to get the class name of the descendent
  44. // class on which this method is called, this method must be implemented
  45. // in each descendent class.
  46.  
  47. if (!is_array($GLOBALS['validator_rules']))
  48. $GLOBALS['validator_rules'] = array();
  49. $class = __CLASS__;
  50. if (!isset($GLOBALS['validator_rules'][$class]))
  51. $GLOBALS['validator_rules'][$class] = new $class;
  52. return $GLOBALS['validator_rules'][$class];
  53. }
  54. }
  55.  
  56. ?>

Documentation generated on Wed, 19 Sep 2007 10:22:49 -0400 by phpDocumentor 1.3.0RC3