Development

Changeset 5821

You must first sign up to be able to contribute.

Changeset 5821

Show
Ignore:
Timestamp:
11/02/07 19:07:30 (1 year ago)
Author:
dwhittle
Message:

dwhittle: merge trunk changes to branch

Files:

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,input 
    2 { margin: 0; padding: 0; } 
    3 a img,:link img,:visited img { border: none; } 
    4  
    5 a 
    6 { 
    7   text-decoration: none; 
    8 } 
    9  
    10 a:hover 
    11 { 
    12   text-decoration: underline; 
    13 } 
    14  
    15 body, td 
    16 { 
    17   margin: 0; 
    18   padding: 0; 
    19   font-family: Arial, Verdana, sans-serif; 
    20   font-size: 11px; 
    21   background-color: #fff; 
    22 } 
    23  
    24 body 
    25 { 
    26   padding: 20px; 
    27 } 
  • branches/dwhittle/lib/action/sfAction.class.php

    r5503 r5821  
    546546   * @param string Template name 
    547547   */ 
    548   public function setTemplate($name
     548  public function setTemplate($name, $module = null
    549549  { 
    550550    if (sfConfig::get('sf_logging_enabled')) 
    551551    { 
    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; 
    553558    } 
    554559 
  • branches/dwhittle/lib/action/sfActions.class.php

    r4952 r5821  
    2727   * defined action name. 
    2828   * 
    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 
    3032   * 
    3133   * @throws sfInitializationException 
     
    3335   * @see sfAction 
    3436   */ 
    35   public function execute(
     37  public function execute($request
    3638  { 
    3739    // dispatch action 
     
    4951 
    5052    // run action 
    51     $ret = $this->$actionToRun(); 
    52  
    53     return $ret; 
     53    return $this->$actionToRun($request); 
    5454  } 
    5555} 
  • branches/dwhittle/lib/action/sfComponent.class.php

    r4963 r5821  
    6969   * single product. 
    7070   * 
    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); 
    7476 
    7577  /** 
  • branches/dwhittle/lib/action/sfComponents.class.php

    r4599 r5821  
    1919abstract class sfComponents extends sfComponent 
    2020{ 
    21   public function execute(
     21  public function execute($request
    2222  { 
    2323    throw new sfInitializationException('sfComponents initialization failed.'); 
  • branches/dwhittle/lib/filter/sfExecutionFilter.class.php

    r5386 r5821  
    101101    // execute the action 
    102102    $actionInstance->preExecute(); 
    103     $viewName = $actionInstance->execute(); 
     103    $viewName = $actionInstance->execute($this->context->getRequest()); 
    104104    $actionInstance->postExecute(); 
    105105 
  • branches/dwhittle/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php

    r5386 r5821  
    158158    // execute the action 
    159159    $actionInstance->preExecute(); 
    160     $viewName = $actionInstance->execute(); 
     160    $viewName = $actionInstance->execute($this->context->getRequest()); 
    161161    $actionInstance->postExecute(); 
    162162 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php

    r5769 r5821  
    177177    if (is_null($culture)) 
    178178    { 
    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; 
    185180    } 
    186181 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php

    r5248 r5821  
    1717require_once 'propel/Propel.php'; 
    1818 
     19$dispatcher = sfContext::getInstance()->getEventDispatcher(); 
     20 
    1921if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) 
    2022{ 
    2123  // add propel logger 
    22   Propel::setLogger(new sfPropelLogger()); 
     24  Propel::setLogger(new sfPropelLogger($dispatcher)); 
    2325} 
    2426 
     
    2628Propel::setConfiguration(sfPropelDatabase::getConfiguration()); 
    2729Propel::initialize(); 
     30 
     31sfPropel::initialize($dispatcher, sfContext::getInstance()->getUser()->getCulture()); 
  • branches/dwhittle/lib/plugins/sfPropelPlugin/lib/propel/sfPropelDatabaseSchema.class.php

    r5125 r5821  
    240240              $this->database[$table][$column] = array( 
    241241                'type'             => 'integer', 
     242                'required'         => true, 
    242243                'foreignTable'     => $foreign_table, 
    243                 'foreignReference' => 'id' 
     244                'foreignReference' => 'id', 
    244245              ); 
    245246            } 
     
    249250            } 
    250251          } 
    251            
    252252        } 
    253253        else 
  • branches/dwhittle/lib/validator/sfValidator.class.php

    r5758 r5821  
    2525 
    2626  protected 
    27     $messages = array(), 
    28     $options  = array(); 
     27    $requiredOptions = array(), 
     28    $defaultMessages = array(), 
     29    $defaultOptions  = array(), 
     30    $messages        = array(), 
     31    $options         = array(); 
    2932 
    3033  /** 
     
    4245  public function __construct($options = array(), $messages = array()) 
    4346  { 
    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); 
    4649 
    4750    $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    } 
    4872 
    4973    $this->options  = array_merge($this->options, $options); 
    5074    $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  { 
    5194  } 
    5295 
     
    199242 
    200243  /** 
     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  /** 
    201286   * Returns an array of all error codes for this validator. 
    202287   * 
    203    * Subclasses of sfValidator may override this method to register 
    204    * their own error codes. 
    205    * 
    206    * By default this method return required and invalid as errors codes. 
    207    * 
    208288   * @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; 
    274355  } 
    275356 
     
    295376 
    296377  /** 
     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  /** 
    297399   * Returns all options with non default values. 
    298400   * 
     
    304406 
    305407    // 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) 
    309409    { 
    310410      if (array_key_exists($key, $options) && $options[$key] === $value) 
     
    316416    return $options; 
    317417  } 
    318  
    319   /** 
    320    * Returns all error messages with non default values. 
    321    * 
    322    * @return string A string representation of the error messages 
    323    */ 
    324   protected function getMessagesWithoutDefaults() 
    325   { 
    326     $messages = $this->messages; 
    327  
    328     // remove default option values 
    329     $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   } 
    341418} 
  • branches/dwhittle/lib/validator/sfValidatorAll.class.php

    r5758 r5821  
    5555    } 
    5656 
    57     if (!isset($messages['invalid'])) 
    58     { 
    59       $messages['invalid'] = null; 
    60     } 
     57    parent::__construct($options, $messages); 
     58  } 
    6159 
    62     parent::__construct($options, $messages); 
     60  /** 
     61   * @see sfValidator 
     62   */ 
     63  public function configure($options = array(), $messages = array()) 
     64  { 
     65    $this->setMessage('invalid', null); 
    6366  } 
    6467 
     
    145148    } 
    146149 
    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)); 
    152151  } 
    153152} 
  • branches/dwhittle/lib/validator/sfValidatorAny.class.php

    r5758 r5821  
    5555    } 
    5656 
    57     if (!isset($messages['invalid'])) 
    58     { 
    59       $messages['invalid'] = null; 
    60     } 
     57    parent::__construct($options, $messages); 
     58  } 
    6159 
    62     parent::__construct($options, $messages); 
     60  /** 
     61   * @see sfValidator 
     62   */ 
     63  public function configure($options = array(), $messages = array()) 
     64  { 
     65    $this->setMessage('invalid', null); 
    6366  } 
    6467 
     
    139142    } 
    140143 
    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)); 
    146145  } 
    147146} 
  • branches/dwhittle/lib/validator/sfValidatorBoolean.class.php

    r5651 r5821  
    3333    $this->setOption('true_values', array('true', 't', 'yes', 'y', 'on', '1')); 
    3434    $this->setOption('false_values', array('false', 'f', 'no', 'n', 'off', '0')); 
    35  
    3635    $this->setOption('required', false); 
    3736  } 
  • branches/dwhittle/lib/validator/sfValidatorCallback.class.php

    r5758 r5821  
    2020{ 
    2121  /** 
    22    * Constructor. 
     22   * Configures the current validator. 
    2323   * 
    2424   * Available options: 
    2525   * 
    26    *  * callback: A valid PHP callback 
     26   *  * callback: A valid PHP callback (required) 
    2727   * 
    28    * @see sfValidator 
    29    */ 
    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   /** 
    4128   * @see sfValidator 
    4229   */ 
    4330  protected function configure($options = array(), $messages = array()) 
    4431  { 
    45     $this->options['required'] = false; 
     32    $this->addRequiredOption('callback'); 
     33    $this->setOption('required', false); 
    4634  } 
    4735 
     
    5341    return call_user_func($this->getOption('callback'), $this, $value); 
    5442  } 
    55  
    56   /** 
    57    * @see sfValidator 
    58    */ 
    59   protected function getOptionsWithoutDefaults() 
    60   { 
    61     return parent::getOptionsWithoutDefaults(array('callback' => array('--fake--'))); 
    62   } 
    63  
    64   /** 
    65    * @see sfValidator 
    66    */ 
    67   protected function getMessagesWithoutDefaults() 
    68   { 
    69     return parent::getMessagesWithoutDefaults(array('callback' => array('--fake--'))); 
    70   } 
    7143} 
  • branches/dwhittle/lib/validator/sfValidatorChoice.class.php

    r5758 r5821  
    2020{ 
    2121  /** 
    22    * Constructor. 
     22   * Configures the current validator. 
    2323   * 
    2424   * Available options: 
    2525   * 
    26    *  * choices: An array of expected values 
     26   *  * choices: An array of expected values (required) 
    2727   * 
    2828   * @see sfValidator 
    2929   */ 
    30   public function __construct($options = array(), $messages = array()) 
     30  protected function configure($options = array(), $messages = array()) 
    3131  { 
    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'); 
    3833  } 
    3934 
     
    4338  protected function doClean($value) 
    4439  { 
    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)) 
    4647    { 
    4748      throw new sfValidatorError($this, 'invalid', array('value' => $value)); 
     
    5051    return $value; 
    5152  } 
    52  
    53   /** 
    54    * @see sfValidator 
    55    */ 
    56   protected function getOptionsWithoutDefaults() 
    57   { 
    58     return parent::getOptionsWithoutDefaults(array('choices' => array('--fake--'))); 
    59   } 
    60  
    61   /** 
    62    * @see sfValidator 
    63    */ 
    64   protected function getMessagesWithoutDefaults() 
    65   { 
    66     return parent::getMessagesWithoutDefaults(array('choices' => array('--fake--'))); 
    67   } 
    6853} 
  • branches/dwhittle/lib/validator/sfValidatorDate.class.php

    r5582 r5821  
    3535    $this->setMessage('bad_format', '"%value%" does not match the date format (%date_format%).'); 
    3636 
     37    $this->setOption('date_format', null); 
    3738    $this->setOption('with_time', false); 
    3839    $this->setOption('date_output', 'Y-m-d'); 
     
    4546  protected function doClean($value) 
    4647  { 
    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')) 
    4853    { 
    4954      if (!preg_match($regex, $value, $match)) 
     
    5257      } 
    5358 
    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); 
    6260    } 
    6361    else if (!ctype_digit($value)) 
    6462    { 
    6563      $clean = strtotime($value); 
    66       if ($clean === -1 || $clean === false
     64      if (false === $clean
    6765      { 
    6866        throw new sfValidatorError($this, 'invalid', array('value' => $value)); 
     
    7876 
    7977  /** 
    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 
    8185   */ 
    82   public function getErrorCodes(
     86  protected function convertDateArrayToTimestamp($value
    8387  { 
    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; 
    85103  } 
    86104} 
  • branches/dwhittle/lib/validator/sfValidatorDecorator.class.php

    r5758 r5821  
    149149   * @see sfValidator 
    150150   */ 
    151   public function getErrorCodes(
     151  public function asString($indent = 0
    152152  { 
    153     return $this->getValidator()->getErrorCodes(); 
     153    return $this->validator->asString($indent); 
    154154  } 
    155155 
     
    157157   * @see sfValidator 
    158158   */ 
    159   public function asString($indent = 0
     159  public function getDefaultOptions(
    160160  { 
    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(); 
    162170  } 
    163171} 
  • branches/dwhittle/lib/validator/sfValidatorEmail.class.php

    r5758 r5821  
    2222   * @see sfValidatorRegex 
    2323   */ 
    24   public function __construct($options = array(), $messages = array()) 
     24  protected function configure($options = array(), $messages = array()) 
    2525  { 
    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'); 
    2927  } 
    3028} 
  • branches/dwhittle/lib/validator/sfValidatorInteger.class.php

    r5651 r5821  
    3434    $this->setMessage('min', '"%value%" must be greater than %min%.'); 
    3535    $this->setMessage('invalid', '"%value%" is not an integer.'); 
     36 
     37    $this->setOption('min', null); 
     38    $this->setOption('max', null); 
    3639  } 
    3740 
     
    6063    return $clean; 
    6164  } 
    62  
    63   /** 
    64    * @see sfValidator 
    65    */ 
    66   public function getErrorCodes() 
    67   { 
    68     return array_merge(parent::getErrorCodes(), array('max', 'min')); 
    69   } 
    7065} 
  • branches/dwhittle/lib/validator/sfValidatorNumber.class.php

    r5582 r5821  
    3434    $this->setMessage('min', '"%value%" is too short (smallest allowed is %min%).'); 
    3535    $this->setMessage('invalid', '"%value%" is not a number.'); 
     36 
     37    $this->setOption('min', null); 
     38    $this->setOption('max', null); 
    3639  } 
    3740 
     
    6063    return $clean; 
    6164  } 
    62  
    63   /** 
    64    * @see sfValidator 
    65    */ 
    66   public function getErrorCodes() 
    67   { 
    68     return array_merge(parent::getErrorCodes(), array('max', 'min')); 
    69   } 
    7065} 
  • branches/dwhittle/lib/validator/sfValidatorRegex.class.php

    r5758 r5821  
    2020{ 
    2121  /** 
    22    * Constructor. 
     22   * Configures the current validator. 
    2323   * 
    2424   * Available options: 
    2525   * 
    26    *  * pattern: A regex pattern compatible with PCRE 
     26   *  * pattern: A regex pattern compatible with PCRE (required) 
    2727   * 
    2828   * @see sfValidator 
    2929   */ 
    30   public function __construct($options = array(), $messages = array()) 
     30  protected function configure($options = array(), $messages = array()) 
    3131  { 
    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'); 
    3833  } 
    3934 
     
    5247    return $clean; 
    5348  } 
    54  
    55   /** 
    56    * @see sfValidator 
    57    */ 
    58   protected function getOptionsWithoutDefaults() 
    59   { 
    60     return parent::getOptionsWithoutDefaults(array('pattern' => array('--fake--'))); 
    61   } 
    62  
    63   /** 
    64    * @see sfValidator 
    65    */ 
    66   protected function getMessagesWithoutDefaults() 
    67   { 
    68     return parent::getMessagesWithoutDefaults(array('pattern' => array('--fake--'))); 
    69   } 
    7049} 
  • branches/dwhittle/lib/validator/sfValidatorSchema.class.php

    r5758 r5821  
    7070  public function configure($options = array(), $messages = array()) 
    7171  { 
    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%.')
    7676  } 
    7777 
     
    190190 
    191191  /** 
    192