Extensibility interfaces
Extensibility interfaces are one way to customize iTop behaviors. To learn more about the others, check Extensibility API
Interfaces reference documentation
There are several interfaces for extending iTop. Each interface corresponds to a specific type of extension. Here are some examples:
Interface | Description |
---|---|
iApplicationUIExtension | Implement this interface to change the behavior of the GUI for some objects (when displaying the details or editing an object). |
iApplicationObjectExtension | Old interface to perform specific actions on objects during CRUD, replaced by the events handling |
iPageUIBlockExtension | Implement this interface to add content to any iTopWebPage |
iPortalUIExtension | Implement this interface to add content to any portal page |
iPopupMenuExtension | Add menu items on iTop objects and list, in console and portal |
iRestServiceProvider | Add verbs to the REST API. |
Those interfaces and abstract classes are defined in the application/applicationextension.inc.php file.
Here is a reference documentation of those interfaces: API Reference for extensions
iPopupMenuExtension example
Let's imagine that we have web based application which provides some advanced reporting on the availability of Servers. We would like to provide an hyperlink so that end-users can quickly jump from the details of a Server in iTop into the corresponding report in the monitoring application.
One possible solution is to show this an hyperlink to the monitoring application into the “Actions” popup-menu on all Servers.
The implementation consists in implementing the interface
iPopupMenuExtension
:
- main.mymodule.php
-
class MyPopupExtension implements iPopupMenuExtension { public static function EnumItems($iMenuId, $param) { if ($iMenuId == self::MENU_OBJDETAILS_ACTIONS) { $oObject = $param; if ($oObject instanceof Server) { $sUID = 'MyPopupExtension-Monitoring'; // Make sure that each menu item has a unique "ID" $sLabel = 'Monthly report'; $sURL = 'http://myapp/show_report?server_fqdn='.$oObject->Get('name'); $sTarget = '_blank'; $oMenuItem = new URLPopupMenuItem($sUID, $sLabel, $sURL, $sTarget); return array($oMenuItem); } } return array(); } }
The method EnumItems
will be called by iTop in
several circumstances. When displaying the details of an object,
$params
is the target object.
As our method will be called for any kind of object, we have to filter out the classes of objects that are not relevant for this action.
As you can see, one can handle several types of objects and
several types of menus with the same extension (depending on
$iMenuId
and $param
).
The outcome of this plugin is an additional menu entry on the details page of any server:
Other examples
Those tutorials are using the iTop interface API:
-
iPopupMenuExtension: Add entry in ''other actions'' popup menu
-
iPopupMenuExtension: Add action on a list
-
iBackofficeStyleExtension: Hide History from Activity panel