Changeset 968

Show
Ignore:
Timestamp:
11/03/2007 05:11:03 AM (13 months ago)
Author:
Geert
Message:

Various updates:

  • directory setting in Pagination library allows you to set the path to the view folder that contains your pagination templates, defaults to 'pagination'
  • finished log.threshold functionality
  • other code clean ups
Location:
trunk/system
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/config/log.php

    r866 r968  
    1414 *  2 - Debug Messages 
    1515 *  3 - Informational Messages 
    16  *  4 - All Messages 
    1716 * 
    1817 * Options: 
    19  * threshold  - Message threshold 
     18 * threshold  - Cascading message threshold 
    2019 * directory  - Log file directory, relative to application/, or absolute 
    2120 * format     - PHP date format for timestamps, see: http://php.net/date 
     
    2726$config = array 
    2827( 
    29         'threshold' => 4, 
     28        'threshold' => 1, 
    3029        'directory' => 'logs', 
    3130        'format'    => 'Y-m-d H:i:s' 
  • trunk/system/config/pagination.php

    r866 r968  
    44 * 
    55 * Options: 
    6  *  style          - Style name 
     6 *  directory      - Views folder in which your pagination style templates reside 
     7 *  style          - Style name (matches template filename) 
     8 *  uri_segment    - URI segment (or 'label') in which the current page number can be found 
    79 *  items_per_page - Number of items in a page of results 
    810 */ 
    911$config = array 
    1012( 
     13        'directory'      => 'pagination', 
    1114        'style'          => 'classic', 
     15        'uri_segment'    => 3, 
    1216        'items_per_page' => 20 
    1317); 
  • trunk/system/core/Log.php

    r957 r968  
    1111final class Log { 
    1212 
     13        private static $types = array(1 => 'error', 2 => 'debug', 3 => 'info'); 
    1314        private static $messages = array(); 
    1415 
     
    2324        public static function add($type, $message) 
    2425        { 
    25                 self::$messages[$type][] = array 
     26                self::$messages[strtolower($type)][] = array 
    2627                ( 
    2728                        date(Config::item('log.format')), 
     
    6364                foreach(self::$messages as $type => $data) 
    6465                { 
     66                        if (array_search($type, self::$types) > $threshold) 
     67                                continue; 
     68 
    6569                        foreach($data as $date => $text) 
    6670                        { 
    6771                                list($date, $message) = $text; 
    68                                 $messages .= $date.' --- '.$type.': '.$message."\r\n"; 
     72                                $messages .= $date.' -- '.$type.': '.$message."\r\n"; 
    6973                        } 
    7074                } 
  • trunk/system/libraries/Auth.php

    r958 r968  
    4444                                'username' => $username, 
    4545                                'password' => sha1($password), 
    46                                 'level >=' => $level 
     46                                'level >=' => (int) $level 
    4747                        )) 
    4848                        ->limit(1) 
    4949                        ->get(); 
    5050 
    51                 if (count($result) === 1) 
    52                 { 
    53                         // Get the first result 
    54                         $result = $result->offsetGet(0); 
     51                if (count($result) !== 1) 
     52                        return FALSE; 
    5553 
    56                         // Update the number of logins 
    57                         $this->db 
    58                                 ->set('logins', ($result->logins + 1)) 
    59                                 ->where('id', $result->id) 
    60                                 ->update($this->users_table); 
    61  
    62                         // Store session data 
    63                         $this->session->set(array 
    64                         ( 
    65                                 'user_id'  => $result->id, 
    66                                 'username' => $username, 
    67                                 'level'    => $result->level 
    68                         )); 
    69  
    70                         return TRUE; 
    71                 } 
    72  
    73                 return FALSE; 
     54                // Get the first result 
     55                $result = $result->offsetGet(0); 
     56         
     57                // Update the number of logins 
     58                $this->db 
     59                        ->set('logins', ($result->logins + 1)) 
     60                        ->where('id', (int) $result->id) 
     61                        ->update($this->users_table); 
     62         
     63                // Store session data 
     64                $this->session->set(array 
     65                ( 
     66                        'user_id'  => (int) $result->id, 
     67                        'username' => $username, 
     68                        'level'    => (int) $result->level 
     69                )); 
     70         
     71                return TRUE; 
    7472        } 
    7573 
  • trunk/system/libraries/Pagination.php

    r932 r968  
    1010class Pagination_Core { 
    1111         
    12         public $base_url           = ''; 
    13         public $style              = 'classic'; 
    14         public $uri_segment        = 3; 
    15         public $items_per_page     = 10; 
     12        public $base_url       = ''; 
     13        public $directory      = 'pagination'; 
     14        public $style          = 'classic'; 
     15        public $uri_segment    = 3; 
     16        public $items_per_page = 10; 
    1617         
    1718        public $current_page; 
     
    109110                $style = (isset($style)) ? $style : $this->style; 
    110111                 
    111                 return (string) new View('pagination/'.$style, get_object_vars($this)); 
     112                return (string) new View(trim($this->directory, '/').'/'.$style, get_object_vars($this)); 
    112113        } 
    113114         
     
    119120        /* 
    120121         * Method: url 
    121          *  Get the base_url with the specified page number. 
     122         *  Gets the base_url with the specified page number. 
    122123         * 
    123124         * Parameters: 
     
    136137        /* 
    137138         * Method: sql_offset 
    138          *  Get the SQL offset of the first row to return. 
     139         *  Gets the SQL offset of the first row to return. 
    139140         * 
    140141         * Returns: 
     
    148149        /* 
    149150         * Method: url 
    150          *  Generate the complete SQL LIMIT clause. 
     151         *  Generates the complete SQL LIMIT clause. 
    151152         * 
    152153         * Returns: 
  • trunk/system/libraries/drivers/Database_Mysql.php

    r962 r968  
    161161        public function escape_column($column) 
    162162        { 
    163                 if (strtolower($column) == 'count(*)' or $column == '*') 
     163                if (strtolower($column) == 'count(*)' OR $column == '*') 
    164164                        return $column; 
    165165 
  • trunk/system/libraries/drivers/Database_Pgsql.php

    r828 r968  
    120120                { 
    121121 
    122                         $prefix = (($num_wheres > 0) or ($count++ > 1)) ? $type : ''; 
     122                        $prefix = (($num_wheres > 0) OR ($count++ > 1)) ? $type : ''; 
    123123 
    124124                        if ($quote === -1)