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/JSCreator.php |
first commit after acervus codebase
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"; + } +} |