blob: fe61a3f6ff4eb26cee1290939ec0f1b29853c362 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?php
/**
* PHPCreator is a FeedCreator that implements a PHP output, suitable for an include
*
* @since 1.7.3
* @author Barry Hunter <geo@barryhunter.co.uk>
*/
class PHPCreator extends FeedCreator
{
/**
* PHPCreator constructor.
*/
public function __construct()
{
$this->contentType = "text/plain";
$this->encoding = "utf-8";
}
/** @inheritdoc */
public function createFeed()
{
$feed = "<?php\n";
$feed .= "class FeedItem {}\n";
$feed .= " \$feedTitle='".addslashes(FeedCreator::iTrunc(htmlspecialchars($this->title), 100))."';\n";
$this->truncSize = 500;
$feed .= " \$feedDescription='".addslashes($this->getDescription())."';\n";
$feed .= " \$feedLink='".$this->link."';\n";
$feed .= " \$feedItem = array();\n";
for ($i = 0; $i < count($this->items); $i++) {
$feed .= " \$feedItem[$i] = new FeedItem();\n";
if ($this->items[$i]->guid != "") {
$feed .= " \$feedItem[$i]->id='".htmlspecialchars($this->items[$i]->guid)."';\n";
}
$feed .= " \$feedItem[$i]->title='".addslashes(
FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)
)."';\n";
$feed .= " \$feedItem[$i]->link='".htmlspecialchars($this->items[$i]->link)."';\n";
$feed .= " \$feedItem[$i]->date=".htmlspecialchars($this->items[$i]->date).";\n";
if ($this->items[$i]->author != "") {
$feed .= " \$feedItem[$i]->author='".htmlspecialchars($this->items[$i]->author)."';\n";
if ($this->items[$i]->authorEmail != "") {
$feed .= " \$feedItem[$i]->authorEmail='".$this->items[$i]->authorEmail."';\n";
}
}
$feed .= " \$feedItem[$i]->description='".addslashes($this->items[$i]->getDescription())."';\n";
if ($this->items[$i]->thumb != "") {
$feed .= " \$feedItem[$i]->thumbURL='".htmlspecialchars($this->items[$i]->thumb)."';\n";
}
}
$feed .= "?>\n";
return $feed;
}
}
|