Piwik\View\

UIControl

Base type of UI controls.

The JavaScript companion class can be found in plugins/CoreHome/javascripts/uiControl.js.

Constants

This class defines the following constants:

  • TEMPLATE — The Twig template file that generates the control's HTML.

TEMPLATE

Derived classes must set this constant.

Properties

This class defines the following properties:

  • $cssIdentifier — The CSS class that is used to map the root element of this control with the JavaScript class.
  • $jsClass — The name of the JavaScript class that handles the behavior of this control.
  • $jsNamespace — The JavaScript module that contains the JavaScript class.
  • $cssClass — Extra CSS class(es) for the root element.
  • $htmlAttributes — HTML Attributes for the root element

$cssIdentifier

The CSS class that is used to map the root element of this control with the JavaScript class.

This field must be set prior to rendering.

Signature

  • It is a string value.

$jsClass

The name of the JavaScript class that handles the behavior of this control.

This field must be set prior to rendering.

Signature

  • It is a string value.

$jsNamespace

The JavaScript module that contains the JavaScript class.

Signature

  • It is a string value.

$cssClass

Extra CSS class(es) for the root element.

Signature

  • It is a string value.

$htmlAttributes

HTML Attributes for the root element

Signature

  • It is a string value.

Methods

The class defines the following methods:

<

div> that is used by the UIControl JavaScript class. - setContentType() ash; Set stored value used in the Content-Type HTTP header field. Inherited from View - setXFrameOptions() ash; Set X-Frame-Options field in the HTTP response. Inherited from View - singleReport() ash; Creates a View for and then renders the single report template. Inherited from View - getClientSideProperties() — Returns the array of property names whose values are passed to the UIControl JavaScript class. - getClientSideParameters() — Returns an array of property names whose values are passed to the UIControl JavaScript class.

__construct()

Constructor.

Signature

disableCacheBuster()

Disables the cache buster (adding of ?cb=...) to JavaScript and stylesheet files

Signature

  • It does not return anything.

getTemplateFile()

Returns the template filename.

Signature

  • It returns a string value.

getTemplateVars()

See View::getTemplateVars().

Signature

  • It accepts the following parameter(s):
    • $override (array) — Template variable override values. Mainly useful when including View templates in other templates.
  • It returns a array value.

__set()

Sets a variable.

See View::__set().

Signature

  • It accepts the following parameter(s):
    • $key (string) — The variable name.
    • $val (mixed) — The variable value.
  • It does not return anything.

__get()

Gets a view variable.

See View::__get().

Signature

  • It accepts the following parameter(s):

    • $key (string) — The variable name.
  • Returns: mixed — The variable value.

__isset()

Returns true if a template variable has been set or not.

Signature

  • It accepts the following parameter(s):

    • $key
  • It returns a bool value.

__unset()

Unsets a template variable.

Signature

  • It accepts the following parameter(s):
    • $name (string) — The name of the template variable.
  • It does not return anything.

render()

Renders the control view within a containing

<

div> that is used by the UIControl JavaScript class.

Signature

  • Returns: string — Generated template.

setContentType()

Set stored value used in the Content-Type HTTP header field.

The header is set just before rendering.

Signature

  • It accepts the following parameter(s):

    • $contentType (string) —
  • It does not return anything.

setXFrameOptions()

Set X-Frame-Options field in the HTTP response.

The header is set just before rendering.

Note: setting this allows you to make sure the View cannot be embedded in iframes. Learn more here.

Signature

  • It accepts the following parameter(s):
    • $option (string) — ('deny' or 'sameorigin')
  • It does not return anything.

singleReport()

Creates a View for and then renders the single report template.

Can be used for pages that display only one report to avoid having to create a new template.

Signature

  • It accepts the following parameter(s):

    • $title (string) — The report title.
    • $reportHtml (string) — The report body HTML.
  • Returns: string|void — The report contents if $fetch is true.

getClientSideProperties()

Returns the array of property names whose values are passed to the UIControl JavaScript class.

Should be overriden by descendants.

Signature

  • It returns a array value.

getClientSideParameters()

Returns an array of property names whose values are passed to the UIControl JavaScript class.

These values differ from those in $clientSideProperties in that they are meant to passed as request parameters when the JavaScript code makes an AJAX request.

Should be overriden by descendants.

Signature

  • It returns a array value.