/program/themes/sophia/sophia_install.php -- installer for the sophia theme
This file contains the sophia theme installer. The interface consists of these functions:
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.
add demonstration data to the system
this routine adds demonstration data to the freshly installed system
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.
The array $config contains the following information.
With this information, we can add a demonstration configuration for the public area, which shows off the possibilities.
install the theme
this routine performs the necessary actions to make this theme usable. More specific, this routine adds a handful 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.
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.
upgrade the theme
this routine performs an upgrade to the installed theme. Note that this minimalistic 'sophia' 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 responsabilty 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.
Documentation generated on Tue, 28 Jun 2016 19:12:08 +0200 by phpDocumentor 1.4.0