792dec9a979bfbdeea7b0bfbce37f2627770edc0
1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2007 Fabian Hickert
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 require_once("class_setupStep.inc");
23 class setup extends plugin
24 {
26 var $i_steps = 5; // Number of setup steps
27 var $i_current= 1; // Current step
28 var $i_last = 1; // Last setup step;
29 var $o_steps = array();
31 var $captured_values = array();
33 function setup()
34 {
35 for($i = 1 ; $i <= $this->i_steps; $i ++ ){
36 $class= "setup_step_".$i;
37 $this->o_steps[$i] = new $class();
38 }
39 }
41 function execute()
42 {
43 $smarty = get_smarty();
44 $this->o_steps[$this->i_last]->set_active(FALSE);
45 $this->o_steps[$this->i_current]->set_active();
46 $content = $this->o_steps[$this->i_current]->execute();
47 return($content);
48 }
51 /* Save posted attributes */
52 function save_object()
53 {
54 /* Call save_object for current setup step */
55 $this->o_steps[$this->i_current] -> save_object();
57 /* Get attributes from setup step */
58 $tmp = $this->o_steps[$this->i_current]->get_attributes();
59 foreach($tmp as $name => $value){
60 $this->captured_values[$name] = $value;
61 }
63 /* check if current setup step is completed now
64 and activate the next step if possible */
65 for($i = 1 ; $i <= $this->i_steps ; $i ++ ){
66 if($this->o_steps[$i]->is_completed()){
67 if(isset($this->o_steps[($i+1)])){
68 $this->o_steps[($i+1)]->set_enabled();
69 }
70 }
71 }
73 /* Check if step was selected */
74 if(isset($_GET['step'])){
75 $step = $_GET['step'];
77 if($this->selectable_step($step)){
78 $this->i_last = $this->i_current;
79 $this->i_current = $_GET['step'];
80 }
81 }
82 }
85 /* Create navigation menu */
86 function get_navigation_html()
87 {
88 $str = "";
89 foreach($this->o_steps as $key => $step){
91 $s_title = $step -> get_title();
92 $s_info = $step -> get_small_info();
93 $b_active = $step -> is_active();
94 $b_enabled = $step -> is_enabled();
96 $str .="<div >";
97 if($b_enabled){
98 if($b_active){
99 $str .= "<a href='?step=".$key."' class='navigation_element_active'>";
100 $str .= "<span class='navigation_title_active'>".$s_title."</span>";
101 $str .= "<br>";
102 $str .= "<span class='navigation_info'>".$s_info."</span>";
103 $str .= "</a><br>\n";
104 }else{
105 $str .= "<a href='?step=".$key."' class='navigation_element'>";
106 $str .= "<span class='navigation_title_inactive'>".$s_title."</span>";
107 $str .= "</a><br>\n";
108 }
109 }else{
110 $str .= "<div class='navigation_element'>";
111 $str .= "<div class='navigation_title_disabled'>".$s_title."</div>";
112 $str .= "</div>";
113 }
114 $str .= "</div>" ;
115 }
116 return($str);
117 }
120 /* Create header entry */
121 function get_header_html()
122 {
123 $str ="<font style='font-size:20px;'>";
124 $str.= $this->o_steps[$this->i_current]->get_long_title();
125 $str.="</font>";
126 return ($str);
127 }
130 /* Check if the given step id is valid and selectable */
131 function selectable_step($id)
132 {
133 if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){
134 return(true);
135 }
136 return(false);
137 }
138 }
143 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
144 ?>