From cbfef8e43e1c5c1201d3fb3dcd5c6a7c3efb41f3 Mon Sep 17 00:00:00 2001 From: nliautaud Date: Mon, 6 Nov 2017 11:39:04 +0100 Subject: [PATCH 1/3] remove previous and next pages from output to avoid recursion --- PicoOutput.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PicoOutput.php b/PicoOutput.php index ac88276..6f81f0e 100644 --- a/PicoOutput.php +++ b/PicoOutput.php @@ -59,6 +59,9 @@ public function enabledFormat() private function contentOutput() { $pico = $this->getPico(); + $page = $pico->getCurrentPage(); + unset($page['previous_page']); + unset($page['next_page']); switch ($this->contentFormat) { case 'raw': return $pico->getRawContent(); @@ -66,11 +69,11 @@ private function contentOutput() return $pico->prepareFileContent($pico->getRawContent(), $pico->getFileMeta()); case 'json': header('Content-Type: application/json;charset=utf-8'); - return json_encode($pico->getCurrentPage()); + return json_encode($page); case 'xml': header("Content-type: text/xml"); $xml = new SimpleXMLElement(''); - $this->array_to_xml($pico->getCurrentPage(), $xml); + $this->array_to_xml($page, $xml); return $xml->asXML(); default: return $pico->getFileContent(); From 943f27135b8019bff3ef8ac0befdc0becdae24aa Mon Sep 17 00:00:00 2001 From: nliautaud Date: Mon, 6 Nov 2017 15:04:32 +0100 Subject: [PATCH 2/3] update config doc to yml --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 422ede4..0934a10 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ Copy `PicoOutput.php` to the `plugins/` directory of your Pico Project. ## Usage -Enable the plugin and the output formats in Pico `config.php`. +Enable output formats in Pico config file. -```php -$config['PicoOutput.enabled'] = true; // by default -$config['PicoOutput.enabledFormats'] = array('content', 'prepared'); +```yml +PicoOutput.enabled: true # by default +PicoOutput.enabledFormats: [content, raw, prepared, xml, json] ``` Then add `?output=format` to any url. From cb6bd4004fc561855a2f0316600acccc71747808 Mon Sep 17 00:00:00 2001 From: nliautaud Date: Tue, 5 Jun 2018 12:47:32 +0200 Subject: [PATCH 3/3] remove pico 2 page tree data from output --- PicoOutput.php | 8 +++++--- README.md | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PicoOutput.php b/PicoOutput.php index 6f81f0e..89be6cb 100644 --- a/PicoOutput.php +++ b/PicoOutput.php @@ -1,15 +1,16 @@ getCurrentPage(); unset($page['previous_page']); unset($page['next_page']); + unset($page['tree_node']); switch ($this->contentFormat) { case 'raw': return $pico->getRawContent(); @@ -78,7 +80,7 @@ private function contentOutput() default: return $pico->getFileContent(); } - } + } // function defination to convert array to xml private function array_to_xml( $data, &$xml_data ) diff --git a/README.md b/README.md index 0934a10..4477185 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pico Output -Output the page content or data as raw, html, json or xml with `?output` in [Pico CMS](http://picocms.org). +Output [Pico CMS](http://picocms.org) page data as raw text, html, json or xml with `?output`. ## Installation