@@ -12,31 +12,31 @@ |
||
12 | 12 | |
13 | 13 | class CRSSFeed { |
14 | 14 | |
15 | - // constructor - initialize SimplePie. |
|
16 | - public function __construct($feedArr, $duration = 3600) { |
|
17 | - $this->object = new SimplePie(); |
|
18 | - $this->object->set_cache_location(CACHE); |
|
19 | - $this->object->set_cache_duration($duration); |
|
20 | - $this->object->set_feed_url($feedArr); |
|
21 | - $this->object->init(); |
|
22 | - } |
|
15 | + // constructor - initialize SimplePie. |
|
16 | + public function __construct($feedArr, $duration = 3600) { |
|
17 | + $this->object = new SimplePie(); |
|
18 | + $this->object->set_cache_location(CACHE); |
|
19 | + $this->object->set_cache_duration($duration); |
|
20 | + $this->object->set_feed_url($feedArr); |
|
21 | + $this->object->init(); |
|
22 | + } |
|
23 | 23 | |
24 | - // return content. |
|
25 | - public function getFeed() { |
|
26 | - $feedItems = $this->object->get_items(); |
|
27 | - $html = '<article>'; |
|
28 | - $html .= "<h1>Senaste nytt fran IDG</h1>"; |
|
29 | - foreach($feedItems as $content) { |
|
30 | - $html .= '<div class="feed-content">'; |
|
31 | - $html .= "<h2>" . $content->get_title() . "</h2>" ; |
|
32 | - $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
|
33 | - $html .= "<p>{$content->get_content()}</p>"; |
|
34 | - $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
|
35 | - $html .= '</div>'; |
|
36 | - } |
|
37 | - $html .= "</article>"; |
|
38 | - return $html; |
|
39 | - } |
|
24 | + // return content. |
|
25 | + public function getFeed() { |
|
26 | + $feedItems = $this->object->get_items(); |
|
27 | + $html = '<article>'; |
|
28 | + $html .= "<h1>Senaste nytt fran IDG</h1>"; |
|
29 | + foreach($feedItems as $content) { |
|
30 | + $html .= '<div class="feed-content">'; |
|
31 | + $html .= "<h2>" . $content->get_title() . "</h2>" ; |
|
32 | + $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
|
33 | + $html .= "<p>{$content->get_content()}</p>"; |
|
34 | + $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
|
35 | + $html .= '</div>'; |
|
36 | + } |
|
37 | + $html .= "</article>"; |
|
38 | + return $html; |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /*$rss = new SimplePie(); |
@@ -14,38 +14,38 @@ |
||
14 | 14 | class CRSSFeedTest extends \PHPUnit_Framework_TestCase { |
15 | 15 | |
16 | 16 | |
17 | - /** ------------------------------------------------------- |
|
17 | + /** ------------------------------------------------------- |
|
18 | 18 | * Test 1a |
19 | - * |
|
19 | + * |
|
20 | 20 | */ |
21 | 21 | |
22 | 22 | |
23 | - private $feed; |
|
23 | + private $feed; |
|
24 | 24 | |
25 | 25 | |
26 | - public function setUp(){ |
|
27 | - $rss = new SimplePie(); |
|
28 | - $rss->get_items(1,1); |
|
29 | - $this->feed = new CRSSFeed($rss); |
|
30 | - } |
|
26 | + public function setUp(){ |
|
27 | + $rss = new SimplePie(); |
|
28 | + $rss->get_items(1,1); |
|
29 | + $this->feed = new CRSSFeed($rss); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - public function testAssertTags(){ |
|
34 | - $matcher = array( |
|
35 | - 'tag' => 'h1', 'content' => 'regexp:/<h1>.*<\/h1>/', |
|
36 | - 'parent' => array('tag' => 'article') |
|
37 | - ); |
|
33 | + public function testAssertTags(){ |
|
34 | + $matcher = array( |
|
35 | + 'tag' => 'h1', 'content' => 'regexp:/<h1>.*<\/h1>/', |
|
36 | + 'parent' => array('tag' => 'article') |
|
37 | + ); |
|
38 | 38 | |
39 | - $matchFeed = array( |
|
40 | - 'tag'=> 'h2', 'content' => 'regexp:/<h2>.*<\/h2>/', |
|
41 | - 'tag'=> 'small', 'content' => 'regexp:/<small>.*<\/small>/', |
|
42 | - 'tag'=> 'p', 'content' => 'regexp:/<p>.*<\/p>/', |
|
43 | - 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'feed-content')) |
|
44 | - ); |
|
45 | - } |
|
39 | + $matchFeed = array( |
|
40 | + 'tag'=> 'h2', 'content' => 'regexp:/<h2>.*<\/h2>/', |
|
41 | + 'tag'=> 'small', 'content' => 'regexp:/<small>.*<\/small>/', |
|
42 | + 'tag'=> 'p', 'content' => 'regexp:/<p>.*<\/p>/', |
|
43 | + 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'feed-content')) |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - public function testGetFeed(){ |
|
49 | - $this->assertInternalType('string', 'regexp:/<article>.*<\/article>/'); |
|
50 | - } |
|
48 | + public function testGetFeed(){ |
|
49 | + $this->assertInternalType('string', 'regexp:/<article>.*<\/article>/'); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -3505,7 +3505,7 @@ discard block |
||
3505 | 3505 | } |
3506 | 3506 | if ($match !== null) |
3507 | 3507 | { |
3508 | - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); |
|
3508 | + $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); |
|
3509 | 3509 | $this->position += strlen($entities[$match]) - strlen($consumed) - 1; |
3510 | 3510 | } |
3511 | 3511 | break; |
@@ -5213,7 +5213,7 @@ discard block |
||
5213 | 5213 | call_user_func(array($this, 'set_' . $name), $value); |
5214 | 5214 | } |
5215 | 5215 | elseif ( |
5216 | - $name === 'iauthority' |
|
5216 | + $name === 'iauthority' |
|
5217 | 5217 | || $name === 'iuserinfo' |
5218 | 5218 | || $name === 'ihost' |
5219 | 5219 | || $name === 'ipath' |
@@ -5560,13 +5560,13 @@ discard block |
||
5560 | 5560 | || $character >= 0xFDD0 && $character <= 0xFDEF |
5561 | 5561 | || ( |
5562 | 5562 | // Everything else not in ucschar |
5563 | - $character > 0xD7FF && $character < 0xF900 |
|
5563 | + $character > 0xD7FF && $character < 0xF900 |
|
5564 | 5564 | || $character < 0xA0 |
5565 | 5565 | || $character > 0xEFFFD |
5566 | 5566 | ) |
5567 | 5567 | && ( |
5568 | 5568 | // Everything not in iprivate, if it applies |
5569 | - !$iprivate |
|
5569 | + !$iprivate |
|
5570 | 5570 | || $character < 0xE000 |
5571 | 5571 | || $character > 0x10FFFD |
5572 | 5572 | ) |
@@ -5775,13 +5775,13 @@ discard block |
||
5775 | 5775 | elseif (isset($cache[$iri])) |
5776 | 5776 | { |
5777 | 5777 | list($this->scheme, |
5778 | - $this->iuserinfo, |
|
5779 | - $this->ihost, |
|
5780 | - $this->port, |
|
5781 | - $this->ipath, |
|
5782 | - $this->iquery, |
|
5783 | - $this->ifragment, |
|
5784 | - $return) = $cache[$iri]; |
|
5778 | + $this->iuserinfo, |
|
5779 | + $this->ihost, |
|
5780 | + $this->port, |
|
5781 | + $this->ipath, |
|
5782 | + $this->iquery, |
|
5783 | + $this->ifragment, |
|
5784 | + $return) = $cache[$iri]; |
|
5785 | 5785 | return $return; |
5786 | 5786 | } |
5787 | 5787 | else |
@@ -5797,13 +5797,13 @@ discard block |
||
5797 | 5797 | && $this->set_query($parsed['query']) |
5798 | 5798 | && $this->set_fragment($parsed['fragment']); |
5799 | 5799 | $cache[$iri] = array($this->scheme, |
5800 | - $this->iuserinfo, |
|
5801 | - $this->ihost, |
|
5802 | - $this->port, |
|
5803 | - $this->ipath, |
|
5804 | - $this->iquery, |
|
5805 | - $this->ifragment, |
|
5806 | - $return); |
|
5800 | + $this->iuserinfo, |
|
5801 | + $this->ihost, |
|
5802 | + $this->port, |
|
5803 | + $this->ipath, |
|
5804 | + $this->iquery, |
|
5805 | + $this->ifragment, |
|
5806 | + $return); |
|
5807 | 5807 | return $return; |
5808 | 5808 | } |
5809 | 5809 | } |
@@ -5841,9 +5841,9 @@ discard block |
||
5841 | 5841 | elseif (isset($cache[$authority])) |
5842 | 5842 | { |
5843 | 5843 | list($this->iuserinfo, |
5844 | - $this->ihost, |
|
5845 | - $this->port, |
|
5846 | - $return) = $cache[$authority]; |
|
5844 | + $this->ihost, |
|
5845 | + $this->port, |
|
5846 | + $return) = $cache[$authority]; |
|
5847 | 5847 | return $return; |
5848 | 5848 | } |
5849 | 5849 | else |
@@ -5874,9 +5874,9 @@ discard block |
||
5874 | 5874 | $this->set_host($remaining) && |
5875 | 5875 | $this->set_port($port); |
5876 | 5876 | $cache[$authority] = array($this->iuserinfo, |
5877 | - $this->ihost, |
|
5878 | - $this->port, |
|
5879 | - $return); |
|
5877 | + $this->ihost, |
|
5878 | + $this->port, |
|
5879 | + $return); |
|
5880 | 5880 | return $return; |
5881 | 5881 | } |
5882 | 5882 | } |
@@ -9128,7 +9128,7 @@ discard block |
||
9128 | 9128 | elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output))) |
9129 | 9129 | { |
9130 | 9130 | return $return; |
9131 | - } |
|
9131 | + } |
|
9132 | 9132 | // This is last, as behaviour of this varies with OS userland and PHP version |
9133 | 9133 | elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) |
9134 | 9134 | { |