Was this page helpful?

Plugins

    Warning: Hooks are still a work in progress on the front-end. Interfaces may change between releases.

    Overview

    MindTouch PHP plugins allow developers to add in their own functionality at specific integration points throughout the application's user interface(UI).  Each point has a defined list of arguments and name. Together, these are hooks.

    Hooks are mechanisms, available since the Lyons release, on the PHP front-end of MindTouch which allows developers to modify existing UI views or add pre/post-process handlers for any actions undertaken through the UI. With hooks, you can change the behavior of existing special pages, add additional workflows inside MindTouch, or simply add your own custom PHP applications to MindTouch without worrying about breaking future upgrade compatibility. Any PHP scripts which are written to take advantage of hooks are referred to as plugins. Examples of common plugins in every MindTouch installation are the left navigation pane as well as all the special pages.

    Components

    All plugin components are located inside:

    {dekiroot}/deki/plugins

    Plugin hooks and core code is located in the deki_plugin.php file:

    {dekiroot}/deki/plugins/deki_plugin.php

    As one would guess, plugins are stored inside the plugins folder. Each plugin is defined by a unique folder name, as well as a required PHP file. Both the folder and main plugin PHP file must be named the same. When naming your plugin, follow these guidelines:

    • lowercase names
    • no spaces
    • no dashes, use underscores (MindTouch UI convention)

    Examples

    Folder PHP file Structure
    my_first_plugin my_first_plugin.php my_first_plugin/my_first_plugin.php
    helloworld helloworld.php helloworld/helloworld.php

     

    Special Pages

    Special pages are a specific implementation of plugins. All special page plugins should be located under:

    {dekiroot}/deki/plugins/special_page

    Convenience methods can be inherited by implementing the SpecialPagePlugin class. For reference, special_page.php is located at:

    {dekiroot}/deki/plugins/special_page/special_page.php

    These plugins are not loaded until a user makes a request to the Special namespace.  When that request is made, it's marshalled to the appropriate special page for rendering the request. Special page plugins must be activated in a similar fashion to normal plugins. See the section on activation for more information.

    Activation

    Whitelisting

    By default, plugins are disabled and must be explicitly enabled via LocalSettings.php.  In order to enable a plugin, it must first be located in the plugins folder. Once there, add the following to enable a plugin named my_first_plugin:

    $wgDekiPlugins[] = 'my_first_plugin';

    If attempting to enable a new special page plugin, it must be located in the plugins/special_page folder. Once there, add the following to enable a new special page plugin named my_special_page:

    $wgDekiSpecialPages[] = 'my_special_page';

    Directory

    An alternate method for loading plugins is by directory. Directory loading is disabled by default and should only be used for plugin development.  When enabled, MindTouch will scan the plugins directory and load each plugin it encounters. To enabled directory loading, add the following to your LocalSettings.php:

    $wgDekiPluginMode = 'directory';

    When directory loading is enabled, plugins do not need to be whitelisted for them to work.

    Hook summary

    To fully realize the potential of plugins, look over the list of available hooks.  By using the appropriate hooks for your plugin, you can create a fluid, seamless application integration inside every MindTouch installation.

    Each hook is defined by a case-insensitive string. All application hooks are defined within the Hooks class located in the deki_plugin.php file. Plugin developers can use the Hooks class constants or simply reference the hook by name.

    When the system executes a hook, it looks for plugins that are registered with the hook.  As a convention, each hook name is composed of a relevant section and name. For instance, each special page hook is prefixed with Special: followed by the name of the page to hook against.  Other sections include Editor:, Main:, and Page: which apply to editor hooks, main application hooks, and page specific hooks.

    Developing with hooks

    TODO

    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by