function crumbs_Debug_CandidateLogger::getAsMatrix in Crumbs, the Breadcrumbs suite 7.2
Parameters
array $trail:
Return value
array
File
- lib/
Debug/ CandidateLogger.php, line 39
Class
Code
function getAsMatrix($trail) {
$rows = array();
$weights = array();
$empty_row = array();
$default_row = array();
$paths = array_keys($trail);
foreach ($paths as $i => $path) {
$empty_row["{$path}:title"] = '';
$default_row["{$path}:title"] = isset($trail[$path]['title']) ? $trail[$path]['title'] : 'NULL';
$empty_row["{$path}:parent"] = '';
$default_row["{$path}:parent"] = isset($paths[$i + 1]) ? $paths[$i + 1] : 'END';
}
if (isset($path)) {
// The last item does not have a parent.
unset($empty_row["{$path}:parent"]);
unset($default_row["{$path}:parent"]);
}
$best_cells = array();
foreach (array(
'parent' => $this->logFindParent,
'title' => $this->logFindTitle,
) as $type => $log) {
foreach ($log as $info) {
if (isset($info['bestCandidateKey'])) {
$best_cells[$info['bestCandidateKey']][$info['path'] . ':' . $type] = TRUE;
}
else {
$best_cells['(default)'][$info['path'] . ':' . $type] = TRUE;
}
if (isset($info['candidates'])) {
foreach ($info['candidates'] as $key => $candidate) {
if (!isset($rows[$key])) {
$rows[$key] = $empty_row;
$weights[$key] = $candidate['weight'];
}
if (!isset($candidate['raw'])) {
$value = '(NULL)';
}
elseif (FALSE === $candidate['raw']) {
$value = '(FALSE)';
}
else {
$value = check_plain($candidate['raw']);
if ($candidate['processed'] !== $candidate['raw']) {
$value .= '<br/>->' . check_plain($candidate['processed']);
}
}
$rows[$key][$info['path'] . ':' . $type] = $value;
}
}
if (isset($info['path'])) {
$cols[$info['path']] = array();
}
}
}
asort($weights);
$matrix = array();
foreach ($weights as $key => $weight) {
$matrix[$key] = $rows[$key];
}
$weights['(default)'] = '-';
$matrix['(default)'] = $default_row;
return array(
$matrix,
$best_cells,
$weights,
);
}