Implement this interface to change the behavior of the GUI for some objects.

All methods are invoked by iTop for a given object. There are basically two usages:

1) To tweak the form of an object, you will have to implement a specific behavior within:

  • OnDisplayProperties (bEditMode = true)
  • OnFormSubmit
  • OnFormCancel

2) To tune the display of the object details, you can use:

  • OnDisplayProperties
  • OnDisplayRelations
  • GetIcon
  • GetHilightClass

Please note that some of the APIs can be called several times for a single page displayed. Therefore it is not recommended to perform too many operations, such as querying the database. A recommended pattern is to cache data by the mean of static members.

package Extensibility
api

 Methods

Called when building the Actions menu for a single object or a list of objects

EnumAllowedActions(\DBObjectSet $oSet) : \string[string]

Use this to add items to the Actions menu. You will have to specify a label and an URL.

Example:

$oObject = $oSet->fetch();
if ($oObject instanceof Sheep)
{
    return array('View in my app' => 'http://myserver/view_sheeps?id='.$oObject->Get('name'));
}
else
{
    return array();
}

See also iPopupMenuExtension for greater flexibility

Parameters

$oSet

\DBObjectSet

A set of persistent objects (DBObject)

Returns

\string[string]

Not yet called by the framework!

EnumUsedAttributes(\DBObject $oObject) : \type

Sorry, the verb has been reserved. You must implement it, but it is not called as of now.

Parameters

$oObject

\DBObject

The object being displayed

Returns

\typedesc

Invoked when the object is displayed alone or within a list

GetHilightClass(\DBObject $oObject) : integer

Returns a value influencing the appearance of the object depending on its state.

Possible values are:

  • HILIGHT_CLASS_CRITICAL
  • HILIGHT_CLASS_WARNING
  • HILIGHT_CLASS_OK
  • HILIGHT_CLASS_NONE

Parameters

$oObject

\DBObject

The object being displayed

Returns

integerThe value representing the mood of the object

Not yet called by the framework!

GetIcon(\DBObject $oObject) : string

Sorry, the verb has been reserved. You must implement it, but it is not called as of now.

Parameters

$oObject

\DBObject

The object being displayed

Returns

stringPath of the icon, relative to the modules directory.

Invoked when an object is being displayed (wiew or edit)

OnDisplayProperties(\DBObject $oObject, \WebPage $oPage, boolean $bEditMode) : void

The method is called right after the main tab has been displayed. You can add output to the page, either to change the display, or to add a form input

Example:

if ($bEditMode)
{
    $oPage->p('Age of the captain: <input type="text" name="captain_age"/>');
}
else
{
    $oPage->p('Age of the captain: '.$iCaptainAge);
}

Parameters

$oObject

\DBObject

The object being displayed

$oPage

\WebPage

The output context

$bEditMode

boolean

True if the edition form is being displayed

Invoked when an object is being displayed (wiew or edit)

OnDisplayRelations(\DBObject $oObject, \WebPage $oPage, boolean $bEditMode) : void

The method is called rigth after all the tabs have been displayed

Parameters

$oObject

\DBObject

The object being displayed

$oPage

\WebPage

The output context

$bEditMode

boolean

True if the edition form is being displayed

Invoked when the end-user clicks on Cancel from the object edition form

OnFormCancel(string $sTempId) : void

Implement here any cleanup. This is necessary when you have injected some javascript into the edition form, and if that code requires to store temporary data (this is the case when a file must be uploaded).

Parameters

$sTempId

string

Unique temporary identifier made of session_id and transaction_id. It identifies the object in a unique way.

Invoked when the end-user clicks on Modify from the object edition form

OnFormSubmit(\DBObject $oObject, string $sFormPrefix) : void

The method is called after the changes from the standard form have been taken into account, and before saving the changes into the database.

Parameters

$oObject

\DBObject

The object being edited

$sFormPrefix

string

Prefix given to the HTML form inputs