Skip to content

Commit 4f848c7

Browse files
committed
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
1 parent 691fa9c commit 4f848c7

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

TracyDebugger.module.php

Lines changed: 7 additions & 8 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.38',
30+
'version' => '4.26.39',
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',
@@ -286,7 +286,7 @@ static public function getDefaultData() {
286286
"todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules',
287287
"todoScanAssets" => null,
288288
"todoScanModules" => null,
289-
"todoSpecificModulesOnly" => '',
289+
"todoSpecifiedDirectories" => '',
290290
"todoAllowedExtensions" => 'php, module, inc, txt, latte, html, htm, md, css, scss, less, js',
291291
"variablesShowPwObjects" => null,
292292
"alwaysShowDebugTools" => 1,
@@ -4305,12 +4305,11 @@ public function getModuleConfigInputfields(array $data) {
43054305
$fieldset->add($f);
43064306

43074307
$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']);
4308+
$f->attr('name', 'todoSpecifiedDirectories');
4309+
$f->label = __('Specified directories', __FILE__);
4310+
$f->description = __('Line break separated directories to be scanned for ToDo items.', __FILE__);
4311+
$f->notes = __('For example `site/classes` or `site/modules/MyModuleName`', __FILE__);
4312+
if($data['todoSpecifiedDirectories']) $f->attr('value', $data['todoSpecifiedDirectories']);
43144313
$fieldset->add($f);
43154314

43164315
// ProcessWire and Tracy Log Panels

panels/TodoPanel.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public function getTab() {
1212
if(\TracyDebugger::isAdditionalBar()) return;
1313
\Tracy\Debugger::timer('todo');
1414

15-
$pathReplace = \TracyDebugger::getDataValue('todoScanModules') == 1 || \TracyDebugger::getDataValue('todoScanAssets') == 1 ? $this->wire('config')->paths->root : $this->wire('config')->paths->templates;
16-
1715
$numEntries = 0;
1816
$thisPageNumEntries = 0;
1917
$files = $this->getTodos();
@@ -35,7 +33,7 @@ public function getTab() {
3533
$this->entries .= "
3634
\n<tr>";
3735
if($currentFile !== $item['file']) {
38-
$this->entries .= "<td" . ($i==0 ? " rowspan='" . count($files[$file]) . "'" : "") . $thisPageFile . ">" . str_replace($pathReplace, '', $item['file']) . "</td>";
36+
$this->entries .= "<td" . ($i==0 ? " rowspan='" . count($files[$file]) . "'" : "") . $thisPageFile . ">" . str_replace($this->wire('config')->paths->root, '', $item['file']) . "</td>";
3937
}
4038
// if "todo" or other matched tag is at start of comment then remove it
4139
// otherwise, underline it wherever it is in the comment
@@ -149,22 +147,19 @@ protected function sectionHeader($columnNames = array()) {
149147

150148

151149
private function getTodos() {
152-
$items = array();
153-
$moduleItems = array();
154150
$items = $this->scanDirectories($this->wire('config')->paths->templates);
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-
}
151+
if(\TracyDebugger::getDataValue('todoScanModules') == 1) $moduleItems = $this->scanDirectories($this->wire('config')->paths->siteModules);
165152
if(isset($moduleItems)) $items = array_merge($items, $moduleItems);
166153
if(\TracyDebugger::getDataValue('todoScanAssets') == 1) $assetsItems = $this->scanDirectories($this->wire('config')->paths->assets);
167154
if(isset($assetsItems)) $items = array_merge($items, $assetsItems);
155+
156+
if(\TracyDebugger::getDataValue('todoSpecifiedDirectories') != '') {
157+
foreach(array_map('trim', explode("\n", \TracyDebugger::getDataValue('todoSpecifiedDirectories'))) as $customSpecifiedDir) {
158+
$customSpecifiedItems = $this->scanDirectories($this->wire('config')->paths->root . $customSpecifiedDir);
159+
$items = array_merge($items, $customSpecifiedItems);
160+
}
161+
}
162+
168163
return $items;
169164
}
170165

0 commit comments

Comments
 (0)