Skip to content

Commit

Permalink
Change "Specific Modules Only" from last commit and change it to "Spe…
Browse files Browse the repository at this point in the history
…cified directories" option which is more flexible and should support all requirements of Issue#98
  • Loading branch information
adrianbj committed Oct 16, 2024
1 parent 691fa9c commit 4f848c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
15 changes: 7 additions & 8 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.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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
25 changes: 10 additions & 15 deletions panels/TodoPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -35,7 +33,7 @@ public function getTab() {
$this->entries .= "
\n<tr>";
if($currentFile !== $item['file']) {
$this->entries .= "<td" . ($i==0 ? " rowspan='" . count($files[$file]) . "'" : "") . $thisPageFile . ">" . str_replace($pathReplace, '', $item['file']) . "</td>";
$this->entries .= "<td" . ($i==0 ? " rowspan='" . count($files[$file]) . "'" : "") . $thisPageFile . ">" . str_replace($this->wire('config')->paths->root, '', $item['file']) . "</td>";
}
// if "todo" or other matched tag is at start of comment then remove it
// otherwise, underline it wherever it is in the comment
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 4f848c7

Please sign in to comment.