mandriva

This page describes how a module can add a configuration page to the admin module, making it possible to change the module’s settings through mmc’s web interface.

For this example’s purpose we will call our module test

Create a page

A configuration page is created by creating two files:

web/modules/admin/pages/<module_name>.inc.php

and

web/modules/admin/configure/<module_name>.php

The web/modules/admin/pages/<module_name>.inc.php file

This file contains the definition of the page. It creates the page and add it to the sidemenu when any page the configure module is loaded.

Include this file to get all classes needed to build your page

  include_once("modules/admin/includes/configure.inc.php");

Then create a configuration page

  $page = new ConfigurationPage("Inventory", "index");

This ConfigurationPage? class is a subclass of the usual PageGenerator? class

You can then add all the options you want to be configurable through this page:

  $options = array();
  /* Create a list of options. An option is ONE value from a
  configuration file (or from the database)
  The arguments are as follows:
   - The section name
   - The option name
  */
  $options[] = new SelectOption("section", "option", array("first", "second"));
  $page->addOptions('base', $options);

  /* Add the option array to the page.
  Options are added by array instead of one by one because they can
  be grouped by configuration file. The content of each concerned
  file can be retrieved (through xmlrpc) only once
  Arguments:
   - The configuration file name
   - The options array
  */
  $page->addOptions('base', $options);

The web/modules/admin/configure/<module_name>.php file

This file just takes the page created in the previous file and displays it if the selected action is this one.

require("graph/navbar.inc.php");
include_once("modules/admin/includes/commons.inc.php");
/* load the page that was previously created */
$page = get_config_page('test');

/* and just display it */
$page->display();