From 1007ccf3bcb7521482bafc652280add8d4c1a342 Mon Sep 17 00:00:00 2001 From: adrianbj Date: Tue, 13 Mar 2018 10:52:27 -0700 Subject: [PATCH] Support for Template Info section of Request Info panel when viewing template settings in the admin. Minor Tracy core updates. --- TracyDebugger.module | 2 +- panels/RequestInfoPanel.php | 39 +++++++++++++++--------- tracy-master/src/Tracy/Helpers.php | 2 +- tracy-master/src/Tracy/assets/Bar/bar.js | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/TracyDebugger.module b/TracyDebugger.module index 17a25bc5..a8e83e8c 100644 --- a/TracyDebugger.module +++ b/TracyDebugger.module @@ -32,7 +32,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule { 'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__), 'author' => 'Adrian Jones', 'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/', - 'version' => '4.9.26', + 'version' => '4.9.27', 'autoload' => true, 'singular' => true, 'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4', diff --git a/panels/RequestInfoPanel.php b/panels/RequestInfoPanel.php index 659113ca..421e98aa 100644 --- a/panels/RequestInfoPanel.php +++ b/panels/RequestInfoPanel.php @@ -338,7 +338,10 @@ public function getPanel() { // Template info // defining $templateFilePath even if templateInfo not a selected panel because it's used to build the template editing button at the bottom of the panel - if($isPwPage && ($this->wire('process') == 'ProcessPageView' || $this->wire('process') == 'ProcessPageEdit')) { + if($this->wire('input')->get('id') && $this->wire('page')->process == 'ProcessTemplate') { + $templateFilePath = $this->wire('templates')->get((int)$this->wire('input')->get('id'))->filename; + } + elseif($isPwPage && ($this->wire('process') == 'ProcessPageView' || $this->wire('process') == 'ProcessPageEdit')) { if(file_exists($p->template->filename)) $templateFilePath = $p->template->filename; } elseif($isPwPage && $this->wire('process')) { @@ -347,6 +350,7 @@ public function getPanel() { else { $templateFilePath = $_SERVER['SCRIPT_FILENAME']; } + if(!isset($templateFilePath) || !file_exists($templateFilePath)) $templateFilePath = null; $templateFileEditorLinkIcon = ' wire('input')->get('id') && $this->wire('page')->process == 'ProcessTemplate') { + $template = $this->wire('templates')->get((int)$this->wire('input')->get('id')); + } + else { + $template = $p->template; + } + $templateInfo = ' - + - + - + - + - + @@ -405,35 +416,35 @@ public function getPanel() { - + - + - + - + - + - + - + - +
label'.($this->wire('languages') ? $p->template->getLabel($userLang) : $p->template->label).''.($this->wire('languages') ? $template->getLabel($userLang) : $template->label).'
name'.$p->template->name.''.$template->name.'
id'.$p->template->id.''.$template->id.'
modified'.date("Y-m-d H:i:s", $p->template->modified).''.date("Y-m-d H:i:s", $template->modified).'
fieldgroup'.$p->template->fieldgroup.''.$template->fieldgroup.'
filename
compile'.($p->template->compile == 0 ? 'No' : ($p->template->compile == 1 ? 'Yes (template file only)' : 'Yes (and included files)')).''.($template->compile === 0 ? 'No' : ($template->compile === 1 ? 'Yes (template file only)' : 'Yes (and included files)')).'
contentType'.$p->template->contentType.''.$template->contentType.'
allowPageNum'.($p->template->allowPageNum ? 'Enabled' : 'Disabled').''.($template->allowPageNum === 1 ? 'Enabled' : 'Disabled').'
urlSegments'.($p->template->urlSegments ? 'Enabled' : 'Disabled').''.($template->urlSegments === 1 ? 'Enabled' : 'Disabled').'
noChildren (Children Allowed)'.($p->template->noChildren ? 'No' : 'Yes').''.($template->noChildren === 1 ? 'No' : 'Yes').'
noParents (Allow for New Page)'.($p->template->noParents < 0 ? 'Only One' : ($p->template->noParents == 1 ? 'No' : 'Yes')).''.($template->noParents < 0 ? 'Only One' : ($template->noParents === 1 ? 'No' : 'Yes')).'
sortfield (Children Sorted By)'.$p->template->sortfield.''.$template->sortfield.'
cache_time (Cache Time)'.$p->template->cache_time.''.$template->cache_time.'
'; } diff --git a/tracy-master/src/Tracy/Helpers.php b/tracy-master/src/Tracy/Helpers.php index 3d9a35e1..0c45e5a0 100644 --- a/tracy-master/src/Tracy/Helpers.php +++ b/tracy-master/src/Tracy/Helpers.php @@ -242,7 +242,7 @@ public static function isAjax() /** @internal */ public static function getNonce() { - return preg_match('#^Content-Security-Policy:.*\sscript-src\s+(?:[^;]+\s)?\'nonce-([\w+/]+=*)\'#mi', implode("\n", headers_list()), $m) + return preg_match('#^Content-Security-Policy(?:-Report-Only)?:.*\sscript-src\s+(?:[^;]+\s)?\'nonce-([\w+/]+=*)\'#mi', implode("\n", headers_list()), $m) ? $m[1] : null; } diff --git a/tracy-master/src/Tracy/assets/Bar/bar.js b/tracy-master/src/Tracy/assets/Bar/bar.js index 996749db..0c87d56e 100644 --- a/tracy-master/src/Tracy/assets/Bar/bar.js +++ b/tracy-master/src/Tracy/assets/Bar/bar.js @@ -6,7 +6,7 @@ Tracy = window.Tracy || {}; if (document.currentScript) { - var nonce = document.currentScript.getAttribute('nonce'); + var nonce = document.currentScript.getAttribute('nonce') || document.currentScript.nonce; var contentId = document.currentScript.dataset.id; }