Piwik\DataTable\Filter\

BeautifyTimeRangeLabels

A DataTable filter that replaces range labels whose values are in seconds with prettier, human-friendlier versions.

This filter customizes the behavior of the BeautifyRangeLabels filter so range values that are less than one minute are displayed in seconds but other ranges are displayed in minutes.

Basic usage

$dataTable->filter('BeautifyTimeRangeLabels', array("%1$s-%2$s min", "1 min", "%s min"));

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):

    • $table (DataTable) —

    • $labelSecondsPlural (string) — A string to use when beautifying range labels whose lower bound is between 0 and 60. Must be a format string that takes two numeric params.

    • $labelMinutesSingular (string) — A string to use when replacing a range that equals 60-60 (or 1 minute - 1 minute).
    • $labelMinutesPlural (string) — A string to use when replacing a range that spans multiple minutes. This must be a format string that takes one string parameter.

filter()

See ColumnCallbackReplace.

Signature

  • It accepts the following parameter(s):

  • It does not return anything or a mixed result.

enableRecursive()

Enables/Disables recursive filtering. Whether this property is actually used is up to the derived BaseFilter class.

Signature

  • It accepts the following parameter(s):

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

filterSubTable()

Filters a row's subtable, if one exists and is loaded in memory.

Signature

  • It accepts the following parameter(s):
    • $row (Row) — The row whose subtable should be filter.
  • It does not return anything or a mixed result.

beautify()

Beautifies a range label and returns the pretty result. See BeautifyRangeLabels.

Signature

  • It accepts the following parameter(s):

    • $value (string) — The range string. This must be in either a '$min-$max' format a '$min+' format.
  • Returns: string — The pretty range label.

getSingleUnitLabel()

Beautifies and returns a range label whose range spans over one unit, ie 1-1, 2-2 or 3-3.

If the lower bound of the range is less than 60 the pretty range label will be in seconds. Otherwise, it will be in minutes.

Signature

  • It accepts the following parameter(s):

    • $oldLabel (string) — The original label value.
    • $lowerBound (int) — The lower bound of the range.
  • Returns: string — The pretty range label.

getRangeLabel()

Beautifies and returns a range label whose range is bounded and spans over more than one unit, ie 1-5, 5-10 but NOT 11+.

If the lower bound of the range is less than 60 the pretty range label will be in seconds. Otherwise, it will be in minutes.

Signature

  • It accepts the following parameter(s):

    • $oldLabel (string) — The original label value.
    • $lowerBound (int) — The lower bound of the range.
    • $upperBound (int) — The upper bound of the range.
  • Returns: string — The pretty range label.

getUnboundedLabel()

Beautifies and returns a range label whose range is unbounded, ie 5+, 10+, etc.

If the lower bound of the range is less than 60 the pretty range label will be in seconds. Otherwise, it will be in minutes.

Signature

  • It accepts the following parameter(s):

    • $oldLabel (string) — The original label value.
    • $lowerBound (int) — The lower bound of the range.
  • Returns: string — The pretty range label.