Skip to content

Commit

Permalink
Add ability for TODO panel to limit to specific modules only.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Oct 16, 2024
1 parent 647f065 commit 691fa9c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
28 changes: 19 additions & 9 deletions TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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__);
Expand All @@ -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
Expand Down
12 changes: 11 additions & 1 deletion panels/TodoPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 691fa9c

Please sign in to comment.