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