Development

Changeset 12149 for branches/dwhittle

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
10/12/08 07:08:50 (2 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/storage/sfMySQLSessionStorage.class.php

    r10594 r12149  
    101101    $id = $this->db_escape($id); 
    102102 
    103     // delete the record associated with this id 
     103    // get the record associated with this id 
    104104    $sql = "SELECT $db_data_col FROM $db_table WHERE $db_id_col = '$id'"; 
    105105 
  • branches/dwhittle/1.2/UPGRADE_TO_1_2

    r11971 r12149  
    4949 `sfCreoleSessionStorage` | `sfPDOSessionStorage` 
    5050  
    51 The `propel:build-db` task has been removed as this functionality is provided by 
    52 `propel:insert-sql`
     51The `propel:build-db` task has been removed as this functionality is not yet 
     52provided by Propel 1.3
    5353 
    5454The first step to upgrading is changing from Creole to PDO syntax in the 
     
    328328 
    329329The `sfForm` class has a new `hasErrors()` method which returns true if the 
    330 form has no errors and false otherwise. This methods returns `false` if the 
     330form has some errors and false otherwise. This methods returns `false` if the 
    331331form is not bound. This method is quite useful in a template: 
    332332 
     
    504504 
    505505These new widgets are now used by default for the Propel generated forms. 
     506 
     507All widgets have a new `label` option. This option sets the label for the widget 
     508when used in a widget schema context: 
     509 
     510    [php] 
     511    $widget = new sfWidgetFormInput(array('label' => 'Enter your name here')); 
     512    $widget->setLabel('Enter your name here'); 
     513    echo $widget->getLabel(); 
    506514 
    507515Response 
     
    574582--------------------------- 
    575583 
    576 symfony continues to decouple its bundled software. In 1.2 the bundled Prototype  
    577 and Scriptaculous libraries and helper (`JavascriptHelper`) have been moved to a  
    578 core-plugin. Core plugins behave like real plugins but are shipped by symfony platform
    579 This will make the javscript and css files of the new `sfProtoculousPlugin`  
    580 (the more or less inofficial name of the often featured duo) behave like real plugin 
    581 assets. They will be now in `web/sfProtoculousPlugin` rather than in `web/sf`  
    582 (as it has been in 1.0 and 1.1). The `prototype_web_dir` setting will also now point  
     584symfony continues to decouple its bundled software. In 1.2 the bundled Prototype 
     585and Scriptaculous libraries and helpers (`JavascriptHelper`) have been moved to a 
     586core-plugin. Core plugins behave like any plugin but are shipped with symfony
     587This will make the JavaScript and CSS files of the new `sfProtoculousPlugin` 
     588(the more or less unofficial name of the often featured duo) behave like real plugin 
     589assets. They will be now in `web/sfProtoculousPlugin` rather than in `web/sf` 
     590(as it has been in 1.0 and 1.1). The `prototype_web_dir` setting will also now point 
    583591to the new directory. 
    584592 
     
    593601    <?php end_javascript_tag() ?> 
    594602 
    595  
    596603>**CAUTION** 
    597 >**Work in progress:** As plugins are normally installed via a task and this invokes the  
     604>**Work in progress:** As plugins are normally installed via a task and this invokes the 
    598605>creation of the symlink in the web directory this is required for core plugins as well. 
    599606>To do this manually you need to invoke: 
    600607> 
    601 > ``symfony plugin:configure-core`
     608> `symfony plugin:configure-core
    602609> 
    603 > The target is that the project creation and upgrade task do this for you 
     610> The target is that the project creation and upgrade task do this for you. 
    604611 
    605612Browser 
     
    875882It will output the submitted values and all the errors if any. 
    876883 
     884## Coverage 
     885 
     886There is a new `test:coverage` task that output the code coverage for some given 
     887tests: 
     888 
     889    [php] 
     890    ./symfony test:coverage test/unit/model/ArticleTest.php lib/model/Article.php 
     891 
     892The first argument is a test file or a test directory. The second one is the 
     893file or directory you want to cover. 
     894 
     895If you want to know which lines are not covered, simply add the `--detailed` option: 
     896 
     897    [php] 
     898    ./symfony test:coverage --detailed test/unit/model/ArticleTest.php lib/model/Article.php 
     899 
    877900YAML 
    878901---- 
     
    10561079pass the `no-confirmation` option: 
    10571080 
    1058    $ php symfony propel:insert-sql --no-confirmation 
     1081    $ php symfony propel:insert-sql --no-confirmation 
     1082 
     1083Before symfony 1.2, the `propel:insert-sql` task was the only task to read its 
     1084database configuration information from `propel.ini`. As of symfony 1.2, it 
     1085reads its information from `databases.yml`. So, if you use several different 
     1086connections in your model, the task will take those into account. 
     1087Thanks to this new feature, you can now use the `--connection` option 
     1088if you want to only load SQL statements for a given connection: 
     1089 
     1090    $ php symfony propel:insert-sql --connection=propel 
     1091 
     1092You can also use the `--env` and the `--application` options to select a 
     1093specific configuration to use: 
     1094 
     1095    $ php symfony propel:insert-sql --env=prod --application=frontend 
    10591096 
    10601097The `sfTask` base class now provides three new methods to use in your tasks: 
     
    15971634For example, an uncaught exception during an XML request could render 
    15981635`config/error/exception.xml.php` when your application is in debug mode, or 
    1599 `config/error/error500.xml.php` when your application is not in debug mode. 
    1600  
    1601 Your symfony 1.1 project's `config/error500.php` file will also render, but 
    1602 your symfony 1.0 project's `web/errors/error500.php` file must be moved. This 
    1603 is done for you by the upgrade task. 
     1636`config/error/error.xml.php` when your application is not in debug mode. 
     1637 
     1638If you had customized the 500 error template in your project, you will 
     1639need to manually move it to the new directory: 
     1640 
     1641  * For symfony 1.1: from `config/error500.php` to `config/error/error.html.php` 
     1642  * For symfony 1.0: from `web/errors/error500.php` to `config/error/error.html.php` 
  • branches/dwhittle/1.2/lib/addon/sfData.class.php

    r9083 r12149  
    5050   * Loads data for the database from a YAML file 
    5151   * 
    52    * @param string $fixture_file The path to the YAML file. 
     52   * @param string $file The path to the YAML file. 
    5353   */ 
    54   protected function doLoadDataFromFile($fixture_file) 
     54  protected function doLoadDataFromFile($file) 
    5555  { 
    5656    // import new datas 
    57     $data = sfYaml::load($fixture_file); 
     57    $data = sfYaml::load($file); 
    5858 
    5959    $this->loadDataFromArray($data); 
     
    7171   * loading them into the data source 
    7272   * 
    73    * @param array $fixture_files The path names of the YAML data files 
     73   * @param array $files The path names of the YAML data files 
    7474   */ 
    75   protected function doLoadData($fixture_files) 
     75  protected function doLoadData($files) 
    7676  { 
    7777    $this->object_references = array(); 
    7878    $this->maps = array(); 
    7979 
    80     sort($fixture_files); 
    81     foreach ($fixture_files as $fixture_file) 
     80    foreach ($files as $file) 
    8281    { 
    83       $this->doLoadDataFromFile($fixture_file); 
     82      $this->doLoadDataFromFile($file); 
    8483    } 
    8584  } 
    8685 
    8786  /** 
    88    * Gets a list of one or more *.yml files and returns the list in an array 
     87   * Gets a list of one or more *.yml files and returns the list in an array. 
    8988   * 
    90    * @param string $directory_or_file A directory or file name; if null, then defaults to 'sf_data_dir'/fixtures 
     89   * The returned array of files is sorted by alphabetical order. 
    9190   * 
    92    * @returns array A list of *.yml files. 
     91   * @param  string|array $element A directory or file name or an array of directories and/or file names 
     92   *                               If null, then defaults to 'sf_data_dir'/fixtures 
     93   * 
     94   * @return array A list of *.yml files 
    9395   * 
    9496   * @throws sfInitializationException If the directory or file does not exist. 
    9597   */ 
    96   protected function getFiles($directory_or_file = null) 
     98  public function getFiles($element = null) 
    9799  { 
    98     // directory or file? 
    99     $fixture_files = array(); 
    100     if (!$directory_or_file) 
     100    if (is_null($element)) 
    101101    { 
    102102      $directory_or_file = sfConfig::get('sf_data_dir').'/fixtures'; 
    103103    } 
    104104 
    105     if (is_file($directory_or_file)) 
     105    $files = array(); 
     106    if (is_array($element)) 
    106107    { 
    107       $fixture_files[] = $directory_or_file; 
     108      foreach ($element as $e) 
     109      { 
     110        $files = array_merge($files, $this->getFiles($e)); 
     111      } 
    108112    } 
    109     else if (is_dir($directory_or_file)) 
     113    else if (is_file($element)) 
    110114    { 
    111       $fixture_files = sfFinder::type('file')->name('*.yml')->in($directory_or_file); 
     115      $files[] = $element; 
     116    } 
     117    else if (is_dir($element)) 
     118    { 
     119      $files = sfFinder::type('file')->name('*.yml')->in($element); 
    112120    } 
    113121    else 
    114122    { 
    115       throw new sfInitializationException('You must give a directory or a file.'); 
     123      throw new sfInitializationException('You must give an array, a directory or a file to sfPropelData::getFiles().'); 
    116124    } 
    117125 
    118     return $fixture_files; 
     126    $files = array_unique($files); 
     127    sort($files); 
     128 
     129    return $files; 
    119130  } 
    120131} 
  • branches/dwhittle/1.2/lib/autoload/sfCoreAutoload.class.php

    r11940 r12149  
    305305  'sfRouteCollection' => 'routing', 
    306306  'sfRouting' => 'routing', 
     307  'sfCacheSessionStorage' => 'storage', 
    307308  'sfDatabaseSessionStorage' => 'storage', 
    308309  'sfMySQLSessionStorage' => 'storage', 
     
    360361  'sfViewCacheManagerUpgrade' => 'task/project/upgrade1.1', 
    361362  'sfWebDebugUpgrade' => 'task/project/upgrade1.1', 
    362   'sfExceptionTemplatesUpgrade' => 'task/project/upgrade1.2', 
    363363  'sfFactories12Upgrade' => 'task/project/upgrade1.2', 
    364364  'sfPropel13Upgrade' => 'task/project/upgrade1.2', 
     
    369369  'sfTask' => 'task', 
    370370  'sfTestAllTask' => 'task/test', 
     371  'sfTestCoverageTask' => 'task/test', 
    371372  'sfTestFunctionalTask' => 'task/test', 
    372373  'sfTestUnitTask' => 'task/test', 
  • branches/dwhittle/1.2/lib/config/sfGeneratorConfigHandler.class.php

    r11663 r12149  
    7373              "// auto-generated by sfGeneratorConfigHandler\n". 
    7474              "// date: %s\n%s\n"; 
    75     $retval = sprintf($retval, date('Y/m/d H:i:s'), $this->getContent($generatorManager, $config['class'], $generatorParam)); 
     75    $retval = sprintf($retval, date('Y/m/d H:i:s'), self::getContent($generatorManager, $config['class'], $generatorParam)); 
    7676 
    7777    return $retval; 
     
    8484    // TODO: remove when the admin generator is moved to the new form framework 
    8585    $r = new ReflectionClass($class); 
    86     if ('sfPropelAdminGenerator' == $class || $r->isSubclassOf(new ReflectionClass('sfPropelAdminGenerator'))) 
     86    if ( 
     87      (class_exists('sfPropelAdminGenerator') && ('sfPropelAdminGenerator' == $class || $r->isSubclassOf(new ReflectionClass('sfPropelAdminGenerator')))) 
     88      || 
     89      (class_exists('sfDoctrineAdminGenerator') && ('sfDoctrineAdminGenerator' == $class || $r->isSubclassOf(new ReflectionClass('sfDoctrineAdminGenerator')))) 
     90    ) 
    8791    { 
    88       $data .= <<<EOF 
    89 require sfConfig::get('sf_symfony_lib_dir').'/plugins/sfCompat10Plugin/config/config.php'; 
    90  
    91 EOF; 
     92      $data .= "require sfConfig::get('sf_symfony_lib_dir').'/plugins/sfCompat10Plugin/config/config.php';\n"; 
    9293    } 
    9394 
  • branches/dwhittle/1.2/lib/config/sfProjectConfiguration.class.php

    r11824 r12149  
    219219  { 
    220220    $this->plugins = $plugins; 
     221 
     222    $this->pluginPaths = array(); 
    221223  } 
    222224 
     
    228230  public function enablePlugins($plugins) 
    229231  { 
     232    $this->setPlugins(array_merge($this->plugins, is_array($plugins) ? $plugins : array($plugins))); 
     233  } 
     234 
     235  /** 
     236   * Disables a plugin. 
     237   * 
     238   * @param array|string A plugin name or a plugin list 
     239   */ 
     240  public function disablePlugins($plugins) 
     241  { 
    230242    if (!is_array($plugins)) 
    231243    { 
     
    233245    } 
    234246 
    235     $this->plugins = array_merge($this->plugins, $plugins); 
    236   } 
    237  
    238   /** 
    239    * Disables a plugin. 
    240    * 
    241    * @param array|string A plugin name or a plugin list 
    242    */ 
    243   public function disablePlugins($plugins) 
    244   { 
    245     if (!is_array($plugins)) 
    246     { 
    247       $plugins = array($plugins); 
    248     } 
    249  
    250247    foreach ($plugins as $plugin) 
    251248    { 
     
    255252      } 
    256253    } 
     254 
     255    $this->pluginPaths = array(); 
    257256  } 
    258257 
  • branches/dwhittle/1.2/lib/exception/data/exception.atom.php

    r11824 r12149  
    1 <?php include dirname(__FILE__).'/exception.xml.php' ?> 
     1<?php include sfException::getTemplatePathForError('xml', true) ?> 
  • branches/dwhittle/1.2/lib/exception/data/exception.css.php

    r11824 r12149  
    11/* 
    2   500 Internal Server Error 
     2  <?php echo $code ?> <?php echo $text ?> 
    33 
    4   <?php echo $name."\n".$message."\n" ?> 
     4  <?php echo $name ?> 
     5  <?php echo $message ?> 
     6 
     7  <?php foreach ($traces as $trace): ?> 
     8    <?php echo $trace ?> 
     9 
     10  <?php endforeach; ?> 
    511*/ 
  • branches/dwhittle/1.2/lib/exception/data/exception.html.php

    r11824 r12149  
    3333  <center><div id="main"> 
    3434  <div style="float: right"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAZCAYAAAAiwE4nAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEfklEQVRIx7VUa0wUVxT+Znd2FxZk0YKACAtaGwEDUhUTBTEIItmKYk3UNqalD7StMSQ1JKatP5omTYyx0VRrjPERX7XWAG2t9GVi3drU2h+gi4BCWV67lOe6O/uYmXtPf0BRrMBK6UlObmbON9935p6HQEQI1o7uXeSy1dsjHn2Xlpr0oKzililoEiIKymvOr9q+pzyZZN894moHcbWDZN892lOeTN9fKHgrWB5NsInZ7joOrtv4JgR2F4r0AxTpRwisEes2bsNtW+eBYHmCEqw8kVsp6oy6jMUFYIoTxFUQqWBqNzIWr4aoC9NVnlxZNSWC1mqLsa6ubd36zbug+m3gXBlypoCYAuavx4Ytu1Fbay+2VluME/GJEwHsnT3WpLlzhbi4Z6D46gBosP/gVQDA669kIzJSRWxcApLnPie0dw3cALBw0k1z5dyKrIqyWHL1/Eye7n3kcX5MH75fRAAIAJUUZ5Cnez9JPYfI1XuDKsriqOZcbtakm6alte/yqsIi6LVt4KobxAIAqSPxwUEJxAPgqgcG0YH8NS+gxT5wZVI1/PrU0q1O54OoFfmvQZZsIBYA5zIy0maOYFZmJ4GYAuIyZG8jcvLfgMPhmnHlbG7pUws2NfUeWVvyMpj3d3DVB84C4MyPxNkP+8I0TQRn/qGY6gP316J4w6uob3AceirBzw9nnBD1RmN65nLIUhOIBUBcBjEZ5viQEZx5thFcdQ+50o+A5w7SM5dBFHWhFz5bdOpJ3MLjq63mdHrIr7f6PaXbPtBGht4DUwYAQXikyVTkb/gKtbYBNFpzYYoY3egarR6D7jCcPmtly5ZEh6/ZWucfdyycPep3ycmJ2phoAzx9ziERLoMzN4hJAICI8KEkp4VxcCaP+p4zGdHTw2FOiNB2OTzfAMgf80qrjmem1zf256zf9B6kvmvgqgeqrw2qvx1cGQRxBcQV5GRFIGepaeT5cfdJXbAUPY+79z15l47MWzDmH7a3P/g2Ly9X4O6LkKUWEPeOMbwMpnANiClPDkOBXteL3OXxQnNL72UA5n/V8NLR9Bdrb/ddLN+5VvD23wTA8d9MgNH0LD759DrS5oeUbN7RWjXqSu//OXi8sCBFkN11IFJAxMZ0e4cP12+6xsUQqZC9nShclYTWtsDJUTU8cyDlsE7URqTMC4Eiu8fN+/JVF7I3NuGlna2wlDaPi1VkN1LnR0GvF00n95kPAICm+tgcQ9N9V5ll9Tz4JSem2vySE5bCFDS3+t+uPjbHIA64dF/MioU2aoYGXndgQgJLngnWL0PR1iUje0n4hHimBhA1XYA5IVz8q1eu0oSGqCc6HV4ihAIQgso6MV4flNhDUR/iYqbBI1GqZtM7zVUzZ4p3rl5rQIgxesqvVCsa0O8y4Lc/nGp8rLhcBIA7Df7C7hlKe2ZGojYmZsGUCsqygvOnf6FZsbrtm3bY+wUigiAIC/funlXR0RXYgv/BzAmGn979qGvXyOALghAJQAtAB0A/fIrDY6MNurj/LBqADW8OFYACQB4+2d80or7Ra0ZtxAAAAABJRU5ErkJggg==" /></div> 
    35   <h1>[<?php echo $name ?>]</h1> 
     35  <h1><?php echo $code ?> | <?php echo $text ?> | <?php echo $name ?></h1> 
    3636  <h2 id="message"><?php echo str_replace("\n", '<br />', htmlspecialchars($message, ENT_QUOTES, sfConfig::get('sf_charset', 'UTF-8'))) ?></h2> 
    3737  <h2>stack trace</h2> 
  • branches/dwhittle/1.2/lib/exception/data/exception.js.php

    r11824 r12149  
    11/* 
    2   500 Internal Server Error 
     2  <?php echo $code ?> <?php echo $text ?> 
    33 
    44  <?php echo $name ?> 
    55  <?php echo $message ?> 
     6 
     7  <?php foreach ($traces as $trace): ?> 
     8    <?php echo $trace ?> 
     9 
     10  <?php endforeach; ?> 
    611*/ 
  • branches/dwhittle/1.2/lib/exception/data/exception.json.php

    r11824 r12149  
    11{ 
    2   'error'
     2  "error"
    33  { 
    4     'code':    500
    5     'message': 'Internal Server Error'
    6     'debug'
     4    "code":    <?php echo $code ?>
     5    "message": "<?php echo addcslashes($text, "\0..\37\\'\"\177..\377\/") ?>"
     6    "debug"
    77    { 
    8       'name':   '<?php echo $name ?>', 
    9       'message':'<?php echo addcslashes($message, "\0..\37\\'\"\177..\377\/") ?>' 
     8      "name":    "<?php echo $name ?>", 
     9      "message": "<?php echo addcslashes($message, "\0..\37\\'\"\177..\377\/") ?>" 
     10      "traces": 
     11      [ 
     12<?php foreach ($traces as $trace): ?> 
     13        "<?php echo addcslashes($trace, "\0..\37\\'\"\177..\377\/") ?>" 
     14 
     15<?php endoreach; ?> 
     16      ] 
    1017    } 
    1118  } 
  • branches/dwhittle/1.2/lib/exception/data/exception.rdf.php

    r11824 r12149  
    1 <?php include dirname(__FILE__).'/exception.xml.php' ?> 
     1<?php include sfException::getTemplatePathForError('xml', true) ?> 
  • branches/dwhittle/1.2/lib/exception/data/exception.txt

    r10639 r12149  
    1 [exception]   <?php echo $name ?>  
    2 [message]     <?php echo $message ?>  
     1[exception]   <?php echo $code.' | '.$text.' | '.$name ?> 
     2[message]     <?php echo $message ?> 
    33<?php if (count($traces) > 0): ?> 
    44[stack trace] 
     
    99<?php endif; ?> 
    1010[symfony]     v. <?php echo SYMFONY_VERSION ?> (symfony-project.org) 
    11 [PHP]         v. <?php echo PHP_VERSION ?>  
     11[PHP]         v. <?php echo PHP_VERSION ?> 
  • branches/dwhittle/1.2/lib/exception/data/exception.xml.php

    r11824 r12149  
    11<?xml version="1.0" encoding="<?php echo sfConfig::get('sf_charset', 'UTF-8') ?>"?> 
    2 <error code="500" message="Internal Server Error"> 
     2<error code="<?php echo $code ?>" message="<?php echo $text ?>"> 
    33  <debug> 
    44    <name><?php echo $name ?></name> 
    55    <message><?php echo htmlspecialchars($message, ENT_QUOTES, sfConfig::get('sf_charset', 'UTF-8')) ?></message> 
     6    <traces> 
     7<?php foreach ($traces as $trace): ?> 
     8        <trace><?php echo $trace ?></trace> 
     9<?php endforeach; ?> 
     10    </traces> 
    611  </debug> 
    712</error> 
  • branches/dwhittle/1.2/lib/exception/sfException.class.php

    r11887 r12149  
    9696  static protected function outputStackTrace(Exception $exception) 
    9797  { 
    98     if (class_exists('sfContext', false) && sfContext::hasInstance()) 
     98    $format = 'html'; 
     99    $code   = '500'; 
     100    $text   = 'Internal Server Error'; 
     101 
     102    if (class_exists('sfContext', false) && sfContext::hasInstance() && is_object($request = sfContext::getInstance()->getRequest()) && is_object($response = sfContext::getInstance()->getResponse())) 
    99103    { 
    100104      $dispatcher = sfContext::getInstance()->getEventDispatcher(); 
     
    111115      } 
    112116 
    113       $request  = sfContext::getInstance()->getRequest(); 
    114       $response = sfContext::getInstance()->getResponse(); 
    115  
    116117      if ($response->getStatusCode() < 300) 
    117118      { 
     
    120121      } 
    121122 
    122       if ($mimeType = $request->getMimeType($format = $request->getRequestFormat())) 
    123       { 
    124         $response->setContentType($mimeType); 
    125       } 
    126       else 
    127       { 
    128         $format = 'html'; 
    129         $response->setContentType('text/html'); 
    130       } 
     123      $response->setContentType('text/html'); 
    131124 
    132125      if (!sfConfig::get('sf_test')) 
     
    137130        } 
    138131      } 
     132 
     133      $code = $response->getStatusCode(); 
     134      $text = $response->getStatusText(); 
     135 
     136      $format = $request->getRequestFormat(); 
     137      if (!$format) 
     138      { 
     139        $format = 'html'; 
     140      } 
     141 
     142      if ($mimeType = $request->getMimeType($format)) 
     143      { 
     144        $response->setContentType($mimeType); 
     145      } 
    139146    } 
    140147    else 
    141148    { 
    142149      // a backward compatible default 
    143       $format = 'html'; 
    144  
    145150      if (!sfConfig::get('sf_test')) 
    146151      { 
     
    148153      } 
    149154    } 
    150  
    151     $templatePaths = array( 
    152       sfConfig::get('sf_app_config_dir').'/error', 
    153       sfConfig::get('sf_config_dir').'/error', 
    154       dirname(__FILE__).'/data', 
    155     ); 
    156155 
    157156    // send an error 500 if not in debug mode 
    158157    if (!sfConfig::get('sf_debug')) 
    159158    { 
    160       $template = sprintf('error500.%s.php', $format); 
    161       foreach ($templatePaths as $path) 
    162       { 
    163         if (is_null($path)) 
    164         { 
    165           continue; 
    166         } 
    167  
    168         if (is_readable($file = $path.'/'.$template)) 
    169         { 
    170           include $file; 
    171           return; 
    172         } 
    173  
    174         // for backward compatibility with symfony 1.1 
    175         if ('html' == $format && is_readable($file = $path.'/../error500.php')) 
    176         { 
    177           include $file; 
    178           return; 
    179         } 
     159      if ($template = self::getTemplatePathForError($format, false)) 
     160      { 
     161        include $template; 
     162        return; 
    180163      } 
    181164    } 
     
    183166    $message = is_null($exception->getMessage()) ? 'n/a' : $exception->getMessage(); 
    184167    $name    = get_class($exception); 
    185     $traces  = self::getTraces($exception, 0 == strncasecmp(PHP_SAPI, 'cli', 3) ? 'plain' : 'html'); 
     168    $traces  = self::getTraces($exception, 'html' != $format || 0 == strncasecmp(PHP_SAPI, 'cli', 3) ? 'plain' : 'html'); 
    186169 
    187170    // dump main objects values 
     
    198181    } 
    199182 
    200     $template = sprintf('exception.%s.php', $format); 
     183    if ($template = self::getTemplatePathForError($format, true)) 
     184    { 
     185      include $template; 
     186      return; 
     187    } 
     188  } 
     189 
     190  /** 
     191   * Returns the path for the template error message. 
     192   * 
     193   * @param  string  $format The request format 
     194   * @param  Boolean $debug  Whether to return a template for the debug mode or not 
     195   * 
     196   * @return string|Boolean  false if the template cannot be found for the given format, 
     197   *                         the absolute path to the template otherwise 
     198   */ 
     199  static public function getTemplatePathForError($format, $debug) 
     200  { 
     201    $templatePaths = array( 
     202      sfConfig::get('sf_app_config_dir').'/error', 
     203      sfConfig::get('sf_config_dir').'/error', 
     204      dirname(__FILE__).'/data', 
     205    ); 
     206 
     207    $template = sprintf('%s.%s.php', $debug ? 'exception' : 'error', $format); 
    201208    foreach ($templatePaths as $path) 
    202209    { 
    203210      if (!is_null($path) && is_readable($file = $path.'/'.$template)) 
    204211      { 
    205         include $file; 
    206         return; 
    207       } 
    208     } 
     212        return $file; 
     213      } 
     214    } 
     215 
     216    return false; 
    209217  } 
    210218 
     
    322330      else if ($value === null) 
    323331      { 
    324         $result[] = '<em>null</em>'; 
     332        $result[] = $format == 'html' ? '<em>null</em>' : 'null'; 
    325333      } 
    326334      else if (!is_int($key)) 
    327335      { 
    328         $result[] = "'$key' =&gt; '$value'"; 
     336        $result[] = $format == 'html' ? "'$key' =&gt; '$value'" : "'$key' => '$value'"; 
    329337      } 
    330338      else 
  • branches/dwhittle/1.2/lib/form/sfForm.class.php

    r11971 r12149  
    511511 
    512512  /** 
     513   * Set a validator for the given field name. 
     514   * 
     515   * @param string      $name      The field name 
     516   * @param sfValidator $validator The validator 
     517   */ 
     518  public function setValidator($name, sfValidatorBase $validator) 
     519  { 
     520    $this->validatorSchema[$name] = $validator; 
     521 
     522    $this->resetFormFields(); 
     523  } 
     524 
     525  /** 
     526   * Gets a validator for the given field name. 
     527   * 
     528   * @param  string      $name      The field name 
     529   * 
     530   * @return sfValidator $validator The validator 
     531   */ 
     532  public function getValidator($name) 
     533  { 
     534    if (!isset($this->validatorSchema[$name])) 
     535    { 
     536      throw new InvalidArgumentException(sprintf('The validator "%s" does not exist.', $name)); 
     537    } 
     538 
     539    return $this->validatorSchema[$name]; 
     540  } 
     541 
     542  /** 
    513543   * Sets the validator schema associated with this form. 
    514544   * 
     
    540570  { 
    541571    $this->setWidgetSchema(new sfWidgetFormSchema($widgets)); 
     572  } 
     573 
     574  /** 
     575   * Set a widget for the given field name. 
     576   * 
     577   * @param string       $name   The field name 
     578   * @param sfWidgetForm $widget The widget 
     579   */ 
     580  public function setWidget($name, sfWidgetForm $widget) 
     581  { 
     582    $this->widgetSchema[$name] = $widget; 
     583 
     584    $this->resetFormFields(); 
     585  } 
     586 
     587  /** 
     588   * Gets a widget for the given field name. 
     589   * 
     590   * @param  string       $name      The field name 
     591   * 
     592   * @return sfWidgetForm $widget The widget 
     593   */ 
     594  public function getWidget($name) 
     595  { 
     596    if (!isset($this->widgetSchema[$name])) 
     597    { 
     598      throw new InvalidArgumentException(sprintf('The widget "%s" does not exist.', $name)); 
     599    } 
     600 
     601    return $this->widgetSchema[$name]; 
    542602  } 
    543603 
  • branches/dwhittle/1.2/lib/helper/JavascriptBaseHelper.php

    r11887 r12149  
    5353 
    5454    return content_tag('a', $name, $html_options); 
     55  } 
     56 
     57  /** 
     58   * Returns a button that'll trigger a javascript function using the 
     59   * onclick handler and return false after the fact. 
     60   * 
     61   * Examples: 
     62   *   <?php echo button_to_function('Greeting', "alert('Hello world!')") ?> 
     63   */ 
     64  function button_to_function($name, $function, $html_options = array()) 
     65  { 
     66    $html_options = _parse_attributes($html_options); 
     67 
     68    $html_options['onclick'] = $function.'; return false;'; 
     69    $html_options['type']    = 'button'; 
     70    $html_options['value']   = $name; 
     71 
     72    return tag('input', $html_options); 
    5573  } 
    5674 
  • branches/dwhittle/1.2/lib/response/sfWebResponse.class.php

    r11971 r12149  
    205205 
    206206  /** 
     207   * Retrieves status text for the current web response. 
     208   * 
     209   * @return string Status text 
     210   */ 
     211  public function getStatusText() 
     212  { 
     213    return $this->statusText; 
     214  } 
     215 
     216  /** 
    207217   * Retrieves status code for the current web response. 
    208218   * 
    209    * @return string Status code 
     219   * @return integer Status code 
    210220   */ 
    211221  public function getStatusCode() 
  • branches/dwhittle/1.2/lib/routing/sfPatternRouting.class.php

    r11824 r12149  
    170170   * @see connect 
    171171   */ 
    172   public function prependRoute($name, sfRoute $route) 
     172  public function prependRoute($name, $route) 
    173173  { 
    174174    $routes = $this->routes; 
     
    187187   * @see connect 
    188188   */ 
    189   public function appendRoute($name, sfRoute $route) 
     189  public function appendRoute($name, $route) 
    190190  { 
    191191    return $this->connect($name, $route); 
     
    197197   * @see connect 
    198198   */ 
    199   public function insertRouteBefore($pivot, $name, sfRoute $route) 
     199  public function insertRouteBefore($pivot, $name, $route) 
    200200  { 
    201201    if (!isset($this->routes[$pivot])) 
  • branches/dwhittle/1.2/lib/storage/sfMySQLSessionStorage.class.php

    r10594 r12149  
    101101    $id = $this->db_escape($id); 
    102102 
    103     // delete the record associated with this id 
     103    // get the record associated with this id 
    104104    $sql = "SELECT $db_data_col FROM $db_table WHERE $db_id_col = '$id'"; 
    105105 
  • branches/dwhittle/1.2/lib/task/app/sfAppRoutesTask.class.php

    r11479 r12149  
    4848    $config = new sfRoutingConfigHandler(); 
    4949    $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml')); 
    50     $this->routes = sfPatternRouting::flattenRoutes($routes); 
     50 
     51    $routing = new sfPatternRouting($this->dispatcher); 
     52    $routing->setRoutes($routes); 
     53 
     54    $this->dispatcher->notify(new sfEvent($routing, 'routing.load_configuration')); 
     55 
     56    $this->routes = $routing->getRoutes(); 
    5157 
    5258    // display 
  • branches/dwhittle/1.2/lib/task/generator/sfGenerateAppTask.class.php

    r10879 r12149  
    137137      'ENVIRONMENT' => 'dev', 
    138138      'IS_DEBUG'    => 'true', 
    139       'IP_CHECK'    => '// this check prevents access to debug front conrollers that are deployed by accident to production servers.'.PHP_EOL. 
     139      'IP_CHECK'    => '// this check prevents access to debug front controllers that are deployed by accident to production servers.'.PHP_EOL. 
    140140                       '// feel free to remove this, extend it or make something more sophisticated.'.PHP_EOL. 
    141141                       'if (!in_array(@$_SERVER[\'REMOTE_ADDR\'], array(\'127.0.0.1\', \'::1\')))'.PHP_EOL. 
  • branches/dwhittle/1.2/lib/task/generator/skeleton/app/web/index.php

    r9489 r12149  
    11<?php 
     2 
    23##IP_CHECK## 
    34require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); 
  • branches/dwhittle/1.2/lib/validator/sfValidatorRegex.class.php

    r9048 r12149  
    1717 * @version    SVN: $Id$ 
    1818&nb