xref: /dokuwiki/vendor/openpsa/universalfeedcreator/lib/Creator/PIECreator01.php (revision 3a97d936870170491bdd7d03d71143143b10191d)
1<?php
2
3/**
4 * PIECreator01 is a FeedCreator that implements the emerging PIE specification,
5 * as in http://intertwingly.net/wiki/pie/Syntax.
6 *
7 * @deprecated
8 * @since   1.3
9 * @author  Scott Reynen <scott@randomchaos.com> and Kai Blankenhorn <kaib@bitfolge.de>
10 * @package de.bitfolge.feedcreator
11 */
12class PIECreator01 extends FeedCreator
13{
14
15    /**
16     * PIECreator01 constructor.
17     */
18    public function __construct()
19    {
20        $this->encoding = "utf-8";
21    }
22
23    /** @inheritdoc */
24    public function createFeed()
25    {
26        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
27        $feed .= $this->_createStylesheetReferences();
28        $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n";
29        $feed .= "    <title>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n";
30        $this->truncSize = 500;
31        $feed .= "    <subtitle>".$this->getDescription()."</subtitle>\n";
32        $feed .= "    <link>".$this->link."</link>\n";
33        for ($i = 0; $i < count($this->items); $i++) {
34            $feed .= "    <entry>\n";
35            $feed .= "        <title>".FeedCreator::iTrunc(
36                    htmlspecialchars(strip_tags($this->items[$i]->title)),
37                    100
38                )."</title>\n";
39            $feed .= "        <link>".htmlspecialchars($this->items[$i]->link)."</link>\n";
40            $itemDate = new FeedDate($this->items[$i]->date);
41            $feed .= "        <created>".htmlspecialchars($itemDate->iso8601())."</created>\n";
42            $feed .= "        <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n";
43            $feed .= "        <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n";
44            $feed .= "        <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n";
45            if ($this->items[$i]->author != "") {
46                $feed .= "        <author>\n";
47                $feed .= "            <name>".htmlspecialchars($this->items[$i]->author)."</name>\n";
48                if ($this->items[$i]->authorEmail != "") {
49                    $feed .= "            <email>".$this->items[$i]->authorEmail."</email>\n";
50                }
51                $feed .= "        </author>\n";
52            }
53            $feed .= "        <content type=\"text/html\" xml:lang=\"en-us\">\n";
54            $feed .= "            <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription(
55                )."</div>\n";
56            $feed .= "        </content>\n";
57            $feed .= "    </entry>\n";
58        }
59        $feed .= "</feed>\n";
60
61        return $feed;
62    }
63}
64