2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 - [#]year[#], Blue Static
41 abstract class BSInstaller
44 * All the method steps
47 private $steps = array();
50 * The file name of this module
56 * Constructor: set up the steps
58 * @param string The file name for this module
60 public function __construct($fileName)
62 $this->fileName
= $fileName;
64 BSApp
::RequiredModules(array('Input'));
66 $methods = get_class_methods($this);
67 foreach ($methods AS $name)
69 if (preg_match('#step([0-9]+)#', $name))
71 $this->steps
[] = $name;
74 natsort($this->steps
);
76 $this->_runStep(BSApp
::GetType('Input')->inputClean('step', TYPE_UINT
));
79 // ###################################################################
81 * An abstract method that needs to be overridden by a subclass that
82 * populates the page title
84 * @return string Returns the page title
86 protected abstract function _pageTitle();
88 // ###################################################################
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();
97 // ###################################################################
99 * Abstract method that prints out the first welcome screen that the
100 * user sees when no step has been selected
102 protected abstract function _welcomePage();
104 // ###################################################################
106 * Prints out the page header... you really don't do this more than
109 protected function _setUp()
112 <DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
113 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
114 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
116 <meta http
-equiv
="content-type" content
="text/html; charset=iso-8859-1" />
117 <title
><?= $this->_pageTitle() ?></title
>
119 <style type
="text/css">
123 font
-family
: Verdana
, Arial
, Helvetica
, sans
-serif
;
129 color
: rgb(0, 0, 238);
134 color
: rgb(66, 137, 155);
146 border
: 1px solid black
;
147 text
-decoration
: none
;
148 color
: rgb(37, 37, 37);
149 background
-color
: rgb(239, 239, 239);
160 // ###################################################################
162 * Runs the specific step method; if it does not exist, it will throw
165 * @param integer Step number
167 protected function _runStep($step)
172 $this->_welcomePage();
175 else if (in_array("step$step", $this->steps))
178 $this->{"step$step"}();
179 $this->_setDown($step);
183 throw new Exception("step
$step() does not exist in this module
");
187 // ###################################################################
189 * Prints out the footer part of the page, and the appropriate forwarding
192 * @param integer Step number
194 protected function _setDown($step)
196 // this is the last step, print the final button
197 if ($step == sizeof($this->steps))
199 echo '<div class="buttonlink
">' . $this->_finalLink() . '</div>';
204 echo '<div class="buttonlink
"><a href="' . $this->fileName . '?step
=' . ++$step . '">' . _('Next Step') . '</a></div>';
214 /*=====================================================================*\
215 || ###################################################################
218 || ###################################################################
219 \*=====================================================================*/