|
1 | 1 | <?php |
| 2 | + |
2 | 3 | /** |
3 | 4 | * AtomCreator03 is a FeedCreator that implements the atom specification, |
4 | 5 | * as in http://www.intertwingly.net/wiki/pie/FrontPage. |
5 | 6 | * Please note that just by using AtomCreator03 you won't automatically |
6 | 7 | * produce valid atom files. For example, you have to specify either an editor |
7 | 8 | * for the feed or an author for every single feed item. |
8 | | - * |
9 | 9 | * Some elements have not been implemented yet. These are (incomplete list): |
10 | 10 | * author URL, item author's email and URL, item contents, alternate links, |
11 | 11 | * other link content types than text/html. Some of them may be created with |
12 | 12 | * AtomCreator03::additionalElements. |
13 | 13 | * |
14 | | - * @see FeedCreator#additionalElements |
15 | | - * @since 1.6 |
16 | | - * @author Kai Blankenhorn <kaib@bitfolge.de>, Scott Reynen <scott@randomchaos.com> |
| 14 | + * @see FeedCreator#additionalElements |
| 15 | + * @since 1.6 |
| 16 | + * @author Kai Blankenhorn <kaib@bitfolge.de>, Scott Reynen <scott@randomchaos.com> |
17 | 17 | * @package de.bitfolge.feedcreator |
18 | 18 | */ |
19 | | -class AtomCreator03 extends FeedCreator { |
| 19 | +class AtomCreator03 extends FeedCreator |
| 20 | +{ |
20 | 21 |
|
21 | 22 | /** |
22 | 23 | * AtomCreator03 constructor. |
23 | 24 | */ |
24 | | - public function __construct() { |
| 25 | + public function __construct() |
| 26 | + { |
25 | 27 | $this->contentType = "application/atom+xml"; |
26 | 28 | $this->encoding = "utf-8"; |
27 | 29 | } |
28 | 30 |
|
29 | 31 | /** @inheritdoc */ |
30 | | - public function createFeed() { |
| 32 | + public function createFeed() |
| 33 | + { |
31 | 34 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
32 | | - $feed.= $this->_createGeneratorComment(); |
33 | | - $feed.= $this->_createStylesheetReferences(); |
34 | | - $feed.= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
35 | | - if ($this->format=='TOOLBAR') { |
36 | | - $feed.= " xmlns:gtb=\"http://toolbar.google.com/custombuttons/\""; |
| 35 | + $feed .= $this->_createGeneratorComment(); |
| 36 | + $feed .= $this->_createStylesheetReferences(); |
| 37 | + $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
| 38 | + if ($this->format == 'TOOLBAR') { |
| 39 | + $feed .= " xmlns:gtb=\"http://toolbar.google.com/custombuttons/\""; |
37 | 40 | } |
38 | | - if ($this->language!="") { |
39 | | - $feed.= " xml:lang=\"".$this->language."\""; |
| 41 | + if ($this->language != "") { |
| 42 | + $feed .= " xml:lang=\"".$this->language."\""; |
40 | 43 | } |
41 | | - $feed.= ">\n"; |
42 | | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
43 | | - $feed.= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
44 | | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
45 | | - $feed.= " <id>".htmlspecialchars($this->link)."</id>\n"; |
| 44 | + $feed .= ">\n"; |
| 45 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
| 46 | + $feed .= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
| 47 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
| 48 | + $feed .= " <id>".htmlspecialchars($this->link)."</id>\n"; |
46 | 49 | $now = new FeedDate(); |
47 | | - $feed.= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
48 | | - if ($this->editor!="") { |
49 | | - $feed.= " <author>\n"; |
50 | | - $feed.= " <name>".$this->editor."</name>\n"; |
51 | | - if ($this->editorEmail!="") { |
52 | | - $feed.= " <email>".$this->editorEmail."</email>\n"; |
| 50 | + $feed .= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
| 51 | + if ($this->editor != "") { |
| 52 | + $feed .= " <author>\n"; |
| 53 | + $feed .= " <name>".$this->editor."</name>\n"; |
| 54 | + if ($this->editorEmail != "") { |
| 55 | + $feed .= " <email>".$this->editorEmail."</email>\n"; |
53 | 56 | } |
54 | | - $feed.= " </author>\n"; |
| 57 | + $feed .= " </author>\n"; |
55 | 58 | } |
56 | | - $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
57 | | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
58 | | - for ($i=0;$i<count($this->items);$i++) { |
59 | | - $feed.= " <entry>\n"; |
60 | | - $feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
61 | | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
62 | | - if ($this->items[$i]->date=="") { |
| 59 | + $feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
| 60 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
| 61 | + for ($i = 0; $i < count($this->items); $i++) { |
| 62 | + $feed .= " <entry>\n"; |
| 63 | + $feed .= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
| 64 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars( |
| 65 | + $this->items[$i]->link |
| 66 | + )."\"/>\n"; |
| 67 | + if ($this->items[$i]->date == "") { |
63 | 68 | $this->items[$i]->date = time(); |
64 | 69 | } |
65 | 70 | $itemDate = new FeedDate($this->items[$i]->date); |
66 | | - $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
67 | | - $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
68 | | - $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
69 | | - $feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
70 | | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
71 | | - if ($this->items[$i]->author!="") { |
72 | | - $feed.= " <author>\n"; |
73 | | - $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
74 | | - $feed.= " </author>\n"; |
| 71 | + $feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
| 72 | + $feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
| 73 | + $feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
| 74 | + $feed .= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
| 75 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
| 76 | + if ($this->items[$i]->author != "") { |
| 77 | + $feed .= " <author>\n"; |
| 78 | + $feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
| 79 | + $feed .= " </author>\n"; |
75 | 80 | } |
76 | | - if ($this->items[$i]->description!="") { |
77 | | - $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
| 81 | + if ($this->items[$i]->description != "") { |
| 82 | + $feed .= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
78 | 83 | } |
79 | 84 | if (isset($this->items[$i]->thumbdata)) { |
80 | | - $feed.= " <gtb:icon mode=\"base64\" type=\"image/jpeg\">\n"; |
81 | | - $feed.= chunk_split(base64_encode($this->items[$i]->thumbdata))."\n"; |
82 | | - $feed.= " </gtb:icon>\n"; |
| 85 | + $feed .= " <gtb:icon mode=\"base64\" type=\"image/jpeg\">\n"; |
| 86 | + $feed .= chunk_split(base64_encode($this->items[$i]->thumbdata))."\n"; |
| 87 | + $feed .= " </gtb:icon>\n"; |
83 | 88 | } |
84 | | - $feed.= " </entry>\n"; |
| 89 | + $feed .= " </entry>\n"; |
85 | 90 | } |
86 | | - $feed.= "</feed>\n"; |
| 91 | + $feed .= "</feed>\n"; |
| 92 | + |
87 | 93 | return $feed; |
88 | 94 | } |
89 | 95 | } |
0 commit comments