SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class Widget

Base class for widgets

Variables

NameVisibilityDescription
$default_settings
Array of default settings for new widgets
$friendly_desc
A description, for display in the admin
$friendly_name
The friendly name, for display in the admin
$heading
Optional HTML H2 heading that's rendered on front-end view
$settings
Settings - These get automatically set in the admin and loaded on the front-end

Functions

NameVisibilityDescription
cleanupSettingspublicRun after import of settings, allows extending widgets to clean up settings which may
getDefaultSettingspublicReturns the default settings for the widget
getEditUrlpublicThis function should return a URL which can be used to edit the *content* which is
getFriendlyDescpublicGets the english name of this widget
getFriendlyNamepublicGets the english name of this widget
getInfoLabelspublicThis function should return a summary of what this widget's *content* is.
getNotAvailableReasonpublicIs there sufficent content to add this addon at the moment?
getSettingspublicReturn the currently loaded settings for the widget
getSettingsFormpublicThis function should return the content of the widget settings form.
getTitlepublicReturns the title to use for the widget - should not contain HTML
importSettingspublicImports the settings
renderpublicThis function should return the content of the widget that is used on the front-end of the website.
setTitlepublicSet widget title

public cleanupSettings

void $Widget->cleanupSettings ( );

Run after import of settings, allows extending widgets to clean up settings which may
have bad values for some reason

public getDefaultSettings

unknown $Widget->getDefaultSettings ( );

Returns the default settings for the widget

public getEditUrl

unknown $Widget->getEditUrl ( );

This function should return a URL which can be used to edit the *content* which is
displayed by this widget.

Most widgets show content using a category selection box; the URL should in that
case direct the user to the contents list for that category.

Return NULL if there isn't an appropriate URL to use.

public getFriendlyDesc

unknown $Widget->getFriendlyDesc ( );

Gets the english name of this widget

public getFriendlyName

unknown $Widget->getFriendlyName ( );

Gets the english name of this widget

public getInfoLabels

unknown $Widget->getInfoLabels ( );

This function should return a summary of what this widget's *content* is.
Don't specify the widget name; we already know that!

Most widgets show content using a category selection box; in that case
the most useful thing is probably the category name, perhaps also the
order and limit.

Return NULL if there isn't an appropriate label to use.

public getNotAvailableReason

unknown $Widget->getNotAvailableReason ( );

Is there sufficent content to add this addon at the moment?
If this widget is not available, a string message should be returned
If this widget *is* available, NULL should be returned.

public getSettings

array $Widget->getSettings ( );

Return the currently loaded settings for the widget

public getSettingsForm

string $Widget->getSettingsForm ( );

This function should return the content of the widget settings form.
The content should be returned as well-formed HTML.
The content will be contained within a DIV element, which is inside a FORM element.

This function will be called from an AJAX request, so Needs cannot be used.
Inline CSS and Javascript should be loaded correctly by the jQuery library.

Form fields *must* be generated using the Form helper, to ensure correct field
prefix as well as reloading of field values

public getTitle

unknown $Widget->getTitle ( );

Returns the title to use for the widget - should not contain HTML

public importSettings

void $Widget->importSettings ( array $settings );

Imports the settings

public render

string $Widget->render ( int $orientation );

This function should return the content of the widget that is used on the front-end of the website.
The content should be returned as well-formed HTML.
The content will be contained within a DIV element,
which has the class 'widget', and the class 'widget-[WIDGETNAME]' applied to it.

Styles and Javascript can be loaded with the needs helper, usually the Needs::fileGroup function is most useful.

public setTitle

void $Widget->setTitle ( string $str );

Set widget title