diff options
Diffstat (limited to 'platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/JSCreator.php')
-rw-r--r-- | platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/JSCreator.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/JSCreator.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/JSCreator.php new file mode 100644 index 0000000..5aa31fa --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Creator/JSCreator.php @@ -0,0 +1,44 @@ +<?php + +/** + * JSCreator is a class that writes a js file to a specific + * location, overriding the createFeed method of the parent HTMLCreator. + * + * @author Pascal Van Hecke + */ +class JSCreator extends HTMLCreator +{ + protected $contentType = "text/javascript"; + + /** + * writes the javascript + * + * @inheritdoc + */ + public function createFeed() + { + $feed = parent::createFeed(); + $feedArray = explode("\n", $feed); + + $jsFeed = ""; + foreach ($feedArray as $value) { + $jsFeed .= "document.write('".trim(addslashes($value))."');\n"; + } + + return $jsFeed; + } + + /** + * Overrides parent to produce .js extensions + * + * @return string the feed cache filename + * @since 1.4 + * @access private + */ + protected function _generateFilename() + { + $fileInfo = pathinfo($_SERVER["PHP_SELF"]); + + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"]) + 1)).".js"; + } +} |