App Structure

InfoCentral

The core code of InfoCentral is located in ‘src’. Beneath ‘src’ are the following directories:

  • business – Classes (ending in ‘Operator’) that perform logical operations on data
  • controllers – Classes (ending in ‘Controller’) that route user requests and validate permissions
  • database – Classes (ending in ‘DatabaseHandler’) that interact with the database
  • exceptions – Classes (ending in ‘Exception’) that are thrown if errors occur
  • extensions – A folder to place extensions
  • factories – A single class, ControllerFactory, that will load the correct controller for a user request
  • models – Classes representing data used by the core application
  • public – .htaccess, a file used to re-write URLs, the ‘doorway’ index page, and a setup script
  • sshkeys – The directory to put ssh keys if using a feature that requires one
  • uploaded – A directory where uploaded files will be stored if a feature uses it
  • utilities – Miscellaneous classes that perform various operations

Extensions

Extensions must be placed in a directory with a unique name under ‘extensions’. The structure of an extension mimics the core code:

  • business
  • controllers
  • database
  • models
  • utilities

Directly inside the extension folder must be a class named ‘ExtConfig’. This class must include two public constants:

  • ROUTES – mappings of (unique) URI paths to the fully qualified name of the controller that handles the request
  • OPTIONS – extra options that will be used by classes within the extension

If the extension will be recording history logs, and those logs should be viewable to the user, the following constants must also be defined:

  • HISTORY_OBJECTS – an indexed array with a user-friendly name of an object as the key, and the underlying table name as the value
  • HISTORY_PERMISSIONS – an indexed array with the table name as the key, and a permission code as the value. This permission code will control who can query history records for that table. If a permission is not defined for a table, no requests for history records will be allowed.

When extensions are loaded, these ‘extended configurations’ are loaded and used to build a master list of all routes. If route names conflict, the last loaded will be the only route used.

There is an option for an extension to provide special scenarios for handling a history request, such as a natural key being used to both store and access history logs. In this case, the constant HISTORY_CUSTOM_OPERATOR should be defined listing the table names that should be processed by the extension. In this case, a class names ExtHistoryOperator must be defined in the extension’s utilities namespace with a getHistory function mirroring getHistory in HistoryOperator. This function should call HistoryDatabaseHandler’s select function after any parameter or result modification and return it.

InfoScape

The core code of InfoScape is located in ‘src’. Beneath ‘src’ are the following directories:

  • controllers – Classes (ending in ‘Controller’) that route user requests to the proper view
  • exceptions – Classes (ending in ‘Exception’) that are thrown if errors occur
  • factories – A single class, ControllerFactory, that will load the correct controller for a user request
  • html – Source HTML files that will be used to construct pages for the user
  • models – HTTP Request and response objects, and a user object
  • public – Images and other media files needed by the browser, the ‘doorway’ index page, and .htaccess, a file used to re-write URLs
  • scripts – Javascript files
  • stylesheets – CSS files
  • utilities – Miscellaneous classes that perform various operations
  • views – Classes (of type ‘Form’, ‘Element’, ‘Page’, and ‘Content’) representing all or part of a page

Extensions

Extensions must be placed in a directory with a unique name under ‘extensions’. The structure of an extension mimics the core code:

  • controllers
  • html
  • scripts
  • stylesheets
  • views

When accessing stylesheets or scripts from your HTML templates, you must include the proper name of the extension (the name of the directory containing it) in the URI.

Like InfoCentral, InfoScape extensions must have the class ExtConfig. Instead of OPTIONS, InfoScape extensions must have the public constant MENU. This is used to add the extension to the Portal Menu users see when the first log in. The structure of MENU is:

    public const MENU = array(
        'extensionName' => array(
            'title' => 'Your Extension',
            'permission' => 'code',
            'icon' => 'image.png',
            'link' => 'extensionName'
        ),
    );

The image name used for ‘icon’ must be available in the public/media/menu directory.