Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _build/data/transport.plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'OnWebPagePrerender' => array(),
'OnWebPageInit' => array(),
'OnLoadWebPageCache' => array(),
'OnElementNotFound' => array(),
)
)
);
Expand Down
3 changes: 3 additions & 0 deletions core/components/debugparser/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changelog for debugParser.

==============
- Added logging for not found element at OnElementNotFound event

1.1.0 pl
==============
- Added support of pdoParser with Fenom syntax.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
$modx->parser->generateReport();
}
break;

case 'OnElementNotFound':
if (method_exists($modx->parser, 'addNFElement')) {
$modx->parser->addNFElement($class, $name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<tr>
<td>[[+class]]</td>
<td class="tag">[[+elements]]</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
[[+rows]]
</table>

<table class="info">
<thead>
<tr>
<th>Class of not found elements</th>
<th>Element names</th>
</tr>
</thead>

[[+nfRows]]
</table>

<table class="info">
<tr><th>Total parse time</th><th>[[+total_parse_time]] s</th></tr>
<tr><th>Total queries</th><td>[[+total_queries]]</td></tr>
Expand Down
19 changes: 19 additions & 0 deletions core/components/debugparser/model/debugparser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class debugParser extends modParser {
public $tags = array();
public $nfElements = array();
public $from_cache = false;
/** @var modParser $parser */
protected $parser = null;
Expand Down Expand Up @@ -75,6 +76,7 @@ public function generateReport() {
// Get templates
$tplOuter = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.outer.tpl');
$tpl = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.row.tpl');
$tplNF = file_get_contents(MODX_CORE_PATH . 'components/debugparser/elements/templates/template.report.nfrow.tpl');


$idx = 1;
Expand All @@ -93,6 +95,14 @@ public function generateReport() {
}
}

$data['nf'] = '';
if (!empty($this->nfElements)) {
foreach ($this->nfElements as $class => $elements) {
$pls = $this->makePlaceholders(array('class' => $class, 'elements' => implode(', ', $elements)));
$data['nfRows'] .= str_replace($pls['pl'], $pls['vl'], $tplNF);
}
}

/** @var modProcessorResponse $response */
$response = $this->modx->runProcessor('system/info');
if (!$response->isError()) {
Expand Down Expand Up @@ -171,6 +181,15 @@ public function clearCache($context = null) {
}
}

public function addNFElement($class, $name) {
if (!isset($this->nfElements[$class])) {
$this->nfElements[$class] = array();
}
if (!in_array($name, $this->nfElements[$class])) {
$this->nfElements[$class][] = $name;
}
}

/**
* /manager/controllers/default/system/info.class.php
*
Expand Down
4 changes: 4 additions & 0 deletions core/components/debugparser/model/debugpdoparser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ public function clearCache($context = null) {
$this->parser->clearCache($context);
}

public function addNFElement($class, $name) {
$this->parser->addNFElement($class, $name);
}

}