Development

Changeset 6962

You must first sign up to be able to contribute.

Changeset 6962

Show
Ignore:
Timestamp:
01/06/08 05:11:43 (11 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch (r6961)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.0/LICENSE

    r6598 r6962  
    1 Copyright (c) 2004-2006 Fabien Potencier 
     1Copyright (c) 2004-2008 Fabien Potencier 
    22 
    3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 
     3Permission is hereby granted, free of charge, to any person obtaining a copy 
     4of this software and associated documentation files (the "Software"), to deal 
     5in the Software without restriction, including without limitation the rights 
     6to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     7copies of the Software, and to permit persons to whom the Software is furnished 
     8to do so, subject to the following conditions: 
    49 
    5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 
     10The above copyright notice and this permission notice shall be included in all 
     11copies or substantial portions of the Software. 
    612 
    7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
     16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
     17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
     18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
     19THE SOFTWARE. 
  • branches/dwhittle/1.1/lib/form/sfForm.class.php

    r6772 r6962  
    275275 
    276276  /** 
     277   * Sets the validators associated with this form. 
     278   * 
     279   * @param array An array of named validators 
     280   */ 
     281  public function setValidators(array $validators) 
     282  { 
     283    $this->setValidatorSchema(new sfValidatorSchema($validators)); 
     284  } 
     285 
     286  /** 
    277287   * Sets the validator schema associated with this form. 
    278288   * 
     
    294304  { 
    295305    return $this->validatorSchema; 
     306  } 
     307 
     308  /** 
     309   * Sets the widgets associated with this form. 
     310   * 
     311   * @param array An array of named widgets 
     312   */ 
     313  public function setWidgets(array $widgets) 
     314  { 
     315    $this->setWidgetSchema(new sfWidgetFormSchema($widgets)); 
    296316  } 
    297317 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/data/generator/sfPropelForm/default/template/sfPropelFormGeneratedTemplate.php

    r6874 r6962  
    1313  public function setup() 
    1414  { 
    15     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     15    $this->setWidgets(array( 
    1616<?php foreach ($this->table->getColumns() as $column): ?> 
    1717      '<?php echo strtolower($column->getColumnName()) ?>'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($column->getColumnName())) ?> => new <?php echo $this->getWidgetClassForColumn($column) ?>(<?php echo $this->getWidgetOptionsForColumn($column) ?>), 
     
    2020      '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfWidgetFormSelectMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['relatedTable']->getPhpName() ?>Choices')))), 
    2121<?php endforeach; ?> 
    22     )))
     22    ))
    2323 
    24     $this->setValidatorSchema(new sfValidatorSchema(array( 
     24    $this->setValidators(array( 
    2525<?php foreach ($this->table->getColumns() as $column): ?> 
    2626      '<?php echo strtolower($column->getColumnName()) ?>'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($column->getColumnName())) ?> => new <?php echo $this->getValidatorClassForColumn($column) ?>(<?php echo $this->getValidatorOptionsForColumn($column) ?>), 
     
    2929      '<?php echo $tables['relatedTable']->getName() ?>_list'<?php echo str_repeat(' ', $this->getColumnNameMaxLength() - strlen($tables['relatedTable']->getName().'_list')) ?> => new sfValidatorChoiceMany(array('choices' => new sfCallable(array($this, 'get<?php echo $tables['relatedTable']->getPhpName() ?>IdentifierChoices')))), 
    3030<?php endforeach; ?> 
    31     )))
     31    ))
    3232 
    3333    $this->widgetSchema->setNameFormat('<?php echo $this->table->getName() ?>[%s]'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/sql/pgsql/PgsqlDDLBuilder.php

    r6294 r6962  
    173173      $colDDL = $this->getColumnDDL($col); 
    174174      if ($col->isAutoIncrement() && $table->getIdMethodParameters() == null) { 
    175         $colDDL = str_replace($col->getType(),'serial',$colDDL); 
     175        if($col->getType() === PropelTypes::BIGINT) { 
     176          $colDDL = str_replace($col->getType(),'bigserial',$colDDL); 
     177        } else { 
     178          $colDDL = str_replace($col->getType(),'serial',$colDDL); 
     179        } 
    176180      } 
    177181      $lines[] = $colDDL; 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/crud/crudBrowser.class.php

    r6884 r6962  
    4545 
    4646    // list page 
     47    $this->test()->diag('list page'); 
    4748    $this-> 
    4849      get('/article')-> 
     
    7677 
    7778    // create page 
     79    $this->test()->diag('create page'); 
    7880    $this-> 
    7981      click('Create')-> 
     
    9698 
    9799    // save 
     100    $this->test()->diag('save'); 
    98101    $this->saveValues($options, array( 
    99102      'title'       => 'my real title', 
     
    106109 
    107110    // go back to the list 
     111    $this->test()->diag('go back to the list'); 
    108112    $this-> 
    109113      click('Cancel')-> 
     
    114118 
    115119    // edit page 
     120    $this->test()->diag('edit page'); 
    116121    $this-> 
    117122      click('3')-> 
     
    142147 
    143148    // save / validation 
     149    $this->test()->diag('save / validation'); 
    144150    $values = array( 
    145151      'title'       => '', 
     
    156162      isRequestParameter('action', in_array('non-atomic-actions', $options) ? 'edit' : 'update')-> 
    157163      checkFormValues(array_merge($values, array( 
    158         'end_date' => array('year' => null, 'month' => 12, 'day' => 15, 'hour' => '10', 'minute' => '20'))) 
     164        'end_date' => array('year' => null, 'month' => null, 'day' => 15, 'hour' => '10', 'minute' => '20'))) 
    159165      )-> 
    160166      checkResponseElement('ul[class="error_list"] li:contains("Required.")', 2)-> 
     
    163169 
    164170    // save 
     171    $this->test()->diag('save'); 
    165172    $this->saveValues($options, array( 
    166173      'title'       => 'my title', 
     
    173180 
    174181    // go back to the list 
     182    $this->test()->diag('go back to the list'); 
    175183    $this-> 
    176184      click('Cancel')-> 
     
    181189 
    182190    // delete 
     191    $this->test()->diag('delete'); 
    183192    $this-> 
    184193      get('/article/edit/id/3')-> 
     
    204213    { 
    205214      // show page 
     215      $this->test()->diag('show page'); 
    206216      $this-> 
    207217        get('/article/show/id/2')-> 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/form/base/BaseArticleForm.class.php

    r6884 r6962  
    1212  public function setup() 
    1313  { 
    14     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     14    $this->setWidgets(array( 
    1515      'id'          => new sfWidgetFormInputHidden(), 
    1616      'title'       => new sfWidgetFormInput(), 
     
    2121      'end_date'    => new sfWidgetFormDateTime(), 
    2222      'book_id'     => new sfWidgetFormSelect(array('choices' => new sfCallable(array($this, 'getBookChoices')))), 
    23     )))
     23    ))
    2424 
    25     $this->setValidatorSchema(new sfValidatorSchema(array( 
     25    $this->setValidators(array( 
    2626      'id'          => new sfValidatorInteger(array('required' => false)), 
    2727      'title'       => new sfValidatorString(), 
     
    3232      'end_date'    => new sfValidatorDateTime(array('required' => false)), 
    3333      'book_id'     => new sfValidatorChoice(array('choices' => new sfCallable(array($this, 'getBookIdentifierChoices')), 'required' => false)), 
    34     )))
     34    ))
    3535 
    3636    $this->widgetSchema->setNameFormat('article[%s]'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/form/base/BaseAuthorArticleForm.class.php

    r6884 r6962  
    1212  public function setup() 
    1313  { 
    14     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     14    $this->setWidgets(array( 
    1515      'author_id'  => new sfWidgetFormSelect(array('choices' => new sfCallable(array($this, 'getAuthorChoices')))), 
    1616      'article_id' => new sfWidgetFormSelect(array('choices' => new sfCallable(array($this, 'getArticleChoices')))), 
    1717      'id'         => new sfWidgetFormInputHidden(), 
    18     )))
     18    ))
    1919 
    20     $this->setValidatorSchema(new sfValidatorSchema(array( 
     20    $this->setValidators(array( 
    2121      'author_id'  => new sfValidatorChoice(array('choices' => new sfCallable(array($this, 'getAuthorIdentifierChoices')), 'required' => false)), 
    2222      'article_id' => new sfValidatorChoice(array('choices' => new sfCallable(array($this, 'getArticleIdentifierChoices')), 'required' => false)), 
    2323      'id'         => new sfValidatorInteger(array('required' => false)), 
    24     )))
     24    ))
    2525 
    2626    $this->widgetSchema->setNameFormat('author_article[%s]'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/form/base/BaseAuthorForm.class.php

    r6884 r6962  
    1212  public function setup() 
    1313  { 
    14     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     14    $this->setWidgets(array( 
    1515      'id'   => new sfWidgetFormInputHidden(), 
    1616      'name' => new sfWidgetFormInput(), 
    17     )))
     17    ))
    1818 
    19     $this->setValidatorSchema(new sfValidatorSchema(array( 
     19    $this->setValidators(array( 
    2020      'id'   => new sfValidatorInteger(array('required' => false)), 
    2121      'name' => new sfValidatorString(array('required' => false)), 
    22     )))
     22    ))
    2323 
    2424    $this->widgetSchema->setNameFormat('author[%s]'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/form/base/BaseBookForm.class.php

    r6884 r6962  
    1212  public function setup() 
    1313  { 
    14     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     14    $this->setWidgets(array( 
    1515      'id'   => new sfWidgetFormInputHidden(), 
    1616      'name' => new sfWidgetFormInput(), 
    17     )))
     17    ))
    1818 
    19     $this->setValidatorSchema(new sfValidatorSchema(array( 
     19    $this->setValidators(array( 
    2020      'id'   => new sfValidatorInteger(array('required' => false)), 
    2121      'name' => new sfValidatorString(array('required' => false)), 
    22     )))
     22    ))
    2323 
    2424    $this->widgetSchema->setNameFormat('book[%s]'); 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/lib/form/base/BaseCategoryForm.class.php

    r6884 r6962  
    1212  public function setup() 
    1313  { 
    14     $this->setWidgetSchema(new sfWidgetFormSchema(array( 
     14    $this->setWidgets(array( 
    1515      'id'   => new sfWidgetFormInputHidden(), 
    1616      'name' => new sfWidgetFormInput(), 
    17     )))
     17    ))
    1818 
    19     $this->setValidatorSchema(new sfValidatorSchema(array( 
     19    $this->setValidators(array( 
    2020      'id'   => new sfValidatorInteger(array('required' => false)), 
    2121      'name' => new sfValidatorString(array('required' => false)), 
    22     )))
     22    ))
    2323 
    2424    $this->widgetSchema->setNameFormat('category[%s]'); 
  • branches/dwhittle/1.1/lib/validator/sfValidator.class.php

    r6198 r6962  
    296296   * @throws sfValidatorError 
    297297   */ 
    298   abstract protected function doClean($value); 
     298  abstract protected function doClean($value); 
    299299 
    300300  /** 
  • branches/dwhittle/1.1/lib/validator/sfValidatorErrorSchema.class.php

    r6198 r6962  
    4646   * Adds an error. 
    4747   * 
     48   * This method merges sfValidatorErrorSchema errors with the current instance. 
     49   * 
    4850   * @param sfValidatorError A sfValidatorError instance 
    4951   * @param string           The error name 
     
    5153  public function addError(sfValidatorError $error, $name = null) 
    5254  { 
    53     if (is_null($name)
     55    if (is_null($name) || is_integer($name)
    5456    { 
     57      if ($error instanceof sfValidatorErrorSchema) 
     58      { 
     59        throw new LogicException('Unable to merge a sfValidatorErrorSchema to global errors.'); 
     60      } 
     61 
    5562      $this->globalErrors[] = $error; 
    5663      $this->errors[] = $error; 
    5764    } 
    58     else if (is_integer($name)) 
    59     { 
    60       $this->namedErrors[$name] = $error; 
    61       $this->errors[$name] = $error; 
    62     } 
    6365    else 
    6466    { 
    65       $this->namedErrors[$name] = $error; 
    66       $this->errors[$name] = $error; 
     67      if (!isset($this->namedErrors[$name]) && !$error instanceof sfValidatorErrorSchema) 
     68      { 
     69        $this->namedErrors[$name] = $error; 
     70        $this->errors[$name] = $error; 
     71      } 
     72      else 
     73      { 
     74        if (!isset($this->namedErrors[$name])) 
     75        { 
     76          $this->namedErrors[$name] = new sfValidatorErrorSchema($error->getValidator()); 
     77          $this->errors[$name] = new sfValidatorErrorSchema($error->getValidator()); 
     78        } 
     79        else if (!$this->namedErrors[$name] instanceof sfValidatorErrorSchema) 
     80        { 
     81          $current = $this->namedErrors[$name]; 
     82          $this->namedErrors[$name] = new sfValidatorErrorSchema($current->getValidator()); 
     83          $this->errors[$name] = new sfValidatorErrorSchema($current->getValidator()); 
     84 
     85          $method = $current instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError'; 
     86          $this->namedErrors[$name]->$method($current); 
     87          $this->errors[$name]->$method($current); 
     88        } 
     89 
     90        $method = $error instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError'; 
     91        $this->namedErrors[$name]->$method($error); 
     92        $this->errors[$name]->$method($error); 
     93      } 
    6794    } 
    6895 
     
    249276  protected function updateCode() 
    250277  { 
    251     $this->code = implode(" ", array_merge( 
     278    $this->code = implode(' ', array_merge( 
    252279      array_map(create_function('$e', 'return $e->getCode();'), $this->globalErrors), 
    253280      array_map(create_function('$n,$e', 'return $n.\' [\'.$e->getCode().\']\';'), array_keys($this->namedErrors), array_values($this->namedErrors)) 
     
    260287  protected function updateMessage() 
    261288  { 
    262     $this->message = implode(" ", array_merge( 
     289    $this->message = implode(' ', array_merge( 
    263290      array_map(create_function('$e', 'return $e->getMessage();'), $this->globalErrors), 
    264291      array_map(create_function('$n,$e', 'return $n.\' [\'.$e->getMessage().\']\';'), array_keys($this->namedErrors), array_values($this->namedErrors)) 
  • branches/dwhittle/1.1/lib/validator/sfValidatorFromDescription.class.php

    r6198 r6962  
    340340    $this->operator = $operator; 
    341341    $this->arguments = $arguments; 
    342     $this->class = 'or' == $operator ? 'sfValidatorAny' : 'sfValidatorAll'; 
     342    $this->class = 'or' == $operator ? 'sfValidatorOr' : 'sfValidatorAnd'; 
    343343  } 
    344344 
  • branches/dwhittle/1.1/lib/validator/sfValidatorSchema.class.php

    r6198 r6962  
    2222{ 
    2323  protected 
    24     $fields = array(); 
     24    $fields        = array(), 
     25    $preValidator  = null, 
     26    $postValidator = null; 
    2527 
    2628  /** 
     
    7274   * @see sfValidator 
    7375   */ 
    74   public function configure($options = array(), $messages = array()) 
     76  protected function configure($options = array(), $messages = array()) 
    7577  { 
    7678    $this->addOption('allow_extra_fields', false); 
     
    103105    } 
    104106 
    105     $clean = array(); 
     107    $clean = array(); 
    106108    $unused = array_keys($this->fields); 
    107     $errors = array(); 
     109    $errorSchema = new sfValidatorErrorSchema($this); 
    108110 
    109111    // pre validator 
    110     if (isset($this->fields['_pre_validator'])) 
    111     { 
    112       try 
    113       { 
    114         $this->fields['_pre_validator']->clean($values); 
    115       } 
    116       catch (sfValidatorError $e) 
    117       { 
    118         $errors[] = $e; 
    119       } 
     112    try 
     113    { 
     114      $this->preClean($values); 
     115    } 
     116    catch (sfValidatorErrorSchema $e) 
     117    { 
     118      $errorSchema->addErrors($e); 
     119    } 
     120    catch (sfValidatorError $e) 
     121    { 
     122      $errorSchema->addError($e); 
    120123    } 
    121124 
     
    128131        if (!$this->options['allow_extra_fields']) 
    129132        { 
    130           $errors[] = new sfValidatorError($this, 'extra_fields', array('field' => $name)); 
     133          $errorSchema->addError(new sfValidatorError($this, 'extra_fields', array('field' => $name))); 
    131134        } 
    132135        else if (!$this->options['filter_extra_fields']) 
     
    149152        $clean[$name] = null; 
    150153 
    151         $errors[$name] = $e
     154        $errorSchema->addError($e, (string) $name)
    152155      } 
    153156    } 
     
    156159    foreach ($unused as $name) 
    157160    { 
    158       if (in_array($name, array('_pre_validator', '_post_validator'))) 
    159       { 
    160         continue; 
    161       } 
    162  
    163161      // validate value 
    164162      try 
     
    168166      catch (sfValidatorError $e) 
    169167      { 
    170         $errors[$name] = $e
     168        $errorSchema->addError($e, (string) $name)
    171169      } 
    172170    } 
    173171 
    174172    // post validator 
    175     if (isset($this->fields['_post_validator'])) 
    176     { 
    177       try 
    178       { 
    179         $clean = $this->fields['_post_validator']->clean($clean); 
    180       } 
    181       catch (sfValidatorError $e) 
    182       { 
    183         $errors[] = $e; 
    184       } 
    185     } 
    186  
    187     if (count($errors)) 
    188     { 
    189       throw new sfValidatorErrorSchema($this, $errors); 
     173    try 
     174    { 
     175      $clean = $this->postClean($clean); 
     176    } 
     177    catch (sfValidatorErrorSchema $e) 
     178    { 
     179      $errorSchema->addErrors($e); 
     180    } 
     181    catch (sfValidatorError $e) 
     182    { 
     183      $errorSchema->addError($e); 
     184    } 
     185 
     186    if (count($errorSchema)) 
     187    { 
     188      throw $errorSchema; 
    190189    } 
    191190 
    192191    return $clean; 
     192  } 
     193 
     194  /** 
     195   * Cleans the input values. 
     196   * 
     197   * This method is the first validator executed by doClean(). 
     198   * 
     199   * It executes the validator returned by getPreValidator() 
     200   * on the global array of values. 
     201   * 
     202   * @param  array The input values 
     203   * 
     204   * @throws sfValidatorError 
     205   */ 
     206  public function preClean($values) 
     207  { 
     208    if (is_null($validator = $this->getPreValidator())) 
     209    { 
     210      return; 
     211    } 
     212 
     213    $validator->clean($values); 
     214  } 
     215 
     216  /** 
     217   * Cleans the input values. 
     218   * 
     219   * This method is the last validator executed by doClean(). 
     220   * 
     221   * It executes the validator returned by getPostValidator() 
     222   * on the global array of cleaned values. 
     223   * 
     224   * @param  array The input values 
     225   * 
     226   * @throws sfValidatorError 
     227   */ 
     228  public function postClean($values) 
     229  { 
     230    if (is_null($validator = $this->getPostValidator())) 
     231    { 
     232      return $values; 
     233    } 
     234 
     235    return $validator->clean($values); 
     236  } 
     237 
     238  /** 
     239   * Sets the pre validator. 
     240   * 
     241   * @param sfValidator A sfValidator instance 
     242   */ 
     243  public function setPreValidator(sfValidator $validator) 
     244  { 
     245    $this->preValidator = $validator; 
     246  } 
     247 
     248  /** 
     249   * Returns the pre validator. 
     250   * 
     251   * @return sfValidator A sfValidator instance 
     252   */ 
     253  public function getPreValidator() 
     254  { 
     255    return $this->preValidator; 
     256  } 
     257 
     258  /** 
     259   * Sets the post validator. 
     260   * 
     261   * @param sfValidator A sfValidator instance 
     262   */ 
     263  public function setPostValidator(sfValidator $validator) 
     264  { 
     265    $this->postValidator = $validator; 
     266  } 
     267 
     268  /** 
     269   * Returns the post validator. 
     270   * 
     271   * @return sfValidator A sfValidator instance 
     272   */ 
     273  public function getPostValidator() 
     274  { 
     275    return $this->postValidator; 
    193276  } 
    194277 
  • branches/dwhittle/1.1/lib/validator/sfValidatorSchemaCompare.class.php

    r6198 r6962  
    2929   * Constructor. 
    3030   * 
    31    * Available operator
     31   * Available options
    3232   * 
    33    *  * self::EQUAL 
    34    *  * self::NOT_EQUAL 
    35    *  * self::LESS_THAN 
    36    *  * self::LESS_THAN_EQUAL 
    37    *  * self::GREATER_THAN 
    38    *  * self::GREATER_THAN_EQUAL 
     33   *  * left_field:         The left field name 
     34   *  * operator:           The comparison operator 
     35   *                          * self::EQUAL 
     36   *                          * self::NOT_EQUAL 
     37   *                          * self::LESS_THAN 
     38   *                          * self::LESS_THAN_EQUAL 
     39   *                          * self::GREATER_THAN 
     40   *                          * self::GREATER_THAN_EQUAL 
     41   *  * right_field:        The right field name 
     42   *  * throw_global_error: Whether to throw a global error (false by default) or an error tied to the left field 
    3943   * 
    4044   * @param string The left field name 
     
    5155    $this->addOption('operator', $operator); 
    5256    $this->addOption('right_field', $rightField); 
     57 
     58    $this->addOption('throw_global_error', false); 
    5359 
    5460    parent::__construct(null, $options, $messages); 
     
    97103    if (!$valid) 
    98104    { 
    99       throw new sfValidatorError($this, 'invalid', array( 
     105      $error = new sfValidatorError($this, 'invalid', array( 
    100106        'left_field'  => $leftValue, 
    101107        'right_field' => $rightValue, 
    102108        'operator'    => $this->getOption('operator'), 
    103109      )); 
     110      if ($this->getOption('throw_global_error')) 
     111      { 
     112        throw $error; 
     113      } 
     114 
     115      throw new sfValidatorErrorSchema($this, array($this->getOption('left_field') => $error)); 
    104116    } 
    105117 
  • branches/dwhittle/1.1/lib/validator/sfValidatorSchemaForEach.class.php

    r6198 r6962  
    1010 
    1111/** 
    12  *  
     12 * sfValidatorSchemaForEach wraps a validator multiple times in a single validator. 
    1313 * 
    1414 * @package    symfony 
  • branches/dwhittle/1.1/lib/validator/sfValidatorUrl.class.php

    r5895 r6962  
    2222   * @see sfValidatorRegex 
    2323   */ 
    24   public function configure($options = array(), $messages = array()) 
     24  protected function configure($options = array(), $messages = array()) 
    2525  { 
    2626    parent::configure($options, $messages); 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormDate.class.php

    r6419 r6962  
    5050  public function render($name, $value = null, $attributes = array(), $errors = array()) 
    5151  { 
    52     // convert value to a timestamp 
     52    // convert value to an array 
     53    $default = array('year' => null, 'month' => null, 'day' => null); 
    5354    if (is_array($value)) 
    5455    { 
    55       $value = $this->convertDateArrayToTimestamp($value); 
     56      $value = array_merge($default, $value); 
    5657    } 
    5758    else 
    5859    { 
    5960      $value = ctype_digit($value) ? (integer) $value : strtotime($value); 
     61      if (false === $value) 
     62      { 
     63        $value = $default; 
     64      } 
     65      else 
     66      { 
     67        $value = array('year' => date('Y', $value), 'month' => date('n', $value), 'day' => date('j', $value)); 
     68      } 
    6069    } 
    6170 
     
    6574    // days 
    6675    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days'))); 
    67     $date['%day%'] = $widget->render($name.'[day]', $value ? date('j', $value) : ''); 
     76    $date['%day%'] = $widget->render($name.'[day]', $value['day']); 
    6877 
    6978    // months 
    7079    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months'))); 
    71     $date['%month%'] = $widget->render($name.'[month]', $value ? date('n', $value) : ''); 
     80    $date['%month%'] = $widget->render($name.'[month]', $value['month']); 
    7281 
    7382    // years 
    7483    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years'))); 
    75     $date['%year%'] = $widget->render($name.'[year]', $value ? date('Y', $value) : ''); 
     84    $date['%year%'] = $widget->render($name.'[year]', $value['year']); 
    7685 
    7786    return strtr($this->getOption('format'), $date); 
    7887  } 
    79  
    80   /** 
    81    * Converts an array representing a date to a timestamp. 
    82    * 
    83    * The array can contains the following keys: year, month, day, hour, minute, second 
    84    * 
    85    * @param  array   An array of date elements 
    86    * 
    87    * @return integer A timestamp 
    88    */ 
    89   protected function convertDateArrayToTimestamp($value) 
    90   { 
    91     $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']); 
    92  
    93     return false === $clean ? null : $clean; 
    94   } 
    9588} 
  • branches/dwhittle/1.1/lib/widget/sfWidgetFormTime.class.php

    r6419 r6962  
    5353  public function render($name, $value = null, $attributes = array(), $errors = array()) 
    5454  { 
    55     // convert value to a timestamp 
     55    // convert value to an array 
     56    $default = array('hour' => null, 'minute' => null, 'second' => null); 
    5657    if (is_array($value)) 
    5758    { 
    58       $value = $this->convertDateArrayToTimestamp($value); 
     59      $value = array_merge($default, $value); 
    5960    } 
    6061    else 
    6162    { 
    6263      $value = ctype_digit($value) ? (integer) $value : strtotime($value); 
     64      if (false === $value) 
     65      { 
     66        $value = $default; 
     67      } 
     68      else 
     69      { 
     70        $value = array('hour' => date('G', $value), 'minute' => date('i', $value), 'second' => date('s', $value)); 
     71      } 
    6372    } 
    6473 
     
    6877    // hours 
    6978    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours'))); 
    70     $time['%hour%'] = $widget->render($name.'[hour]', $value ? date('G', $value) : ''); 
     79    $time['%hour%'] = $widget->render($name.'[hour]', $value['hour']); 
    7180 
    7281    // minutes 
    7382    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes'))); 
    74     $time['%minute%'] = $widget->render($name.'[