Development

Changeset 4897

You must first sign up to be able to contribute.

Changeset 4897

Show
Ignore:
Timestamp:
08/25/07 10:51:44 (1 year ago)
Author:
dwhittle
Message:

dwhittle: merged trunk changes to branch (revs 4866:4896)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/data/config/factories.yml

    r4855 r4897  
    3636  routing: 
    3737    class: sfPatternRouting 
     38    param: 
     39      load_configuration: true 
    3840 
    3941  logger: 
  • branches/dwhittle/data/generator/sfPropelAdmin/default/template/templates/_edit_messages.php

    r2823 r4897  
    55[?php foreach ($sf_request->getErrorNames() as $name): ?] 
    66  <dt>[?php echo __($labels[$name]) ?]</dt> 
    7   <dd>[?php echo $sf_request->getError($name) ?]</dd> 
     7  <dd>[?php echo __($sf_request->getError($name)) ?]</dd> 
    88[?php endforeach; ?] 
    99</dl> 
  • branches/dwhittle/data/generator/sfPropelAdmin/default/template/templates/_list_messages.php

    r4636 r4897  
    1 [?php if ($sf_request->getError('delete')): ?] 
     1[?php if ($sf_request->hasError('delete')): ?] 
    22<div class="form-errors"> 
    33  <h2>[?php echo __('Could not delete the selected %name%', array('%name%' => '<?php echo sfInflector::humanize($this->getSingularName()) ?>')) ?]</h2> 
    44  <ul> 
    5     <li>[?php echo $sf_request->getError('delete') ?]</li> 
     5    <li>[?php echo __($sf_request->getError('delete')) ?]</li> 
    66  </ul> 
    77</div> 
  • branches/dwhittle/data/skeleton/app/app/config/factories.yml

    r4864 r4897  
    2020  storage: 
    2121    class: sfSessionTestStorage 
     22    param: 
     23      session_path: %SF_TEST_CACHE_DIR%/sessions 
    2224 
    2325#all: 
  • branches/dwhittle/lib/action/sfActionStackEntry.class.php

    r3199 r4897  
    2525    $actionName     = null, 
    2626    $moduleName     = null, 
    27     $presentation   = null, 
    28     $viewInstance   = null; 
     27    $presentation   = null; 
    2928 
    3029  /** 
     
    6362 
    6463  /** 
    65    * Retrieves this entry's view instance. 
    66    * 
    67    * @return sfView A sfView implementation instance. 
    68    */ 
    69   public function getViewInstance() 
    70   { 
    71     return $this->viewInstance; 
    72   } 
    73  
    74   /** 
    75    * Sets this entry's view instance. 
    76    * 
    77    * @param sfView A sfView implementation instance. 
    78    */ 
    79   public function setViewInstance($viewInstance) 
    80   { 
    81     $this->viewInstance = $viewInstance; 
    82   } 
    83  
    84   /** 
    8564   * Retrieves this entry's module name. 
    8665   * 
  • branches/dwhittle/lib/addon/creole/i18n/sfMessageSource_Creole.class.php

    r4599 r4897  
    165165 
    166166  /** 
    167    * Retrieve catalogue details, array($cat_id, $variant, $count). 
     167   * Retrieve catalogue details, array($catId, $variant, $count). 
    168168   * 
    169169   * @param string catalogue 
    170    * @return array catalogue details, array($cat_id, $variant, $count). 
     170   * @return array catalogue details, array($catId, $variant, $count). 
    171171   */ 
    172172  protected function getCatalogueDetails($catalogue = 'messages') 
     
    194194    $rs->next(); 
    195195 
    196     $cat_id = $rs->getInt(1); 
     196    $catId = $rs->getInt(1); 
    197197 
    198198    //first get the catalogue ID 
     
    201201    $stmt = $this->db->prepareStatement($sql); 
    202202 
    203     $rs = $stmt->executeQuery(array($cat_id), ResultSet::FETCHMODE_NUM); 
     203    $rs = $stmt->executeQuery(array($catId), ResultSet::FETCHMODE_NUM); 
    204204 
    205205    $rs->next(); 
    206206    $count = $rs->getInt(1); 
    207207 
    208     return array($cat_id, $variant, $count); 
     208    return array($catId, $variant, $count); 
    209209  } 
    210210 
     
    214214   * @return boolean true if updated, false otherwise. 
    215215   */ 
    216   protected function updateCatalogueTime($cat_id, $variant) 
     216  protected function updateCatalogueTime($catId, $variant) 
    217217  { 
    218218    $time = time(); 
     
    222222    $stmt = $this->db->prepareStatement($sql); 
    223223 
    224     $result = $stmt->executeUpdate(array($time, $cat_id)); 
     224    $result = $stmt->executeUpdate(array($time, $catId)); 
    225225 
    226226    if (!empty($this->cache)) 
     
    253253    if ($details) 
    254254    { 
    255       list($cat_id, $variant, $count) = $details; 
     255      list($catId, $variant, $count) = $details; 
    256256    } 
    257257    else 
     
    260260    } 
    261261 
    262     if ($cat_id <= 0) 
     262    if ($catId <= 0) 
    263263    { 
    264264      return false; 
     
    297297      foreach ($messages as $message) 
    298298      { 
    299         $stmt->executeUpdate(array($cat_id, $message, '', '', $time, $time)); 
     299        $stmt->executeUpdate(array($catId, $message, '', '', $time, $time)); 
    300300        ++$inserted; 
    301301      } 
     
    310310    if ($inserted > 0) 
    311311    { 
    312       $this->updateCatalogueTime($cat_id, $variant); 
     312      $this->updateCatalogueTime($catId, $variant); 
    313313    } 
    314314 
     
    329329    if ($details) 
    330330    { 
    331       list($cat_id, $variant, $count) = $details; 
     331      list($catId, $variant, $count) = $details; 
    332332    } 
    333333    else 
     
    342342    $stmt = $this->db->prepareStatement($sql); 
    343343 
    344     $rows = $stmt->executeUpdate(array($cat_id, $message)); 
     344    $rows = $stmt->executeUpdate(array($catId, $message)); 
    345345 
    346346    if ($rows == 1) 
    347347    { 
    348       $deleted = $this->updateCatalogueTime($cat_id, $variant); 
     348      $deleted = $this->updateCatalogueTime($catId, $variant); 
    349349    } 
    350350 
     
    361361   * @return boolean true if translation was updated, false otherwise. 
    362362   */ 
    363   function update($text, $target, $comments, $catalogue='messages') 
     363  function update($text, $target, $comments, $catalogue = 'messages') 
    364364  { 
    365365    $details = $this->getCatalogueDetails($catalogue); 
    366366    if ($details) 
    367367    { 
    368       list($cat_id, $variant, $count) = $details; 
     368      list($catId, $variant, $count) = $details; 
    369369    } 
    370370    else 
     
    381381    $stmt = $this->db->prepareStatement($sql); 
    382382 
    383     $rows = $stmt->executeUpdate(array($target, $comments, $time, $cat_id, $text)); 
     383    $rows = $stmt->executeUpdate(array($target, $comments, $time, $catId, $text)); 
    384384 
    385385    if ($rows == 1) 
    386386    { 
    387       $updated = $this->updateCatalogueTime($cat_id, $variant); 
     387      $updated = $this->updateCatalogueTime($catId, $variant); 
    388388    } 
    389389 
  • branches/dwhittle/lib/addon/creole/storage/sfCreoleSessionStorage.class.php

    r4599 r4897  
    1616 * Provides support for session storage using a CreoleDb database abstraction layer. 
    1717 * 
    18  * <b>Required parameters:</b> 
    19  * 
    20  * # <b>db_table</b> - [none] - The database table in which session data will be 
    21  *                              stored. 
    22  * 
    23  * <b>Optional parameters:</b> 
    24  * 
    25  * # <b>database</b>     - [default]   - The database connection to use 
    26  *                                       (see databases.ini). 
    27  * # <b>db_id_col</b>    - [sess_id]   - The database column in which the 
    28  *                                       session id will be stored. 
    29  * # <b>db_data_col</b>  - [sess_data] - The database column in which the 
    30  *                                       session data will be stored. 
    31  * # <b>db_time_col</b>  - [sess_time] - The database column in which the 
    32  *                                       session timestamp will be stored. 
    33  * # <b>session_name</b> - [Agavi]    - The name of the session. 
     18 * <b>parameters:</b> see sfDatabaseSessionStorage 
    3419 * 
    3520 * @package    symfony 
     
    4025 * @version    SVN: $Id$ 
    4126 */ 
    42 class sfCreoleSessionStorage extends sfSessionStorage 
     27class sfCreoleSessionStorage extends sfDatabaseSessionStorage 
    4328{ 
    44   /** 
    45    * Creole Database Connection 
    46    * @var Connection 
    47    */ 
    48   protected $db; 
    49  
    50   /** 
    51    * Initialize this Storage. 
    52    * 
    53    * @param Context A Context instance. 
    54    * @param array   An associative array of initialization parameters. 
    55    * 
    56    * @return bool true, if initialization completes successfully, otherwise 
    57    *              false. 
    58    * 
    59    * @throws <b>InitializationException</b> If an error occurs while 
    60    *                                        initializing this Storage. 
    61    */ 
    62   public function initialize($context, $parameters = null) 
    63   { 
    64     // disable auto_start 
    65     $parameters['auto_start'] = false; 
    66  
    67     // initialize the parent 
    68     parent::initialize($context, $parameters); 
    69  
    70     if (!$this->getParameterHolder()->has('db_table')) 
    71     { 
    72       // missing required 'db_table' parameter 
    73       throw new sfInitializationException('Factory configuration file is missing required "db_table" parameter for the Storage category.'); 
    74     } 
    75  
    76     // use this object as the session handler 
    77     session_set_save_handler(array($this, 'sessionOpen'), 
    78                              array($this, 'sessionClose'), 
    79                              array($this, 'sessionRead'), 
    80                              array($this, 'sessionWrite'), 
    81                              array($this, 'sessionDestroy'), 
    82                              array($this, 'sessionGC')); 
    83  
    84     // start our session 
    85     session_start(); 
    86   } 
    87  
    88   /** 
    89   * Close a session. 
    90   * 
    91   * @return bool true, if the session was closed, otherwise false. 
    92   */ 
    93   public function sessionClose() 
    94   { 
    95     // do nothing 
    96     return true; 
    97   } 
    98  
    9929  /** 
    10030   * Destroy a session. 
     
    10939  { 
    11040    // get table/column 
    111     $db_table  = $this->getParameterHolder()->get('db_table'); 
    112     $db_id_col = $this->getParameterHolder()->get('db_id_col', 'sess_id'); 
     41    $db_table  = $this->getParameter('db_table'); 
     42    $db_id_col = $this->getParameter('db_id_col', 'sess_id'); 
    11343 
    11444    // delete the record associated with this id 
    115     $sql = 'DELETE FROM ' . $db_table . ' WHERE ' . $db_id_col . '=?'; 
     45    $sql = 'DELETE FROM '.$db_table.' WHERE '.$db_id_col.'= ?'; 
    11646 
    11747    try 
     
    12555      throw new sfDatabaseException(sprintf('Creole SQLException was thrown when trying to manipulate session data. Message: %s.', $e->getMessage())); 
    12656    } 
     57 
     58    return true; 
    12759  } 
    12860 
     
    13870  public function sessionGC($lifetime) 
    13971  { 
    140     // determine deletable session time 
    141     $time = time() - $lifetime; 
    142  
    14372    // get table/column 
    144     $db_table    = $this->getParameterHolder()->get('db_table'); 
    145     $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time'); 
     73    $db_table    = $this->getParameter('db_table'); 
     74    $db_time_col = $this->getParameter('db_time_col', 'sess_time'); 
    14675 
    14776    // delete the record associated with this id 
    148     $sql = 'DELETE FROM ' . $db_table . ' ' . 
    149       'WHERE ' . $db_time_col . ' < ' . $time; 
     77    $sql = 'DELETE FROM '.$db_table.' WHERE '.$db_time_col.' < '.(time() - $lifetime); 
    15078 
    15179    try 
    15280    { 
    15381      $this->db->executeQuery($sql); 
    154       return true; 
    15582    } 
    15683    catch (SQLException $e) 
    15784    { 
    15885      throw new sfDatabaseException(sprintf('Creole SQLException was thrown when trying to manipulate session data. Message: %s.', $e->getMessage())); 
    159     } 
    160   } 
    161  
    162   /** 
    163    * Open a session. 
    164    * 
    165    * @param string 
    166    * @param string 
    167    * 
    168    * @return bool true, if the session was opened, otherwise an exception is thrown. 
    169    * 
    170    * @throws <b>DatabaseException</b> If a connection with the database does 
    171    *                                  not exist or cannot be created. 
    172    */ 
    173   public function sessionOpen($path, $name) 
    174   { 
    175     // what database are we using? 
    176     $database = $this->getParameterHolder()->get('database', 'default'); 
    177  
    178     // autoload propel propely if we're reusing the propel connection for session storage 
    179     if ($this->getContext()->getDatabaseManager()->getDatabase($database) instanceof sfPropelDatabase && !Propel::isInit()) 
    180     { 
    181       throw new sfDatabaseException('Creole dabatase connection is the same as the propel database connection, but could not be initialized.'); 
    182     } 
    183  
    184     $this->db = $this->getContext()->getDatabaseConnection($database); 
    185     if ($this->db == null || !$this->db instanceof Connection) 
    186     { 
    187       throw new sfDatabaseException('Creole dabatase connection doesn\'t exist. Unable to open session.'); 
    18886    } 
    18987 
     
    203101  { 
    204102    // get table/columns 
    205     $db_table    = $this->getParameterHolder()->get('db_table'); 
    206     $db_data_col = $this->getParameterHolder()->get('db_data_col', 'sess_data'); 
    207     $db_id_col   = $this->getParameterHolder()->get('db_id_col', 'sess_id'); 
    208     $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time'); 
     103    $db_table    = $this->getParameter('db_table'); 
     104    $db_data_col = $this->getParameter('db_data_col', 'sess_data'); 
     105    $db_id_col   = $this->getParameter('db_id_col', 'sess_id'); 
     106    $db_time_col = $this->getParameter('db_time_col', 'sess_time'); 
    209107 
    210108    try 
    211109    { 
    212       $sql = 'SELECT ' . $db_data_col . ' FROM ' . $db_table . ' WHERE ' . $db_id_col . '=?'; 
     110      $sql = 'SELECT '.$db_data_col.' FROM '.$db_table.' WHERE '.$db_id_col.'=?'; 
    213111 
    214112      $stmt = $this->db->prepareStatement($sql); 
     
    220118      { 
    221119        $data = $dbRes->getString(1); 
     120 
    222121        return $data; 
    223122      } 
     
    225124      { 
    226125        // session does not exist, create it 
    227         $sql = 'INSERT INTO ' . $db_table . '('.$db_id_col.','.$db_data_col.','.$db_time_col; 
    228         $sql .= ') VALUES (?,?,?)'; 
     126        $sql = 'INSERT INTO '.$db_table.'('.$db_id_col.','.$db_data_col.','.$db_time_col.') VALUES (?,?,?)'; 
    229127 
    230128        $stmt = $this->db->prepareStatement($sql); 
     
    233131        $stmt->setInt(3, time()); 
    234132        $stmt->executeUpdate(); 
     133 
    235134        return ''; 
    236135      } 
     
    256155  { 
    257156    // get table/column 
    258     $db_table    = $this->getParameterHolder()->get('db_table'); 
    259     $db_data_col = $this->getParameterHolder()->get('db_data_col', 'sess_data'); 
    260     $db_id_col   = $this->getParameterHolder()->get('db_id_col', 'sess_id'); 
    261     $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time'); 
     157    $db_table    = $this->getParameter('db_table'); 
     158    $db_data_col = $this->getParameter('db_data_col', 'sess_data'); 
     159    $db_id_col   = $this->getParameter('db_id_col', 'sess_id'); 
     160    $db_time_col = $this->getParameter('db_time_col', 'sess_time'); 
    262161 
    263     $sql = 'UPDATE ' . $db_table . ' SET ' . $db_data_col . '=?, ' . $db_time_col . ' = ' . time() . 
    264       ' WHERE ' . $db_id_col . '=?'; 
     162    $sql = 'UPDATE '.$db_table.' SET '.$db_data_col.'=?, '.$db_time_col.' = '.time().' WHERE '.$db_id_col.'=?'; 
    265163 
    266164    try 
     
    270168      $stmt->setString(2, $id); 
    271169      $stmt->executeUpdate(); 
    272       return true; 
    273170    } 
    274  
    275171    catch (SQLException $e) 
    276172    { 
     
    278174    } 
    279175 
    280     return false; 
     176    return true; 
    281177  } 
    282  
    283   /** 
    284    * Execute the shutdown procedure. 
    285    * 
    286    * @return void 
    287    */ 
    288   public function shutdown() 
    289   { 
    290   } 
    291  
    292178} 
  • branches/dwhittle/lib/config/sfFactoryConfigHandler.class.php

    r4855 r4897  
    111111 
    112112          // append instance initialization 
    113           $inits[] = sprintf("  \$this->factories['request']->initialize(\$this, sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", var_export($parameters, true)); 
     113          $inits[] = sprintf("  \$this->factories['request']->initialize(\$this->factories['logger'], \$this->factories['routing'], sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", var_export($parameters, true)); 
    114114          break; 
    115115 
     
    119119 
    120120          // append instance initialization 
    121           $inits[] = sprintf("  \$this->factories['response']->initialize(\$this, sfConfig::get('sf_factory_response_parameters', %s));", var_export($parameters, true)); 
     121          $inits[] = sprintf("  \$this->factories['response']->initialize(\$this->factories['logger'], sfConfig::get('sf_factory_response_parameters', %s));", var_export($parameters, true)); 
     122          $inits[] = sprintf("  if ('HEAD' == \$this->factories['request']->getMethodName())\n  {  \n    \$this->factories['response']->setHeaderOnly(true);\n  }\n"); 
    122123          break; 
    123124 
     
    127128 
    128129          // append instance initialization 
    129           $inits[] = sprintf("  \$this->factories['storage']->initialize(\$this, sfConfig::get('sf_factory_storage_parameters', %s));", var_export($parameters, true)); 
     130          $defaultParameters = array(); 
     131          $defaultParameters[] = sprintf("'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); 
     132          if (is_subclass_of($class, 'sfDatabaseSessionStorage')) 
     133          { 
     134            $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); 
     135          } 
     136          $inits[] = sprintf("  \$this->factories['storage']->initialize(array_merge(array(\n%s\n), sfConfig::get('sf_factory_storage_parameters', %s)));", implode("\n", $defaultParameters), var_export($parameters, true)); 
    130137          break; 
    131138 
     
    179186 
    180187          // append instance initialization 
    181           $inits[] = sprintf("  \$this->factories['routing']->initialize(\$this, sfConfig::get('sf_factory_routing_parameters', %s));", var_export($parameters, true)); 
     188          $inits[] = sprintf("  \$this->factories['routing']->initialize(\$this->factories['logger'], array_merge(array('suffix' => sfConfig::get('sf_suffix'), 'default_module' => sfConfig::get('sf_default_module'), 'default_action' => sfConfig::get('sf_default_action')), sfConfig::get('sf_factory_routing_parameters', %s)));", var_export(is_array($parameters) ? $parameters : array(), true)); 
    182189          break; 
    183190 
  • branches/dwhittle/lib/database/sfDatabase.class.php

    r3248 r4897  
    2323{ 
    2424  protected 
     25    $parameterHolder = null, 
    2526    $connection      = null, 
    26     $parameterHolder = null, 
    2727    $resource        = null; 
    2828 
     
    4646  public function getConnection() 
    4747  { 
    48     if ($this->connection == null
     48    if (is_null($this->connection)
    4949    { 
    5050      $this->connect(); 
     
    6363  public function getResource() 
    6464  { 
    65     if ($this->resource == null
     65    if (is_null($this->resource)
    6666    { 
    6767      $this->connect(); 
  • branches/dwhittle/lib/database/sfMySQLDatabase.class.php

    r4599 r4897  
    4545  public function connect() 
    4646  { 
    47  
    4847    // determine how to get our 
    4948    $method = $this->getParameter('method', 'normal'); 
     
    8382    // let's see if we need a persistent connection 
    8483    $persistent = $this->getParameter('persistent', false); 
    85     $connect    = ($persistent) ? 'mysql_pconnect' : 'mysql_connect'; 
     84    $connect    = $persistent ? 'mysql_pconnect' : 'mysql_connect'; 
    8685 
    8786    if ($password == null) 
  • branches/dwhittle/lib/database/sfPDODatabase.class.php

    r4599 r4897  
    9494      $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true); 
    9595    } 
     96 
     97    $this->resource = $this->connection; 
     98 
    9699  } 
    97100 
     
    105108  public function shutdown() 
    106109  { 
    107     if ($this->connection !== null) 
    108     { 
    109       $this->connection = null; 
    110     } 
     110    $this->connection = null; 
    111111  } 
    112112} 
  • branches/dwhittle/lib/helper/AssetHelper.php

    r4232 r4897  
    101101  foreach ($sources as $source) 
    102102  { 
    103     $condition = false; 
     103 
    104104    $absolute = false; 
    105105    if (isset($sourceOptions['absolute'])) 
     
    117117      unset($sourceOptions['raw_name']); 
    118118    } 
    119  
    120     if(isset($sourceOptions['condition'])) 
    121     { 
    122       $condition = $sourceOptions['condition']; 
    123       unset($sourceOptions['condition']); 
    124     } 
    125  
    126119    $options = array_merge(array('type' => 'text/javascript', 'src' => $source), $sourceOptions); 
    127     $content = content_tag('script', '', $options)."\n"; 
    128     $html .= ($condition) ? conditional($condition, $content) : $content; 
    129  
     120    $html   .= content_tag('script', '', $options)."\n"; 
    130121  } 
    131122 
     
    192183  foreach ($sources as $source) 
    193184  { 
    194     $condition = false; 
    195185    $absolute = false; 
    196186    if (isset($sourceOptions['absolute'])) 
     
    208198      unset($sourceOptions['raw_name']); 
    209199    } 
    210  
    211     if(isset($sourceOptions['condition'])) 
    212     { 
    213       $condition = $sourceOptions['condition']; 
    214       unset($sourceOptions['condition']); 
    215     } 
    216  
    217200    $options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $source), $sourceOptions); 
    218     $content = tag('link', $options)."\n"; 
    219     $html .= ($condition) ? conditional($condition, $content) : $content; 
     201    $html   .= tag('link', $options)."\n"; 
    220202  } 
    221203 
     
    244226 
    245227/** 
    246  * Returns a <script> include tag relative to a dynamic PJS action. 
    247  * 
    248  * <b>Examples:</b> 
    249  * <code> 
    250  *  echo pjs_include_tag('foo/bar'); 
    251  *    => <script language="JavaScript" type="text/javascript" src="/js/foo/bar.pjs"></script> 
    252  *  echo pjs_include_tag('foo/bar?id=12'); 
    253  *    => <script language="JavaScript" type="text/javascript" src="/js/foo/bar/id/12.pjs"></script> 
    254  *  echo pjs_include_tag('foo/bar', null, array('query_string' => 'id=12')); 
    255  *    => <script language="JavaScript" type="text/javascript" src="/js/foo/bar.pjs?id=12"></script> 
    256  *  echo pjs_include_tag('foo/bar', true); 
    257  *    => <script language="JavaScript" type="text/javascript" src="http://localhost/js/foo/bar.pjs"></script> 
    258  * </code> 
    259  * 
    260  * @param  string Internal URI of the action to call 
    261  * @param  bool return absolute path ? 
    262  * @param  array options for the URL generation (to include query string) 
    263  * @return string <script> include tag to the dynamic JavaScript file 
    264  */ 
    265 function pjs_include_tag($uri, $absolute = false, $options = array()) 
    266 { 
    267   return javascript_include_tag(pjs_path($uri, $absolute, $options), array('raw_name' => true)); 
    268 } 
    269  
    270 /** 
    271  * Adds a <script> include tag relative to the response content, where it is called 
    272  * 
    273  * @see pjs_include_tag 
    274  * 
    275  */ 
    276 function use_pjs($uri, $absolute = false, $options = array()) 
    277 { 
    278   echo pjs_include_tag($uri, $absolute = false, $options = array()); 
    279 } 
    280  
    281 /** 
    282  * Returns the path to a dynamic PJS action. 
    283  * 
    284  * <b>Examples:</b> 
    285  * <code> 
    286  *  echo pjs_path('foo/bar'); 
    287  *    => /js/foo/bar.pjs 
    288  *  echo pjs_path('foo/bar?id=12'); 
    289  *    => /js/foo/bar/id/12.pjs 
    290  *  echo pjs_path('foo/bar', null, array('query_string' => 'id=12')); 
    291  *    => /js/foo/bar.pjs?id=12 
    292  *  echo pjs_path('foo/bar', true); 
    293  *    => http://localhost/js/foo/bar.pjs 
    294  * </code> 
    295  * 
    296  * @param  string Internal URI of the action to call 
    297  * @param  bool return absolute path ? 
    298  * @param  array options for the URL generation (to include query string) 
    299  * @return string external URL to the dynamic JavaScript file 
    300  */ 
    301 function pjs_path($uri, $absolute = false, $options = array()) 
    302 { 
    303   $urlArguments = ''; 
    304   if (false !== $pos = strpos($uri, '?')) 
    305   { 
    306     $urlArguments = '&'.substr($uri, $pos + 1); 
    307     $uri = substr($uri, 0, $pos); 
    308   } 
    309  
    310   list($module, $action) = explode('/', $uri); 
    311  
    312   $url = sprintf('@default_pjs?format=js&module=%s&action=%s'.$urlArguments, $module, $action); 
    313   $query_string = isset($options['query_string']) ? '?'.$options['query_string'] : ''; 
    314  
    315   return url_for($url, $absolute).$query_string; 
    316 } 
    317  
    318 /** 
    319228 * Decorates the current template with a given layout. 
    320229 * 
     
    323232function decorate_with($layout) 
    324233{ 
    325   $view = sfContext::getInstance()->getActionStack()->getLastEntry()->getViewInstance(); 
    326234  if (false === $layout) 
    327235  { 
    328     $view->setDecorator(false); 
     236    sfContext::getInstance()->get('view_instance')->setDecorator(false); 
    329237  } 
    330238  else 
    331239  { 
    332     $view->setDecoratorTemplate($layout); 
     240    sfContext::getInstance()->get('view_instance')->setDecoratorTemplate($layout); 
    333241  } 
    334242} 
     
    435343  { 
    436344    $source = $sf_relative_url_root.'/'.$dir.'/'.$source; 
     345 
    437346  } 
    438347 
     
    476385 * </code> 
    477386 * 
    478  * <b>Note:</b> Modify the sfResponse object or the view.yml to change, add or remove metas. 
     387 * <b>Note:</b> Modify the view.yml or use sfWebResponse::addMeta() to change, add or remove metas. 
    479388 * 
    480389 * @return string XHTML compliant <meta> tag(s) 
    481390 * @see    include_http_metas 
     391 * @see    sfWebResponse::addMeta() 
    482392 */ 
    483393function include_metas() 
    484394{ 
    485   foreach (sfContext::getInstance()->getResponse()->getMetas() as $name => $content) 
    486   { 
    487     echo tag('meta', array('name' => $name, 'content' => $content))."\n"; 
     395  $context = sfContext::getInstance(); 
     396  $i18n = sfConfig::get('sf_i18n') ? $context->getI18N() : null; 
     397  foreach ($context->getResponse()->getMetas() as $name => $content) 
     398  { 
     399    echo tag('meta', array('name' => $name, 'content' => is_null($i18n) ? $content : $i18n->__($content)))."\n"; 
    488400  } 
    489401} 
     
    499411 * </code> 
    500412 * 
    501  * <b>Note:</b> Modify the sfResponse object or the view.yml to change, add or remove metas. 
     413 * <b>Note:</b> Modify the view.yml or use sfWebResponse::addMeta() to change, add or remove HTTP metas. 
    502414 * 
    503415 * @return string XHTML compliant <meta> tag(s) 
    504416 * @see    include_metas 
     417 * @see    sfWebResponse::addHttpMeta() 
    505418 */ 
    506419function include_http_metas() 
     
    564477 
    565478  return $html; 
     479 
    566480} 
    567481 
  • branches/dwhittle/lib/helper/ObjectHelper.php

    r4599 r4897  
    6767 * NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
    6868 */ 
    69 function objects_for_select($options = array(), $value_method, $text_method = null, $selected = null, $html_options = array()) 
     69function objects_for_select($options, $value_method, $text_method = null, $selected = null, $html_options = array()) 
    7070{ 
    7171  $select_options = array(); 
  • branches/dwhittle/lib/helper/PartialHelper.php

    r4855 r4897  
    5555function get_component_slot($name, $vars = array()) 
    5656{ 
    57   $context = sfContext::getInstance(); 
    58  
    59   $actionStackEntry = $context->getController()->getActionStack()->getLastEntry(); 
    60   $viewInstance     = $actionStackEntry->getViewInstance(); 
     57  $viewInstance = sfContext::getInstance()->get('view_instance'); 
    6158 
    6259  if (!$viewInstance->hasComponentSlot($name)) 
  • branches/dwhittle/lib/helper/ValidationHelper.php

    r1553 r4897  
    3030  $options = _parse_attributes($options); 
    3131 
    32   $request = sfContext::getInstance()->getRequest(); 
     32  $context = sfContext::getInstance(); 
     33  $request = $context->getRequest(); 
    3334 
    3435  $style = $request->hasError($param_for_sf) ? '' : 'display:none;'; 
     
    5859  } 
    5960 
    60   $error = $request->getError($param_for_sf, $catalogue); 
     61  // translate error message if needed 
     62  $error = $request->getError($param_for_sf); 
     63  if (sfConfig::get('sf_i18n')) 
     64  { 
     65    $error = $context->getI18N()->__($error, null, $catalogue); 
     66  } 
    6167 
    6268  return content_tag('div', $prefix.$error.$suffix, $options)."\n"; 
  • branches/dwhittle/lib/request/sfConsoleRequest.class.php

    r3688 r4897  
    2323   * Initializes this sfRequest. 
    2424   * 
    25    * @param sfContext A sfContext instance 
    26    * @param array   An associative array of initialization parameters 
    27