@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * @param string $class The fully-qualified class name. |
| 12 | 12 | * @return void |
| 13 | 13 | */ |
| 14 | -spl_autoload_register(function ($class) { |
|
| 14 | +spl_autoload_register(function($class) { |
|
| 15 | 15 | |
| 16 | 16 | // project-specific namespace prefix |
| 17 | 17 | //$prefix = 'Foo\\Bar\\'; |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | |
| 10 | 10 | // Prepare the page content |
| 11 | 11 | $rss = new Anax\Rssfeed\CRssfeed([ |
| 12 | - 'url' => 'http://feeds.idg.se/ComputerSweden20SenasteNyheter', |
|
| 13 | - 'heading' => 'An example RSS feed - Computer Sweden', |
|
| 14 | - 'items' => '5', |
|
| 15 | - ]); |
|
| 12 | + 'url' => 'http://feeds.idg.se/ComputerSweden20SenasteNyheter', |
|
| 13 | + 'heading' => 'An example RSS feed - Computer Sweden', |
|
| 14 | + 'items' => '5', |
|
| 15 | + ]); |
|
| 16 | 16 | |
| 17 | 17 | $content = $rss->readRSS(); |
| 18 | 18 | |
| 19 | 19 | $app->theme->setVariable('title', "Test page")
|
| 20 | - ->setVariable('main', "
|
|
| 20 | + ->setVariable('main', "
|
|
| 21 | 21 | <p><i>This is a sample pagecontroller that lists a RSS feed.</i></p> |
| 22 | 22 | {$content}
|
| 23 | 23 | "); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Get environment & autoloader and the $app-object. |
| 8 | -require __DIR__.'/config_with_app.php'; |
|
| 8 | +require __DIR__ . '/config_with_app.php'; |
|
| 9 | 9 | |
| 10 | 10 | // Prepare the page content |
| 11 | 11 | $rss = new Anax\Rssfeed\CRssfeed([ |
@@ -21,34 +21,34 @@ |
||
| 21 | 21 | * @param array $options to alter the default behaviour. |
| 22 | 22 | */ |
| 23 | 23 | public function __construct($options=array()) { |
| 24 | - $this->url = $options['url']; |
|
| 25 | - $this->heading = $options['heading']; |
|
| 26 | - $this->items = $options['items']; |
|
| 24 | + $this->url = $options['url']; |
|
| 25 | + $this->heading = $options['heading']; |
|
| 26 | + $this->items = $options['items']; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function readRSS(){ |
| 30 | 30 | |
| 31 | - $html = "<article>"; |
|
| 32 | - $heading = $this->heading; |
|
| 33 | - $html .= "<h1>$heading</h1>"; |
|
| 34 | - $xml = simplexml_load_file($this->url); |
|
| 35 | - for($i = 0; $i < $this->items; $i++){ |
|
| 36 | - $title = $xml->channel->item[$i]->title; |
|
| 37 | - $link = $xml->channel->item[$i]->link; |
|
| 38 | - $description = $xml->channel->item[$i]->description; |
|
| 39 | - $pubDate = $xml->channel->item[$i]->pubDate; |
|
| 31 | + $html = "<article>"; |
|
| 32 | + $heading = $this->heading; |
|
| 33 | + $html .= "<h1>$heading</h1>"; |
|
| 34 | + $xml = simplexml_load_file($this->url); |
|
| 35 | + for($i = 0; $i < $this->items; $i++){ |
|
| 36 | + $title = $xml->channel->item[$i]->title; |
|
| 37 | + $link = $xml->channel->item[$i]->link; |
|
| 38 | + $description = $xml->channel->item[$i]->description; |
|
| 39 | + $pubDate = $xml->channel->item[$i]->pubDate; |
|
| 40 | 40 | |
| 41 | - // Formatting the date |
|
| 42 | - $pubDate= date("D, d M Y H:i:s T", strtotime($pubDate)); |
|
| 41 | + // Formatting the date |
|
| 42 | + $pubDate= date("D, d M Y H:i:s T", strtotime($pubDate)); |
|
| 43 | 43 | |
| 44 | - $html .= "<a href='$link'><h3>$title</h3></a>"; |
|
| 45 | - $html .= "<small>$pubDate</small><br /><br />"; |
|
| 46 | - $html .= "$description"; |
|
| 47 | - $html .= "<hr />"; |
|
| 48 | - } |
|
| 49 | - $html .= "</article>"; |
|
| 44 | + $html .= "<a href='$link'><h3>$title</h3></a>"; |
|
| 45 | + $html .= "<small>$pubDate</small><br /><br />"; |
|
| 46 | + $html .= "$description"; |
|
| 47 | + $html .= "<hr />"; |
|
| 48 | + } |
|
| 49 | + $html .= "</article>"; |
|
| 50 | 50 | |
| 51 | - return $html; |
|
| 51 | + return $html; |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
@@ -20,26 +20,26 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @param array $options to alter the default behaviour. |
| 22 | 22 | */ |
| 23 | - public function __construct($options=array()) { |
|
| 23 | + public function __construct($options = array()) { |
|
| 24 | 24 | $this->url = $options['url']; |
| 25 | 25 | $this->heading = $options['heading']; |
| 26 | 26 | $this->items = $options['items']; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function readRSS(){ |
|
| 29 | + public function readRSS() { |
|
| 30 | 30 | |
| 31 | 31 | $html = "<article>"; |
| 32 | 32 | $heading = $this->heading; |
| 33 | 33 | $html .= "<h1>$heading</h1>"; |
| 34 | 34 | $xml = simplexml_load_file($this->url); |
| 35 | - for($i = 0; $i < $this->items; $i++){ |
|
| 35 | + for ($i = 0; $i < $this->items; $i++) { |
|
| 36 | 36 | $title = $xml->channel->item[$i]->title; |
| 37 | 37 | $link = $xml->channel->item[$i]->link; |
| 38 | 38 | $description = $xml->channel->item[$i]->description; |
| 39 | 39 | $pubDate = $xml->channel->item[$i]->pubDate; |
| 40 | 40 | |
| 41 | 41 | // Formatting the date |
| 42 | - $pubDate= date("D, d M Y H:i:s T", strtotime($pubDate)); |
|
| 42 | + $pubDate = date("D, d M Y H:i:s T", strtotime($pubDate)); |
|
| 43 | 43 | |
| 44 | 44 | $html .= "<a href='$link'><h3>$title</h3></a>"; |
| 45 | 45 | $html .= "<small>$pubDate</small><br /><br />"; |