1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
/**
* © Copyright 2012 IntraHealth International, Inc.
*
* This File is part of I2CE
*
* I2CE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @package ihris
* @subpackage retain
* @author Carl Leitner <litlfred@ibiblio.org>
* @version v1.2.0.135
* @since v1.2.0.135
* @filesource
*/
/**
* Class iHRIS_RetainBreadCrumbs
*
* @access public
*/
class iHRIS_RetainBreadCrumbs {
public static $step_links =
array(1=>'financial?instruct=1&parent=',
2=>'pools?instruct=2&parent=',
3=>'intervention?instruct=3&parent=',
4=>'view?tab=intervention&instruct=4&id=',
5=>'design_scenarios?instruct=5&parent=',
6=>'view?tab=reports&instruct=6&id=');
public static function show($page,$projection, $step = null, $show_help = true) {
if(!$page instanceof I2CE_Page) {
I2CE::raiseError("Bad page");
return false;
}
if (! ($template = $page->getTemplate()) instanceof I2CE_Template) {
I2CE::raiseError("Bad template");
return false;
}
$template->appendFileById( "projection_breadcrumb.html", "div", "breadcrumb" );
if (!$projection instanceof iHRIS_Projection) {
I2CE::raiseError("Bad projection");
return false;
}
if ($step === null) {
if (count($projection->getChildIds('financial')) == 0) {
$step = 1;
} else if (count($projection->getChildIds('pool')) == 0) {
$step = 2;
} else if (!$projection->hasInterventions()) {
$step = 3;
} else if (count($projection->getChildIds('scenario')) == 0) {
$step = 4;
} else {
$step = 6;
}
}
if ($page->request_exists('instruct')) {
$step = $page->request('instruct');
}
if ($show_help) {
$help_file = 'step_' . $step .'.html';
if ($help_file = $template->findTemplate($help_file )) {
$template->userMessage(file_get_contents($help_file),'notice',false);
}
}
$template->setDisplayDataImmediate('instruct', $step);
$template->setAttribute( "class", "active", "breadcrumb", ".//*[@class='breadcrumb_step_" . $step . "']");
$parent_id = $projection->getNameId();
for ($i = 1; $i <=6; $i++) {
$template->setDisplayDataImmediate("instruct_{$i}_link",self::$step_links[$i] . $parent_id);
}
return $step;
}
}
# Local Variables:
# mode: php
# c-default-style: "bsd"
# indent-tabs-mode: nil
# c-basic-offset: 4
# End:
|