Source for file installstep.php

Documentation is available at installstep.php

  1. <?php
  2. /**
  3. * An Installation Step class
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Installer
  11. */
  12.  
  13. class InstallStep {
  14.  
  15.   var $prev = NULL;
  16.   var $next = NULL;
  17.   var $name;
  18.   var $action;
  19.  
  20.   function InstallStep($name$action{
  21.     $this->name = $name;
  22.     $this->action = $action;
  23.   }
  24.  
  25.   function setNext($step{
  26.     $this->next = $step;
  27.   }
  28.  
  29.   function setPrev($step{
  30.     $this->prev = $step;
  31.   }
  32.  
  33.   function getNextButton($name=NULL{
  34.     if ($this->next == NULLreturn '';
  35.     return $this->next->makeNextButton($name);
  36.   }
  37.  
  38.   function getPrevButton($name=NULL{
  39.     if ($this->prev == NULLreturn '';
  40.     return $this->prev->makePrevButton($name);
  41.   }
  42.  
  43.   function getThisButton($name=NULL{
  44.     if ($name == NULL$name $this->name;
  45.     return $this->makeButton($name);
  46.   }
  47.  
  48.   function makePrevButton($name{
  49.     if ($name == NULL$name $this->name;
  50.     return $this->makeButton('&laquo; '.$name);
  51.   }
  52.  
  53.   function makeNextButton($name{
  54.     if ($name == NULL$name $this->name;
  55.     return $this->makeButton($name.' &raquo;');
  56.   }
  57.  
  58.   function makeButton($name{
  59.     return "<input type='submitname='{$this->action}value='{$name}' />";
  60.   }
  61. }
  62.  
  63.  
  64. class InstallStepCollection {
  65.  
  66.   var $steps = array();
  67.   var $index = 1;
  68.  
  69.   function addStep($step) {
  70.     $num = count($this->steps);
  71.     if ($num != 0) {
  72.       $step->setPrev($this->steps[$num]);
  73.       $this->steps[$num]->setNext($step);
  74.     }
  75.     $this->steps[$num+1] = $step;
  76.   }
  77.  
  78.   function numSteps() {
  79.     return count($this->steps);
  80.   }
  81.  
  82.   function getIndex() {
  83.     return $this->index;
  84.   }
  85.  
  86.   function getStepButtons() {
  87.     $t = '';
  88.     foreach ($this->steps as $num => $s) {
  89.       $t .= "<input type='submitname='{$s->action}value='$num. {$s->name}'"
  90.         .($this->index<$num ? " disabled='1'" : "")." />";
  91.     }
  92.     return $t;
  93.   }
  94.  
  95.   function getPrevNextButtons($prev=NULL, $next=NULL) {
  96.     if ($prev   === NULL) $prev = 'Previous';
  97.     if ($next   === NULL) $next = 'Continue';
  98.     return $this->steps[$this->index]->getPrevButton($prev).' '
  99.           .$this->steps[$this->index]->getNextButton($next);
  100.   }
  101.  
  102.   function getPrevReloadNextButtons($prev=NULL, $reload=NULL, $next=NULL) {
  103.     if ($prev   === NULL) $prev = 'Previous';
  104.     if ($reload === NULL) $reload = 'Reload';
  105.     if ($next   === NULL) $next = 'Continue';
  106.     return $this->steps[$this->index]->getPrevButton($prev).' '
  107.           .$this->steps[$this->index]->getThisButton($reload).' '
  108.           .$this->steps[$this->index]->getNextButton($next);
  109.   }
  110.  
  111.   function getPrevSkipToButtons($skip=1, $prev=NULL, $next=NULL) {
  112.     if ($prev   === NULL) $prev = 'Previous';
  113.     if ($next   === NULL) $next = 'Continue';
  114.     return $this->steps[$this->index]->getPrevButton($prev).' '
  115.           .$this->steps[$this->index+$skip]->getNextButton($next);
  116.   }
  117.  
  118.   function setCurrent($num) {
  119.     $this->index = $num;
  120.   }
  121.  
  122.   function increment() {
  123.     $this->index++;
  124.   }
  125.  
  126. }
  127.  

Documentation generated on Tue, 06 Mar 2007 10:01:38 +0000 by phpDocumentor 1.3.0