This guide will get you on your way to easy script installation.
Firstly, the installation process in general is a series of sequential steps aimed at gathering information from both the user and the software environment using an simple wizard-like interface. PIS provides a simple array of tools which provides the framework to any installation process.
For instance, the PIS::input() function will insert a text area, select box or license agreement into an installation page which then takes and stores a user’s response in the installation-wide heap of variables.
Each installation process has a heap of variables either set by the script as a result of environment tests, or by the user specifying a configuration setting. This heap is accessible during the entire installation process, from page to page.
Every installation step is really a seperate method defined in the installation class. So the first step in the installation is going to call page_welcom(). It is inside these page methods that we construct each page’s elements. The steps proceed in the order the methods were defined in the class.
//Adds a form input to the page, automatically sets the
//value in the heap when submitted.
$this->input ( "text", "varname" ,array("attribute"=>"value") );
//Test for something, if it fails, will prevent installation from proceeding
$this->test ( sometest(), "Some Test Failed" );
//Can be used to conditionally bypass a step(method) //
$this->bypass ( ‘previouspage’, ‘nextpage’ );
//Retreive a variable from the heap//
$this->get( ‘varname’, ‘defaultifblank’ );
//Manullay set a variable in the heap//
$this->set( ‘varname’, ‘value’ );
//Inserts a <hr /> tag into the page//
$this->hr();
//Creates a configuration file/string from the heap of variables//
$this->makeConfig();
//Another useful technique is if you have a couple different
//installation classes such as a new install verses an update
//script, you can define both then create one depending on some
//outside state.
if ( $isUpdate ){
$installer = new MyUpdater( ‘My Updater’ );
} else {
$installer = new MyInstaller( ‘My Installer’ );
}
text – creates a simple text input field.
password – creates a simple password input field.
hidden – creates a hidden form field.
select – creates a select box. Its options are specified in the "options" attribute as an associative array. The key determines the label, value the option value.
textarea – creates a textarea input.
boolean – creates a true/false dropdown for those config file flags.
agreement – creates an agreement input consisting of a textarea and checkbox asking for agreement to the license. This input accepts an additional attribute named file which when set to the path of the license file (mit.txt,gnu.txt,etc) will load it into the textarea.
The input attributes are set using an associative array passed to the input() function.
required – Will require the user to enter something.
label – The label for the field. Defaults to input id parameter.
help – The help string for more information on the field. This string is pushed into a javascript alert box and triggered by adding a "?" next to the field.
value – Default value of the field.
options – Currently only for select input, must be an associative array of key=value pairs.
file – Currently only for agreement input, path to a license text file to load into a page.
| Available Extra Input Attributes | |||||||||
| Input Type | required | label | cols | rows | help | size | value | options | file |
| text | X | X | X | X | X | ||||
| password | X | X | X | X | X | ||||
| hidden | X | ||||||||
| select | X | X | X | X | X | X | |||
| textarea | X | X | X | X | X | X | |||
| boolean | X | X | X | ||||||
| agreement | X | X | X | X | |||||