From 9810d8b32016cff5cedb3abb6e720cf614d9bb38 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 12 Dec 2006 05:26:27 +0000 Subject: [PATCH] A brand new, shiny installer class that will prove to make useful installation modules --- installer.php | 197 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 160 insertions(+), 37 deletions(-) diff --git a/installer.php b/installer.php index 1043e3b..5795585 100644 --- a/installer.php +++ b/installer.php @@ -20,72 +20,195 @@ \*=====================================================================*/ /** -* Installer subsystem -* install.php +* Installer creator (Install.php) * * @package ISSO */ -// ################################################################### /** -* Constructs the header of a page; imbeds the CSS from installer.css.php +* Installer +* +* Installer modules should extend this class. In the install module router, +* instantiate the right module. Methods beginning with step*() will be executed +* in numerical order. +* +* @author Blue Static +* @copyright Copyright (c)2002 - [#]year[#], Blue Static +* @version $Revision$ +* @package ISSO * -* @access public */ -function page_start() +abstract class BSInstaller { - require_once($GLOBALS['isso:callback']->get('sourcepath') . 'installer.css.php'); -?> - + /** + * All the method steps + * @var array + */ + private $steps = array(); + + /** + * The file name of this module + * @var string + */ + protected $fileName; + + /** + * Constructor: set up the steps + * + * @param string The file name for this module + */ + public function __construct($fileName) + { + $this->fileName = $fileName; + + BSRegister::RequiredModules(array('Input')); + + $methods = get_class_methods($this); + foreach ($methods AS $name) + { + if (preg_match('#step([0-9]+)#', $name)) + { + $this->steps[] = $name; + } + } + natsort($this->steps); + + $this->_runStep(BSRegister::GetType('Input')->inputClean('step', TYPE_UINT)); + } + + // ################################################################### + /** + * An abstract method that needs to be overridden by a subclass that + * populates the page title + * + * @return string Returns the page title + */ + protected abstract function _pageTitle(); + + // ################################################################### + /** + * Abstract method that will return link to the page after all the + * steps are completed. This needs to provide it's own + * + * @return string Final page link + */ + protected abstract function _finalLink(); + + // ################################################################### + /** + * Abstract method that prints out the first welcome screen that the + * user sees when no step has been selected + */ + protected abstract function _welcomePage(); + + // ################################################################### + /** + * Prints out the page header... you really don't do this more than + * once + */ + protected function _setUp() + { + ?> + - <?= $GLOBALS['isso:callback']->get('application') ?> Installer - + <?= $this->_pageTitle() ?> + - for when all the steps have been reached. -* -* @access public -* -* @param bool Produce the "Next" button? -*/ -function page_end($next = true) -{ - if (defined('STOP_MARK') AND $next) + in['mark'] >= STOP_MARK AND !defined('IGNORE_STOP')) + if ($step == 0) + { + $this->_setUp(); + $this->_welcomePage(); + $this->_setDown(0); + } + else if (in_array("step$step", $this->steps)) { - echo ''; + $this->_setUp(); + $this->{"step$step"}(); + $this->_setDown($step); } else { - echo ''; + trigger_error("step$step() does not exist in this module"); } } - echo ' - + // ################################################################### + /** + * Prints out the footer part of the page, and the appropriate forwarding + * action button + * + * @param integer Step number + */ + protected function _setDown($step) + { + // this is the last step, print the final button + if ($step == sizeof($this->steps)) + { + echo ''; + } + // just another step + else + { + echo ''; + } + + echo ' '; - - exit; + } } /*=====================================================================*\ -- 2.43.5