Changeset 3300

Show
Ignore:
Timestamp:
08/08/2008 09:23:57 AM (4 months ago)
Author:
OscarB
Message:

Fixed example controller methods to work properly for 2.2

Files:
1 modified

Legend:

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

    r3293 r3300  
    4747        } 
    4848 
    49         public function archive($build = FALSE) 
    50         { 
    51                 if ($build === 'build') 
    52                 { 
    53                         // Load archive 
    54                         $archive = new Archive('zip'); 
    55  
    56                         // Download the application/views directory 
    57                         $archive->add(APPPATH.'views/', 'app_views/', TRUE); 
    58  
    59                         // Download the built archive 
    60                         $archive->download('test.zip'); 
    61                 } 
    62                 else 
    63                 { 
    64                         echo html::anchor(Router::$current_uri.'/build', 'Download views'); 
    65                 } 
    66         } 
    67  
    68         /** 
    69          * Demonstrates how to use views inside of views. 
    70          */ 
    71         function template() 
    72         { 
    73                 $data = array 
    74                 ( 
    75                         'title'   => 'View-in-View Example', 
    76                         'content' => 'This is my view-in-view page content.', 
    77                         'copyright' => '© 2007 Kohana Team' 
    78                 ); 
    79  
    80                 $view = new View('viewinview/container', $data); 
    81                 $view->header = new View('viewinview/header', $data); 
    82  
    83                 $view->render(TRUE); 
    84         } 
     49        /** 
     50         * Demonstrates how to archive a directory. First enable the archive module 
     51         */ 
     52        //public function archive($build = FALSE) 
     53        //{ 
     54        //      if ($build === 'build') 
     55        //      { 
     56        //              // Load archive 
     57        //              $archive = new Archive('zip'); 
     58 
     59        //              // Download the application/views directory 
     60        //              $archive->add(APPPATH.'views/', 'app_views/', TRUE); 
     61 
     62        //              // Download the built archive 
     63        //              $archive->download('test.zip'); 
     64        //      } 
     65        //      else 
     66        //      { 
     67        //              echo html::anchor(Router::$current_uri.'/build', 'Download views'); 
     68        //      } 
     69        //} 
    8570 
    8671        /** 
     
    422407                $profiler = new Profiler; 
    423408 
    424                 $cal = new Calendar(5, 2007); 
    425  
    426                 echo $cal->render(); 
    427         } 
    428  
     409                $calendar = new Calendar(8, 2008); 
     410                $calendar->attach($calendar->event() 
     411                                ->condition('year', 2008) 
     412                                ->condition('month', 8) 
     413                                ->condition('day', 8) 
     414                                ->output(html::anchor('http://forum.kohanaphp.com/comments.php?DiscussionID=275', 'Learning about Kohana Calendar'))); 
     415 
     416                echo $calendar->render(); 
     417        } 
     418 
     419        /** 
     420         * Demonstrates how to use the Image libarary.. 
     421         */ 
    429422        function image() 
    430423        { 
    431                 $profiler = new Profiler; 
    432  
    433                 // Upload directory 
     424                // Application Upload directory 
    434425                $dir = realpath(DOCROOT.'upload').'/'; 
    435426 
    436427                // Image filename 
    437                 $image = $dir.'mypic.jpg'; 
     428                $image = DOCROOT.'kohana.png'; 
    438429 
    439430                // Create an instance of Image, with file 
     431                // The orginal image is not affected 
    440432                $image = new Image($image); 
    441433 
    442                 // Resize the image 
    443                 $image->resize(100, 100); 
     434                // Most methods are chainable 
     435                // Resize the image, crop the center left 
     436                $image->resize(200, 100)->crop(150, 50, 'center', 'left'); 
     437 
     438                // Display image in browser 
     439                $image->render(); 
    444440 
    445441                // Save the image 
    446442                $image->save($dir.'mypic_thumb.jpg'); 
    447443 
    448                 echo Kohana::debug($image); 
    449         } 
    450  
     444                //echo Kohana::debug($image); 
     445        } 
     446 
     447        /** 
     448         * Demonstrates how to use vendor software with Kohana. 
     449         */ 
     450        function vendor() 
     451        { 
     452                // Let's do a little Markdown shall we. 
     453                $br = "\n\n"; 
     454                $output = '#Marked Down!#'.$br; 
     455                $output .= 'This **_markup_** is created *on-the-fly*, by '; 
     456                $output .= '[php-markdown-extra](http://michelf.com/projects/php-markdown/extra)'.$br; 
     457                $output .= 'It\'s *great* for user <input> & writing about `<HTML>`'.$br; 
     458                $output .= 'It\'s also good at footnotes :-) [^1]'.$br; 
     459                $output .= '[^1]: A footnote.'; 
     460 
     461                // looks in system/vendor for Markdown.php 
     462                require Kohana::find_file('vendor', 'Markdown'); 
     463 
     464                echo Markdown($output); 
     465 
     466                echo 'done in {execution_time} seconds'; 
     467        } 
    451468} // End Examples