2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * Installer creator (Install.php)
31 * Installer modules should extend this class. In the install module router,
32 * instantiate the right module. Methods beginning with step*() will be executed
36 * @copyright Copyright (c)2002 - 2007, Blue Static
40 abstract class BSInstaller
43 * All the method steps
46 private $steps = array();
49 * The file name of this module
55 * Constructor: set up the steps
57 * @param string The file name for this module
59 public function __construct($fileName)
61 $this->fileName
= $fileName;
63 BSApp
::RequiredModules(array('Input'));
65 $methods = get_class_methods($this);
66 foreach ($methods AS $name)
68 if (preg_match('#step([0-9]+)#', $name))
70 $this->steps
[] = $name;
73 natsort($this->steps
);
75 $this->_runStep(BSApp
::GetType('Input')->inputClean('step', TYPE_UINT
));
78 // ###################################################################
80 * An abstract method that needs to be overridden by a subclass that
81 * populates the page title
83 * @return string Returns the page title
85 protected abstract function _pageTitle();
87 // ###################################################################
89 * Abstract method that will return link to the page after all the
90 * steps are completed. This needs to provide it's own <a>
92 * @return string Final page link
94 protected abstract function _finalLink();
96 // ###################################################################
98 * Abstract method that prints out the first welcome screen that the
99 * user sees when no step has been selected
101 protected abstract function _welcomePage();
103 // ###################################################################
105 * Prints out the page header... you really don't do this more than
108 protected function _setUp()
111 <DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
112 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
113 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
115 <meta http
-equiv
="content-type" content
="text/html; charset=iso-8859-1" />
116 <title
><?= $this->_pageTitle() ?></title
>
118 <style type
="text/css">
122 font
-family
: Verdana
, Arial
, Helvetica
, sans
-serif
;
128 color
: rgb(0, 0, 238);
133 color
: rgb(66, 137, 155);
145 border
: 1px solid black
;
146 text
-decoration
: none
;
147 color
: rgb(37, 37, 37);
148 background
-color
: rgb(239, 239, 239);
159 // ###################################################################
161 * Runs the specific step method; if it does not exist, it will throw
164 * @param integer Step number
166 protected function _runStep($step)
171 $this->_welcomePage();
174 else if (in_array("step$step", $this->steps))
177 $this->{"step$step"}();
178 $this->_setDown($step);
182 throw new Exception("step
$step() does not exist in this module
");
186 // ###################################################################
188 * Prints out the footer part of the page, and the appropriate forwarding
191 * @param integer Step number
193 protected function _setDown($step)
195 // this is the last step, print the final button
196 if ($step == sizeof($this->steps))
198 echo '<div class="buttonlink
">' . $this->_finalLink() . '</div>';
203 echo '<div class="buttonlink
"><a href="' . $this->fileName . '?step
=' . ++$step . '">' . _('Next Step') . '</a></div>';