Skip to content

Commit

Permalink
Made the Variable and Value headers pull from imported reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorn committed Jun 13, 2012
1 parent 995859c commit 96baa3e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/headers/HeaderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static function beforeRender(&$report) {

}

public function afterParse(&$report) {
public static function afterParse(&$report) {

}
}
2 changes: 1 addition & 1 deletion classes/headers/IncludeHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function beforeRender(&$report) {

}

public function afterParse(&$report) {
public static function afterParse(&$report) {

}
}
6 changes: 6 additions & 0 deletions classes/headers/ValueHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ public static function parse($key, $value, &$report) {
$report->macros[$var] = $default;
}
}

public static function afterParse(&$report) {
foreach($report->options['Includes'] as $included_report) {
$report->importHeaders($included_report,'Value');
}
}
}
6 changes: 5 additions & 1 deletion classes/headers/VariableHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ public static function parse($key, $value, &$report) {
}
}

public function afterParse(&$report) {
public static function afterParse(&$report) {
$classname = $report->options['Type'].'ReportType';

foreach($report->options['Includes'] as $included_report) {
$report->importHeaders($included_report,'Variable');
}

foreach($report->options['Variables'] as $var=>$params) {
if(isset($params['values_database'])) {
$classname::openConnection($report);
Expand Down
11 changes: 10 additions & 1 deletion lib/PhpReports/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected function parseHeaders() {

$this->options = array(
'Filters'=>array(),
'Variables'=>array()
'Variables'=>array(),
'Includes'=>array()
);
$this->headers = array();

Expand Down Expand Up @@ -148,6 +149,14 @@ protected function parseHeaders() {
if(!isset($this->options['Name'])) $this->options['Name'] = $this->report;
}

public function importHeaders($report, $name=null) {
foreach($report->header_lines as $line) {
if(!$name || $line['name']===$name) {
$this->parseHeader($line['name'],$line['value']);
}
}
}

public function parseHeader($name,$value) {
$classname = $name.'Header';
if(class_exists($classname)) {
Expand Down

0 comments on commit 96baa3e

Please sign in to comment.