|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Output the page content or data as raw, html, json or xml with `?output`. |
| 3 | + * Output Pico CMS page data as raw text, html, json or xml with `?output`. |
4 | 4 | * |
5 | 5 | * @author Nicolas Liautaud |
6 | 6 | * @link https://github.com/nliautaud/pico-content-output |
7 | 7 | * @link http://picocms.org |
8 | 8 | * @license http://opensource.org/licenses/MIT The MIT License |
9 | | - * @version 0.1.0 |
10 | 9 | */ |
11 | 10 | final class PicoOutput extends AbstractPicoPlugin |
12 | 11 | { |
| 12 | + const API_VERSION = 2; |
| 13 | + |
13 | 14 | private $serveContent; |
14 | 15 | private $contentFormat; |
15 | 16 |
|
@@ -59,23 +60,27 @@ public function enabledFormat() |
59 | 60 | private function contentOutput() |
60 | 61 | { |
61 | 62 | $pico = $this->getPico(); |
| 63 | + $page = $pico->getCurrentPage(); |
| 64 | + unset($page['previous_page']); |
| 65 | + unset($page['next_page']); |
| 66 | + unset($page['tree_node']); |
62 | 67 | switch ($this->contentFormat) { |
63 | 68 | case 'raw': |
64 | 69 | return $pico->getRawContent(); |
65 | 70 | case 'prepared': |
66 | 71 | return $pico->prepareFileContent($pico->getRawContent(), $pico->getFileMeta()); |
67 | 72 | case 'json': |
68 | 73 | header('Content-Type: application/json;charset=utf-8'); |
69 | | - return json_encode($pico->getCurrentPage()); |
| 74 | + return json_encode($page); |
70 | 75 | case 'xml': |
71 | 76 | header("Content-type: text/xml"); |
72 | 77 | $xml = new SimpleXMLElement('<page/>'); |
73 | | - $this->array_to_xml($pico->getCurrentPage(), $xml); |
| 78 | + $this->array_to_xml($page, $xml); |
74 | 79 | return $xml->asXML(); |
75 | 80 | default: |
76 | 81 | return $pico->getFileContent(); |
77 | 82 | } |
78 | | - } |
| 83 | + } |
79 | 84 |
|
80 | 85 | // function defination to convert array to xml |
81 | 86 | private function array_to_xml( $data, &$xml_data ) |
|
0 commit comments