From 2847407c21d5b5bffc413bb62271394c822094a6 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 29 Jan 2007 08:32:37 +0000 Subject: [PATCH] Intitial setup rework. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5640 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/{setup.php => setup.old} | 0 setup/class_setup.inc | 142 ++++++++++++++++++++++++++++++++++ setup/class_setupStep.inc | 105 +++++++++++++++++++++++++ setup/class_setupStep1.inc | 63 +++++++++++++++ setup/class_setupStep2.inc | 39 ++++++++++ setup/class_setupStep3.inc | 39 ++++++++++ setup/class_setupStep4.inc | 39 ++++++++++ setup/class_setupStep5.inc | 39 ++++++++++ setup/main.inc | 37 +++++++++ setup/setup.tpl | 4 + setup/setup_frame.tpl | 27 +++++++ setup/setup_step1.tpl | 6 ++ 12 files changed, 540 insertions(+) rename html/{setup.php => setup.old} (100%) create mode 100644 setup/class_setup.inc create mode 100644 setup/class_setupStep.inc create mode 100644 setup/class_setupStep1.inc create mode 100644 setup/class_setupStep2.inc create mode 100644 setup/class_setupStep3.inc create mode 100644 setup/class_setupStep4.inc create mode 100644 setup/class_setupStep5.inc create mode 100644 setup/main.inc create mode 100644 setup/setup.tpl create mode 100644 setup/setup_frame.tpl create mode 100644 setup/setup_step1.tpl diff --git a/html/setup.php b/html/setup.old similarity index 100% rename from html/setup.php rename to html/setup.old diff --git a/setup/class_setup.inc b/setup/class_setup.inc new file mode 100644 index 000000000..89949ecd2 --- /dev/null +++ b/setup/class_setup.inc @@ -0,0 +1,142 @@ +i_steps; $i ++ ){ + $class= "setup_step_".$i; + $this->o_steps[$i] = new $class(); + } + } + + function execute() + { + $smarty = get_smarty(); + $this->o_steps[$this->i_last]->set_active(FALSE); + $this->o_steps[$this->i_current]->set_active(); + $content = $this->o_steps[$this->i_current]->execute(); + return($content); + } + + + /* Save posted attributes */ + function save_object() + { + /* Call save_object for current setup step */ + $this->o_steps[$this->i_current] -> save_object(); + + /* Get attributes from setup step */ + $tmp = $this->o_steps[$this->i_current]->get_attributes(); + foreach($tmp as $name => $value){ + $this->captured_values[$name] = $value; + } + + /* check if current setup step is completed now + and activate the next step if possible */ + for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ + if($this->o_steps[$i]->is_completed()){ + if(isset($this->o_steps[($i+1)])){ + $this->o_steps[($i+1)]->set_enabled(); + } + } + } + + /* Check if step was selected */ + if(isset($_GET['step'])){ + $step = $_GET['step']; + + if($this->selectable_step($step)){ + $this->i_last = $this->i_current; + $this->i_current = $_GET['step']; + } + } + } + + + /* Create navigation menu */ + function get_navigation_html() + { + $str = ""; + + foreach($this->o_steps as $key => $step){ + + $s_title = $step -> get_title(); + $s_info = $step -> get_small_info(); + $b_active = $step -> is_active(); + $b_enabled = $step -> is_enabled(); + + $str .= ""; + } + $str .="
"; + if($b_enabled){ + $str .= ""; + $str .= "".$s_title.""; + if($b_active){ + $str .= "
"; + $str .= " ".$s_info.""; + $str .= "
"; + } + $str .= "
"; + }else{ + $str .= "".$s_title.""; + } + $str .= "

 

"; + $str .= "
"; + return($str); + } + + + /* Create header entry */ + function get_header_html() + { + $str =""; + $str.= $this->o_steps[$this->i_current]->get_long_title(); + $str.=""; + return ($str); + } + + + /* Check if the given step id is valid and selectable */ + function selectable_step($id) + { + if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){ + return(true); + } + return(false); + } +} + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep.inc b/setup/class_setupStep.inc new file mode 100644 index 000000000..52cfbdc79 --- /dev/null +++ b/setup/class_setupStep.inc @@ -0,0 +1,105 @@ +s_title); + } + + function get_long_title() + { + return($this->s_title_long); + } + + function get_small_info() + { + return($this->s_info); + } + + function is_active() + { + return($this->is_active); + } + + function is_enabled() + { + return($this->is_enabled); + } + + function is_completed() + { + return($this->is_completed); + } + + function set_active($value = TRUE) + { + if($value){ + $this->is_active = TRUE; + }else{ + $this->is_active = FALSE; + } + } + + function set_enabled($value = TRUE) + { + if($value){ + $this->is_enabled = TRUE; + }else{ + $this->is_enabled = FALSE; + } + } + + function set_completed($value = TRUE) + { + if($value){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + /* Return attributes handled by this setup step */ + function get_attributes() + { + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this->$attr; + } + return($tmp); + } +} + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep1.inc b/setup/class_setupStep1.inc new file mode 100644 index 000000000..de6c1017b --- /dev/null +++ b/setup/class_setupStep1.inc @@ -0,0 +1,63 @@ +is_enabled = TRUE; + $this->is_active = TRUE; + + $this->s_title = _("Language selection"); + $this->s_title_long = _("Please choose a language"); + $this->s_info = _("This step is allows you to define your prefered language."); + + $this->languages = array("de_DE" => _("German"), + "fr_FR" => _("French"), + "en_EN" => _("English"), + "ru_RU" => _("Russian")); + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("languages", $this->languages); + $smarty->assign("lang", $this->lang); + return($smarty->fetch(get_template_path("setup_step1.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + if((isset($_POST['lang'])) && isset($this->languages[$_POST['lang']])) { + $this->lang = $_POST['lang']; + $this->is_completed = TRUE; + $_SESSION['lang'] = $this->lang; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep2.inc b/setup/class_setupStep2.inc new file mode 100644 index 000000000..e037f9c24 --- /dev/null +++ b/setup/class_setupStep2.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep3.inc b/setup/class_setupStep3.inc new file mode 100644 index 000000000..7e359482e --- /dev/null +++ b/setup/class_setupStep3.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep4.inc b/setup/class_setupStep4.inc new file mode 100644 index 000000000..860aedb0d --- /dev/null +++ b/setup/class_setupStep4.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep5.inc b/setup/class_setupStep5.inc new file mode 100644 index 000000000..b801d421d --- /dev/null +++ b/setup/class_setupStep5.inc @@ -0,0 +1,39 @@ + diff --git a/setup/main.inc b/setup/main.inc new file mode 100644 index 000000000..fe41c8030 --- /dev/null +++ b/setup/main.inc @@ -0,0 +1,37 @@ +save_object(); +$display= $setup->execute(); + +/* Store changes in session */ +$_SESSION['setup']= $setup; + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/setup.tpl b/setup/setup.tpl new file mode 100644 index 000000000..3bb21f795 --- /dev/null +++ b/setup/setup.tpl @@ -0,0 +1,4 @@ +
+{$php_errors} +sadffasdsdfa +
diff --git a/setup/setup_frame.tpl b/setup/setup_frame.tpl new file mode 100644 index 000000000..888a8bcbf --- /dev/null +++ b/setup/setup_frame.tpl @@ -0,0 +1,27 @@ + + +{$php_errors} +
+ + + + + + + + + + + +
+ GOsa Setup blabla +
+ {$navigation} + + {$header} +
+ {$contents} +
+
+ + diff --git a/setup/setup_step1.tpl b/setup/setup_step1.tpl new file mode 100644 index 000000000..7c8fc338f --- /dev/null +++ b/setup/setup_step1.tpl @@ -0,0 +1,6 @@ +{t}Language{/t} + + + -- 2.30.2