Changeset 4887
- Timestamp:
- 08/22/07 19:21:41 (1 year ago)
- Files:
-
- trunk/lib/addon/creole/i18n/sfMessageSource_Creole.class.php (modified) (13 diffs)
- trunk/lib/addon/creole/storage/sfCreoleSessionStorage.class.php (modified) (9 diffs)
- trunk/lib/database/sfMySQLDatabase.class.php (modified) (2 diffs)
- trunk/lib/database/sfPDODatabase.class.php (modified) (2 diffs)
- trunk/lib/request/sfWebRequest.class.php (modified) (1 diff)
- trunk/lib/routing/sfPatternRouting.class.php (modified) (14 diffs)
- trunk/lib/storage/sfMySQLSessionStorage.class.php (modified) (1 diff)
- trunk/lib/storage/sfPDOSessionStorage.class.php (modified) (1 diff)
- trunk/lib/storage/sfPostgreSQLSessionStorage.class.php (modified) (1 diff)
- trunk/lib/storage/sfSessionStorage.class.php (modified) (1 diff)
- trunk/lib/util/sfContext.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/addon/creole/i18n/sfMessageSource_Creole.class.php
r4597 r4887 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 trunk/lib/addon/creole/storage/sfCreoleSessionStorage.class.php
r4597 r4887 113 113 114 114 // delete the record associated with this id 115 $sql = 'DELETE FROM ' . $db_table . ' WHERE ' . $db_id_col .'=?';115 $sql = 'DELETE FROM '.$db_table.' WHERE '.$db_id_col.'=?'; 116 116 117 117 try … … 146 146 147 147 // delete the record associated with this id 148 $sql = 'DELETE FROM ' . $db_table . ' ' . 149 'WHERE ' . $db_time_col . ' < ' . $time; 148 $sql = 'DELETE FROM '.$db_table.' '.'WHERE '.$db_time_col.' < '.$time; 150 149 151 150 try … … 210 209 try 211 210 { 212 $sql = 'SELECT ' . $db_data_col . ' FROM ' . $db_table . ' WHERE ' . $db_id_col .'=?';211 $sql = 'SELECT '.$db_data_col.' FROM '.$db_table.' WHERE '.$db_id_col.'=?'; 213 212 214 213 $stmt = $this->db->prepareStatement($sql); … … 220 219 { 221 220 $data = $dbRes->getString(1); 221 222 222 return $data; 223 223 } … … 225 225 { 226 226 // session does not exist, create it 227 $sql = 'INSERT INTO ' . $db_table . '('.$db_id_col.','.$db_data_col.','.$db_time_col; 228 $sql .= ') VALUES (?,?,?)'; 227 $sql = 'INSERT INTO '.$db_table.'('.$db_id_col.','.$db_data_col.','.$db_time_col.') VALUES (?,?,?)'; 229 228 230 229 $stmt = $this->db->prepareStatement($sql); … … 233 232 $stmt->setInt(3, time()); 234 233 $stmt->executeUpdate(); 234 235 235 return ''; 236 236 } … … 261 261 $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time'); 262 262 263 $sql = 'UPDATE ' . $db_table . ' SET ' . $db_data_col . '=?, ' . $db_time_col . ' = ' . time() . 264 ' WHERE ' . $db_id_col . '=?'; 263 $sql = 'UPDATE '.$db_table.' SET '.$db_data_col.'=?, '.$db_time_col.' = '.time().' WHERE '.$db_id_col.'=?'; 265 264 266 265 try … … 270 269 $stmt->setString(2, $id); 271 270 $stmt->executeUpdate(); 271 272 272 return true; 273 273 } … … 289 289 { 290 290 } 291 292 291 } trunk/lib/database/sfMySQLDatabase.class.php
r4597 r4887 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) trunk/lib/database/sfPDODatabase.class.php
r4597 r4887 68 68 $this->connection->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); 69 69 } 70 71 $this->resource = $this->connection; 70 72 } 71 73 … … 79 81 public function shutdown() 80 82 { 81 if ($this->connection !== null) 82 { 83 $this->connection = null; 84 } 83 $this->connection = null; 85 84 } 86 85 } trunk/lib/request/sfWebRequest.class.php
r4643 r4887 475 475 { 476 476 // routing map defined? 477 $r = sfContext::getInstance()->getRouting();477 $r = $this->context->getRouting(); 478 478 if ($r->hasRoutes()) 479 479 { trunk/lib/routing/sfPatternRouting.class.php
r4602 r4887 65 65 if (is_null($this->currentInternalUri)) 66 66 { 67 list($url, $regexp, $names, $names _hash, $defaults, $requirements, $suffix) = $this->routes[$this->currentRouteName];67 list($url, $regexp, $names, $namesHash, $defaults, $requirements, $suffix) = $this->routes[$this->currentRouteName]; 68 68 69 69 $request = $this->context->getRequest(); … … 71 71 if ($with_route_name) 72 72 { 73 $internal _uri = '@'.$this->currentRouteName;73 $internalUri = '@'.$this->currentRouteName; 74 74 } 75 75 else 76 76 { 77 $internal _uri = $request->getParameter('module', isset($defaults['module']) ? $defaults['module'] : '').'/'.$request->getParameter('action', isset($defaults['action']) ? $defaults['action'] : '');77 $internalUri = $request->getParameter('module', isset($defaults['module']) ? $defaults['module'] : '').'/'.$request->getParameter('action', isset($defaults['action']) ? $defaults['action'] : ''); 78 78 } 79 79 … … 105 105 sort($params); 106 106 107 $this->currentInternalUri = $internal _uri.($params ? '?'.implode('&', $params) : '');107 $this->currentInternalUri = $internalUri.($params ? '?'.implode('&', $params) : ''); 108 108 } 109 109 … … 228 228 229 229 // used for performance reasons 230 $names _hash = array();230 $namesHash = array(); 231 231 232 232 $r = null; … … 293 293 $parsed[] = '(?:\/('.$regex.'))?'; 294 294 $names[] = $element; 295 $names _hash[$element] = 1;295 $namesHash[$element] = 1; 296 296 } 297 297 elseif (preg_match('/^\*$/', $element, $r)) … … 306 306 $regexp = '#^'.join('', $parsed).$regexp_suffix.'$#'; 307 307 308 $this->routes[$name] = array($route, $regexp, $names, $names _hash, $default, $requirements, $suffix);308 $this->routes[$name] = array($route, $regexp, $names, $namesHash, $default, $requirements, $suffix); 309 309 } 310 310 … … 328 328 public function generate($name, $params, $querydiv = '/', $divider = '/', $equals = '/') 329 329 { 330 $global _defaults = sfConfig::get('sf_routing_defaults', null);330 $globalDefaults = sfConfig::get('sf_routing_defaults', null); 331 331 332 332 // named route? … … 338 338 } 339 339 340 list($url, $regexp, $names, $names _hash, $defaults, $requirements, $suffix) = $this->routes[$name];341 if ($global _defaults !== null)342 { 343 $defaults = array_merge($defaults, $global _defaults);340 list($url, $regexp, $names, $namesHash, $defaults, $requirements, $suffix) = $this->routes[$name]; 341 if ($globalDefaults !== null) 342 { 343 $defaults = array_merge($defaults, $globalDefaults); 344 344 } 345 345 … … 359 359 foreach ($this->routes as $name => $route) 360 360 { 361 list($url, $regexp, $names, $names _hash, $defaults, $requirements, $suffix) = $route;362 if ($global _defaults !== null)363 { 364 $defaults = array_merge($defaults, $global _defaults);361 list($url, $regexp, $names, $namesHash, $defaults, $requirements, $suffix) = $route; 362 if ($globalDefaults !== null) 363 { 364 $defaults = array_merge($defaults, $globalDefaults); 365 365 } 366 366 … … 376 376 foreach ($defaults as $key => $value) 377 377 { 378 if (isset($names _hash[$key])) continue;378 if (isset($namesHash[$key])) continue; 379 379 380 380 if (!isset($tparams[$key]) || $tparams[$key] != $value) continue 2; … … 412 412 $params = array_merge($defaults, $params); 413 413 414 $real _url = preg_replace('/\:([^\/]+)/e', 'urlencode($params["\\1"])', $url);414 $realUrl = preg_replace('/\:([^\/]+)/e', 'urlencode($params["\\1"])', $url); 415 415 416 416 // we add all other params if * 417 if (strpos($real _url, '*'))417 if (strpos($realUrl, '*')) 418 418 { 419 419 $tmp = array(); 420 420 foreach ($params as $key => $value) 421 421 { 422 if (isset($names _hash[$key]) || isset($defaults[$key])) continue;422 if (isset($namesHash[$key]) || isset($defaults[$key])) continue; 423 423 424 424 if (is_array($value)) … … 439 439 $tmp = $querydiv.$tmp; 440 440 } 441 $real _url = preg_replace('/\/\*(\/|$)/', "$tmp$1", $real_url);441 $realUrl = preg_replace('/\/\*(\/|$)/', "$tmp$1", $realUrl); 442 442 } 443 443 444 444 // strip off last divider character 445 if (strlen($real _url) > 1)446 { 447 $real _url = rtrim($real_url, $divider);448 } 449 450 if ($real _url != '/')451 { 452 $real _url .= $suffix;453 } 454 455 return $real _url;445 if (strlen($realUrl) > 1) 446 { 447 $realUrl = rtrim($realUrl, $divider); 448 } 449 450 if ($realUrl != '/') 451 { 452 $realUrl .= $suffix; 453 } 454 455 return $realUrl; 456 456 } 457 457 … … 486 486 $r = null; 487 487 488 list($route, $regexp, $names, $names _hash, $defaults, $requirements, $suffix) = $route;488 list($route, $regexp, $names, $namesHash, $defaults, $requirements, $suffix) = $route; 489 489 490 490 $break = false; … … 539 539 { 540 540 // we add this parameters if not in conflict with named url element (i.e. ':action') 541 if (!isset($names _hash[$key]))541 if (!isset($namesHash[$key])) 542 542 { 543 543 $out[$key] = $value; trunk/lib/storage/sfMySQLSessionStorage.class.php
r4597 r4887 163 163 164 164 // get the database resource 165 $this->resource = $this->context 166 ->getDatabaseManager() 167 ->getDatabase($database) 168 ->getResource(); 165 $this->resource = $this->context->getDatabaseManager()->getDatabase($database)->getResource(); 169 166 170 167 return true; trunk/lib/storage/sfPDOSessionStorage.class.php
r4593 r4887 170 170 $database = $this->getParameterHolder()->get('database', 'default'); 171 171 172 $this->db = $this->context->getDatabase Connection($database);172 $this->db = $this->context->getDatabaseManager()->getDatabase($database)->getResource(); 173 173 if ($this->db == null || !$this->db instanceof PDO) 174 174 { trunk/lib/storage/sfPostgreSQLSessionStorage.class.php
r4597 r4887 162 162 163 163 // get the database resource 164 $this->resource = $this->context 165 ->getDatabaseManager() 166 ->getDatabase($database) 167 ->getResource(); 164 $this->resource = $this->context->getDatabaseManager()->getDatabase($database)->getResource(); 168 165 169 166 return true; trunk/lib/storage/sfSessionStorage.class.php
r3329 r4887 46 46 session_name($sessionName); 47 47 48 $use_cookies = (boolean) ini_get('session.use_cookies'); 49 if (!$use_cookies) 48 if (!(boolean) ini_get('session.use_cookies')) 50 49 { 51 50 $sessionId = $context->getRequest()->getParameter($sessionName, ''); trunk/lib/util/sfContext.class.php
r4885 r4887 163 163 public function getDatabaseConnection($name = 'default') 164 164 { 165 if ( $this->factories['databaseManager'] != null)165 if (!is_null($this->factories['databaseManager'])) 166 166 { 167 167 return $this->factories['databaseManager']->getDatabase($name)->getConnection();