Changeset 801

Show
Ignore:
Timestamp:
10/12/2007 05:56:14 PM (14 months ago)
Author:
Shadowhand
Message:

Added rss example

Files:
1 modified

Legend:

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

    r784 r801  
    1010                                echo html::anchor('welcome/'.$method, $method)."<br/>\n"; 
    1111                } 
     12        } 
     13 
     14        function rss_example() 
     15        { 
     16                include Kohana::find_file('vendor', 'Markdown'); 
     17 
     18                $feed = new DOMDocument(); 
     19                $feed->load(APPPATH.'cache/rss.xml'); 
     20 
     21                foreach($feed->getElementsByTagName('item') as $index => $node) 
     22                { 
     23                        if ($index > 4) break; 
     24 
     25                        $title = $node->getElementsByTagName('title')->item(0)->nodeValue; 
     26                        $desc  = $node->getElementsByTagName('description')->item(0)->nodeValue; 
     27                        $link  = $node->getElementsByTagName('link')->item(0)->nodeValue; 
     28                        $date  = $node->getElementsByTagName('pubDate')->item(0)->nodeValue; 
     29 
     30                        print Markdown("### [{$title}]({$link})\n$desc\n"); 
     31                } 
     32 
     33                print Kohana::lang('core.stats_footer'); 
    1234        } 
    1335 
     
    90112                { 
    91113                        echo '<p>YES! Lets do some work =)</p>'; 
    92                          
     114 
    93115                        $query = $this->db->select('title')->from($table)->get(); 
    94116                        echo '<h3>Iterate through the result:</h3>'; 
     
    109131                                echo '<pre>'.print_r($item, true).'</pre>'; 
    110132                        } 
    111                          
     133 
    112134                        echo '<h3>Try Query Binding with arrays (returns both associative and numeric because I pass MYSQL_BOTH to result():</h3>'; 
    113135                        $sql = 'SELECT * FROM '.$table.' WHERE id = ?'; 
     
    119141                                echo '<pre>'.print_r($item, true).'</pre>'; 
    120142                        } 
    121                          
     143 
    122144                        echo '<h3>Look, we can also manually advance the result pointer!</h3>'; 
    123145                        $query = $this->db->select('title')->from($table)->get();