Skip to content

Commit fd32c4e

Browse files
authored
Merge pull request #1 from nliautaud/pico-2.0
Pico 2.0 support
2 parents 47a2a7e + cb6bd40 commit fd32c4e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

PicoOutput.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22
/**
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`.
44
*
55
* @author Nicolas Liautaud
66
* @link https://github.com/nliautaud/pico-content-output
77
* @link http://picocms.org
88
* @license http://opensource.org/licenses/MIT The MIT License
9-
* @version 0.1.0
109
*/
1110
final class PicoOutput extends AbstractPicoPlugin
1211
{
12+
const API_VERSION = 2;
13+
1314
private $serveContent;
1415
private $contentFormat;
1516

@@ -59,23 +60,27 @@ public function enabledFormat()
5960
private function contentOutput()
6061
{
6162
$pico = $this->getPico();
63+
$page = $pico->getCurrentPage();
64+
unset($page['previous_page']);
65+
unset($page['next_page']);
66+
unset($page['tree_node']);
6267
switch ($this->contentFormat) {
6368
case 'raw':
6469
return $pico->getRawContent();
6570
case 'prepared':
6671
return $pico->prepareFileContent($pico->getRawContent(), $pico->getFileMeta());
6772
case 'json':
6873
header('Content-Type: application/json;charset=utf-8');
69-
return json_encode($pico->getCurrentPage());
74+
return json_encode($page);
7075
case 'xml':
7176
header("Content-type: text/xml");
7277
$xml = new SimpleXMLElement('<page/>');
73-
$this->array_to_xml($pico->getCurrentPage(), $xml);
78+
$this->array_to_xml($page, $xml);
7479
return $xml->asXML();
7580
default:
7681
return $pico->getFileContent();
7782
}
78-
}
83+
}
7984

8085
// function defination to convert array to xml
8186
private function array_to_xml( $data, &$xml_data )

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Pico Output
22

3-
Output the page content or data as raw, html, json or xml with `?output` in [Pico CMS](http://picocms.org).
3+
Output [Pico CMS](http://picocms.org) page data as raw text, html, json or xml with `?output`.
44

55
## Installation
66

77
Copy `PicoOutput.php` to the `plugins/` directory of your Pico Project.
88

99
## Usage
1010

11-
Enable the plugin and the output formats in Pico `config.php`.
11+
Enable output formats in Pico config file.
1212

13-
```php
14-
$config['PicoOutput.enabled'] = true; // by default
15-
$config['PicoOutput.enabledFormats'] = array('content', 'prepared');
13+
```yml
14+
PicoOutput.enabled: true # by default
15+
PicoOutput.enabledFormats: [content, raw, prepared, xml, json]
1616
```
1717
1818
Then add `?output=format` to any url.

0 commit comments

Comments
 (0)