Back to Joomla project (class list)

Class HTMLHelper - list of methods

Utility class for all HTML drawing classes
Package: Joomla\CMS\HTML
Copyright: (C) 2005 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/HTML/HTMLHelper.php
Project: Joomla

Method Summary

protected static array
(mixed $key)

Method to extract a key
Parameters
  • string $key The name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers.
Returns
  • array Contains lowercase key, prefix, file, function.
Since
  • 1.6
Deprecated
  • 5.0
Show source code of this method: extract Source Code

public static mixed
(string $key, mixed $methodArgs)

Class loader method
Parameters
  • string $key The name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers.
  • array $methodArgs The arguments to pass forward to the method being called
Returns
  • mixed Result of HTMLHelper::call($function, $args)
Since
  • 1.5
-
  • \InvalidArgumentException
Show source code of this method: _ Source Code

public static bool
(mixed $key, callable $function)

Registers a function to be called with a specific key
Parameters
  • string $key The name of the key
  • callable $function Function or method
Returns
  • bool True if the function is callable
Since
  • 1.6
Deprecated
  • 5.0
Show source code of this method: register Source Code

public static bool
(mixed $key)

Removes a key for a method from registry.
Parameters
  • string $key The name of the key
Returns
  • bool True if a set key is unset
Since
  • 1.6
Deprecated
  • 5.0
Show source code of this method: unregister Source Code

public static bool
(mixed $key)

Test if the key is registered.
Parameters
  • string $key The name of the key
Returns
  • bool True if the key is registered.
Since
  • 1.6
Show source code of this method: isRegistered Source Code

public static \Joomla\CMS\HTML\Registry
()

Retrieves the service registry.
Returns
  • \Joomla\CMS\HTML\Registry
Since
  • 4.0.0
Show source code of this method: getServiceRegistry Source Code

protected static mixed
(callable $function, mixed $args)

Function caller method
Parameters
  • callable $function Function or method to call
  • array $args Arguments to be passed to function
Returns
  • mixed Function result or false on error.
Since
  • 1.6
-
  • https://www.php.net/manual/en/function.call-user-func-array.php
  • \InvalidArgumentException
Show source code of this method: call Source Code

public static string
(mixed $url, mixed $text, mixed $attribs = null)

Write a `<a>` element
Parameters
  • string $url The relative URL to use for the href attribute
  • string $text The target attribute to use
  • array|string $attribs Attributes to be added to the `<a>` element
Returns
  • string
Since
  • 1.5
Show source code of this method: link Source Code

public static string
(mixed $url, mixed $name, mixed $attribs = null, mixed $noFrames = '')

Write a `<iframe>` element
Parameters
  • string $url The relative URL to use for the src attribute.
  • string $name The target attribute to use.
  • array|string $attribs Attributes to be added to the `<iframe>` element
  • string $noFrames The message to display if the iframe tag is not supported.
Returns
  • string
Since
  • 1.5
Show source code of this method: iframe Source Code

protected static array
(mixed $folder, mixed $file, mixed $relative, mixed $detectBrowser, mixed $detectDebug)

Compute the files to be included
Parameters
  • string $folder Folder name to search in (i.e. images, css, js).
  • string $file Path to file.
  • bool $relative Flag if the path to the file is relative to the /media folder (and searches in template).
  • bool $detectBrowser Flag if the browser should be detected to include specific browser files.
  • bool $detectDebug Flag if debug mode is enabled to include uncompressed files if debug is on.
Returns
  • array files to be included.
Since
  • 1.6
-
  • \Joomla\CMS\Environment\Browser
Show source code of this method: includeRelativeFiles Source Code

public static object
(mixed $url)

Gets a URL, cleans the Joomla specific params and returns an object
Parameters
  • string $url The relative or absolute URL to use for the src attribute.
Returns
  • object
Since
  • 4.0.0
-
  • { url: 'string', attributes: [ width: integer, height: integer, ] }
Show source code of this method: cleanImageURL Source Code

public static string|null
(mixed $file, mixed $alt, mixed $attribs = null, mixed $relative = false, mixed $returnPath = 0)

Write a `<img>` element
Parameters
  • string $file The relative or absolute URL to use for the src attribute.
  • string $alt The alt text.
  • array|string $attribs Attributes to be added to the `<img>` element
  • bool $relative Flag if the path to the file is relative to the /media folder (and searches in template).
  • int $returnPath Defines the return value for the method: -1: Returns a `<img>` tag without looking for relative files 0: Returns a `<img>` tag while searching for relative files 1: Returns the file path to the image while searching for relative files
Returns
  • string|null HTML markup for the image, relative path to the image, or null if path is to be returned but image is not found
Since
  • 1.5
Show source code of this method: image Source Code

public static array|string|null
(mixed $file, mixed $options = array(), mixed $attribs = array())

Write a `<link>` element to load a CSS file
Parameters
  • string $file Path to file
  • array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
  • array $attribs Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Returns
  • array|string|null nothing if $returnPath is false, null, path or array of path if specific CSS browser files were detected
Since
  • 1.5
-
  • \Joomla\CMS\Environment\Browser
Show source code of this method: stylesheet Source Code

