Login/Register
Last Update: 2014-02-19

Application Package Modification and Customization Guide

Installatron Server and Installatron Plugin benefit from a robust modification and customization system that enables changes to be applied to any custom or Installatron-maintained application package. This system can be used to add additional languages, add plugins or templates, or make just about any convincible change. Best of all, the system is designed to be simple and only requires very minimal programming knowledge to use.

The idea behind this system is to "register" one or more sets of commands to be executed at specified locations within each install and/or upgrade process. These sets of commands should be formatted according to this guide and written to the /usr/local/installatron/etc/installercustomcode.php file or entered to the Customize installers code field in Administration >> Applications >> Customization.

For example, take this sample installercustomcode.php file:


<?php
class i_installer_customcode   
{   
       function 
init()
       {
               
$this->registerArchive("wp_supercache","http://downloads.wordpress.org/plugin/wp-super-cache.1.0.zip""zip");
               
$this->registerCustomCode("wordpress""all""install""last""process""wordpressinstall");
       }

       function 
wordpressinstall($o)
       {
               
$o->extract("wp_supercache""wp-content/plugins");
       }

}
?>
In this example we extract an archive containing the WordPress SuperCache plugin after each WordPress install. Let's look at each line of code in this example:

function init()

The init function is called prior to the execution of every install and upgrade and registers commands for later execution.

$this->registerArchive()

A registerArchive call registers an archive that may or may not be extracted later.

$this->registerArchive("id", "url", "archive_type", "md5_checksum");

id is a unique id, typically within the A-Za-z0-9_ character set, for the archive being registered.

url is the URL to the archive.

archive_type is the type of archive and can be "tar", "tar.gz" or "zip". No other types are currently supported.

md5_checksum is the md5 checksum of the archive. This field is optional.

$this->registerCustomCode()

A registerCustomCode call registers code to be executed at a specified hook during the install and/or upgrade processes.

$this->registerCustomCode("app", "limit_version", "subsystem", "hook", "hook2", "function");

app is the ID of the application package the code pertains to.

limit_version defines a specific version the code should be limited to, or if the code applies to all versions, the keyword "all" can be specified.

subsystem specifies whether the code should be executed for the install, uninstall, or upgrade processes.

hook specifies the location within the install/upgrade process this code should be executed. A value of "last" executes the code at the end (recommended). A value of "1" executes the code before the install/upgrade process has started, when input fields are presented to the client. A value of "2" executes at the beginning.

hook2 provides further accuracy in regards to where the specified code should be executed. Typically, a value of "process" is used. However, a value of "init" should be used when defining input fields.

function specifies the function that contains the code to be executed.

function wordpressinstall($o)

The wordpressinstall($o) function is an example of code that will be executed (if it's registered in the init function). The $o object referenced is an instance of the application package as defined in the package's install.php or upgrade.php file.

All the tools and functions available in the install.php and upgrade.php files are available for use. For a full list of available functions, please reference the Installatron Application Packaging SDK:

Installatron Application Packaging SDK: A function reference

Need assistance?

Don't hesitate to contact Installatron Support with any questions regarding this system.

© 2004 - 2016 Installatron LLC. All rights reserved.