Skip to content

Commit

Permalink
Add JSON page type to Symphony's system types. Closes #732
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Oct 21, 2011
1 parent 5216a17 commit 67eeada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 8 additions & 3 deletions symphony/lib/toolkit/class.frontendpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ public function generate($page) {
));

if (is_null($devkit)) {
if(in_array('XML', $this->_pageData['type']) || in_array('xml', $this->_pageData['type'])) {
if(General::in_iarray('XML', $this->_pageData['type'])) {
$this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8');
}
else if(General::in_iarray('JSON', $this->_pageData['type'])) {
$this->addHeaderToPage('Content-Type', 'application/json; charset=utf-8');
}
else{
$this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8');
}
Expand Down Expand Up @@ -249,8 +252,10 @@ public function generate($page) {
return $devkit->build();
}

## EVENT DETAILS IN SOURCE
if ($this->is_logged_in && Symphony::Configuration()->get('display_event_xml_in_source', 'public') == 'yes') {
// Display the Event Results in the page source if the user is logged
// into Symphony, the page is not JSON and if it is enabled in the
// configuration.
if ($this->is_logged_in && !General::in_iarray('JSON', $this->_pageData['type']) && Symphony::Configuration()->get('display_event_xml_in_source', 'public') == 'yes') {
$output .= PHP_EOL . '<!-- ' . PHP_EOL . $this->_events_xml->generate(true) . ' -->';
}

Expand Down
7 changes: 4 additions & 3 deletions symphony/lib/toolkit/class.pagemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,17 @@ public static function fetchPageTypes($page_id = null) {

/**
* Returns all the page types that exist in this Symphony install.
* There are 5 default system page types, and new types can be added
* There are 6 default system page types, and new types can be added
* by Developers via the Page Editor.
*
* @since Symphony 2.3 introduced the JSON type.
* @return array
* An array of strings of the page types used in this Symphony
* install. At the minimum, this will be an array with the values
* 'index', 'XML', 'admin', '404' and '403'.
* 'index', 'XML', 'JSON', 'admin', '404' and '403'.
*/
public static function fetchAvailablePageTypes(){
$system_types = array('index', 'XML', 'admin', '404', '403');
$system_types = array('index', 'XML', 'JSON', 'admin', '404', '403');

$types = PageManager::fetchPageTypes();

Expand Down

0 comments on commit 67eeada

Please sign in to comment.