From 51f0dd5e37db0e8d2a8690655555d399249942df Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 5 Dec 2009 01:03:04 -0500 Subject: [PATCH] Add configuration option to toggle the indenting of the output HTML. Defaults to indent enabled. --- actions/twitapisearchatom.php | 2 +- config.php.sample | 5 +++++ lib/action.php | 2 +- lib/default.php | 1 + lib/error.php | 2 +- lib/htmloutputter.php | 2 +- lib/rssaction.php | 2 +- lib/xmloutputter.php | 5 ++++- plugins/Facebook/facebookaction.php | 2 +- plugins/Facebook/facebookutil.php | 2 +- 10 files changed, 17 insertions(+), 8 deletions(-) diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index 526ca2ae8b..1cb8d7efe6 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -71,7 +71,7 @@ class TwitapisearchatomAction extends ApiAction * @see Action::__construct */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); } diff --git a/config.php.sample b/config.php.sample index 9fccb84f3b..473eb74e2c 100644 --- a/config.php.sample +++ b/config.php.sample @@ -236,6 +236,11 @@ $config['sphinx']['port'] = 3312; // Use a different hostname for SSL-encrypted pages // $config['site']['sslserver'] = 'secure.example.org'; +// Indent HTML and XML +// Enable (default) for easier to read markup for developers, +// disable to save some bandwidth. +// $config['site']['indent'] = true; + // If you have a lot of status networks on the same server, you can // store the site data in a database and switch as follows // Status_network::setupDB('localhost', 'statusnet', 'statuspass', 'statusnet'); diff --git a/lib/action.php b/lib/action.php index 8ad3917550..87d8a43993 100644 --- a/lib/action.php +++ b/lib/action.php @@ -68,7 +68,7 @@ class Action extends HTMLOutputter // lawsuit * @see XMLOutputter::__construct * @see HTMLOutputter::__construct */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); } diff --git a/lib/default.php b/lib/default.php index d4ef045ea5..db90aeca3e 100644 --- a/lib/default.php +++ b/lib/default.php @@ -53,6 +53,7 @@ $default = 'shorturllength' => 30, 'dupelimit' => 60, # default for same person saying the same thing 'textlimit' => 140, + 'indent' => true, ), 'db' => array('database' => 'YOU HAVE TO SET THIS IN config.php', diff --git a/lib/error.php b/lib/error.php index 3162cfe656..87a4d913b4 100644 --- a/lib/error.php +++ b/lib/error.php @@ -50,7 +50,7 @@ class ErrorAction extends Action var $message = null; var $default = null; - function __construct($message, $code, $output='php://output', $indent=true) + function __construct($message, $code, $output='php://output', $indent=null) { parent::__construct($output, $indent); diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index fd448ced5e..2091c6e2ca 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -67,7 +67,7 @@ class HTMLOutputter extends XMLOutputter * @param boolean $indent Whether to indent output, default true */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); } diff --git a/lib/rssaction.php b/lib/rssaction.php index d591c99ed8..62e3f21b61 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -52,7 +52,7 @@ class Rss10Action extends Action * @see Action::__construct */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); } diff --git a/lib/xmloutputter.php b/lib/xmloutputter.php index 5f06e491df..15b18e7d90 100644 --- a/lib/xmloutputter.php +++ b/lib/xmloutputter.php @@ -67,10 +67,13 @@ class XMLOutputter * @param boolean $indent Whether to indent output, default true */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { $this->xw = new XMLWriter(); $this->xw->openURI($output); + if(is_null($indent)) { + $indent = common_config('site', 'indent'); + } $this->xw->setIndent($indent); } diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php index c852bbf5e6..b090e9bd9a 100644 --- a/plugins/Facebook/facebookaction.php +++ b/plugins/Facebook/facebookaction.php @@ -44,7 +44,7 @@ class FacebookAction extends Action var $app_uri = null; var $app_name = null; - function __construct($output='php://output', $indent=true, $facebook=null, $flink=null) + function __construct($output='php://output', $indent=null, $facebook=null, $flink=null) { parent::__construct($output, $indent); diff --git a/plugins/Facebook/facebookutil.php b/plugins/Facebook/facebookutil.php index 6f50c173ad..2abcbb14e2 100644 --- a/plugins/Facebook/facebookutil.php +++ b/plugins/Facebook/facebookutil.php @@ -168,7 +168,7 @@ function facebookBroadcastNotice($notice) function updateProfileBox($facebook, $flink, $notice) { $fbaction = new FacebookAction($output = 'php://output', - $indent = true, $facebook, $flink); + $indent = null, $facebook, $flink); $fbaction->updateProfileBox($notice); }