setOptions($options); } public static function &getInstance($type, $options) { $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); $class = 'SESanityTest'.ucfirst($type); if( !class_exists($class) ) { $path = dirname(__FILE__).DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.$type.'.php'; if( file_exists($path) ) { require_once($path); } else { die('Unable to load test class: '.$type); } } $instance = new $class($options); $instance->type = $type; return $instance; } function setOptions($options) { if( isset($options['level']) ) $this->level_default = $options['level']; if( isset($options['category']) ) $this->category = $options['category']; if( isset($options['critical']) ) $this->is_critical = $options['critical']; if( isset($options['lang_title']) ) $this->lang_title = $options['lang_title']; if( isset($options['lang_message']) ) $this->lang_message = $options['lang_message']; if( isset($options['recommendation']) ) $this->is_recommendation = $options['recommendation']; if( isset($options['callback']) && is_callable($options['callback']) ) $this->level_default = $options['callback']; } function preset() { $name = $this->getName(); if( is_callable(array('SESanityHelpers', $name)) ) { call_user_func_array(array('SESanityHelpers', $name), array($name)); } elseif( $this->callback ) { call_user_func_array($this->callback, array($name)); } else { return FALSE; } return TRUE; /* if( !$this->callback && is_callable(array('SESanityHelpers', $name)) ) { $this->callback = array('SESanityHelpers', $name); } if( !is_callable($this->callback) ) return FALSE; call_user_func_array($this->callback, array(&$this)); return TRUE; */ } function getType() { return $this->type; } function getName() { return $this->name; } // Functions that must be implemented by the child classes function execute() { } function merge() { } function getValue() { } function getTitle() { return $this->lang_title; } function getCategory() { $sanity = SESanity::getInstance(); return $sanity->categories[$this->category]['lang_title']; } function getMessage() { return $this->lang_message; } function getCustomMessage() { return $this->custom_message; } } ?>