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 87f5e6e..fbcca9f 100755 --- a/content/content.debug.php +++ b/content/content.debug.php @@ -24,22 +24,51 @@ throw new Exception(__('Cache folder is not writable. Please check permissions on "%s".', array(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']); @@ -50,6 +79,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, @@ -95,14 +132,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/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; 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