Skip to content

Commit 691fa9c

Browse files
committed
Add ability for TODO panel to limit to specific modules only.
1 parent 647f065 commit 691fa9c

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

TracyDebugger.module.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.26.37',
30+
'version' => '4.26.38',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -284,8 +284,9 @@ static public function getDefaultData() {
284284
"userSwitcherRestricted" => null,
285285
"userSwitcherIncluded" => null,
286286
"todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules',
287-
"todoScanModules" => null,
288287
"todoScanAssets" => null,
288+
"todoScanModules" => null,
289+
"todoSpecificModulesOnly" => '',
289290
"todoAllowedExtensions" => 'php, module, inc, txt, latte, html, htm, md, css, scss, less, js',
290291
"variablesShowPwObjects" => null,
291292
"alwaysShowDebugTools" => 1,
@@ -4285,6 +4286,15 @@ public function getModuleConfigInputfields(array $data) {
42854286
if($data['todoAllowedExtensions']) $f->attr('value', $data['todoAllowedExtensions']);
42864287
$fieldset->add($f);
42874288

4289+
$f = $this->wire('modules')->get("InputfieldCheckbox");
4290+
$f->attr('name', 'todoScanAssets');
4291+
$f->label = __('Scan site assets', __FILE__);
4292+
$f->description = __('Check to allow the ToDo to scan the /site/assets directory. Otherwise it will only scan /site/templates.', __FILE__);
4293+
$f->notes = __('If you check this, you should add files, logs, cache, sessions and other relevant terms to the `Ignore Directories` field.', __FILE__);
4294+
$f->columnWidth = 50;
4295+
$f->attr('checked', $data['todoScanAssets'] == '1' ? 'checked' : '');
4296+
$fieldset->add($f);
4297+
42884298
$f = $this->wire('modules')->get("InputfieldCheckbox");
42894299
$f->attr('name', 'todoScanModules');
42904300
$f->label = __('Scan site modules', __FILE__);
@@ -4294,13 +4304,13 @@ public function getModuleConfigInputfields(array $data) {
42944304
$f->attr('checked', $data['todoScanModules'] == '1' ? 'checked' : '');
42954305
$fieldset->add($f);
42964306

4297-
$f = $this->wire('modules')->get("InputfieldCheckbox");
4298-
$f->attr('name', 'todoScanAssets');
4299-
$f->label = __('Scan site assets', __FILE__);
4300-
$f->description = __('Check to allow the ToDo to scan the /site/assets directory. Otherwise it will only scan /site/templates.', __FILE__);
4301-
$f->notes = __('If you check this, you should add files, logs, cache, sessions and other relevant terms to the `Ignore Directories` field.', __FILE__);
4302-
$f->columnWidth = 50;
4303-
$f->attr('checked', $data['todoScanAssets'] == '1' ? 'checked' : '');
4307+
$f = $this->wire('modules')->get("InputfieldTextarea");
4308+
$f->attr('name', 'todoSpecificModulesOnly');
4309+
$f->label = __('Specific Modules Only', __FILE__);
4310+
$f->description = __('Comma separated list of module folder names to be included when scanning for ToDo items.', __FILE__);
4311+
$f->notes = __('If blank, all modules will be scanned.', __FILE__);
4312+
$f->showIf = 'todoScanModules=1';
4313+
if($data['todoSpecificModulesOnly']) $f->attr('value', $data['todoSpecificModulesOnly']);
43044314
$fieldset->add($f);
43054315

43064316
// ProcessWire and Tracy Log Panels

panels/TodoPanel.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,18 @@ protected function sectionHeader($columnNames = array()) {
150150

151151
private function getTodos() {
152152
$items = array();
153+
$moduleItems = array();
153154
$items = $this->scanDirectories($this->wire('config')->paths->templates);
154-
if(\TracyDebugger::getDataValue('todoScanModules') == 1) $moduleItems = $this->scanDirectories($this->wire('config')->paths->siteModules);
155+
if(\TracyDebugger::getDataValue('todoScanModules') == 1) {
156+
if(\TracyDebugger::getDataValue('todoSpecificModulesOnly') != '') {
157+
foreach(array_map('trim', explode(',', \TracyDebugger::getDataValue('todoSpecificModulesOnly'))) as $moduleDir) {
158+
$moduleItems += $this->scanDirectories($this->wire('config')->paths->siteModules . $moduleDir);
159+
}
160+
}
161+
else {
162+
$moduleItems += $this->scanDirectories($this->wire('config')->paths->siteModules);
163+
}
164+
}
155165
if(isset($moduleItems)) $items = array_merge($items, $moduleItems);
156166
if(\TracyDebugger::getDataValue('todoScanAssets') == 1) $assetsItems = $this->scanDirectories($this->wire('config')->paths->assets);
157167
if(isset($assetsItems)) $items = array_merge($items, $assetsItems);

0 commit comments

Comments
 (0)