From 691fa9cb2ec3e8bcd29d4f1dd8b2f2e6cc3bb6e1 Mon Sep 17 00:00:00 2001 From: Adrian Jones Date: Tue, 15 Oct 2024 20:22:31 -0700 Subject: [PATCH] Add ability for TODO panel to limit to specific modules only. --- TracyDebugger.module.php | 28 +++++++++++++++++++--------- panels/TodoPanel.php | 12 +++++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/TracyDebugger.module.php b/TracyDebugger.module.php index d57c650..bc48d6f 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.37', + 'version' => '4.26.38', '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', @@ -284,8 +284,9 @@ static public function getDefaultData() { "userSwitcherRestricted" => null, "userSwitcherIncluded" => null, "todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules', - "todoScanModules" => null, "todoScanAssets" => null, + "todoScanModules" => null, + "todoSpecificModulesOnly" => '', "todoAllowedExtensions" => 'php, module, inc, txt, latte, html, htm, md, css, scss, less, js', "variablesShowPwObjects" => null, "alwaysShowDebugTools" => 1, @@ -4285,6 +4286,15 @@ public function getModuleConfigInputfields(array $data) { if($data['todoAllowedExtensions']) $f->attr('value', $data['todoAllowedExtensions']); $fieldset->add($f); + $f = $this->wire('modules')->get("InputfieldCheckbox"); + $f->attr('name', 'todoScanAssets'); + $f->label = __('Scan site assets', __FILE__); + $f->description = __('Check to allow the ToDo to scan the /site/assets directory. Otherwise it will only scan /site/templates.', __FILE__); + $f->notes = __('If you check this, you should add files, logs, cache, sessions and other relevant terms to the `Ignore Directories` field.', __FILE__); + $f->columnWidth = 50; + $f->attr('checked', $data['todoScanAssets'] == '1' ? 'checked' : ''); + $fieldset->add($f); + $f = $this->wire('modules')->get("InputfieldCheckbox"); $f->attr('name', 'todoScanModules'); $f->label = __('Scan site modules', __FILE__); @@ -4294,13 +4304,13 @@ public function getModuleConfigInputfields(array $data) { $f->attr('checked', $data['todoScanModules'] == '1' ? 'checked' : ''); $fieldset->add($f); - $f = $this->wire('modules')->get("InputfieldCheckbox"); - $f->attr('name', 'todoScanAssets'); - $f->label = __('Scan site assets', __FILE__); - $f->description = __('Check to allow the ToDo to scan the /site/assets directory. Otherwise it will only scan /site/templates.', __FILE__); - $f->notes = __('If you check this, you should add files, logs, cache, sessions and other relevant terms to the `Ignore Directories` field.', __FILE__); - $f->columnWidth = 50; - $f->attr('checked', $data['todoScanAssets'] == '1' ? 'checked' : ''); + $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']); $fieldset->add($f); // ProcessWire and Tracy Log Panels diff --git a/panels/TodoPanel.php b/panels/TodoPanel.php index 7892c6b..6aaf4af 100644 --- a/panels/TodoPanel.php +++ b/panels/TodoPanel.php @@ -150,8 +150,18 @@ 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) $moduleItems = $this->scanDirectories($this->wire('config')->paths->siteModules); + 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(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);