File/program/themes/frugal/frugal_install.php

Description

/program/themes/frugal/frugal_install.php -- installer of the frugal theme

This file contains the frugal theme installer. The interface consists of these functions:

    frugal_install(&$messages,$theme_id) frugal_upgrade(&$messages,$theme_id) frugal_uninstall(&$messages,$theme_id) frugal_demodata(&$messages,$theme_id,$config,$manifest)

These functions can be called from the main installer and/or admin.php.

Note You cannot be sure about the environment from which these routines are called. If the caller is the Install Wizard, you do not have all subroutines available. However, it IS possible to manipulate the database via the db_*() routines and/or the global $DB object. Therefore you have to keep the install routine extremly simple. You also have no option to interact with the user; the install has to be a silent install; you can only indicate success (TRUE) or failure (FALSE) and maybe an error message in $messages[] but that's it. Good luck.

Functions
frugal_demodata (line 292)

add demonstration data to the system

this routine is a no-op because all frugal demodata is already created in the main demodata-routine in /program/install/demodata.php. This routine is retained here as an example and also because a routine by this name should exist (even if it does nothing).

Note If the theme is installed via the Install Wizard, this routine is called. However, if a theme is installed as an additional theme after installation, the {$theme}_demodata() routine is never called. This is because the only time you know that demodata is installed is when the Install Wizard runs. If we're called from admin.php, the webmaster may have already deleted existing (core) demodata so you never can be sure what to expect. To put it another way: it is hard to re-construct $config when we're NOT the Instal Wizard.

Fortunately 'frugal' does not need demodata.

  • return: TRUE on success + output via $messages, FALSE otherwise
bool frugal_demodata (array &$messages, int $theme_id,  $config, array $manifest, array $configuration)
  • array &$messages: collects the (error) messages
  • int $theme_id: the key for this theme in the themes table
  • array $configuration: pertinent data for the new website + demodata foundation
  • array $manifest: a copuy from the manifest for this theme
  • $config
frugal_install (line 61)

install the theme

this routine performs the necessary actions to make this theme usable. More specific, this routine adds a handfull of default values into the themes_properties table. Once a theme is actually used in an area, these defaults are copied from the themes_properties table to the themes_areas_properties table for the selected area. The user can subsequently edit these properties in the Area Manager.

  • return: TRUE on success + output via $messages, FALSE otherwise
bool frugal_install (array &$messages, int $theme_id)
  • array &$messages: collects the (error) messages
  • int $theme_id: the key for this theme in the themes table
frugal_uninstall (line 262)

uninstall the theme

this is a hook for future extensions of Website@School. For now we simply return success. Any real code could look like this:

DELETE FROM themes_areas_properties WHERE theme_id = $theme_id; DELETE FROM themes_properties WHERE theme_id = $theme_id; DELETE FROM themes WHERE theme_id = $theme_id;

or whatever.

  • return: TRUE on success + output via $messages, FALSE otherwise
bool frugal_uninstall (array &$messages, int $theme_id)
  • array &$messages: collects the (error) messages
  • int $theme_id: the key for this theme in the themes table
frugal_upgrade (line 240)

upgrade the theme

this routine performs an upgrade to the installed theme. Note that this minimalistic 'frugal' theme does not need any upgrade at all because there never was an earlier version.

However, if there was to be a newer version of this theme, this routine is THE place to bring the database up to date compared with the existing version. For example, if an additional property 'foobar' was to be added to the theme configuration, it could be added to the themes_properties table with a suitable (default) value, Any existing areas with this theme could have their configuration updated with this additional foobar property, e.g. INSERT INTO themes_properties: foobar for all areas in themes_areas_properties with theme_id = $theme_id do INSERT INTO themes_areas_properties: foobar etcetera,

The current version of the theme could be determined by consulting the databse (db_select_single_record(themes,'*','theme_id = $theme_id') etcetera.

Note that it is the responbabilty of the caller to correctly store the data from the manifest in the themes table. You don't have to do this here, in this routine.

  • return: TRUE on success + output via $messages, FALSE otherwise
bool frugal_upgrade (array &$messages, int $theme_id)
  • array &$messages: collects the (error) messages
  • int $theme_id: the key for this theme in the themes table

Documentation generated on Tue, 28 Jun 2016 19:09:36 +0200 by phpDocumentor 1.4.0