Userpanel is built with modularity principle, which means that each module, which represents one menu entry is contained in separate subdirectory of modules directory.
This graph represents directory structure of typical module:
module_name |---locale | |---en | |---strings.php |---style | |---default | |---image.gif |---templates | |---template1.html | |---template2.html |---upgradedb | |---mysql.2005081901.php | |---postgres.2005081901.php |---configuration.php |---functions.php
This requires a few words of explanation:
locale directory contains appropriate locale, obviously. However strings.php file contains only translation strings used in containing module,
style is obviously image and css style dir, with subdirectories for each style (graphical theme) installed in Userpanel,
templates contains Smarty templates for given module,
upgradedb contains auto-upgrade files for tables being used by module. Table names, for those used exclusively by one module, should contain up_modulename_ prefix,
configuration.php and functions.php are two files required for each module. They are described in detail later in this document.
This file contains configuration of given module and is always included during Userpanel initialization. Usually it's built as follows:
<?php $USERPANEL->AddModule(trans('Help'), // Name in menu 'help', // Module name (must be identical as module dir) trans('Runs problems solving creator'), // Tip (on menu hover) 5, // Priority (lower first) trans('This module shows solving problems creator'), // Description 2005081901, // DB version (similar to LMS, see // lms/lib/upgradedb.php) array( // Array of submenus im LMS-UI Userpanel menu array( // (see lib/LMS.menu.php) 'name' => trans('Submenu'), 'link' => '?m=userpanel&module=help', 'tip' => trans('Tooltip'), ), ) ); ?>
This file contains given module functions. There is special function, named module_main() executed first when module is called. If any function is intended to be accessible from Userpanel UI, it should be prefixed with module_, ie. module_function1(), which will be available from the following URL: http://userpanel/?m=module&f=function1. Function named module_setup() is being called from configuration panel of LMS-UI.