This repository was archived by the owner on Jul 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Scriptfile
simonharrer edited this page May 28, 2011
·
6 revisions
The Scriptfile
The scriptfile has to be a class named com#{NAME}InstallerScript with several functions. These functions are separeted in two sections. The main functions and the surrounding functions.
-
$parentis the class which is calling the method. -
function install($parent)called when the extension is installed -
function uninstall($parent)called when the extension is uninstalled -
function update($parent)called when the extension is updated
-
$typeis either"install","update","uninstall","discover_install". TODO what about discover_update? -
function preflight($type, $parent)called BEFORE install, uninstall or update is called -
function postflight($type, $parent)called AFTER install, uninstall or update is called
- Update database before installed, make database upgrade or conversion
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Script file of NAME component
*/
class com_NAMEInstallerScript
{
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
// $parent is the class calling this method
$parent->getParent()->setRedirectURL('index.php?option=com_NAME');
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_NAME_UNINSTALL_TEXT') . '</p>';
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
// $parent is the class calling this method
echo '<p>' . JText::_('COM_NAME_UPDATE_TEXT') . '</p>';
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
function preflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_NAME_PREFLIGHT_' . $type . '_TEXT') . '</p>';
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('COM_NAME_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
}
}