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. Inherited from UIControl

TEMPLATE

Derived classes must set this constant.

Properties

This class defines the following properties:

  • $sendHeadersWhenRendering ash; Can be disabled to not send headers when rendering a view. Inherited from View
  • $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

$sendHeadersWhenRendering

Can be disabled to not send headers when rendering a view. This can be useful if heaps of views are being rendered during one request to possibly prevent a segmentation fault see eg #15307 . It should not be disabled for a main view, but could be disabled for views that are being rendered eg during a twig event as a "subview" which is part of the "main view".

Signature

  • It is a bool value.

$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 - getUseStrictReferrerPolicy() ash; Returns whether a strict Referrer-Policy header will be sent. Inherited from View - setUseStrictReferrerPolicy() ash; Sets whether a strict Referrer-Policy header will be sent (if not, nothing is sent). 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 or a mixed result.

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 or a mixed result.

__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 or a mixed result.

render()

Renders the control view within a containing

<

div> that is used by the UIControl JavaScript class.

Signature

  • Returns: string — Serialized data, eg, (image, array, html...).

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 or a mixed result.

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 or a mixed result.

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.

getUseStrictReferrerPolicy()

Returns whether a strict Referrer-Policy header will be sent. Generally this should be set to 'true'.

Signature

  • It returns a bool value.

setUseStrictReferrerPolicy()

Sets whether a strict Referrer-Policy header will be sent (if not, nothing is sent).

Signature

  • It accepts the following parameter(s):

    • $useStrictReferrerPolicy (bool) —
  • It does not return anything or a mixed result.

getClientSideProperties()

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

Should be overridden 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 overridden by descendants.

Signature

  • It returns a array value.