Skip to content

Commit 36b0082

Browse files
Initial work on directory rendering complete.
1 parent 3a4f43f commit 36b0082

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

PHP/CodeCoverage/Report/HTML/Renderer.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,31 @@ public function __construct($templatePath, $charset, $generator, $date, $lowUppe
108108
}
109109

110110
/**
111-
* @param Text_Template $template
111+
* @param Text_Template $template
112+
* @param string $title
113+
* @param PHP_CodeCoverage_Report_Node $node
112114
*/
113-
protected function setCommonTemplateVariables(Text_Template $template, $title)
115+
protected function setCommonTemplateVariables(Text_Template $template, $title, PHP_CodeCoverage_Report_Node $node = NULL)
114116
{
117+
$link = '';
118+
119+
if ($node !== NULL) {
120+
$path = $node->getPathAsArray();
121+
122+
foreach ($path as $step) {
123+
$link .= sprintf(
124+
'%s<a href="%s.html">%s</a>',
125+
!empty($link) ? ' / ' : '',
126+
PHP_CodeCoverage_Util::nodeToId($step),
127+
$step->getName()
128+
);
129+
}
130+
}
131+
115132
$template->setVar(
116133
array(
117134
'title' => $title,
135+
'link' => $link,
118136
'charset' => $this->charset,
119137
'date' => $this->date,
120138
'version' => '@package_version@',

PHP/CodeCoverage/Report/HTML/Renderer/Directory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $tit
7070

7171
$template = new Text_Template($this->templatePath . 'directory.html');
7272

73-
$this->setCommonTemplateVariables($template, $title);
73+
$this->setCommonTemplateVariables($template, $title, $node);
7474

7575
$items = $this->renderItem($node, TRUE);
7676

PHP/CodeCoverage/Report/HTML/Renderer/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function render(PHP_CodeCoverage_Report_Node_File $node, $file, $title =
113113
);
114114
}
115115

116-
$this->setCommonTemplateVariables($template, $title);
116+
$this->setCommonTemplateVariables($template, $title, $node);
117117

118118
$template->renderTo($file);
119119
}

PHP/CodeCoverage/Report/Node.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ abstract class PHP_CodeCoverage_Report_Node implements Countable
6767
*/
6868
protected $path;
6969

70+
/**
71+
* @var array
72+
*/
73+
protected $pathArray;
74+
7075
/**
7176
* @var PHP_CodeCoverage_Report_Node
7277
*/
@@ -112,6 +117,24 @@ public function getPath()
112117
return $this->path;
113118
}
114119

120+
/**
121+
* @return array
122+
*/
123+
public function getPathAsArray()
124+
{
125+
if ($this->pathArray === NULL) {
126+
if ($this->parent === NULL) {
127+
$this->pathArray = array();
128+
} else {
129+
$this->pathArray = $this->parent->getPathAsArray();
130+
}
131+
132+
$this->pathArray[] = $this;
133+
}
134+
135+
return $this->pathArray;
136+
}
137+
115138
/**
116139
* @return PHP_CodeCoverage_Report_Node
117140
*/

0 commit comments

Comments
 (0)