diff options
author | Yaco <franco@reevo.org> | 2022-03-08 13:08:34 +0000 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2022-03-08 13:08:34 +0000 |
commit | c985c40d3f3fc6a2be3be3186df3bf2f32189475 (patch) | |
tree | cee11f5e5a7e351ee0fec36d58d72cbee4f7e49b /platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php |
first commit after acervus codebase
Diffstat (limited to 'platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php')
-rw-r--r-- | platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php new file mode 100644 index 0000000..fe61a3f --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/PHPCreator.php @@ -0,0 +1,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; + } +} |