Development

Changeset 4887

You must first sign up to be able to contribute.

Changeset 4887

Show
Ignore:
Timestamp:
08/22/07 19:21:41 (1 year ago)
Author:
fabien
Message:

fixed some coding standards

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/addon/creole/i18n/sfMessageSource_Creole.class.php

    r4597 r4887  
    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 
  • trunk/lib/addon/creole/storage/sfCreoleSessionStorage.class.php

    r4597 r4887  
    113113 
    114114    // 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.'=?'; 
    116116 
    117117    try 
     
    146146 
    147147    // 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; 
    150149 
    151150    try 
     
    210209    try 
    211210    { 
    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.'=?'; 
    213212 
    214213      $stmt = $this->db->prepareStatement($sql); 
     
    220219      { 
    221220        $data = $dbRes->getString(1); 
     221 
    222222        return $data; 
    223223      } 
     
    225225      { 
    226226        // 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 (?,?,?)'; 
    229228 
    230229        $stmt = $this->db->prepareStatement($sql); 
     
    233232        $stmt->setInt(3, time()); 
    234233        $stmt->executeUpdate(); 
     234 
    235235        return ''; 
    236236      } 
     
    261261    $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time'); 
    262262 
    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.'=?'; 
    265264 
    266265    try 
     
    270269      $stmt->setString(2, $id); 
    271270      $stmt->executeUpdate(); 
     271 
    272272      return true; 
    273273    } 
     
    289289  { 
    290290  } 
    291  
    292291} 
  • trunk/lib/database/sfMySQLDatabase.class.php

    r4597 r4887  
    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) 
  • trunk/lib/database/sfPDODatabase.class.php

    r4597 r4887  
    6868      $this->connection->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); 
    6969    } 
     70 
     71    $this->resource = $this->connection; 
    7072  } 
    7173 
     
    7981  public function shutdown() 
    8082  { 
    81     if ($this->connection !== null) 
    82     { 
    83       $this->connection = null; 
    84     } 
     83    $this->connection = null; 
    8584  } 
    8685} 
  • trunk/lib/request/sfWebRequest.class.php

    r4643 r4887  
    475475    { 
    476476      // routing map defined? 
    477       $r = sfContext::getInstance()->getRouting(); 
     477      $r = $this->context->getRouting(); 
    478478      if ($r->hasRoutes()) 
    479479      { 
  • trunk/lib/routing/sfPatternRouting.class.php

    r4602 r4887  
    6565    if (is_null($this->currentInternalUri)) 
    6666    { 
    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]; 
    6868 
    6969      $request = $this->context->getRequest(); 
     
    7171      if ($with_route_name) 
    7272      { 
    73         $internal_uri = '@'.$this->currentRouteName; 
     73        $internalUri = '@'.$this->currentRouteName; 
    7474      } 
    7575      else 
    7676      { 
    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'] : ''); 
    7878      } 
    7979 
     
    105105      sort($params); 
    106106 
    107       $this->currentInternalUri = $internal_uri.($params ? '?'.implode('&', $params) : ''); 
     107      $this->currentInternalUri = $internalUri.($params ? '?'.implode('&', $params) : ''); 
    108108    } 
    109109 
     
    228228 
    229229    // used for performance reasons 
    230     $names_hash = array(); 
     230    $namesHash = array(); 
    231231 
    232232    $r = null; 
     
    293293          $parsed[] = '(?:\/('.$regex.'))?'; 
    294294          $names[] = $element; 
    295           $names_hash[$element] = 1; 
     295          $namesHash[$element] = 1; 
    296296        } 
    297297        elseif (preg_match('/^\*$/', $element, $r)) 
     
    306306      $regexp = '#^'.join('', $parsed).$regexp_suffix.'$#'; 
    307307 
    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); 
    309309    } 
    310310 
     
    328328  public function generate($name, $params, $querydiv = '/', $divider = '/', $equals = '/') 
    329329  { 
    330     $global_defaults = sfConfig::get('sf_routing_defaults', null); 
     330    $globalDefaults = sfConfig::get('sf_routing_defaults', null); 
    331331 
    332332    // named route? 
     
    338338      } 
    339339 
    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); 
    344344      } 
    345345 
     
    359359      foreach ($this->routes as $name => $route) 
    360360      { 
    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); 
    365365        } 
    366366 
     
    376376        foreach ($defaults as $key => $value) 
    377377        { 
    378           if (isset($names_hash[$key])) continue; 
     378          if (isset($namesHash[$key])) continue; 
    379379 
    380380          if (!isset($tparams[$key]) || $tparams[$key] != $value) continue 2; 
     
    412412    $params = array_merge($defaults, $params); 
    413413 
    414     $real_url = preg_replace('/\:([^\/]+)/e', 'urlencode($params["\\1"])', $url); 
     414    $realUrl = preg_replace('/\:([^\/]+)/e', 'urlencode($params["\\1"])', $url); 
    415415 
    416416    // we add all other params if * 
    417     if (strpos($real_url, '*')) 
     417    if (strpos($realUrl, '*')) 
    418418    { 
    419419      $tmp = array(); 
    420420      foreach ($params as $key => $value) 
    421421      { 
    422         if (isset($names_hash[$key]) || isset($defaults[$key])) continue; 
     422        if (isset($namesHash[$key]) || isset($defaults[$key])) continue; 
    423423 
    424424        if (is_array($value)) 
     
    439439        $tmp = $querydiv.$tmp; 
    440440      } 
    441       $real_url = preg_replace('/\/\*(\/|$)/', "$tmp$1", $real_url); 
     441      $realUrl = preg_replace('/\/\*(\/|$)/', "$tmp$1", $realUrl); 
    442442    } 
    443443 
    444444    // 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; 
    456456  } 
    457457 
     
    486486      $r = null; 
    487487 
    488       list($route, $regexp, $names, $names_hash, $defaults, $requirements, $suffix) = $route; 
     488      list($route, $regexp, $names, $namesHash, $defaults, $requirements, $suffix) = $route; 
    489489 
    490490      $break = false; 
     
    539539            { 
    540540              // 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])) 
    542542              { 
    543543                $out[$key] = $value; 
  • trunk/lib/storage/sfMySQLSessionStorage.class.php

    r4597 r4887  
    163163 
    164164    // 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(); 
    169166 
    170167    return true; 
  • trunk/lib/storage/sfPDOSessionStorage.class.php

    r4593 r4887  
    170170    $database = $this->getParameterHolder()->get('database', 'default'); 
    171171 
    172     $this->db = $this->context->getDatabaseConnection($database); 
     172    $this->db = $this->context->getDatabaseManager()->getDatabase($database)->getResource(); 
    173173    if ($this->db == null || !$this->db instanceof PDO) 
    174174    { 
  • trunk/lib/storage/sfPostgreSQLSessionStorage.class.php

    r4597 r4887  
    162162 
    163163    // 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(); 
    168165 
    169166    return true; 
  • trunk/lib/storage/sfSessionStorage.class.php

    r3329 r4887  
    4646    session_name($sessionName); 
    4747 
    48     $use_cookies = (boolean) ini_get('session.use_cookies'); 
    49     if (!$use_cookies) 
     48    if (!(boolean) ini_get('session.use_cookies')) 
    5049    { 
    5150      $sessionId = $context->getRequest()->getParameter($sessionName, ''); 
  • trunk/lib/util/sfContext.class.php

    r4885 r4887  
    163163  public function getDatabaseConnection($name = 'default') 
    164164  { 
    165     if ($this->factories['databaseManager'] != null
     165    if (!is_null($this->factories['databaseManager'])
    166166    { 
    167167      return $this->factories['databaseManager']->getDatabase($name)->getConnection();