From bd784cd79d08afde4cd44157b50361285f3597de Mon Sep 17 00:00:00 2001 From: Nicolas Brassard Date: Fri, 22 Feb 2019 17:06:32 -0500 Subject: [PATCH] Add XSLT profiling --- content/content.profile.php | 24 ++++++++++++++++++++++-- extension.driver.php | 6 +++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/content/content.profile.php b/content/content.profile.php index f10ec71..4978d80 100644 --- a/content/content.profile.php +++ b/content/content.profile.php @@ -18,7 +18,7 @@ public function __construct(){ } } - public function build() { + public function build(array $context = []) { $this->_view = (strlen(trim($_GET['profile'])) == 0 ? 'general' : $_GET['profile']); // Build statistics @@ -37,7 +37,7 @@ public function build() { } } - return parent::build(); + return parent::build($context); } protected function buildJump(XMLElement $wrapper) { @@ -87,6 +87,12 @@ protected function buildJump(XMLElement $wrapper) { ($this->_view == 'memory-usage') )); + $list->appendChild($this->buildJumpItem( + __('XSLT Execution'), + '?profile=xslt' . $this->_query_string, + ($this->_view == 'xslt') + )); + if(is_object(Symphony::Database())){ $list->appendChild($this->buildJumpItem( __('Database Queries'), @@ -228,6 +234,20 @@ public function buildContent(XMLElement $wrapper) { } } + else if ($this->_view == 'xslt') { + $file = Frontend::Page()->Proc->getProfiling(); + $content = ($file && General::checkFileReadable($file)) ? file_get_contents($file) : null; + if (!$content) { + $content = __('Error'); + } else { + General::deleteFile($file); + } + $row = new XMLElement('tr'); + $row->appendChild(new XMLElement('th', __('Results'))); + $row->appendChild((new XMLElement('td'))->appendChild(new XMLElement('pre', $content))); + $table->appendChild($row); + } + else if ($this->_records = $this->_records[$this->_view]) { $ds_total = 0; diff --git a/extension.driver.php b/extension.driver.php index 744dd3a..1f486ce 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -25,7 +25,11 @@ public function getSubscribedDelegates() { public function frontendDevKitResolve($context) { if (isset($_GET['profile'])) { require_once(EXTENSIONS . '/profiledevkit/content/content.profile.php'); - + + if ($_GET['profile'] === 'xslt') { + Frontend::Page()->Proc->setProfiling(TMP . '/xslt.profile'); + } + $context['devkit'] = new Content_ProfileDevkit(); self::$active = true; }