Extension:GWToolset/Technical Implementation/Application entry

GWToolset is a Special Page extension. Its entry point is the same as any other Special Page, an initial set-up file, /GWToolset/GWToolset.php, and a special page file, /GWToolset/includes/Specials/SpecialGWToolset.php, extending SpecialPage and overriding the execute() method.

GWToolset.phpEdit

Similar to other set-up pages with the difference being in the use of for loops and the Config.php file to set-up various configuration settings. This convention was chosen in order to maintain a “cleaner” set-up file and isolate the extension’s configuration values within the GWToolset namespace.

SpecialGWToolset.phpEdit

wikiChecks()Edit

A series of checks to make sure the wiki environment is properly setup for the extension and that the user has permission to use it.

setModuleAndHandler()Edit

The extension uses the SpecialGWToolset->module_key to represent a step within the upload process. Each module_key has a corresponding handler, form and allow-get request value; the form value is not required and some module_keys share the same handler.

When the module_key is null or the module_key’s allow-get value is set to false, the introduction copy for the upload process is shown.

The current module_keys are:

  1. metadata-detect
  2. metadata-mapping
  3. metadata-mapping-save
  4. metadata-preview

processRequest()Edit

Sends the code to the proper handler depending on the $this->module_key and whether or not the page request was a GET or a POST. Below is a list of scenarios currently handled.

GETEdit

  1. when $this->module_key has not been set, is invalid, or does not allow GET access, the introduction message to the extension is displayed.
  2. when $this->module_key is valid and allows GET access, the handler’s getForm() method is called.
    • at present, the only $this->module_key that allows for this scenario is ‘metadata-detect’.
    • if an exception is thrown a user message is displayed.

POSTEdit

  1. when $this->module_key is valid and the request is not a GET, the handler’s execute() method is called.
    • if an exception is thrown a user message is displayed.
  2. when $this->module_key is invalid, an exception is thrown and a user message is displayed.