Class WidgetController

Controller for widgets

Namespace: Ip


string SKIN_DIR 'skin'


__construct( mixed $name , mixed $pluginName , [ mixed $core = false ] )
string getTitle( )

Gets widget title

Override this method to set the widget name displayed in widget toolbar.

Return values:

string Widget's title
string getName( )

Return a name, which is unique widget identifier

Return values:

string Widget's name
string getWidgetDir( )

Get widget's administration directory

Return values:

string Widget's directory path
boolean isCore( )

Check if the widget is native ImpressPages widget

Return values:

boolean Returns false, if a widget is provided by installable plugin.
string getIcon( )

Get widget icon URL

Widget icon is displayed in widget toolbar of administration page.

Return values:

string Icon URL
array defaultData( )

Override this method to set default data of the widget

Return values:

array Default data
array getSkins( )

Get all widget skins

Return values:

array List of skins


array update( integer $widgetId , array $postData , array $currentData )

Update widget data

This method is executed each time the widget data is updated.


integer $widgetId Widget ID
array $postData
array $currentData

Return values:

array Data to be stored to the database
mixed post( integer $widgetId , array $data )

Process post data submitted in public mode

You can make posts directly to your widget (e.g., when submitting HTML form in public page).

If you pass the following parameters: sa=Content.widgetPost securityToken=actualSecurityToken widgetId=actualWidgetId

then that post request will be redirected to the specified method.

Use return new \Ip\Response\Json($jsonArray) to return JSON.

Attention: this method is accessible for website visitors without admin login.


integer $widgetId Widget ID
array $data Widget Data array

Return values:

array duplicate( integer $oldId , integer $newId , array $data )

Duplicate widget action

This function is executed after the widget has been duplicated. All widget data is duplicated automatically. This method is used only in case a widget needs to do some maintenance tasks on duplication.


integer $oldId Old widget ID
integer $newId Duplicated widget ID
array $data Data that has been duplicated from old widget to the new one

Return values:

delete( integer $widgetId , array $data )

Delete a widget

This method is executed before actual deletion of a widget. It is used to remove widget data (e.g., photos, files, additional database records and so on). Standard widget data is being deleted automatically. So you don't need to extend this method if your widget does not upload files or add new records to the database manually.


integer $widgetId Widget ID
array $data Data that is being stored in the widget
adminHtmlSnippet( )
string generateHtml( integer $revisionId , integer $widgetId , integer $data , array $skin )

Renders widget's HTML output

You can extend this method when generating widget's HTML.


integer $revisionId Widget revision ID
integer $widgetId Widget ID
integer $widgetId Widget instance ID
array $data Widget data array

Return values:

string Widget's HTML code
array dataForJs( integer $revisionId , integer $widgetId , integer $data , array $skin )

Process data which is passed to widget's JavaScript file for processing


integer $revisionId Widget revision ID
integer $widgetId Widget ID
integer $widgetId Widget instance ID
array $data Widget data array

Return values:

array Data array
comments powered by Disqus