@@ 82-93 (lines=12) @@ | ||
79 | $feed = '<?xml version="1.0" encoding="'.$encoding.'"?><rss version="2.0"><channel></channel></rss>'; |
|
80 | $feed = simplexml_load_string($feed); |
|
81 | ||
82 | foreach ($info as $name => $value) { |
|
83 | if (($name === 'pubDate' or $name === 'lastBuildDate') and (is_int($value) or ctype_digit($value))) { |
|
84 | // Convert timestamps to RFC 822 formatted dates |
|
85 | $value = date(DATE_RFC822, $value); |
|
86 | } elseif (($name === 'link' or $name === 'docs') and strpos($value, '://') === false) { |
|
87 | // Convert URIs to URLs |
|
88 | $value = url::site($value, 'http'); |
|
89 | } |
|
90 | ||
91 | // Add the info to the channel |
|
92 | $feed->channel->addChild($name, $value); |
|
93 | } |
|
94 | ||
95 | foreach ($items as $item) { |
|
96 | // Add the item to the channel |
|
@@ 99-110 (lines=12) @@ | ||
96 | // Add the item to the channel |
|
97 | $row = $feed->channel->addChild('item'); |
|
98 | ||
99 | foreach ($item as $name => $value) { |
|
100 | if ($name === 'pubDate' and (is_int($value) or ctype_digit($value))) { |
|
101 | // Convert timestamps to RFC 822 formatted dates |
|
102 | $value = date(DATE_RFC822, $value); |
|
103 | } elseif (($name === 'link' or $name === 'guid') and strpos($value, '://') === false) { |
|
104 | // Convert URIs to URLs |
|
105 | $value = url::site($value, 'http'); |
|
106 | } |
|
107 | ||
108 | // Add the info to the row |
|
109 | $row->addChild($name, $value); |
|
110 | } |
|
111 | } |
|
112 | ||
113 | return $feed->asXML(); |