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