PHP Class Piwik\Widget\WidgetConfig

Exibir arquivo Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$action
$categoryId
$isEnabled
$isWide
$isWidgetizable
$middlewareParameters
$module
$name
$order
$parameters
$subcategoryId

Public Methods

Method Description
addParameters ( array $parameters ) : static Add new parameters and only overwrite parameters that have the same name. See {@link setParameters()}
checkIsEnabled ( ) This method checks whether the widget is available, see {@link isEnabled()}. If not, it triggers an exception containing a message that will be displayed to the user. You can overwrite this message in case you want to customize the error message. Eg.
disable ( ) Disables the widget. See {@link isEnabled()}
enable ( ) Enables the widget. See {@link isEnabled()}
getAction ( ) : string Get the currently set action.
getCategoryId ( ) : string Get the id of the category the widget belongs to.
getMiddlewareParameters ( ) : array Get defined middleware parameters (if any).
getModule ( )
getName ( ) : string Get the name of the widget.
getOrder ( ) : integer Returns the order of the widget.
getParameters ( ) : array Get all URL parameters needed to render this widget.
getSubcategoryId ( ) : string Get the currently set category ID.
getUniqueId ( ) : string Returns the unique id of an widget based on module, action and the set parameters.
isEnabled ( ) : boolean Defines whether a widget is enabled or not. For instance some widgets might not be available to every user or might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then return true or false. If your report is only available to users having super user access you can do the following: return Piwik::hasUserSuperUserAccess();
isWide ( ) : boolean Detect whether the widget should be shown wide or not.
isWidgetizeable ( ) : boolean Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. This is usually not needed but useful when you eg want to display a widget within the Piwik UI but not want to have it widgetizable.
setAction ( string $action ) : static Set the action of the widget that shall be used in the URL to render the widget.
setCategoryId ( string $categoryId ) : static Set the id of the category the widget belongs to.
setIsEnabled ( boolean $isEnabled ) : static Enable / disable the widget. See {@link isEnabled()}
setIsNotWidgetizable ( ) : static Sets the widget as not widgetizable {@link isWidgetizeable()}.
setIsWide ( ) Marks this widget as a "wide" widget that requires the full width.
setIsWidgetizable ( ) : static Sets the widget as widgetizable {@link isWidgetizeable()}.
setMiddlewareParameters ( array $parameters ) : static If middleware parameters are specified, the corresponding action will be executed before showing the actual widget in the UI. Only if this action (can be a controller method or API method) returns JSON true the widget will be actually shown. It is similar to isEnabled() but the specified action is performed each time the widget is requested in the UI whereas isEnabled is only checked once on the inital page load when we load the inital list of widgets. So if your widget's visibility depends on archived data (aka idSite/period/date) you should specify middle parameters. This has mainly two reasons:
setModule ( string $module ) : static Set the module (aka plugin name) of the widget. The correct module is usually detected automatically and not needed to be configured manually.
setName ( string $name ) : static Set the name of the widget.
setOrder ( integer $order ) : static Set the order of the widget.
setParameters ( array $parameters ) : static Sets (overwrites) the parameters of the widget. These parameters will be added to the URL when rendering the widget. You can access these parameters via `Piwik\Common::getRequestVar(.
setSubcategoryId ( string $subcategoryId ) : static Set the id of the subcategory the widget belongs to. If a subcategory is specified, the widget will be shown in the Piwik reporting UI. The subcategoryId will be used as a translation key for the submenu item.

Method Details

addParameters() public method

Add new parameters and only overwrite parameters that have the same name. See {@link setParameters()}
public addParameters ( array $parameters ) : static
$parameters array eg. ('urlparam' => 'urlvalue')
return static

checkIsEnabled() public method

if (!$this->isEnabled()) { throw new Exception('Setting XYZ is not enabled or the user has not enough permission'); }
public checkIsEnabled ( )

disable() public method

Disables the widget. See {@link isEnabled()}
public disable ( )

enable() public method

Enables the widget. See {@link isEnabled()}
public enable ( )

getAction() public method

Get the currently set action.
public getAction ( ) : string
return string

getCategoryId() public method

Get the id of the category the widget belongs to.
public getCategoryId ( ) : string
return string

getMiddlewareParameters() public method

Get defined middleware parameters (if any).
public getMiddlewareParameters ( ) : array
return array

getModule() public method

public getModule ( )

getName() public method

Get the name of the widget.
public getName ( ) : string
return string

getOrder() public method

Returns the order of the widget.
public getOrder ( ) : integer
return integer

getParameters() public method

Get all URL parameters needed to render this widget.
public getParameters ( ) : array
return array Eg ('urlparam' => 'urlvalue').

getSubcategoryId() public method

Get the currently set category ID.
public getSubcategoryId ( ) : string
return string

getUniqueId() public method

Returns the unique id of an widget based on module, action and the set parameters.
public getUniqueId ( ) : string
return string

isEnabled() public method

Defines whether a widget is enabled or not. For instance some widgets might not be available to every user or might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then return true or false. If your report is only available to users having super user access you can do the following: return Piwik::hasUserSuperUserAccess();
public isEnabled ( ) : boolean
return boolean

isWide() public method

Detect whether the widget should be shown wide or not.
public isWide ( ) : boolean
return boolean

isWidgetizeable() public method

Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. This is usually not needed but useful when you eg want to display a widget within the Piwik UI but not want to have it widgetizable.
public isWidgetizeable ( ) : boolean
return boolean

setAction() public method

The correct action is usually detected automatically and not needed to be configured manually.
public setAction ( string $action ) : static
$action string eg 'renderMyWidget'
return static

setCategoryId() public method

Set the id of the category the widget belongs to.
public setCategoryId ( string $categoryId ) : static
$categoryId string Usually a translation key, eg 'General_Visits', 'Goals_Goals', ...
return static

setIsEnabled() public method

Enable / disable the widget. See {@link isEnabled()}
public setIsEnabled ( boolean $isEnabled ) : static
$isEnabled boolean
return static

setIsNotWidgetizable() public method

Sets the widget as not widgetizable {@link isWidgetizeable()}.
public setIsNotWidgetizable ( ) : static
return static

setIsWide() public method

Marks this widget as a "wide" widget that requires the full width.
public setIsWide ( )

setIsWidgetizable() public method

Sets the widget as widgetizable {@link isWidgetizeable()}.
public setIsWidgetizable ( ) : static
return static

setMiddlewareParameters() public method

- This way the inital page load time is faster as we won't have to request archived data on the initial page load for widgets that are potentially never shown. - We execute that action every time before showing it. As the initial list of widgets is loaded on page load it is possible that some archives have no data yet, but at a later time there might be actually archived data. As we never reload the initial list of widgets we would still not show the widget even there we should. Example: On page load there are no conversions, a few minutes later there might be conversions. As the middleware is executed before showing it, we detect correctly that there are now conversions whereas isEnabled is only checked once on the initial Piwik page load.
public setMiddlewareParameters ( array $parameters ) : static
$parameters array URL parameters eg array('module' => 'Goals', 'action' => 'Conversions')
return static

setModule() public method

Set the module (aka plugin name) of the widget. The correct module is usually detected automatically and not needed to be configured manually.
public setModule ( string $module ) : static
$module string eg 'CoreHome'
return static

setName() public method

Set the name of the widget.
public setName ( string $name ) : static
$name string Usually a translation key, eg 'VisitTime_ByServerTimeWidgetName'
return static

setOrder() public method

Set the order of the widget.
public setOrder ( integer $order ) : static
$order integer eg. 5
return static

setParameters() public method

..)`.
public setParameters ( array $parameters ) : static
$parameters array eg. ('urlparam' => 'urlvalue')
return static

setSubcategoryId() public method

Set the id of the subcategory the widget belongs to. If a subcategory is specified, the widget will be shown in the Piwik reporting UI. The subcategoryId will be used as a translation key for the submenu item.
public setSubcategoryId ( string $subcategoryId ) : static
$subcategoryId string Usually a translation key, eg 'General_Overview', 'Actions_Pages', ...
return static

Property Details

$action protected_oe property

protected $action

$categoryId protected_oe property

protected $categoryId

$isEnabled protected_oe property

protected $isEnabled

$isWide protected_oe property

protected $isWide

$isWidgetizable protected_oe property

protected $isWidgetizable

$middlewareParameters protected_oe property

protected $middlewareParameters

$module protected_oe property

protected $module

$name protected_oe property

protected $name

$order protected_oe property

protected $order

$parameters protected_oe property

protected $parameters

$subcategoryId protected_oe property

protected $subcategoryId