Refactoring Display logic

This commit is contained in:
Josh Sherman 2010-03-12 00:02:29 -05:00
parent 1f4d4acf94
commit 012c3f8717
6 changed files with 135 additions and 193 deletions

View file

@ -3,25 +3,16 @@
/**
* JSON Display Class File for PICKLES
*
* PICKLES is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* PHP version 5
*
* PICKLES is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* Licensed under the GNU General Public License Version 3
* Redistribution of these files must retain the above copyright notice.
*
* You should have received a copy of the GNU Lesser General Public
* License along with PICKLES. If not, see
* <http://www.gnu.org/licenses/>.
*
* @author Joshua John Sherman <josh@phpwithpickles.org>
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
* @package pickles
* @author Josh Sherman <josh@phpwithpickles.org>
* @copyright Copyright 2007-2010, Gravity Boulevard, LLC
* @license http://www.gnu.org/licenses/gpl.html GPL v3
* @link http://phpwithpickles.org
* @license http://www.gnu.org/copyleft/lesser.html
* @package PICKLES
*/
/**
@ -30,20 +21,24 @@
* Displays data in JavaScript Object Notation. Requires PHP 5 >= 5.2.0 or
* PECL json 1.2.0 or 1.2.1
*
* @link http://json.org/
* @link http://us.php.net/json_encode
* @link http://pecl.php.net/package/json
* @link http://json.org/
* @link http://us.php.net/json_encode
* @link http://pecl.php.net/package/json
*/
class Display_JSON extends Display_Common {
class Display_JSON extends Display_Common
{
/**
* Renders the data in JSON format
*/
public function render() {
if (!function_exists('json_encode')) {
public function render()
{
if (!function_exists('json_encode'))
{
echo '{ "type" : "error", "message" : "json_encode() not found" }';
} else {
echo json_encode($this->data);
}
else
{
echo json_encode($this->module_return);
}
}
}