Changeset 5821
- Timestamp:
- 11/02/07 19:07:30 (1 year ago)
- Files:
-
- branches/dwhittle/data/skeleton/project/web/css/main.css (modified) (1 diff)
- branches/dwhittle/lib/action/sfAction.class.php (modified) (1 diff)
- branches/dwhittle/lib/action/sfActions.class.php (modified) (3 diffs)
- branches/dwhittle/lib/action/sfComponent.class.php (modified) (1 diff)
- branches/dwhittle/lib/action/sfComponents.class.php (modified) (1 diff)
- branches/dwhittle/lib/filter/sfExecutionFilter.class.php (modified) (1 diff)
- branches/dwhittle/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php (modified) (1 diff)
- branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php (modified) (1 diff)
- branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropel.class.php (copied) (copied from trunk/lib/plugins/sfPropelPlugin/lib/propel/sfPropel.class.php)
- branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php (modified) (2 diffs)
- branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php (modified) (2 diffs)
- branches/dwhittle/lib/util/sfCallable.class.php (copied) (copied from trunk/lib/util/sfCallable.class.php)
- branches/dwhittle/lib/validator/sfValidator.class.php (modified) (6 diffs)
- branches/dwhittle/lib/validator/sfValidatorAll.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorAny.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorBoolean.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorCallback.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorChoice.class.php (modified) (3 diffs)
- branches/dwhittle/lib/validator/sfValidatorDate.class.php (modified) (4 diffs)
- branches/dwhittle/lib/validator/sfValidatorDecorator.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorEmail.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorInteger.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorNumber.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorRegex.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorSchema.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorSchemaCompare.class.php (modified) (4 diffs)
- branches/dwhittle/lib/validator/sfValidatorSchemaFilter.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorString.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorUrl.class.php (modified) (2 diffs)
- branches/dwhittle/test/unit/util/sfCallableTest.php (copied) (copied from trunk/test/unit/util/sfCallableTest.php)
- branches/dwhittle/test/unit/validator/sfValidatorBooleanTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorChoiceTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorDateTest.php (modified) (3 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorDecoratorTest.php (modified) (3 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorFromDescriptionTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorIntegerTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorNumberTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorRegexTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorSchemaTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorStringTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorTest.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/data/skeleton/project/web/css/main.css
r500 r5821 1 ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input2 { margin: 0; padding: 0; }3 a img,:link img,:visited img { border: none; }4 5 a6 {7 text-decoration: none;8 }9 10 a:hover11 {12 text-decoration: underline;13 }14 15 body, td16 {17 margin: 0;18 padding: 0;19 font-family: Arial, Verdana, sans-serif;20 font-size: 11px;21 background-color: #fff;22 }23 24 body25 {26 padding: 20px;27 }branches/dwhittle/lib/action/sfAction.class.php
r5503 r5821 546 546 * @param string Template name 547 547 */ 548 public function setTemplate($name )548 public function setTemplate($name, $module = null) 549 549 { 550 550 if (sfConfig::get('sf_logging_enabled')) 551 551 { 552 $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change template to "%s"', $name)))); 552 $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Change template to "%s/%s"', is_null($module) ? 'CURRENT' : $module, $name)))); 553 } 554 555 if (!is_null($module)) 556 { 557 $name = sfConfig::get('sf_app_dir').'/modules/'.$module.'/templates/'.$name; 553 558 } 554 559 branches/dwhittle/lib/action/sfActions.class.php
r4952 r5821 27 27 * defined action name. 28 28 * 29 * @return string A string containing the view name associated with this action 29 * @param sfRequest The current sfRequest object 30 * 31 * @return string A string containing the view name associated with this action 30 32 * 31 33 * @throws sfInitializationException … … 33 35 * @see sfAction 34 36 */ 35 public function execute( )37 public function execute($request) 36 38 { 37 39 // dispatch action … … 49 51 50 52 // run action 51 $ret = $this->$actionToRun(); 52 53 return $ret; 53 return $this->$actionToRun($request); 54 54 } 55 55 } branches/dwhittle/lib/action/sfComponent.class.php
r4963 r5821 69 69 * single product. 70 70 * 71 * @return mixed A string containing the view name associated with this action 72 */ 73 abstract function execute(); 71 * @param sfRequest The current sfRequest object 72 * 73 * @return mixed A string containing the view name associated with this action 74 */ 75 abstract function execute($request); 74 76 75 77 /** branches/dwhittle/lib/action/sfComponents.class.php
r4599 r5821 19 19 abstract class sfComponents extends sfComponent 20 20 { 21 public function execute( )21 public function execute($request) 22 22 { 23 23 throw new sfInitializationException('sfComponents initialization failed.'); branches/dwhittle/lib/filter/sfExecutionFilter.class.php
r5386 r5821 101 101 // execute the action 102 102 $actionInstance->preExecute(); 103 $viewName = $actionInstance->execute( );103 $viewName = $actionInstance->execute($this->context->getRequest()); 104 104 $actionInstance->postExecute(); 105 105 branches/dwhittle/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php
r5386 r5821 158 158 // execute the action 159 159 $actionInstance->preExecute(); 160 $viewName = $actionInstance->execute( );160 $viewName = $actionInstance->execute($this->context->getRequest()); 161 161 $actionInstance->postExecute(); 162 162 branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php
r5769 r5821 177 177 if (is_null($culture)) 178 178 { 179 if (is_null($this->culture)) 180 { 181 throw new PropelException(sprintf(\'No culture is set for this "%s" object.\', get_class($this))); 182 } 183 184 $culture = $this->culture; 179 $culture = is_null($this->culture) ? sfPropel::getDefaultCulture() : $this->culture; 185 180 } 186 181 branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php
r5248 r5821 17 17 require_once 'propel/Propel.php'; 18 18 19 $dispatcher = sfContext::getInstance()->getEventDispatcher(); 20 19 21 if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) 20 22 { 21 23 // add propel logger 22 Propel::setLogger(new sfPropelLogger( ));24 Propel::setLogger(new sfPropelLogger($dispatcher)); 23 25 } 24 26 … … 26 28 Propel::setConfiguration(sfPropelDatabase::getConfiguration()); 27 29 Propel::initialize(); 30 31 sfPropel::initialize($dispatcher, sfContext::getInstance()->getUser()->getCulture()); branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php
r5125 r5821 240 240 $this->database[$table][$column] = array( 241 241 'type' => 'integer', 242 'required' => true, 242 243 'foreignTable' => $foreign_table, 243 'foreignReference' => 'id' 244 'foreignReference' => 'id', 244 245 ); 245 246 } … … 249 250 } 250 251 } 251 252 252 } 253 253 else branches/dwhittle/lib/validator/sfValidator.class.php
r5758 r5821 25 25 26 26 protected 27 $messages = array(), 28 $options = array(); 27 $requiredOptions = array(), 28 $defaultMessages = array(), 29 $defaultOptions = array(), 30 $messages = array(), 31 $options = array(); 29 32 30 33 /** … … 42 45 public function __construct($options = array(), $messages = array()) 43 46 { 44 $this-> messages = array('required' => 'Required.', 'invalid' => 'Invalid.');45 $this-> options = array('required' => true, 'trim' => false, 'empty_value' => null);47 $this->options = array_merge(array('required' => true, 'trim' => false, 'empty_value' => null), $this->options); 48 $this->messages = array_merge(array('required' => 'Required.', 'invalid' => 'Invalid.'), $this->messages); 46 49 47 50 $this->configure($options, $messages); 51 52 $this->setDefaultOptions($this->getOptions()); 53 $this->setDefaultMessages($this->getMessages()); 54 55 // check option names 56 if ($diff = array_diff(array_keys($options), array_merge(array_keys($this->options), $this->requiredOptions))) 57 { 58 throw new sfException(sprintf('%s does not support the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 59 } 60 61 // check error code names 62 if ($diff = array_diff(array_keys($messages), array_keys($this->messages))) 63 { 64 throw new sfException(sprintf('%s does not support the following error codes: \'%s\'.', get_class($this), implode('\', \'', $diff))); 65 } 66 67 // check required options 68 if ($diff = array_diff($this->requiredOptions, array_keys($options))) 69 { 70 throw new sfException(sprintf('%s requires the following options: \'%s\'.', get_class($this), implode('\', \'', $diff))); 71 } 48 72 49 73 $this->options = array_merge($this->options, $options); 50 74 $this->messages = array_merge($this->messages, $messages); 75 } 76 77 /** 78 * Configures the current validator. 79 * 80 * This method allows each validator to add options and error messages 81 * during validator creation. 82 * 83 * If some options and messages are given in the sfValidator constructor 84 * they will take precedence over the options and messages you configure 85 * in this method. 86 * 87 * @param array An array of options 88 * @param array An array of error messages 89 * 90 * @see __construct() 91 */ 92 protected function configure($options = array(), $messages = array()) 93 { 51 94 } 52 95 … … 199 242 200 243 /** 244 * Sets the charset to use when validating strings. 245 * 246 * @param string The charset 247 */ 248 static public function setCharset($charset) 249 { 250 self::$charset = $charset; 251 } 252 253 /** 254 * Returns the charset to use when validating strings. 255 * 256 * @return string The charset (default to UTF-8) 257 */ 258 static public function getCharset() 259 { 260 return self::$charset; 261 } 262 263 /** 264 * Returns true if the value is empty. 265 * 266 * @param mixed The input value 267 * 268 * @return Boolean true if the value is empty, false otherwise 269 */ 270 protected function isEmpty($value) 271 { 272 return in_array($value, array(null, '')); 273 } 274 275 /** 276 * Returns an empty value for this validator. 277 * 278 * @return mixed The empty value for this validator 279 */ 280 protected function getEmptyValue() 281 { 282 return $this->getOption('empty_value'); 283 } 284 285 /** 201 286 * Returns an array of all error codes for this validator. 202 287 * 203 * Subclasses of sfValidator may override this method to register204 * their own error codes.205 *206 * By default this method return required and invalid as errors codes.207 *208 288 * @return array An array of possible error codes 209 */ 210 public function getErrorCodes() 211 { 212 return array('required', 'invalid'); 213 } 214 215 /** 216 * Sets the charset to use when validating strings. 217 * 218 * @param string The charset 219 */ 220 static public function setCharset($charset) 221 { 222 self::$charset = $charset; 223 } 224 225 /** 226 * Returns the charset to use when validating strings. 227 * 228 * @return string The charset (default to UTF-8) 229 */ 230 static public function getCharset() 231 { 232 return self::$charset; 233 } 234 235 /** 236 * Returns true if the value is empty. 237 * 238 * @param mixed The input value 239 * 240 * @return Boolean true if the value is empty, false otherwise 241 */ 242 protected function isEmpty($value) 243 { 244 return in_array($value, array(null, '')); 245 } 246 247 /** 248 * Returns an empty value for this validator. 249 * 250 * @return mixed The empty value for this validator 251 */ 252 protected function getEmptyValue() 253 { 254 return $this->getOption('empty_value'); 255 } 256 257 /** 258 * Configures the current validator. 259 * 260 * This method allows each validator to add options and error messages 261 * during validator creation. 262 * 263 * If some options and messages are given in the sfValidator constructor 264 * they will take precedence over the options and messages you configure 265 * in this method. 266 * 267 * @param array An array of options 268 * @param array An array of error messages 269 * 270 * @see __construct() 271 */ 272 protected function configure($options = array(), $messages = array()) 273 { 289 * 290 * @see getDefaultMessages() 291 */ 292 final public function getErrorCodes() 293 { 294 return array_keys($this->getDefaultMessages()); 295 } 296 297 /** 298 * Returns default messages for all possible error codes. 299 * 300 * @return array An array of default error codes and messages 301 */ 302 public function getDefaultMessages() 303 { 304 return $this->defaultMessages; 305 } 306 307 /** 308 * Sets default messages for all possible error codes. 309 * 310 * @param array An array of default error codes and messages 311 */ 312 protected function setDefaultMessages($messages) 313 { 314 $this->defaultMessages = $messages; 315 } 316 317 /** 318 * Returns default option values. 319 * 320 * @return array An array of default option values 321 */ 322 public function getDefaultOptions() 323 { 324 return $this->defaultOptions; 325 } 326 327 /** 328 * Sets default option values. 329 * 330 * @param array An array of default option values 331 */ 332 protected function setDefaultOptions($options) 333 { 334 $this->defaultOptions = $options; 335 } 336 337 /** 338 * Adds a required option. 339 * 340 * @param string The option name 341 */ 342 public function addRequiredOption($name) 343 { 344 $this->requiredOptions[] = $name; 345 } 346 347 /** 348 * Returns all required option names. 349 * 350 * @param array An array of required option names 351 */ 352 public function getRequiredOptions() 353 { 354 return $this->requiredOptions; 274 355 } 275 356 … … 295 376 296 377 /** 378 * Returns all error messages with non default values. 379 * 380 * @return string A string representation of the error messages 381 */ 382 protected function getMessagesWithoutDefaults() 383 { 384 $messages = $this->messages; 385 386 // remove default option values 387 foreach ($this->getDefaultMessages() as $key => $value) 388 { 389 if (array_key_exists($key, $messages) && $messages[$key] === $value) 390 { 391 unset($messages[$key]); 392 } 393 } 394 395 return $messages; 396 } 397 398 /** 297 399 * Returns all options with non default values. 298 400 * … … 304 406 305 407 // remove default option values 306 $reflection = new ReflectionClass(get_class($this)); 307 $default = $reflection->newInstanceArgs(func_get_args()); 308 foreach ($default->getOptions() as $key => $value) 408 foreach ($this->getDefaultOptions() as $key => $value) 309 409 { 310 410 if (array_key_exists($key, $options) && $options[$key] === $value) … … 316 416 return $options; 317 417 } 318 319 /**320 * Returns all error messages with non default values.321 *322 * @return string A string representation of the error messages323 */324 protected function getMessagesWithoutDefaults()325 {326 $messages = $this->messages;327 328 // remove default option values329 $reflection = new ReflectionClass(get_class($this));330 $default = $reflection->newInstanceArgs(func_get_args());331 foreach ($default->getMessages() as $key => $value)332 {333 if (array_key_exists($key, $messages) && $messages[$key] === $value)334 {335 unset($messages[$key]);336 }337 }338 339 return $messages;340 }341 418 } branches/dwhittle/lib/validator/sfValidatorAll.class.php
r5758 r5821 55 55 } 56 56 57 if (!isset($messages['invalid'])) 58 { 59 $messages['invalid'] = null; 60 } 57 parent::__construct($options, $messages); 58 } 61 59 62 parent::__construct($options, $messages); 60 /** 61 * @see sfValidator 62 */ 63 public function configure($options = array(), $messages = array()) 64 { 65 $this->setMessage('invalid', null); 63 66 } 64 67 … … 145 148 } 146 149 147 return sprintf("%s(%s%s)", 148 str_repeat(' ', $indent), 149 $validators, 150 str_repeat(' ', $indent) 151 ); 150 return sprintf("%s(%s%s)", str_repeat(' ', $indent), $validators, str_repeat(' ', $indent)); 152 151 } 153 152 } branches/dwhittle/lib/validator/sfValidatorAny.class.php
r5758 r5821 55 55 } 56 56 57 if (!isset($messages['invalid'])) 58 { 59 $messages['invalid'] = null; 60 } 57 parent::__construct($options, $messages); 58 } 61 59 62 parent::__construct($options, $messages); 60 /** 61 * @see sfValidator 62 */ 63 public function configure($options = array(), $messages = array()) 64 { 65 $this->setMessage('invalid', null); 63 66 } 64 67 … … 139 142 } 140 143 141 return sprintf("%s(%s%s)", 142 str_repeat(' ', $indent), 143 $validators, 144 str_repeat(' ', $indent) 145 ); 144 return sprintf("%s(%s%s)", str_repeat(' ', $indent), $validators, str_repeat(' ', $indent)); 146 145 } 147 146 } branches/dwhittle/lib/validator/sfValidatorBoolean.class.php
r5651 r5821 33 33 $this->setOption('true_values', array('true', 't', 'yes', 'y', 'on', '1')); 34 34 $this->setOption('false_values', array('false', 'f', 'no', 'n', 'off', '0')); 35 36 35 $this->setOption('required', false); 37 36 } branches/dwhittle/lib/validator/sfValidatorCallback.class.php
r5758 r5821 20 20 { 21 21 /** 22 * Con structor.22 * Configures the current validator. 23 23 * 24 24 * Available options: 25 25 * 26 * * callback: A valid PHP callback 26 * * callback: A valid PHP callback (required) 27 27 * 28 * @see sfValidator29 */30 public function __construct($options = array(), $messages = array())31 {32 if (!isset($options['callback']))33 {34 throw new sfException('The "callback" option is mandatory.');35 }36 37 parent::__construct($options, $messages);38 }39 40 /**41 28 * @see sfValidator 42 29 */ 43 30 protected function configure($options = array(), $messages = array()) 44 31 { 45 $this->options['required'] = false; 32 $this->addRequiredOption('callback'); 33 $this->setOption('required', false); 46 34 } 47 35 … … 53 41 return call_user_func($this->getOption('callback'), $this, $value); 54 42 } 55 56 /**57 * @see sfValidator58 */59 protected function getOptionsWithoutDefaults()60 {61 return parent::getOptionsWithoutDefaults(array('callback' => array('--fake--')));62 }63 64 /**65 * @see sfValidator66 */67 protected function getMessagesWithoutDefaults()68 {69 return parent::getMessagesWithoutDefaults(array('callback' => array('--fake--')));70 }71 43 } branches/dwhittle/lib/validator/sfValidatorChoice.class.php
r5758 r5821 20 20 { 21 21 /** 22 * Con structor.22 * Configures the current validator. 23 23 * 24 24 * Available options: 25 25 * 26 * * choices: An array of expected values 26 * * choices: An array of expected values (required) 27 27 * 28 28 * @see sfValidator 29 29 */ 30 p ublic function __construct($options = array(), $messages = array())30 protected function configure($options = array(), $messages = array()) 31 31 { 32 if (!isset($options['choices'])) 33 { 34 throw new sfException('The "choices" option is mandatory.'); 35 } 36 37 parent::__construct($options, $messages); 32 $this->addRequiredOption('choices'); 38 33 } 39 34 … … 43 38 protected function doClean($value) 44 39 { 45 if (!in_array($value, $this->getOption('choices'))) 40 $choices = $this->getOption('choices'); 41 if ($choices instanceof sfCallable) 42 { 43 $choices = $choices->call(); 44 } 45 46 if (!in_array($value, $choices)) 46 47 { 47 48 throw new sfValidatorError($this, 'invalid', array('value' => $value)); … … 50 51 return $value; 51 52 } 52 53 /**54 * @see sfValidator55 */56 protected function getOptionsWithoutDefaults()57 {58 return parent::getOptionsWithoutDefaults(array('choices' => array('--fake--')));59 }60 61 /**62 * @see sfValidator63 */64 protected function getMessagesWithoutDefaults()65 {66 return parent::getMessagesWithoutDefaults(array('choices' => array('--fake--')));67 }68 53 } branches/dwhittle/lib/validator/sfValidatorDate.class.php
r5582 r5821 35 35 $this->setMessage('bad_format', '"%value%" does not match the date format (%date_format%).'); 36 36 37 $this->setOption('date_format', null); 37 38 $this->setOption('with_time', false); 38 39 $this->setOption('date_output', 'Y-m-d'); … … 45 46 protected function doClean($value) 46 47 { 47 if ($regex = $this->getOption('date_format')) 48 if (is_array($value)) 49 { 50 $clean = $this->convertDateArrayToTimestamp($value); 51 } 52 else if ($regex = $this->getOption('date_format')) 48 53 { 49 54 if (!preg_match($regex, $value, $match)) … … 52 57 } 53 58 54 if ($this->getOption('with_time')) 55 { 56 $clean = mktime(isset($match['hour']) ? $match['hour'] : 0, isset($match['minute']) ? $match['minute'] : 0, isset($match['second']) ? $match['second'] : 0, $match['month'], $match['day'], $match['year']); 57 } 58 else 59 { 60 $clean = mktime(0, 0, 0, $match['month'], $match['day'], $match['year']); 61 } 59 $clean = $this->convertDateArrayToTimestamp($match); 62 60 } 63 61 else if (!ctype_digit($value)) 64 62 { 65 63 $clean = strtotime($value); 66 if ( $clean === -1 || $clean === false)64 if (false === $clean) 67 65 { 68 66 throw new sfValidatorError($this, 'invalid', array('value' => $value)); … … 78 76 79 77 /** 80 * @see sfValidator 78 * Converts an array representing a date to a timestamp. 79 * 80 * The array can contains the following keys: year, month, day, hour, minute, second 81 * 82 * @param array An array of date elements 83 * 84 * @return integer A timestamp 81 85 */ 82 p ublic function getErrorCodes()86 protected function convertDateArrayToTimestamp($value) 83 87 { 84 return array_merge(parent::getErrorCodes(), array('date_format')); 88 if ($this->getOption('with_time')) 89 { 90 $clean = mktime(isset($value['hour']) ? $value['hour'] : 0, isset($value['minute']) ? $value['minute'] : 0, isset($value['second']) ? $value['second'] : 0, $value['month'], $value['day'], $value['year']); 91 } 92 else 93 { 94 $clean = mktime(0, 0, 0, $value['month'], $value['day'], $value['year']); 95 } 96 97 if (false === $clean) 98 { 99 throw new sfValidatorError($this, 'invalid', array('value' => var_export($value, true))); 100 } 101 102 return $clean; 85 103 } 86 104 } branches/dwhittle/lib/validator/sfValidatorDecorator.class.php
r5758 r5821 149 149 * @see sfValidator 150 150 */ 151 public function getErrorCodes()151 public function asString($indent = 0) 152 152 { 153 return $this-> getValidator()->getErrorCodes();153 return $this->validator->asString($indent); 154 154 } 155 155 … … 157 157 * @see sfValidator 158 158 */ 159 public function asString($indent = 0)159 public function getDefaultOptions() 160 160 { 161 return $this->getValidator()->asString($indent); 161 return $this->validator->getDefaultOptions(); 162 } 163 164 /** 165 * @see sfValidator 166 */ 167 public function getDefaultMessages() 168 { 169 return $this->validator->getDefaultMessages(); 162 170 } 163 171 } branches/dwhittle/lib/validator/sfValidatorEmail.class.php
r5758 r5821 22 22 * @see sfValidatorRegex 23 23 */ 24 p ublic function __construct($options = array(), $messages = array())24 protected function configure($options = array(), $messages = array()) 25 25 { 26 $options['pattern'] = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; 27 28 parent::__construct($options, $messages); 26 $this->setOption('pattern', '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'); 29 27 } 30 28 } branches/dwhittle/lib/validator/sfValidatorInteger.class.php
r5651 r5821 34 34 $this->setMessage('min', '"%value%" must be greater than %min%.'); 35 35 $this->setMessage('invalid', '"%value%" is not an integer.'); 36 37 $this->setOption('min', null); 38 $this->setOption('max', null); 36 39 } 37 40 … … 60 63 return $clean; 61 64 } 62 63 /**64 * @see sfValidator65 */66 public function getErrorCodes()67 {68 return array_merge(parent::getErrorCodes(), array('max', 'min'));69 }70 65 } branches/dwhittle/lib/validator/sfValidatorNumber.class.php
r5582 r5821 34 34 $this->setMessage('min', '"%value%" is too short (smallest allowed is %min%).'); 35 35 $this->setMessage('invalid', '"%value%" is not a number.'); 36 37 $this->setOption('min', null); 38 $this->setOption('max', null); 36 39 } 37 40 … … 60 63 return $clean; 61 64 } 62 63 /**64 * @see sfValidator65 */66 public function getErrorCodes()67 {68 return array_merge(parent::getErrorCodes(), array('max', 'min'));69 }70 65 } branches/dwhittle/lib/validator/sfValidatorRegex.class.php
r5758 r5821 20 20 { 21 21 /** 22 * Con structor.22 * Configures the current validator. 23 23 * 24 24 * Available options: 25 25 * 26 * * pattern: A regex pattern compatible with PCRE 26 * * pattern: A regex pattern compatible with PCRE (required) 27 27 * 28 28 * @see sfValidator 29 29 */ 30 p ublic function __construct($options = array(), $messages = array())30 protected function configure($options = array(), $messages = array()) 31 31 { 32 if (!isset($options['pattern'])) 33 { 34 throw new sfException('The "pattern" option is mandatory.'); 35 } 36 37 parent::__construct($options, $messages); 32 $this->addRequiredOption('pattern'); 38 33 } 39 34 … … 52 47 return $clean; 53 48 } 54 55 /**56 * @see sfValidator57 */58 protected function getOptionsWithoutDefaults()59 {60 return parent::getOptionsWithoutDefaults(array('pattern' => array('--fake--')));61 }62 63 /**64 * @see sfValidator65 */66 protected function getMessagesWithoutDefaults()67 {68 return parent::getMessagesWithoutDefaults(array('pattern' => array('--fake--')));69 }70 49 } branches/dwhittle/lib/validator/sfValidatorSchema.class.php
r5758 r5821 70 70 public function configure($options = array(), $messages = array()) 71 71 { 72 $this-> options['allow_extra_fields'] = false;73 $this-> options['filter_extra_fields'] = true;74 75 $this-> messages['extra_fields'] = 'Extra field %field%.';72 $this->setOption('allow_extra_fields', false); 73 $this->setOption('filter_extra_fields', true); 74 75 $this->setMessage('extra_fields', 'Extra field %field%.'); 76 76 } 77 77 … … 190 190 191 191 /** 192