Documentation

EsiWidgetController extends EsiWidgetController

JsonAdapter Controller to handle EsiWidgets Usage: - Create a subclass that implements parseWidget() - Register it as a Controller in your ComponentController

Tags
copyright

CLOUDREXX CMS - Cloudrexx AG Thun

author

Project Team SS4U info@cloudrexx.com

subpackage

module_downloads

version
1.0.0

Table of Contents

Constants

FILTER_JOIN_AND  = '&'
Flag used in filters to indicate an **AND** join.
FILTER_JOIN_OR  = '|'
Flag used in filters to indicate an **OR** join.

Properties

$cx  : Cx
Main class instance
$esiParamPage  : Page
Holds

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Creates new controller
getAccessableMethods()  : array<string|int, mixed>
Returns an array of method names accessable from a JSON request
getDefaultPermissions()  : Permission
Returns default permission as object
getMessagesAsString()  : string
Returns all messages as string
getName()  : string
Returns the internal name used as identifier for this adapter
getSystemComponentController()  : SystemComponentController
Returns the main controller
getWidget()  : array<string|int, mixed>
Returns the content of a widget
parseWidget()  : mixed
Parses a widget
getFileContent()  : string
Loads the content of a theme file.
internalParseWidget()  : array<string|int, mixed>
Parses a widget
objectifyParams()  : array<string|int, mixed>
This makes object of the given params (if possible) Known params are page, lang, user, theme, channel, country, currency and ref
parseFilter()  : array<string|int, mixed>
Parses a category filter expression string into a structured array.
parseWidgetDownloadsAsset()  : string
Renders the func_downloads_asset widget.

Constants

FILTER_JOIN_AND

Flag used in filters to indicate an **AND** join.

protected string FILTER_JOIN_AND = '&'

When applied, assets must match all IDs listed in the filter.

FILTER_JOIN_OR

Flag used in filters to indicate an **OR** join.

protected string FILTER_JOIN_OR = '|'

When applied, assets may match any of the IDs listed in the filter.

Properties

Methods

__call()

Route methods like getName(), getType(), getDirectory(), etc.

public __call(string $methodName, array<string|int, mixed> $arguments) : mixed
Parameters
$methodName : string

Name of method to call

$arguments : array<string|int, mixed>

List of arguments for the method to call

Attributes
#[ReturnTypeWillChange]
Return values
mixed

Return value of the method to call

getWidget()

Returns the content of a widget

public getWidget(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

JsonAdapter parameters

Return values
array<string|int, mixed>

Content in an associative array

parseWidget()

Parses a widget

public parseWidget(string $name, Sigma $template, Response $response, array<string|int, mixed> $params) : mixed
Parameters
$name : string

Widget name

$template : Sigma

Widget Template

$response : Response

Current response

$params : array<string|int, mixed>

Array of params

getFileContent()

Loads the content of a theme file.

protected getFileContent(Theme|mixed $theme, string $fileName, Response $response[, bool $parseNodePlaceholders = false ]) : string

Behavior:

  • Resolves the file path for the given theme and filename.
  • Reads the file content via File.
  • Always parses legacy BLOCK_... placeholders (via the Block component).
  • If $parseNodePlaceholders is true, also parses:
    • NODE_... placeholders (via LinkGenerator).
    • (In the future) all widgets. See CLX-1707
Parameters
$theme : Theme|mixed

The theme instance. If not a valid Theme, an empty string is returned.

$fileName : string

The file name within the theme folder (leading slashes are trimmed).

$response : Response

The response providing the current page. Falls back to the global page instance if not set.

$parseNodePlaceholders : bool = false

Whether to additionally parse NODE_... placeholders.

Return values
string

The file content (possibly parsed), or an empty string on error.

internalParseWidget()

Parses a widget

protected internalParseWidget(Widget $widget, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$widget : Widget

The Widget

$params : array<string|int, mixed>

Params passed by ESI (/API) request

Return values
array<string|int, mixed>

Content in an associative array

objectifyParams()

This makes object of the given params (if possible) Known params are page, lang, user, theme, channel, country, currency and ref

protected objectifyParams(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Associative array of params

Return values
array<string|int, mixed>

Associative array of params

parseFilter()

Parses a category filter expression string into a structured array.

protected parseFilter(string $unparsedFilter) : array<string|int, mixed>

A filter string consists of numeric category IDs separated by either an AND operator (static::FILTER_JOIN_AND = &) or an OR operator (static::FILTER_JOIN_OR = |). Each ID may optionally be suffixed with "+" to indicate expansion to its subcategories.

Examples:

  • "12" → single category 12.
  • "12&34" → categories 12 and 34.
  • "12|34|56" → categories 12 or 34 or 56.
  • "12+|34" → category 12 (with subcategories) or category 34.
Parameters
$unparsedFilter : string

The raw filter string to parse.

Tags
@return

array{ ids: array<int,string>, // Category IDs as keys, "+" if expanded, "" otherwise join: string // Either {@see static::FILTER_JOIN_AND} or {@see static::FILTER_JOIN_OR} } Structured filter definition, defaulting to an empty ids list and {@see static::FILTER_JOIN_AND} join if the string is invalid.

Return values
array<string|int, mixed>

parseWidgetDownloadsAsset()

Renders the func_downloads_asset widget.

protected parseWidgetDownloadsAsset(string $name, array<string|int, mixed> $params, Response $response) : string

This method resolves the widget template file, parses category and filter parameters, and delegates rendering to Downloads::parseDownloadsForDownloadsAssetWidget().

Behavior:

  • Determines the widget template name from $params[0], sanitized, defaulting to "Default".
  • Loads the widget template file via EsiWidgetController::getFileContent() and wraps it in a Sigma instance.
  • Parses a category filter string from $params[2] using parseFilter() and expands subcategories if suffixed with "+".
  • Determines a limit ($params[3]) and offset ($params[4]).
  • Builds a filter array including:
    • Excluding expired downloads,
    • Restricting to specified categories.
  • Optionally parses sorting from $params[5] as JSON (field → asc|desc), ignoring invalid definitions.
  • Calls Downloads::parseDownloadsForDownloadsAssetWidget() to populate the template with download entries.
  • Returns the rendered template content, or an empty string if no template or no downloads matched.
Parameters
$name : string

The widget name (used to resolve the template folder).

$params : array<string|int, mixed>

Widget parameters, including:

  • theme: Theme instance to resolve template files.
  • page: Page ID or context for rendering.
  • 0: (optional) Template name (defaults to "Default").
  • 2: (optional) Category filter string (see parseFilter()).
  • 3: (optional) Limit (integer).
  • 4: (optional) Offset (integer).
  • 5: (optional) JSON-encoded sorting definition.
$response : Response

Response object, updated with expiration date if needed.

Tags
todo

Implement widget argument ($realParams[1]). CLX-6264

Return values
string

Rendered widget content, or an empty string if no downloads are found.


        
On this page

Search results