From 4f848c73c8045382b6a3159d16d4e7a6dd3d3291 Mon Sep 17 00:00:00 2001 From: Adrian Jones Date: Tue, 15 Oct 2024 21:58:13 -0700 Subject: [PATCH] Change "Specific Modules Only" from last commit and change it to "Specified directories" option which is more flexible and should support all requirements of Issue#98 --- TracyDebugger.module.php | 15 +++++++-------- panels/TodoPanel.php | 25 ++++++++++--------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/TracyDebugger.module.php b/TracyDebugger.module.php index bc48d6f..b34aa79 100644 --- a/TracyDebugger.module.php +++ b/TracyDebugger.module.php @@ -27,7 +27,7 @@ public static function getModuleInfo() { 'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__), 'author' => 'Adrian Jones', 'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/', - 'version' => '4.26.38', + 'version' => '4.26.39', 'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first 'singular' => true, 'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4', @@ -286,7 +286,7 @@ static public function getDefaultData() { "todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules', "todoScanAssets" => null, "todoScanModules" => null, - "todoSpecificModulesOnly" => '', + "todoSpecifiedDirectories" => '', "todoAllowedExtensions" => 'php, module, inc, txt, latte, html, htm, md, css, scss, less, js', "variablesShowPwObjects" => null, "alwaysShowDebugTools" => 1, @@ -4305,12 +4305,11 @@ public function getModuleConfigInputfields(array $data) { $fieldset->add($f); $f = $this->wire('modules')->get("InputfieldTextarea"); - $f->attr('name', 'todoSpecificModulesOnly'); - $f->label = __('Specific Modules Only', __FILE__); - $f->description = __('Comma separated list of module folder names to be included when scanning for ToDo items.', __FILE__); - $f->notes = __('If blank, all modules will be scanned.', __FILE__); - $f->showIf = 'todoScanModules=1'; - if($data['todoSpecificModulesOnly']) $f->attr('value', $data['todoSpecificModulesOnly']); + $f->attr('name', 'todoSpecifiedDirectories'); + $f->label = __('Specified directories', __FILE__); + $f->description = __('Line break separated directories to be scanned for ToDo items.', __FILE__); + $f->notes = __('For example `site/classes` or `site/modules/MyModuleName`', __FILE__); + if($data['todoSpecifiedDirectories']) $f->attr('value', $data['todoSpecifiedDirectories']); $fieldset->add($f); // ProcessWire and Tracy Log Panels diff --git a/panels/TodoPanel.php b/panels/TodoPanel.php index 6aaf4af..d1fe4cd 100644 --- a/panels/TodoPanel.php +++ b/panels/TodoPanel.php @@ -12,8 +12,6 @@ public function getTab() { if(\TracyDebugger::isAdditionalBar()) return; \Tracy\Debugger::timer('todo'); - $pathReplace = \TracyDebugger::getDataValue('todoScanModules') == 1 || \TracyDebugger::getDataValue('todoScanAssets') == 1 ? $this->wire('config')->paths->root : $this->wire('config')->paths->templates; - $numEntries = 0; $thisPageNumEntries = 0; $files = $this->getTodos(); @@ -35,7 +33,7 @@ public function getTab() { $this->entries .= " \n"; if($currentFile !== $item['file']) { - $this->entries .= "" . str_replace($pathReplace, '', $item['file']) . ""; + $this->entries .= "" . str_replace($this->wire('config')->paths->root, '', $item['file']) . ""; } // if "todo" or other matched tag is at start of comment then remove it // otherwise, underline it wherever it is in the comment @@ -149,22 +147,19 @@ protected function sectionHeader($columnNames = array()) { private function getTodos() { - $items = array(); - $moduleItems = array(); $items = $this->scanDirectories($this->wire('config')->paths->templates); - if(\TracyDebugger::getDataValue('todoScanModules') == 1) { - if(\TracyDebugger::getDataValue('todoSpecificModulesOnly') != '') { - foreach(array_map('trim', explode(',', \TracyDebugger::getDataValue('todoSpecificModulesOnly'))) as $moduleDir) { - $moduleItems += $this->scanDirectories($this->wire('config')->paths->siteModules . $moduleDir); - } - } - else { - $moduleItems += $this->scanDirectories($this->wire('config')->paths->siteModules); - } - } + if(\TracyDebugger::getDataValue('todoScanModules') == 1) $moduleItems = $this->scanDirectories($this->wire('config')->paths->siteModules); if(isset($moduleItems)) $items = array_merge($items, $moduleItems); if(\TracyDebugger::getDataValue('todoScanAssets') == 1) $assetsItems = $this->scanDirectories($this->wire('config')->paths->assets); if(isset($assetsItems)) $items = array_merge($items, $assetsItems); + + if(\TracyDebugger::getDataValue('todoSpecifiedDirectories') != '') { + foreach(array_map('trim', explode("\n", \TracyDebugger::getDataValue('todoSpecifiedDirectories'))) as $customSpecifiedDir) { + $customSpecifiedItems = $this->scanDirectories($this->wire('config')->paths->root . $customSpecifiedDir); + $items = array_merge($items, $customSpecifiedItems); + } + } + return $items; }