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
));
82 * An abstract method that needs to be overridden by a subclass that
83 * populates the page title
85 * @return string Returns the page title
87 protected abstract function _pageTitle();
90 * Abstract method that will return link to the page after all the
91 * steps are completed. This needs to provide it's own <a>
93 * @return string Final page link
95 protected abstract function _finalLink();
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();
104 * Prints out the page header... you really don't do this more than
107 protected function _setUp()
110 <DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
111 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
112 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
114 <meta http
-equiv
="content-type" content
="text/html; charset=iso-8859-1" />
115 <title
><?= $this->_pageTitle() ?></title
>
117 <style type
="text/css">
121 font
-family
: Verdana
, Arial
, Helvetica
, sans
-serif
;
127 color
: rgb(0, 0, 238);
132 color
: rgb(66, 137, 155);
144 border
: 1px solid black
;
145 text
-decoration
: none
;
146 color
: rgb(37, 37, 37);
147 background
-color
: rgb(239, 239, 239);
159 * Runs the specific step method; if it does not exist, it will throw
162 * @param integer Step number
164 protected function _runStep($step)
169 $this->_welcomePage();
172 else if (in_array("step$step", $this->steps))
175 $this->{"step$step"}();
176 $this->_setDown($step);
180 throw new Exception("step
$step() does not exist in this module
");
185 * Prints out the footer part of the page, and the appropriate forwarding
188 * @param integer Step number
190 protected function _setDown($step)
192 // this is the last step, print the final button
193 if ($step == sizeof($this->steps))
195 echo '<div class="buttonlink
">' . $this->_finalLink() . '</div>';
200 echo '<div class="buttonlink
"><a href="' . $this->fileName . '?step
=' . ++$step . '">' . _('Next Step') . '</a></div>';