Show
Ignore:
Timestamp:
02/09/2008 12:07:53 AM (11 months ago)
Author:
PugFish
Message:

Replaced all instances of loading using the now removed Loader library.
Removed missed line that instances Loader.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r2004 r2005  
    7373                ); 
    7474 
    75                 $view = $this->load->view('viewinview/container', $data); 
    76                 $view->header = $this->load->view('viewinview/header', $data); 
     75                $view = new View('viewinview/container', $data); 
     76                $view->header = new View('viewinview/header', $data); 
    7777 
    7878                $view->render(TRUE); 
     
    9898        function session() 
    9999        { 
    100                 $s = new Session(); 
     100                // Gets the singleton instance of the Session library 
     101                $s = Session::instance(); 
    101102 
    102103                echo 'SESSID: <pre>'.session_id()."</pre>\n"; 
     
    112113        function form() 
    113114        { 
    114                 $this->load->library('validation'); 
     115                $validation = new Validation; 
    115116 
    116117                echo form::open('', array('enctype' => 'multipart/form-data')); 
     
    126127                if ( ! empty($_POST)) 
    127128                { 
    128                         $this->validation->set_rules('imageup', 'required|upload[gif,png,jpg,500K]', 'Image Upload'); 
    129                         echo '<p>validation result: '.var_export($this->validation->run(), TRUE).'</p>'; 
    130                 } 
    131  
    132                 echo Kohana::debug($this->validation); 
     129                        $validation->set_rules('imageup', 'required|upload[gif,png,jpg,500K]', 'Image Upload'); 
     130                        echo '<p>validation result: '.var_export($validation->run(), TRUE).'</p>'; 
     131                } 
     132 
     133                echo Kohana::debug($validation); 
    133134                echo Kohana::lang('core.stats_footer'); 
    134135        } 
     
    149150                ); 
    150151 
    151                 // Same as CI, but supports passing an array to the constructor 
    152                 $this->load->library('validation', $data); 
     152                $validation = new Validation($data); 
    153153 
    154154                // Looks familiar... 
    155                 $this->validation->set_rules(array 
     155                $validation->set_rules(array 
    156156                ( 
    157157                        // Format: 
     
    163163 
    164164                // Same syntax as before 
    165                 $this->validation->run(); 
     165                $validation->run(); 
    166166 
    167167                // Same syntax, but dynamcially generated wth __get() 
    168                 echo $this->validation->error_string; 
     168                echo $validation->error_string; 
    169169 
    170170                // Yay! 
     
    193193        function database() 
    194194        { 
    195                 $this->load->database(); 
     195                $db = new Database; 
     196                 
    196197                $table = 'pages'; 
    197198                echo 'Does the '.$table.' table exist? '; 
    198                 if ($this->db->table_exists($table)) 
     199                if ($db->table_exists($table)) 
    199200                { 
    200201                        echo '<p>YES! Lets do some work =)</p>'; 
    201202 
    202                         $query = $this->db->select('DISTINCT pages.*')->from($table)->get(); 
    203                         echo $this->db->last_query(); 
     203                        $query = $db->select('DISTINCT pages.*')->from($table)->get(); 
     204                        echo $db->last_query(); 
    204205                        echo '<h3>Iterate through the result:</h3>'; 
    205206                        foreach($query as $item) 
     
    208209                        } 
    209210                        echo '<h3>Numrows using count(): '.count($query).'</h3>'; 
    210                         echo 'Table Listing:<pre>'.print_r($this->db->list_tables(), TRUE).'</pre>'; 
     211                        echo 'Table Listing:<pre>'.print_r($db->list_tables(), TRUE).'</pre>'; 
    211212 
    212213                        echo '<h3>Try Query Binding with objects:</h3>'; 
    213214                        $sql = 'SELECT * FROM '.$table.' WHERE id = ?'; 
    214                         $query = $this->db->query($sql, array(1)); 
    215                         echo '<p>'.$this->db->last_query().'</p>'; 
     215                        $query = $db->query($sql, array(1)); 
     216                        echo '<p>'.$db->last_query().'</p>'; 
    216217                        $query->result(TRUE); 
    217218                        foreach($query as $item) 
     
    222223                        echo '<h3>Try Query Binding with arrays (returns both associative and numeric because I pass MYSQL_BOTH to result():</h3>'; 
    223224                        $sql = 'SELECT * FROM '.$table.' WHERE id = ?'; 
    224                         $query = $this->db->query($sql, array(1)); 
    225                         echo '<p>'.$this->db->last_query().'</p>'; 
     225                        $query = $db->query($sql, array(1)); 
     226                        echo '<p>'.$db->last_query().'</p>'; 
    226227                        $query->result(FALSE, MYSQL_BOTH); 
    227228                        foreach($query as $item) 
     
    231232 
    232233                        echo '<h3>Look, we can also manually advance the result pointer!</h3>'; 
    233                         $query = $this->db->select('title')->from($table)->get(); 
     234                        $query = $db->select('title')->from($table)->get(); 
    234235                        echo 'First:<pre>'.print_r($query->current(), true).'</pre><br />'; 
    235236                        $query->next(); 
     
    241242                        echo 'Rewound:<pre>'.print_r($query->current(), true).'</pre>'; 
    242243 
    243                         echo '<p>Number of rows using count_records(): '.$this->db->count_records('pages').'</p>'; 
     244                        echo '<p>Number of rows using count_records(): '.$db->count_records('pages').'</p>'; 
    244245                } 
    245246                else 
     
    256257        function pagination() 
    257258        { 
    258                 $this->pagination = new Pagination(array( 
     259                $pagination = new Pagination(array( 
    259260                        // 'base_url'    => 'welcome/pagination_example/page/', // base_url will default to current uri 
    260261                        'uri_segment'    => 'page', // pass a string as uri_segment to trigger former 'label' functionality 
     
    265266 
    266267                // Just echoing it is enough to display the links (__toString() rocks!) 
    267                 echo 'Classic style: '.$this->pagination; 
     268                echo 'Classic style: '.$pagination; 
    268269 
    269270                // You can also use the create_links() method and pick a style on the fly if you want 
    270                 echo '<hr />Digg style:     '.$this->pagination->create_links('digg'); 
    271                 echo '<hr />Extended style: '.$this->pagination->create_links('extended'); 
    272                 echo '<hr />PunBB style:    '.$this->pagination->create_links('punbb'); 
     271                echo '<hr />Digg style:     '.$pagination->create_links('digg'); 
     272                echo '<hr />Extended style: '.$pagination->create_links('extended'); 
     273                echo '<hr />PunBB style:    '.$pagination->create_links('punbb'); 
    273274                echo 'done in {execution_time} seconds'; 
    274275        } 
     
    279280        function user_agent() 
    280281        { 
    281                 $this->load->library('user_agent'); 
     282                $ua = new User_agent; 
    282283 
    283284                foreach(array('agent', 'browser', 'version') as $key) 
    284285                { 
    285                         echo $key.': '.$this->user_agent->$key.'<br/>'."\n"; 
     286                        echo $key.': '.$ua->$key.'<br/>'."\n"; 
    286287                } 
    287288