From fbd63b532faa88cd5f15dc3e88f9dc4c9d50a718 Mon Sep 17 00:00:00 2001 From: Rowan Lewis Date: Fri, 19 Mar 2010 22:13:59 +1000 Subject: [PATCH 1/3] Added the ?debug-capture page to save the state of a request for further debugging. --- content/content.capture.php | 48 +++++++++++++++++++++++++++++++ content/content.debug.php | 56 +++++++++++++++++++++++++++++++------ extension.driver.php | 15 +++++----- readme.md | 10 +++++-- 4 files changed, 111 insertions(+), 18 deletions(-) create mode 100644 content/content.capture.php diff --git a/content/content.capture.php b/content/content.capture.php new file mode 100644 index 0000000..4a0a65c --- /dev/null +++ b/content/content.capture.php @@ -0,0 +1,48 @@ +Author->get('id') + ); + + $_SESSION[$unique_id] = array( + 'param' => $param, + 'xml' => $xml, + 'output' => $output + ); + } + + public function build() { + $page = $this->_page; + $data = $this->_pagedata; + $type = $data['type']; + + if (@in_array('XML', $type) or @in_array('xml', $type)) { + $this->addHeaderToPage('Content-Type', 'text/xml; charset=utf-8'); + } + + else { + $this->addHeaderToPage('Content-Type', 'text/html; charset=utf-8'); + } + + if (@in_array('404', $type)) { + $this->addHeaderToPage('HTTP/1.0 404 Not Found'); + } + + else if (@in_array('403', $type)) { + $this->addHeaderToPage('HTTP/1.0 403 Forbidden'); + } + + $this->__renderHeaders(); + + echo $this->_output; exit; + } + } + +?> \ No newline at end of file diff --git a/content/content.debug.php b/content/content.debug.php index 65a8eea..a0cb969 100755 --- a/content/content.debug.php +++ b/content/content.debug.php @@ -20,22 +20,51 @@ General::realiseDirectory(BITTER_CACHE_PATH); } - class Content_DebugDevKit_Debug extends DevKit { + class Content_DebugDevkit_Debug extends DevKit { protected $_view = ''; protected $_xsl = ''; protected $_full_utility_list = ''; + protected $_using_capture = false; public function __construct(){ parent::__construct(); $this->_title = __('Debug'); - $this->_query_string = parent::__buildQueryString(array('symphony-page', 'debug')); + $this->_query_string = parent::__buildQueryString(array('symphony-page', 'debug', 'debug-capture')); if (!empty($this->_query_string)) { $this->_query_string = '&' . General::sanitize($this->_query_string); } } + public function prepare($page, $pagedata, $xml, $param, $output) { + $unique_id = sprintf( + 'symphony-debug-capture-for-author-%d', + Frontend::instance()->Author->get('id') + ); + + if (isset($_SESSION[$unique_id])) { + if ($_GET['debug'] == 'reset') { + $length = strlen($this->_query_string); + $url = sprintf('%s%sdebug', $this->_query_string, ($length == 0 ? '?' : '&')); + + unset($_SESSION[$unique_id]); + redirect($url); + } + + else { + $this->_using_capture = true; + $data = $_SESSION[$unique_id]; + + $xml = $data['xml']; + $param = $data['param']; + $output = $data['output']; + } + } + + parent::prepare($page, $pagedata, $xml, $param, $output); + } + public function build() { $this->_view = (strlen(trim($_GET['debug'])) == 0 ? 'xml' : $_GET['debug']); $this->_xsl = @file_get_contents($this->_pagedata['filelocation']); @@ -46,6 +75,14 @@ public function build() { protected function buildJump($wrapper) { $list = new XMLElement('ul'); + if ($this->_using_capture) { + $list->appendChild($this->buildJumpItem( + __('Clear Capture'), + '?debug=reset' . $this->_query_string, + ($this->_view == 'reset') + )); + } + $list->appendChild($this->buildJumpItem( __('Params'), '?debug=params' . $this->_query_string, @@ -91,14 +128,17 @@ public function buildContent($wrapper) { if ($this->_view == 'params') { $wrapper->appendChild($this->__buildParams($this->_param)); - - } else if ($this->_view == 'xml') { + } + + else if ($this->_view == 'xml') { $this->appendSource($wrapper, $this->_xml, 'xml'); - - } else if ($this->_view == 'result') { + } + + else if ($this->_view == 'result') { $this->appendSource($wrapper, $this->_output, 'xml'); - - } else { + } + + else { if ($_GET['debug'] == basename($this->_pagedata['filelocation'])) { $this->appendSource($wrapper, $this->_xsl, 'xsl'); diff --git a/extension.driver.php b/extension.driver.php index f274075..a8002b4 100755 --- a/extension.driver.php +++ b/extension.driver.php @@ -9,8 +9,8 @@ class Extension_DebugDevKit extends Extension { public function about() { return array( - 'name' => 'Debug DevKit', - 'version' => '1.0.8', + 'name' => 'Debug Devkit', + 'version' => '1.0.9', 'release-date' => '2010-03-19', 'author' => array( 'name' => 'Rowan Lewis', @@ -39,16 +39,15 @@ public function frontendDevKitResolve($context) { if (false or isset($_GET['debug'])) { require_once(EXTENSIONS . '/debugdevkit/content/content.debug.php'); - $context['devkit'] = new Content_DebugDevKit_Debug(); + $context['devkit'] = new Content_DebugDevkit_Debug(); self::$active = true; } - else if (false and isset($_GET['debug-edit'])) { - require_once(EXTENSIONS . '/debugdevkit/content/content.debug.php'); - require_once(EXTENSIONS . '/debugdevkit/content/content.edit.php'); + // Capture debug information: + else if (isset($_GET['debug-capture'])) { + require_once(EXTENSIONS . '/debugdevkit/content/content.capture.php'); - $context['devkit'] = new Content_DebugDevKit_Edit(); - self::$active = true; + $context['devkit'] = new Content_DebugDevkit_Capture(); } } diff --git a/readme.md b/readme.md index 5ad8ed6..abf73e5 100755 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ A debug panel for Symphony. It is part of the Symphony core download package. -- Version: 1.0.8 +- Version: 1.0.9 - Date: 2010-03-19 - Requirements: Symphony 2.0.4 or later - Author: Rowan Lewis, me@rowanlewis.com @@ -11,10 +11,16 @@ It is part of the Symphony core download package. ## Usage -Append `?debug` to your front-end pages when logged in to initialise this Devkit. +Append `?debug` to your front-end pages when logged in to initialise this +Devkit. Use `?debug-capture` to save a request for viewing with `?debug` +later on. ## Change Log +**Version 1.0.9** + +- Added the `?debug-capture` page to save the state of a request for further debugging. + **Version 1.0.6** - Added localisation files for Dutch, German, Portuguese (Brazil) and Russian From 4658ed0a677529f927f647364ba68940276e4057 Mon Sep 17 00:00:00 2001 From: pointybeard Date: Thu, 20 May 2010 15:10:05 +0800 Subject: [PATCH 2/3] Bitter cache path set to manifest/cache/ --- content/content.debug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/content.debug.php b/content/content.debug.php index a0cb969..5b6d8d5 100755 --- a/content/content.debug.php +++ b/content/content.debug.php @@ -9,7 +9,7 @@ } if (!defined('BITTER_CACHE_PATH')) { - define('BITTER_CACHE_PATH', EXTENSIONS . '/debugdevkit/lib/bitter/caches'); + define('BITTER_CACHE_PATH', CACHE); } require_once(TOOLKIT . '/class.devkit.php'); From 5454ae11ac30e621b2042ab70ed509af2f0258cd Mon Sep 17 00:00:00 2001 From: goldmar Date: Wed, 15 Sep 2010 07:13:21 +0800 Subject: [PATCH 3/3] Fixed shifted lines issue in Opera. --- lib/bitter/formats/symphony.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bitter/formats/symphony.php b/lib/bitter/formats/symphony.php index ff79cd3..48b3924 100755 --- a/lib/bitter/formats/symphony.php +++ b/lib/bitter/formats/symphony.php @@ -56,9 +56,9 @@ protected function processLines() { foreach ($characters as $character) { if ($character == "\n") { - $this->endLine(); - foreach ($stack as $alt_token) $this->output .= ''; + + $this->endLine(); } $this->output .= $character;