Changes between Version 3 and Version 4 of adeiNewModule

Show
Ignore:
Author:
csa (IP: 141.52.232.84)
Timestamp:
07/16/09 16:49:21 (15 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • adeiNewModule

    v3 v4  
    44 * ''Control'' module provides access to the control information 
    55 
    6 It is possible to register new modules providing additional system-specific information. For this, it is necessary to create module file in ADEI ''modules/'' subdirectory. This file should include 3 mandatory methods (the ''module'' prefix should be replaced with actual module name. For example, for alarms module instead of ''$module_title'', the ''$alarms_tittle'' should be used): 
     6It is possible to register new modules providing additional system-specific information. For this, it is necessary to create module file in ADEI ''modules/'' subdirectory. This file should include 3 mandatory methods (the ''module'' prefix should be replaced with actual file name without php extension, called the module name. For example, for alarms module instead of ''$module_title'', the ''$alarms_tittle'' should be used): 
    77 * The variable ''module_title'' contains the module name (as it should be shown to the users in menu): 
    88    {{{$module_title = _("Title of the Module")}}} 
    1515When the module is ready it should be enabled in the configuration file ''config.php'' (or in the appropriate ''setup'' if it should be used optionally). 
    1616 
    17  
    1817The ADEI includes several JavaScript classes providing standard use-cases. They are described bellow. 
    1918 
    2019== XML Module == 
    21 This module uses an ''ADEI service'' generating XML content and XSLT stylesheet to update information on the page. The ''modulePage'' function should just define a single ''div'' element: 
     20This module uses an ''ADEI service'' generating XML content and XSLT stylesheet to update information on the page.  
     21The ''modulePage'' function should just define a single ''div'' element: 
    2222     {{{<div id="module_div" class="xml_module">Loading...</div>}}} 
    2323The ''moduleJS'' function initializes new XMLMODULE object supplying the id of div created in ''modulePage'' function: 
    2626     {{{ return "module_object"; }}} 
    2727 
    28 Complete example (alarms module): 
     28Complete example of a module (alarms module): 
    2929{{{ 
    3030  $alarms_title = _("Alarms"); 
    3737  } 
    3838}}} 
     39 
     40By default, the service ''module_name'' is used to obtain XML document and stylesheet ''module_name'' 
     41is used to covert XML into the HTML. The service should reside in the ''services/'' subdirectory (read about creating services [wiki:adeiNewService here]). The XSLT stylesheet should be placed in the ''xslt'' folder. However, it is possible to have more elaborated service configuration. For that it is necessary to define special ''update'' service. This service should be created in ''services/update'' directory and be named ''module_name.php''. It should contain a single function, called ''ADEIServiceGetUpdateInfo'', which accept a ''REQUEST'' object as a parameter and return associative array with two elements: 
     42 * ''xml'' - specifying the full URL of update service along with all properties (the current options could be obtained and modified using ''GetQueryString'' method of ''REQUEST'' object, see example bellow) 
     43 * ''xslt'' - specifying the name of XSLT stylesheet (without extension) 
     44 
     45The function is executed on each update and, therefore, can dinamically select the appropriate service depending on some of request parameters. 
     46 
     47Example, the ''alarams'' update service (it uses ''control.php'' service to get XML data and adds two additional parameters to the REQUEST properties): 
     48{{{ 
     49  function ADEIServiceGetUpdateInfo(REQUEST $req) { 
     50    if ($req->CheckData()) { 
     51            $query = $req->GetQueryString($extra = array( 
     52                "target" => "alarms_summary", 
     53                "time_format" => "text" 
     54            )); 
     55 
     56            return array( 
     57                "xml" => "services/control.php?$query", 
     58                "xslt" => "alarms" 
     59            ); 
     60    } 
     61    return false; 
     62  } 
     63}}}