Changeset 2593

Show
Ignore:
Timestamp:
04/28/08 16:04:22 (3 months ago)
Author:
Geert
Message:

CodingStyle maintenance!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/application/controllers/examples.php

    r2581 r2593  
    3535                echo "<ul>\n"; 
    3636 
    37                 foreach($examples as $method) 
     37                foreach ($examples as $method) 
    3838                { 
    3939                        if ($method == __FUNCTION__) 
     
    202202                        echo $db->last_query(); 
    203203                        echo '<h3>Iterate through the result:</h3>'; 
    204                         foreach($query as $item) 
     204                        foreach ($query as $item) 
    205205                        { 
    206206                                echo '<p>'.$item->title.'</p>'; 
     
    214214                        echo '<p>'.$db->last_query().'</p>'; 
    215215                        $query->result(TRUE); 
    216                         foreach($query as $item) 
     216                        foreach ($query as $item) 
    217217                        { 
    218218                                echo '<pre>'.print_r($item, true).'</pre>'; 
     
    224224                        echo '<p>'.$db->last_query().'</p>'; 
    225225                        $query->result(FALSE, MYSQL_BOTH); 
    226                         foreach($query as $item) 
     226                        foreach ($query as $item) 
    227227                        { 
    228228                                echo '<pre>'.print_r($item, true).'</pre>'; 
     
    297297        function user_agent() 
    298298        { 
    299                 foreach(array('agent', 'browser', 'version') as $key) 
     299                foreach (array('agent', 'browser', 'version') as $key) 
    300300                { 
    301301                        echo $key.': '.Kohana::user_agent($key).'<br/>'."\n"; 
  • trunk/application/controllers/welcome.php

    r2440 r2593  
    1313        // Disable this controller when Kohana is set to production mode. 
    1414        // See http://doc.kohanaphp.com/installation/deployment for more details. 
    15         const ALLOW_PRODUCTION = FALSE; 
     15        // const ALLOW_PRODUCTION = FALSE; 
    1616 
    17         public function index() 
     17        public function __construct() 
    1818        { 
    19                 // In Kohana, all views are loaded and treated as objects. 
    20                 $welcome = new View('welcome'); 
     19                parent::__construct(); 
     20                new Profiler; 
     21/* 
     22                $pdo = pdomo::registry('default', new PDO(Config::item('pdodb'))); 
     23                echo Kohana::debug($pdo); 
    2124 
    22                 // You can assign anything variable to a view by using standard OOP 
    23                 // methods. In my welcome view, the $title variable will be assigned 
    24                 // the value I give it here. 
    25                 $welcome->title = 'Welcome to Kohana!'
     25                $query = $pdo->prepare('SELECT * FROM :table'); 
     26                $query->bindValue(':table', 'users'); 
     27                $query->setFetchMode(PDO::FETCH_NUM); 
     28                $x = $query->fetch(PDO::FETCH_OBJ)
    2629 
    27                 // An array of links to display. Assiging variables to views is completely 
    28                 // asyncronous. Variables can be set in any order, and can be any type 
    29                 // of data, including objects. 
    30                 $welcome->links = array 
    31                 ( 
    32                         'Home Page'     => 'http://kohanaphp.com/', 
    33                         'Documentation' => 'http://doc.kohanaphp.com/', 
    34                         'Forum'         => 'http://forum.kohanaphp.com/', 
    35                         'License'       => 'Kohana License.html', 
    36                         'Donate'        => 'http://kohanaphp.com/donate.html', 
    37                 ); 
     30                echo Kohana::debug($x); 
    3831 
    39                 // Using views inside of views is completely transparent. In the welcome 
    40                 // view, printing the $content variable will render the welcome_content view. 
    41                 $welcome->content = new View('welcome_content'); 
    42  
    43                 // Using render(TRUE) forces the view to display now, instead of 
    44                 // returning an HTML string. 
    45                 $welcome->render(TRUE); 
     32                foreach ($query as $row) 
     33                { 
     34                        echo $row[0], ', ', $row[1], '<br />'; 
     35                } 
     36*/ 
    4637        } 
    4738 
    4839        public function _default() 
    4940        { 
    50                 // By defining a method called _default, all pages routed to this controller 
    51                 // that result in 404 errors will be handled by this method, instead of 
    52                 // being displayed as "Page Not Found" errors. 
    53                 echo 'This is a _default handler. If you expected the index page, you need to use: welcome/index/'.substr(Router::$current_uri, 8); 
     41                echo html::email('geertdd@gmail.com'); 
     42                echo html::mailto('geert@link.com'); 
    5443        } 
    5544 
     45        public function pdo() 
     46        { 
     47                $dbh = new PDO('mysql:host=localhost;dbname=kohana', 'root', 'html123'); 
     48/* 
     49                echo Kohana::debug($dbh); 
     50 
     51                $query = $dbh->query('SELECT * FROM users LIMIT 3'); 
     52                $query = $dbh->query('SELECT COUNT(*) FROM users ORDER BY id DESC LIMIT 3'); 
     53                echo Kohana::debug($query); 
     54                echo Kohana::debug($query->queryString); 
     55                // $query = $query->fetchAll(PDO::FETCH_OBJ); 
     56                echo Kohana::debug($query); 
     57                foreach ($query as $row) 
     58                { 
     59                        echo Kohana::debug($row); 
     60                } 
     61 
     62                $query = $dbh->exec('DELETE FROM users WHERE id = 2'); 
     63                echo Kohana::debug($query); 
     64 
     65                $query = $dbh->prepare('INSERT INTO users (email, username) VALUES (?, ?)'); 
     66                $query->bindParam(1, $email); 
     67                $query->bindParam(2, $username); 
     68                $email = 'joske3@host.com'; 
     69                $username = 'josse3'; 
     70                $execute = $query->execute(array($email, $username)); 
     71                echo Kohana::debug($execute); 
     72 
     73                $id = $dbh->lastInsertId(); 
     74                echo Kohana::debug($id); 
     75*/ 
     76                $query = $dbh->prepare('SELECT ? FROM users WHERE id = ?'); 
     77                echo Kohana::debug($query); 
     78                $query->bindValue(1, 'username'); 
     79                $query->bindValue(2, 3); 
     80                 
     81                $query->execute(); 
     82                $result = $query->fetchAll(PDO::FETCH_OBJ); 
     83                echo Kohana::debug($result); 
     84                foreach ($result as $row) 
     85                { 
     86                        echo $row->username; 
     87                } 
     88                echo Kohana::debug($query->rowCount()); 
     89        } 
    5690} 
  • trunk/modules/auth/controllers/auth_demo.php

    r2578 r2593  
    4646                        if ( ! $user->username_exists($this->input->post('username'))) 
    4747                        { 
    48                                 foreach($form->as_array() as $key => $val) 
     48                                foreach ($form->as_array() as $key => $val) 
    4949                                { 
    5050                                        // Set user data 
  • trunk/modules/auth/libraries/Auth.php

    r2471 r2593  
    175175                $last_offset = 0; 
    176176 
    177                 foreach($this->config['salt_pattern'] as $offset) 
     177                foreach ($this->config['salt_pattern'] as $offset) 
    178178                { 
    179179                        // Split a new part of the hash off 
     
    215215                $salt = ''; 
    216216 
    217                 foreach($this->config['salt_pattern'] as $i => $offset) 
     217                foreach ($this->config['salt_pattern'] as $i => $offset) 
    218218                { 
    219219                        // Find salt characters... take a good long look.. 
  • trunk/modules/auth/models/user.php

    r2452 r2593  
    5353                        if ($this->id > 0) 
    5454                        { 
    55                                 foreach($this->find_related_roles() as $r) 
     55                                foreach ($this->find_related_roles() as $r) 
    5656                                { 
    5757                                        // Load all the user roles 
  • trunk/modules/forge/libraries/Forge.php

    r2460 r2593  
    8888 
    8989                // Create the input 
    90                 switch(count($args)) 
     90                switch (count($args)) 
    9191                { 
    9292                        case 1: 
     
    155155        { 
    156156                $status = TRUE; 
    157                 foreach($this->inputs as $input) 
     157                foreach ($this->inputs as $input) 
    158158                { 
    159159                        if ($input->validate() == FALSE) 
     
    174174        { 
    175175                $data = array(); 
    176                 foreach(array_merge($this->hidden, $this->inputs) as $input) 
     176                foreach (array_merge($this->hidden, $this->inputs) as $input) 
    177177                { 
    178178                        if (is_object($input->name)) // It's a Forge_Group object (hopefully) 
     
    251251                                if (is_array($errors) AND ! empty($errors)) 
    252252                                { 
    253                                         foreach($errors as $error) 
     253                                        foreach ($errors as $error) 
    254254                                        { 
    255255                                                // Replace the message with the error in the html error string 
     
    271271                        if ( ! empty($this->hidden)) 
    272272                        { 
    273                                 foreach($this->hidden as $input) 
     273                                foreach ($this->hidden as $input) 
    274274                                { 
    275275                                        $hidden[$input->name] = $input->value; 
  • trunk/modules/forge/libraries/Form_Checklist.php

    r2022 r2593  
    3333                        // Return the currently checked values 
    3434                        $array = array(); 
    35                         foreach($this->data['options'] as $id => $opt) 
     35                        foreach ($this->data['options'] as $id => $opt) 
    3636                        { 
    3737                                // Return the options that are checked 
     
    5656 
    5757                $checklist = '<ul class="'.arr::remove('class', $base_data).'">'.$nl; 
    58                 foreach(arr::remove('options', $base_data) as $val => $opt) 
     58                foreach (arr::remove('options', $base_data) as $val => $opt) 
    5959                { 
    6060                        // New set of input data 
     
    7777        protected function load_value() 
    7878        { 
    79                 foreach($this->data['options'] as $val => $checked) 
     79                foreach ($this->data['options'] as $val => $checked) 
    8080                { 
    8181                        if ($input = $this->input_value($this->data['name'])) 
  • trunk/modules/forge/libraries/Form_Dateselect.php

    r1923 r2593  
    6666 
    6767                $input = ''; 
    68                 foreach($this->parts as $type => $val) 
     68                foreach ($this->parts as $type => $val) 
    6969                { 
    7070                        if (is_int($type)) 
  • trunk/modules/forge/libraries/Form_Input.php

    r2362 r2593  
    221221                } 
    222222 
    223                 foreach($rules as $rule) 
     223                foreach ($rules as $rule) 
    224224                { 
    225225                        if ($action === '-') 
     
    306306 
    307307                $messages = array(); 
    308                 foreach($this->errors as $func => $args) 
     308                foreach ($this->errors as $func => $args) 
    309309                { 
    310310                        if (is_string($args)) 
     
    328328                                { 
    329329                                        // Get the proper i18n entry, very hacky but it works 
    330                                         switch($func) 
     330                                        switch ($func) 
    331331                                        { 
    332332                                                case 'valid_url': 
     
    428428                if ( ! empty($this->rules)) 
    429429                { 
    430                         foreach($this->rules as $rule) 
     430                        foreach ($this->rules as $rule) 
    431431                        { 
    432432                                if (($offset = strpos($rule, '[')) !== FALSE) 
     
    456456                                        { 
    457457                                                // Manually call up to 2 args for speed 
    458                                                 switch(count($args)) 
     458                                                switch (count($args)) 
    459459                                                { 
    460460                                                        case 1: 
     
    491491                if ( ! empty($this->matches)) 
    492492                { 
    493                         foreach($this->matches as $input) 
     493                        foreach ($this->matches as $input) 
    494494                        { 
    495495                                if ($this->value != $input->value) 
     
    504504                if ( ! empty($this->callbacks)) 
    505505                { 
    506                         foreach($this->callbacks as $callback) 
     506                        foreach ($this->callbacks as $callback) 
    507507                        { 
    508508                                call_user_func($callback, $this); 
     
    551551                                $this->errors['min_length'] = array($min); 
    552552                        } 
    553                         elseif($length > $max) 
     553                        elseif ($length > $max) 
    554554                        { 
    555555                                $this->errors['max_length'] = array($max); 
  • trunk/modules/forge/libraries/Form_Phonenumber.php

    r2222 r2593  
    5252 
    5353                $input = ''; 
    54                 foreach($this->parts as $type => $val) 
     54                foreach ($this->parts as $type => $val) 
    5555                { 
    5656                        isset($data['value']) OR $data['value'] = ''; 
  • trunk/modules/forge/models/user_edit.php

    r2580 r2593  
    3636                //  
    3737                // $options = array(); 
    38                 // foreach($roles as $role) 
     38                // foreach ($roles as $role) 
    3939                // { 
    4040                //      // Add each role to the options 
     
    7979                        isset($data['roles']) and $roles = arr::remove('roles', $data); 
    8080 
    81                         foreach($data as $field => $val) 
     81                        foreach ($data as $field => $val) 
    8282                        { 
    8383                                // Set object data from the form 
     
    8989                                // if ($new_user) 
    9090                                // { 
    91                                 //      foreach($roles as $role) 
     91                                //      foreach ($roles as $role) 
    9292                                //      { 
    9393                                //              // Add the user roles 
     
    9797                                // else 
    9898                                // { 
    99                                 //      foreach(array_diff($this->roles, $roles) as $role) 
     99                                //      foreach (array_diff($this->roles, $roles) as $role) 
    100100                                //      { 
    101101                                //              // Remove roles that were deactivated 
     
    103103                                //      } 
    104104                                //  
    105                                 //      foreach(array_diff($roles, $this->roles) as $role) 
     105                                //      foreach (array_diff($roles, $this->roles) as $role) 
    106106                                //      { 
    107107                                //              // Add new roles 
  • trunk/modules/forge/views/forge_template.php

    r2027 r2593  
    55<?php endif ?> 
    66<?php 
    7 foreach($inputs as $input): 
     7foreach ($inputs as $input): 
    88 
    99$sub_inputs = array(); 
     
    3131endif; 
    3232 
    33 foreach($sub_inputs as $input): 
     33foreach ($sub_inputs as $input): 
    3434 
    3535?> 
  • trunk/modules/kodoc/controllers/kodoc.php

    r2229 r2593  
    7777                                else 
    7878                                { 
    79                                         foreach(array_reverse(Config::include_paths()) as $path) 
     79                                        foreach (array_reverse(Config::include_paths()) as $path) 
    8080                                        { 
    8181                                                if (is_file($path.$type.'/'.$file.EXT)) 
  • trunk/modules/kodoc/libraries/Kodoc.php

    r1364 r2593  
    3535 
    3636                $files = array(); 
    37                 foreach(self::$types as $type) 
     37                foreach (self::$types as $type) 
    3838                { 
    3939                        $files[$type] = array(); 
    40                         foreach(Kohana::list_files($type, TRUE) as $file) 
     40                        foreach (Kohana::list_files($type, TRUE) as $file) 
    4141                        { 
    4242                                // Not a source file 
     
    169169                $data = file($filename); 
    170170 
    171                 foreach($data as $line) 
     171                foreach ($data as $line) 
    172172                { 
    173173                        if (strpos($line, 'class') !== FALSE AND preg_match('/(?:class|interface)\s+([a-z0-9_]+).+{$/i', $line, $matches)) 
     
    186186                        $source = NULL; 
    187187 
    188                         foreach($data as $line) 
    189                         { 
    190                                 switch(substr(trim($line), 0, 2)) 
     188                        foreach ($data as $line) 
     189                        { 
     190                                switch (substr(trim($line), 0, 2)) 
    191191                                { 
    192192                                        case '/*': 
     
    284284                        $about = ''; 
    285285 
    286                         foreach($comment['about'] as $line) 
     286                        foreach ($comment['about'] as $line) 
    287287                        { 
    288288                                if (strpos($line, '`') !== FALSE) 
     
    377377                if ($implements = $reflection->getInterfaces()) 
    378378                { 
    379                         foreach($implements as $interface) 
     379                        foreach ($implements as $interface) 
    380380                        { 
    381381                                // Get implemented interfaces 
     
    392392                if ($methods = $reflection->getMethods()) 
    393393                { 
    394                         foreach($methods as $method) 
     394                        foreach ($methods as $method) 
    395395                        { 
    396396                                // Don't try to document internal methods 
     
    426426                if ($parameters = $method->getParameters()) 
    427427                { 
    428                         foreach($parameters as $param) 
     428                        foreach ($parameters as $param) 
    429429                        { 
    430430                                // Parameter data 
     
    523523                } 
    524524 
    525                 foreach($this->files as $type => $files) 
    526                 { 
    527                         foreach(Kohana::list_files($type) as $filepath) 
     525                foreach ($this->files as $type => $files) 
     526                { 
     527                        foreach (Kohana::list_files($type) as $filepath) 
    528528                        { 
    529529                                // Get the filename with no extension 
     
    547547        public function get_docs($format = 'html') 
    548548        { 
    549                 switch($format) 
     549                switch ($format) 
    550550                { 
    551551                        default: 
     
    635635                                else 
    636636                                { 
    637                                         switch(substr(trim($line), 0, 2)) 
     637                                        switch (substr(trim($line), 0, 2)) 
    638638                                        { 
    639639                                                case '//': 
  • trunk/modules/kodoc/views/kodoc/class.php

    r1522 r2593  
    3232<?php 
    3333 
    34         foreach($methods as $method): 
     34        foreach ($methods as $method): 
    3535 
    3636                echo new View('kodoc/method', $method); 
  • trunk/modules/kodoc/views/kodoc/documentation.php

    r1330 r2593  
    1818if ( ! empty($docs['comments'])): 
    1919 
    20         foreach($docs['comments'] as $comment): 
     20        foreach ($docs['comments'] as $comment): 
    2121                if ($docs['type'] === 'config'): 
    2222 
     
    3232if ( ! empty($docs['classes'])): 
    3333 
    34         foreach($docs['classes'] as $class): 
     34        foreach ($docs['classes'] as $class): 
    3535 
    3636                echo new View('kodoc/class', $class); 
  • trunk/modules/kodoc/views/kodoc/file_config.php

    r1522 r2593  
    1616 
    1717if ( ! empty($note)): 
    18         foreach($note as $n): 
     18        foreach ($note as $n): 
    1919 
    2020?> 
  • trunk/modules/kodoc/views/kodoc/menu.php

    r1330 r2593  
    33<?php 
    44 
    5 foreach(Kodoc::get_files() as $group => $files): 
     5foreach (Kodoc::get_files() as $group => $files): 
    66 
    77?> 
     
    99<?php 
    1010 
    11 foreach($files as $name => $drivers): 
     11foreach ($files as $name => $drivers): 
    1212 
    1313?> 
     
    2121<?php 
    2222 
    23 foreach($drivers as $driver): 
     23foreach ($drivers as $driver): 
    2424 
    2525        $file = ($name === $driver) ? $driver : $name.'_'.$driver; 
  • trunk/modules/kodoc/views/kodoc/method.php

    r1522 r2593  
    3131<?php 
    3232 
    33         foreach($parameters as $i => $param): 
     33        foreach ($parameters as $i => $param): 
    3434 
    3535        if ( ! empty($comment['param'][$i])): 
     
    8080endif; 
    8181if ( ! empty($comment)): 
    82         foreach($comment as $tag => $vals): 
     82        foreach ($comment as $tag => $vals): 
    8383 
    84                 switch($tag): 
     84                switch ($tag): 
    8585                        case 'throws': 
    8686                        case 'return': 
    87                                 foreach($vals as $i => $val): 
     87                                foreach ($vals as $i => $val): 
    8888                                        if (strpos($val, ' ') !== FALSE): 
    8989 
  • trunk/modules/user_guide/controllers/user_guide.php

    r2229 r2593  
    102102                $tag  = $tag[1]; 
    103103 
    104                 switch($tag) 
     104                switch ($tag) 
    105105                { 
    106106                        case 'benchmark': 
  • trunk/modules/user_guide/views/user_guide/template.php

    r1525 r2593  
    4242<?php 
    4343 
    44 foreach(Kohana::lang('user_guide_menu') as $cat => $menu): 
     44foreach (Kohana::lang('user_guide_menu') as $cat => $menu): 
    4545 
    4646        $active = (strtolower($cat) == $category) ? ' active' : ''; 
     
    5050<?php 
    5151 
    52         foreach($menu as $sec): 
     52        foreach ($menu as $sec): 
    5353 
    5454                $active = (strtolower($sec) == $section) ? 'lite' : ''; 
  • trunk/system/config/session.php

    r2013 r2593  
    2828 * Note: the cookie driver always encrypts session data. Set to TRUE for stronger encryption. 
    2929 */ 
    30 $config['encryption'] = FALSE; 
     30$config['encryption'] = TRUE; 
    3131 
    3232/** 
  • trunk/system/core/Benchmark.php

    r1767 r2593  
    6363                        $times = array(); 
    6464 
    65                         foreach(array_keys(self::$marks) as $name) 
     65                        foreach (array_keys(self::$marks) as $name) 
    6666                        { 
    6767                                // Get each mark recursively 
  • trunk/system/core/Config.php

    r2080 r2593  
    109109                $last = count($keys) - 1; 
    110110 
    111                 foreach($keys as $i => $k) 
     111                foreach ($keys as $i => $k) 
    112112                { 
    113113                        if ($i === $last) 
     
    144144 
    145145                        // Normalize all paths to be absolute and have a trailing slash 
    146                         foreach(self::item('core.modules') as $path) 
     146                        foreach (self::item('core.modules') as $path) 
    147147                        { 
    148148                                if (($path = str_replace('\\', '/', realpath($path))) == '') 
     
    171171 
    172172