2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 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)2005 - 2008, 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 if (!BSApp
::$input instanceof BSInput
)
65 throw new Exception('BSApp::$input is not an instance of BSInput');
68 $methods = get_class_methods($this);
69 foreach ($methods AS $name)
71 if (preg_match('/step([0-9]+)/', $name))
73 $this->steps
[] = $name;
76 natsort($this->steps
);
78 $this->_runStep(BSApp
::$input->inputClean('step', TYPE_UINT
));
81 // ###################################################################
83 * An abstract method that needs to be overridden by a subclass that
84 * populates the page title
86 * @return string Returns the page title
88 protected abstract function _pageTitle();
90 // ###################################################################
92 * Abstract method that will return link to the page after all the
93 * steps are completed. This needs to provide it's own <a>
95 * @return string Final page link
97 protected abstract function _finalLink();
99 // ###################################################################
101 * Abstract method that prints out the first welcome screen that the
102 * user sees when no step has been selected
104 protected abstract function _welcomePage();
106 // ###################################################################
108 * Prints out the page header... you really don't do this more than
111 protected function _setUp()
114 <DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
115 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
116 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
118 <meta http
-equiv
="content-type" content
="text/html; charset=iso-8859-1" />
119 <title
><?= $this->_pageTitle() ?></title
>
121 <style type
="text/css">
125 font
-family
: Verdana
, Arial
, Helvetica
, sans
-serif
;
131 color
: rgb(0, 0, 238);
136 color
: rgb(66, 137, 155);
148 border
: 1px solid black
;
149 text
-decoration
: none
;
150 color
: rgb(37, 37, 37);
151 background
-color
: rgb(239, 239, 239);
162 // ###################################################################
164 * Runs the specific step method; if it does not exist, it will throw
167 * @param integer Step number
169 protected function _runStep($step)
174 $this->_welcomePage();
177 else if (in_array("step$step", $this->steps))
180 $this->{"step$step"}();
181 $this->_setDown($step);
185 throw new Exception("step
$step() does not exist in this module
");
189 // ###################################################################
191 * Prints out the footer part of the page, and the appropriate forwarding
194 * @param integer Step number
196 protected function _setDown($step)
198 // this is the last step, print the final button
199 if ($step == sizeof($this->steps))
201 echo '<div class="buttonlink
">' . $this->_finalLink() . '</div>';
206 echo '<div class="buttonlink
"><a href="' . $this->fileName . '?step
=' . ++$step . '">' . _('Next Step') . '</a></div>';