Function __global->generate_truncation

Definitions

sources/templates.php

  • Advanced truncation/tooltip generator.Note we also have the generate_tooltip_by_truncation function, which is good for simple plain-text tooltips.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$label mixed No No required parameter N/A N/A Label to truncate (string or Tempcode)
$type string No No required parameter left right spread N/A The type of truncation to do
$len integer No No 60 N/A N/A The length to truncate at
$generate_tooltip boolean No No False N/A N/A Whether to generate a tooltip
$is_html ?boolean No No Null N/A N/A Whether $label is HTML (null: HTML if $label is Tempcode)
$literal_pos boolean No No False N/A N/A Whether to use $len as an HTML actual-text-character length, rather than a simple byte length
$grammar_completeness_tolerance float No No 0 N/A N/A Fractional-deviation-tolerance for grammar-preservation
$tooltip_if_truncated ?mixed No No Null N/A N/A Tooltip to add on, but only if we end up creating our own tooltip, string or mixed (null: none)

Returns

  • The result
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Advanced truncation/tooltip generator.Note we also have the generate_tooltip_by_truncation function, which is good for simple plain-text tooltips.
 *
 * @param  mixed $label Label to truncate (string or Tempcode)
 * @param  string $type The type of truncation to do
 * @set left right spread
 * @param  integer $len The length to truncate at
 * @param  boolean $generate_tooltip Whether to generate a tooltip
 * @param  ?boolean $is_html Whether $label is HTML (null: HTML if $label is Tempcode)
 * @param  boolean $literal_pos Whether to use $len as an HTML actual-text-character length, rather than a simple byte length
 * @param  float $grammar_completeness_tolerance Fractional-deviation-tolerance for grammar-preservation
 * @param  ?mixed $tooltip_if_truncated Tooltip to add on, but only if we end up creating our own tooltip, string or mixed (null: none)
 * @return string The result
 */

function generate_truncation($label, string $type, int $len = 60, bool $generate_tooltip = false, ?bool $is_html = null, bool $literal_pos = false, float $grammar_completeness_tolerance = 0, $tooltip_if_truncated = null) : string