public static array|string|null
(mixed $file, mixed $options = array(), mixed $attribs = array())

Write a `<script>` element to load a JavaScript file
Parameters
  • string $file Path to file.
  • array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
  • array $attribs Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Returns
  • array|string|null Nothing if $returnPath is false, null, path or array of path if specific JavaScript browser files were detected
Since
  • 1.5
-
  • \Joomla\CMS\HTML\HTMLHelper::stylesheet()
Show source code of this method: script Source Code

public static void
(mixed $options)

Set format related options.
Parameters
  • array $options Option key/value pairs.
Returns
  • void
Since
  • 1.5
-
  • \Joomla\CMS\HTML\HTMLHelper::$formatOptions
Show source code of this method: setFormatOptions Source Code

public static string
(mixed $input = 'now', mixed $format = null, mixed $tz = true, mixed $gregorian = false)

Returns formatted date according to a given format and time zone.
Parameters
  • string $input String in a format accepted by date(), defaults to "now".
  • string $format The date format specification string (see {@link PHP_MANUAL#date}).
  • mixed $tz Time zone to be used for the date. Special cases: boolean true for user setting, boolean false for server setting.
  • bool $gregorian True to use Gregorian calendar.
Returns
  • string A date translated by the given format and time zone.
Since
  • 1.5
-
  • \Joomla\CMS\HTML\strftime
Show source code of this method: date Source Code

public static string
(mixed $tooltip, mixed $title = '', mixed $image = 'tooltip.png', mixed $text = '', mixed $href = '', mixed $alt = 'Tooltip', mixed $class = 'hasTooltip')

Creates a tooltip with an image as button
Parameters
  • string $tooltip The tip string.
  • mixed $title The title of the tooltip or an associative array with keys contained in {'title','image','text','href','alt'} and values corresponding to parameters of the same name.
  • string $image The image for the tip, if no text is provided.
  • string $text The text for the tip.
  • string $href A URL that will be used to create the link.
  • string $alt The alt attribute for img tag.
  • string $class CSS class for the tool tip.
Returns
  • string
Since
  • 1.5
Show source code of this method: tooltip Source Code

public static string
(mixed $title = '', mixed $content = '', mixed $translate = true, mixed $escape = true)

Converts a double colon separated string or 2 separate strings to a string ready for bootstrap tooltips
Parameters
  • string $title The title of the tooltip (or combined '::' separated string).
  • string $content The content to tooltip.
  • bool $translate If true will pass texts through Text.
  • bool $escape If true will pass texts through htmlspecialchars.
Returns
  • string The tooltip string
Since
  • 3.1.2
Show source code of this method: tooltipText Source Code

public static string
(mixed $value, mixed $name, mixed $id, mixed $format = '%Y-%m-%d', mixed $attribs = array())

Displays a calendar control field
Parameters
  • string $value The date value
  • string $name The name of the text field
  • string $id The id of the text field
  • string $format The date format
  • mixed $attribs Additional HTML attributes The array can have the following keys: readonly Sets the readonly parameter for the input tag disabled Sets the disabled parameter for the input tag autofocus Sets the autofocus parameter for the input tag autocomplete Sets the autocomplete parameter for the input tag filter Sets the filter for the input tag
Returns
  • string HTML markup for a calendar field
Since
  • 1.5
Show source code of this method: calendar Source Code

public static array
(mixed $path = '')

Add a directory where HTMLHelper should search for helpers. You may either pass a string or an array of directories.
Parameters
  • string $path A path to search.
Returns
  • array An array with directory elements
Since
  • 1.5
Deprecated
  • 5.0
Show source code of this method: addIncludePath Source Code

protected static string
(mixed $path = '', mixed $ext = '', mixed $debugMode = false)

Method that searches if file exists in given path and returns the relative path. If a minified version exists it will be preferred.
Parameters
  • string $path The actual path of the file
  • string $ext The extension of the file
  • bool $debugMode Signifies if debug is enabled
Returns
  • string The relative path of the file
Since
  • 4.0.0
Show source code of this method: addFileToBuffer Source Code

protected static string
(mixed $path)

Method that takes a file path and converts it to a relative path
Parameters
  • string $path The actual path of the file
Returns
  • string The relative path of the file
Since
  • 4.0.0
Show source code of this method: convertToRelativePath Source Code

private static string
(mixed $first, mixed $second)

Method that takes two paths and checks if the files exist with different order
Parameters
  • string $first the path of the minified file
  • string $second the path of the non minified file
Returns
  • string
Since
  • 4.0.0
Show source code of this method: checkFileOrder Source Code

Properties Summary

public static array
$formatOptions
Option values related to the generation of HTML output. Recognized options are: fmtDepth, integer. The current indent depth.
Since
  • 1.5
protected static string[]
$includePaths
An array to hold included paths
Since
  • 1.5
-
  • string[]
protected static callable[]
$registry
An array to hold method references
Since
  • 1.6
-
  • callable[]
protected static \Joomla\CMS\HTML\Registry
$serviceRegistry
The service registry for custom and overridden JHtml helpers
Since
  • 4.0.0

Tags Summary

Since
1.5