Changeset 4897
- Timestamp:
- 08/25/07 10:51:44 (1 year ago)
- Files:
-
- branches/dwhittle/data/config/factories.yml (modified) (1 diff)
- branches/dwhittle/data/generator/sfPropelAdmin/default/template/templates/_edit_messages.php (modified) (1 diff)
- branches/dwhittle/data/generator/sfPropelAdmin/default/template/templates/_list_messages.php (modified) (1 diff)
- branches/dwhittle/data/skeleton/app/app/config/factories.yml (modified) (1 diff)
- branches/dwhittle/lib/action/sfActionStackEntry.class.php (modified) (2 diffs)
- branches/dwhittle/lib/addon/creole/i18n/sfMessageSource_Creole.class.php (modified) (13 diffs)
- branches/dwhittle/lib/addon/creole/storage/sfCreoleSessionStorage.class.php (modified) (12 diffs)
- branches/dwhittle/lib/config/sfFactoryConfigHandler.class.php (modified) (4 diffs)
- branches/dwhittle/lib/database/sfDatabase.class.php (modified) (3 diffs)
- branches/dwhittle/lib/database/sfMySQLDatabase.class.php (modified) (2 diffs)
- branches/dwhittle/lib/database/sfPDODatabase.class.php (modified) (2 diffs)
- branches/dwhittle/lib/helper/AssetHelper.php (modified) (10 diffs)
- branches/dwhittle/lib/helper/ObjectHelper.php (modified) (1 diff)
- branches/dwhittle/lib/helper/PartialHelper.php (modified) (1 diff)
- branches/dwhittle/lib/helper/ValidationHelper.php (modified) (2 diffs)
- branches/dwhittle/lib/log/sfLogManager.class.php (deleted)
- branches/dwhittle/lib/request/sfConsoleRequest.class.php (modified) (1 diff)
- branches/dwhittle/lib/request/sfRequest.class.php (modified) (9 diffs)
- branches/dwhittle/lib/request/sfWebRequest.class.php (modified) (13 diffs)
- branches/dwhittle/lib/response/sfConsoleResponse.class.php (modified) (1 diff)
- branches/dwhittle/lib/response/sfResponse.class.php (modified) (5 diffs)
- branches/dwhittle/lib/response/sfWebResponse.class.php (modified) (24 diffs)
- branches/dwhittle/lib/routing/sfNoRouting.class.php (modified) (3 diffs)
- branches/dwhittle/lib/routing/sfPathInfoRouting.class.php (copied) (copied from trunk/lib/routing/sfPathInfoRouting.class.php)
- branches/dwhittle/lib/routing/sfPatternRouting.class.php (modified) (25 diffs)
- branches/dwhittle/lib/routing/sfRouting.class.php (modified) (4 diffs)
- branches/dwhittle/lib/storage/sfDatabaseSessionStorage.class.php (copied) (copied from trunk/lib/storage/sfDatabaseSessionStorage.class.php)
- branches/dwhittle/lib/storage/sfMySQLSessionStorage.class.php (modified) (10 diffs)
- branches/dwhittle/lib/storage/sfNoStorage.class.php (copied) (copied from trunk/lib/storage/sfNoStorage.class.php)
- branches/dwhittle/lib/storage/sfPDOSessionStorage.class.php (modified) (10 diffs)
- branches/dwhittle/lib/storage/sfPostgreSQLSessionStorage.class.php (modified) (13 diffs)
- branches/dwhittle/lib/storage/sfSessionStorage.class.php (modified) (7 diffs)
- branches/dwhittle/lib/storage/sfSessionTestStorage.class.php (modified) (10 diffs)
- branches/dwhittle/lib/storage/sfStorage.class.php (modified) (6 diffs)
- branches/dwhittle/lib/task/log/sfLogRotateTask.class.php (modified) (2 diffs)
- branches/dwhittle/lib/user/sfUser.class.php (modified) (1 diff)
- branches/dwhittle/lib/util/sfContext.class.php (modified) (3 diffs)
- branches/dwhittle/lib/util/sfFillInForm.class.php (modified) (3 diffs)
- branches/dwhittle/lib/view/sfPHPView.class.php (modified) (1 diff)
- branches/dwhittle/lib/view/sfViewCacheManager.class.php (modified) (2 diffs)
- branches/dwhittle/test/functional/fixtures/project/apps/backend/config/factories.yml (modified) (1 diff)
- branches/dwhittle/test/functional/fixtures/project/apps/cache/config/factories.yml (modified) (1 diff)
- branches/dwhittle/test/functional/fixtures/project/apps/crud/config/factories.yml (modified) (1 diff)
- branches/dwhittle/test/functional/fixtures/project/apps/frontend/config/factories.yml (modified) (1 diff)
- branches/dwhittle/test/functional/fixtures/project/apps/i18n/config/factories.yml (modified) (1 diff)
- branches/dwhittle/test/unit/action/sfComponentTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/helper/AssetHelperTest.php (modified) (3 diffs)
- branches/dwhittle/test/unit/request/sfRequestTest.php (modified) (5 diffs)
- branches/dwhittle/test/unit/response/sfResponseTest.php (modified) (4 diffs)
- branches/dwhittle/test/unit/response/sfWebResponseTest.php (modified) (7 diffs)
- branches/dwhittle/test/unit/routing/sfNoRoutingTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/routing/sfPathInfoRoutingTest.php (copied) (copied from trunk/test/unit/routing/sfPathInfoRoutingTest.php)
- branches/dwhittle/test/unit/routing/sfPatternRoutingTest.php (modified) (9 diffs)
- branches/dwhittle/test/unit/sfContextMock.class.php (modified) (2 diffs)
- branches/dwhittle/test/unit/sfWebRequestMock.class.php (deleted)
- branches/dwhittle/test/unit/storage/sfNoStorageTest.php (copied) (copied from trunk/test/unit/storage/sfNoStorageTest.php)
- branches/dwhittle/test/unit/storage/sfPDOSessionStorageTest.php (copied) (copied from trunk/test/unit/storage/sfPDOSessionStorageTest.php)
- branches/dwhittle/test/unit/storage/sfStorageTest.php (modified) (3 diffs)
- branches/dwhittle/test/unit/user/sfBasicSecurityUserTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/user/sfUserTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/util/sfFillInFormTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/data/config/factories.yml
r4855 r4897 36 36 routing: 37 37 class: sfPatternRouting 38 param: 39 load_configuration: true 38 40 39 41 logger: branches/dwhittle/data/generator/sfPropelAdmin/default/template/templates/_edit_messages.php
r2823 r4897 5 5 [?php foreach ($sf_request->getErrorNames() as $name): ?] 6 6 <dt>[?php echo __($labels[$name]) ?]</dt> 7 <dd>[?php echo $sf_request->getError($name) ?]</dd>7 <dd>[?php echo __($sf_request->getError($name)) ?]</dd> 8 8 [?php endforeach; ?] 9 9 </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')): ?] 2 2 <div class="form-errors"> 3 3 <h2>[?php echo __('Could not delete the selected %name%', array('%name%' => '<?php echo sfInflector::humanize($this->getSingularName()) ?>')) ?]</h2> 4 4 <ul> 5 <li>[?php echo $sf_request->getError('delete') ?]</li>5 <li>[?php echo __($sf_request->getError('delete')) ?]</li> 6 6 </ul> 7 7 </div> branches/dwhittle/data/skeleton/app/app/config/factories.yml
r4864 r4897 20 20 storage: 21 21 class: sfSessionTestStorage 22 param: 23 session_path: %SF_TEST_CACHE_DIR%/sessions 22 24 23 25 #all: branches/dwhittle/lib/action/sfActionStackEntry.class.php
r3199 r4897 25 25 $actionName = null, 26 26 $moduleName = null, 27 $presentation = null, 28 $viewInstance = null; 27 $presentation = null; 29 28 30 29 /** … … 63 62 64 63 /** 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 /**85 64 * Retrieves this entry's module name. 86 65 * branches/dwhittle/lib/addon/creole/i18n/sfMessageSource_Creole.class.php
r4599 r4897 165 165 166 166 /** 167 * Retrieve catalogue details, array($cat _id, $variant, $count).167 * Retrieve catalogue details, array($catId, $variant, $count). 168 168 * 169 169 * @param string catalogue 170 * @return array catalogue details, array($cat _id, $variant, $count).170 * @return array catalogue details, array($catId, $variant, $count). 171 171 */ 172 172 protected function getCatalogueDetails($catalogue = 'messages') … … 194 194 $rs->next(); 195 195 196 $cat _id = $rs->getInt(1);196 $catId = $rs->getInt(1); 197 197 198 198 //first get the catalogue ID … … 201 201 $stmt = $this->db->prepareStatement($sql); 202 202 203 $rs = $stmt->executeQuery(array($cat _id), ResultSet::FETCHMODE_NUM);203 $rs = $stmt->executeQuery(array($catId), ResultSet::FETCHMODE_NUM); 204 204 205 205 $rs->next(); 206 206 $count = $rs->getInt(1); 207 207 208 return array($cat _id, $variant, $count);208 return array($catId, $variant, $count); 209 209 } 210 210 … … 214 214 * @return boolean true if updated, false otherwise. 215 215 */ 216 protected function updateCatalogueTime($cat _id, $variant)216 protected function updateCatalogueTime($catId, $variant) 217 217 { 218 218 $time = time(); … … 222 222 $stmt = $this->db->prepareStatement($sql); 223 223 224 $result = $stmt->executeUpdate(array($time, $cat _id));224 $result = $stmt->executeUpdate(array($time, $catId)); 225 225 226 226 if (!empty($this->cache)) … … 253 253 if ($details) 254 254 { 255 list($cat _id, $variant, $count) = $details;255 list($catId, $variant, $count) = $details; 256 256 } 257 257 else … … 260 260 } 261 261 262 if ($cat _id <= 0)262 if ($catId <= 0) 263 263 { 264 264 return false; … … 297 297 foreach ($messages as $message) 298 298 { 299 $stmt->executeUpdate(array($cat _id, $message, '', '', $time, $time));299 $stmt->executeUpdate(array($catId, $message, '', '', $time, $time)); 300 300 ++$inserted; 301 301 } … … 310 310 if ($inserted > 0) 311 311 { 312 $this->updateCatalogueTime($cat _id, $variant);312 $this->updateCatalogueTime($catId, $variant); 313 313 } 314 314 … … 329 329 if ($details) 330 330 { 331 list($cat _id, $variant, $count) = $details;331 list($catId, $variant, $count) = $details; 332 332 } 333 333 else … … 342 342 $stmt = $this->db->prepareStatement($sql); 343 343 344 $rows = $stmt->executeUpdate(array($cat _id, $message));344 $rows = $stmt->executeUpdate(array($catId, $message)); 345 345 346 346 if ($rows == 1) 347 347 { 348 $deleted = $this->updateCatalogueTime($cat _id, $variant);348 $deleted = $this->updateCatalogueTime($catId, $variant); 349 349 } 350 350 … … 361 361 * @return boolean true if translation was updated, false otherwise. 362 362 */ 363 function update($text, $target, $comments, $catalogue ='messages')363 function update($text, $target, $comments, $catalogue = 'messages') 364 364 { 365 365 $details = $this->getCatalogueDetails($catalogue); 366 366 if ($details) 367 367 { 368 list($cat _id, $variant, $count) = $details;368 list($catId, $variant, $count) = $details; 369 369 } 370 370 else … … 381 381 $stmt = $this->db->prepareStatement($sql); 382 382 383 $rows = $stmt->executeUpdate(array($target, $comments, $time, $cat _id, $text));383 $rows = $stmt->executeUpdate(array($target, $comments, $time, $catId, $text)); 384 384 385 385 if ($rows == 1) 386 386 { 387 $updated = $this->updateCatalogueTime($cat _id, $variant);387 $updated = $this->updateCatalogueTime($catId, $variant); 388 388 } 389 389 branches/dwhittle/lib/addon/creole/storage/sfCreoleSessionStorage.class.php
r4599 r4897 16 16 * Provides support for session storage using a CreoleDb database abstraction layer. 17 17 * 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 34 19 * 35 20 * @package symfony … … 40 25 * @version SVN: $Id$ 41 26 */ 42 class sfCreoleSessionStorage extends sf SessionStorage27 class sfCreoleSessionStorage extends sfDatabaseSessionStorage 43 28 { 44 /**45 * Creole Database Connection46 * @var Connection47 */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, otherwise57 * false.58 *59 * @throws <b>InitializationException</b> If an error occurs while60 * initializing this Storage.61 */62 public function initialize($context, $parameters = null)63 {64 // disable auto_start65 $parameters['auto_start'] = false;66 67 // initialize the parent68 parent::initialize($context, $parameters);69 70 if (!$this->getParameterHolder()->has('db_table'))71 {72 // missing required 'db_table' parameter73 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 handler77 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 session85 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 nothing96 return true;97 }98 99 29 /** 100 30 * Destroy a session. … … 109 39 { 110 40 // get table/column 111 $db_table = $this->getParameter Holder()->get('db_table');112 $db_id_col = $this->getParameter Holder()->get('db_id_col', 'sess_id');41 $db_table = $this->getParameter('db_table'); 42 $db_id_col = $this->getParameter('db_id_col', 'sess_id'); 113 43 114 44 // 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.'= ?'; 116 46 117 47 try … … 125 55 throw new sfDatabaseException(sprintf('Creole SQLException was thrown when trying to manipulate session data. Message: %s.', $e->getMessage())); 126 56 } 57 58 return true; 127 59 } 128 60 … … 138 70 public function sessionGC($lifetime) 139 71 { 140 // determine deletable session time141 $time = time() - $lifetime;142 143 72 // get table/column 144 $db_table = $this->getParameter Holder()->get('db_table');145 $db_time_col = $this->getParameter Holder()->get('db_time_col', 'sess_time');73 $db_table = $this->getParameter('db_table'); 74 $db_time_col = $this->getParameter('db_time_col', 'sess_time'); 146 75 147 76 // 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); 150 78 151 79 try 152 80 { 153 81 $this->db->executeQuery($sql); 154 return true;155 82 } 156 83 catch (SQLException $e) 157 84 { 158 85 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 string166 * @param string167 *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 does171 * 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 storage179 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.');188 86 } 189 87 … … 203 101 { 204 102 // get table/columns 205 $db_table = $this->getParameter Holder()->get('db_table');206 $db_data_col = $this->getParameter Holder()->get('db_data_col', 'sess_data');207 $db_id_col = $this->getParameter Holder()->get('db_id_col', 'sess_id');208 $db_time_col = $this->getParameter Holder()->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'); 209 107 210 108 try 211 109 { 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.'=?'; 213 111 214 112 $stmt = $this->db->prepareStatement($sql); … … 220 118 { 221 119 $data = $dbRes->getString(1); 120 222 121 return $data; 223 122 } … … 225 124 { 226 125 // 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 (?,?,?)'; 229 127 230 128 $stmt = $this->db->prepareStatement($sql); … … 233 131 $stmt->setInt(3, time()); 234 132 $stmt->executeUpdate(); 133 235 134 return ''; 236 135 } … … 256 155 { 257 156 // get table/column 258 $db_table = $this->getParameter Holder()->get('db_table');259 $db_data_col = $this->getParameter Holder()->get('db_data_col', 'sess_data');260 $db_id_col = $this->getParameter Holder()->get('db_id_col', 'sess_id');261 $db_time_col = $this->getParameter Holder()->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'); 262 161 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.'=?'; 265 163 266 164 try … … 270 168 $stmt->setString(2, $id); 271 169 $stmt->executeUpdate(); 272 return true;273 170 } 274 275 171 catch (SQLException $e) 276 172 { … … 278 174 } 279 175 280 return false;176 return true; 281 177 } 282 283 /**284 * Execute the shutdown procedure.285 *286 * @return void287 */288 public function shutdown()289 {290 }291 292 178 } branches/dwhittle/lib/config/sfFactoryConfigHandler.class.php
r4855 r4897 111 111 112 112 // 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)); 114 114 break; 115 115 … … 119 119 120 120 // 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"); 122 123 break; 123 124 … … 127 128 128 129 // 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)); 130 137 break; 131 138 … … 179 186 180 187 // 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)); 182 189 break; 183 190 branches/dwhittle/lib/database/sfDatabase.class.php
r3248 r4897 23 23 { 24 24 protected 25 $parameterHolder = null, 25 26 $connection = null, 26 $parameterHolder = null,27 27 $resource = null; 28 28 … … 46 46 public function getConnection() 47 47 { 48 if ( $this->connection == null)48 if (is_null($this->connection)) 49 49 { 50 50 $this->connect(); … … 63 63 public function getResource() 64 64 { 65 if ( $this->resource == null)65 if (is_null($this->resource)) 66 66 { 67 67 $this->connect(); branches/dwhittle/lib/database/sfMySQLDatabase.class.php
r4599 r4897 45 45 public function connect() 46 46 { 47 48 47 // determine how to get our 49 48 $method = $this->getParameter('method', 'normal'); … … 83 82 // let's see if we need a persistent connection 84 83 $persistent = $this->getParameter('persistent', false); 85 $connect = ($persistent)? 'mysql_pconnect' : 'mysql_connect';84 $connect = $persistent ? 'mysql_pconnect' : 'mysql_connect'; 86 85 87 86 if ($password == null) branches/dwhittle/lib/database/sfPDODatabase.class.php
r4599 r4897 94 94 $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true); 95 95 } 96 97 $this->resource = $this->connection; 98 96 99 } 97 100 … … 105 108 public function shutdown() 106 109 { 107 if ($this->connection !== null) 108 { 109 $this->connection = null; 110 } 110 $this->connection = null; 111 111 } 112 112 } branches/dwhittle/lib/helper/AssetHelper.php
r4232 r4897 101 101 foreach ($sources as $source) 102 102 { 103 $condition = false; 103 104 104 $absolute = false; 105 105 if (isset($sourceOptions['absolute'])) … … 117 117 unset($sourceOptions['raw_name']); 118 118 } 119 120 if(isset($sourceOptions['condition']))121 {122 $condition = $sourceOptions['condition'];123 unset($sourceOptions['condition']);124 }125 126 119 $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"; 130 121 } 131 122 … … 192 183 foreach ($sources as $source) 193 184 { 194 $condition = false;195 185 $absolute = false; 196 186 if (isset($sourceOptions['absolute'])) … … 208 198 unset($sourceOptions['raw_name']); 209 199 } 210 211 if(isset($sourceOptions['condition']))212 {213 $condition = $sourceOptions['condition'];214 unset($sourceOptions['condition']);215 }216 217 200 $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"; 220 202 } 221 203 … … 244 226 245 227 /** 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 call261 * @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 file264 */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 called272 *273 * @see pjs_include_tag274 *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.pjs288 * echo pjs_path('foo/bar?id=12');289 * => /js/foo/bar/id/12.pjs290 * echo pjs_path('foo/bar', null, array('query_string' => 'id=12'));291 * => /js/foo/bar.pjs?id=12292 * echo pjs_path('foo/bar', true);293 * => http://localhost/js/foo/bar.pjs294 * </code>295 *296 * @param string Internal URI of the action to call297 * @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 file300 */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 /**319 228 * Decorates the current template with a given layout. 320 229 * … … 323 232 function decorate_with($layout) 324 233 { 325 $view = sfContext::getInstance()->getActionStack()->getLastEntry()->getViewInstance();326 234 if (false === $layout) 327 235 { 328 $view->setDecorator(false);236 sfContext::getInstance()->get('view_instance')->setDecorator(false); 329 237 } 330 238 else 331 239 { 332 $view->setDecoratorTemplate($layout);240 sfContext::getInstance()->get('view_instance')->setDecoratorTemplate($layout); 333 241 } 334 242 } … … 435 343 { 436 344 $source = $sf_relative_url_root.'/'.$dir.'/'.$source; 345 437 346 } 438 347 … … 476 385 * </code> 477 386 * 478 * <b>Note:</b> Modify the sfResponse object or the view.ymlto change, add or remove metas.387 * <b>Note:</b> Modify the view.yml or use sfWebResponse::addMeta() to change, add or remove metas. 479 388 * 480 389 * @return string XHTML compliant <meta> tag(s) 481 390 * @see include_http_metas 391 * @see sfWebResponse::addMeta() 482 392 */ 483 393 function include_metas() 484 394 { 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"; 488 400 } 489 401 } … … 499 411 * </code> 500 412 * 501 * <b>Note:</b> Modify the sfResponse object or the view.yml to change, add or removemetas.413 * <b>Note:</b> Modify the view.yml or use sfWebResponse::addMeta() to change, add or remove HTTP metas. 502 414 * 503 415 * @return string XHTML compliant <meta> tag(s) 504 416 * @see include_metas 417 * @see sfWebResponse::addHttpMeta() 505 418 */ 506 419 function include_http_metas() … … 564 477 565 478 return $html; 479 566 480 } 567 481 branches/dwhittle/lib/helper/ObjectHelper.php
r4599 r4897 67 67 * NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 68 68 */ 69 function objects_for_select($options = array(), $value_method, $text_method = null, $selected = null, $html_options = array())69 function objects_for_select($options, $value_method, $text_method = null, $selected = null, $html_options = array()) 70 70 { 71 71 $select_options = array(); branches/dwhittle/lib/helper/PartialHelper.php
r4855 r4897 55 55 function get_component_slot($name, $vars = array()) 56 56 { 57 $context = sfContext::getInstance(); 58 59 $actionStackEntry = $context->getController()->getActionStack()->getLastEntry(); 60 $viewInstance = $actionStackEntry->getViewInstance(); 57 $viewInstance = sfContext::getInstance()->get('view_instance'); 61 58 62 59 if (!$viewInstance->hasComponentSlot($name)) branches/dwhittle/lib/helper/ValidationHelper.php
r1553 r4897 30 30 $options = _parse_attributes($options); 31 31 32 $request = sfContext::getInstance()->getRequest(); 32 $context = sfContext::getInstance(); 33 $request = $context->getRequest(); 33 34 34 35 $style = $request->hasError($param_for_sf) ? '' : 'display:none;'; … … 58 59 } 59 60 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 } 61 67 62 68 return content_tag('div', $prefix.$error.$suffix, $options)."\n"; branches/dwhittle/lib/request/sfConsoleRequest.class.php
r3688 r4897 23 23 * Initializes this sfRequest. 24 24 * 25 * @param sfContext A sfContext instance 26 * @param array An associative array of initialization parameters 27