13b2c8e94a63f2438402119c27854101e8482e96
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']) || isset($_POST['next'])){
76 if(isset($_GET['step'])){
77 $step = $_GET['step'];
78 }else{
79 $step = $this->i_current + 1;
80 }
82 if($this->selectable_step($step)){
83 $this->i_last = $this->i_current;
84 $this->i_current = $step;
85 }
86 }
87 }
90 /* Create navigation menu */
91 function get_navigation_html()
92 {
93 $str = "";
94 foreach($this->o_steps as $key => $step){
96 $s_title = $step -> get_title();
97 $s_info = $step -> get_small_info();
98 $b_active = $step -> is_active();
99 $b_enabled = $step -> is_enabled();
101 $str .="<div >";
102 if($b_enabled){
103 if($b_active){
104 $str .= "<a href='?step=".$key."' class='navigation_element_active'>";
105 $str .= "<div class='navigation_title_active'>".$s_title."</div>";
106 $str .= "<div class='navigation_info'>".$s_info."</div>";
107 $str .= "</a><br>\n";
108 }else{
109 $str .= "<a href='?step=".$key."' class='navigation_element'>";
110 $str .= "<div class='navigation_title_inactive'>".$s_title."</div>";
111 $str .= "</a><br>\n";
112 }
113 }else{
114 $str .= "<div class='navigation_element'>";
115 $str .= "<div class='navigation_title_disabled'>".$s_title."</div>";
116 $str .= "</div>";
117 }
118 $str .= "</div>" ;
119 }
120 return($str);
121 }
124 /* Create header entry */
125 function get_header_html()
126 {
127 $str ="<font style='font-size:20px;'>";
128 $str.= $this->o_steps[$this->i_current]->get_long_title();
129 $str.="</font>";
130 return ($str);
131 }
134 /* Check if the given step id is valid and selectable */
135 function selectable_step($id)
136 {
137 if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){
138 return(true);
139 }
140 return(false);
141 }
142 }
147 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
148 ?>