Joomla! CMS 3.3 API

JHtml

Utility class for all HTML drawing classes

abstract
package

Joomla.Libraries

subpackage

HTML

since

1.5

Methods

_

Class loader method

_(string $key) : mixed
static

Additional arguments may be supplied and are passed to the sub-class. Additional include paths are also able to be specified for third-party use

since

1.5

throws

\InvalidArgumentException

Arguments

$key

stringThe name of helper method to load, (prefix).(class).function

                   prefix and class are optional and can be used to load custom
                   html helpers.

Response

mixedJHtml::call($function, $args) or False on error

addIncludePath

Add a directory where JHtml should search for helpers. You may either pass a string or an array of directories.

addIncludePath(string $path = '') : array
static
since

1.5

Arguments

$path

stringA path to search.

Response

arrayAn array with directory elements

calendar

Displays a calendar control field

calendar(string $value, string $name, string $id, string $format = '%Y-%m-%d', mixed $attribs = null) : string
static
since

1.5

Arguments

$value

stringThe date value

$name

stringThe name of the text field

$id

stringThe id of the text field

$format

stringThe date format

$attribs

mixedAdditional HTML attributes

Response

stringHTML markup for a calendar field

call

Function caller method

call(callable $function, array $args) : mixed
static
see http://php.net/manual/en/function.call-user-func-array.php
since

1.6

throws

\InvalidArgumentException

Arguments

$function

callableFunction or method to call

$args

arrayArguments to be passed to function

Response

mixedFunction result or false on error.

date

Returns formated date according to a given format and time zone.

date(string $input = 'now', string $format = null, mixed $tz = true, boolean $gregorian = false) : string
static
see \strftime
since

1.5

Arguments

$input

stringString in a format accepted by date(), defaults to "now".

$format

stringThe date format specification string (see {@link PHP_MANUAL#date}).

$tz

mixedTime zone to be used for the date. Special cases: boolean true for user

                          setting, boolean false for server setting.

$gregorian

booleanTrue to use Gregorian calendar.

Response

stringA date translated by the given format and time zone.

extract

Method to extract a key

extract(string $key) : array
static
since

1.6

Arguments

$key

stringThe name of helper method to load, (prefix).(class).function

                   prefix and class are optional and can be used to load custom html helpers.

Response

arrayContains lowercase key, prefix, file, function.

getJSObject

Internal method to get a JavaScript object notation string from an array

getJSObject(array $array = array()) : string
static
since

3.0

Arguments

$array

arrayThe array to convert to JavaScript object notation

Response

stringJavaScript object notation representation of the array

iframe

Write a element

iframe(string $url, string $name, array $attribs = null, string $noFrames = '') : string
static
since

1.5

Arguments

$url

stringThe relative URL to use for the src attribute.

$name

stringThe target attribute to use.

$attribs

arrayAn associative array of attributes to add.

$noFrames

stringThe message to display if the iframe tag is not supported.

Response

string element or message if not supported.

image

Write a element

image(string $file, string $alt, mixed $attribs = null, boolean $relative = false, mixed $path_rel = false) : string
static
since

1.5

Arguments

$file

stringThe relative or absolute URL to use for the src attribute.

$alt

stringThe alt text.

$attribs

mixedString or associative array of attribute(s) to use.

$relative

booleanPath to file is relative to /media folder (and searches in template).

$path_rel

mixedReturn html tag without (-1) or with file computing(false). Return computed path only (true).

Response

string

includeRelativeFiles

Compute the files to be included

includeRelativeFiles(string $folder, string $file, boolean $relative, boolean $detect_browser, boolean $detect_debug) : array
static
see \JBrowser
since

1.6

Arguments

$folder

stringfolder name to search into (images, css, js, ...).

$file

stringpath to file.

$relative

booleanpath to file is relative to /media folder (and searches in template).

$detect_browser

booleandetect browser to include specific browser files.

$detect_debug

booleandetect debug to include compressed files if debug is on.

Response

arrayfiles to be included.

isRegistered

Test if the key is registered.

isRegistered(string $key) : boolean
static
since

1.6

Arguments

$key

stringThe name of the key

Response

booleanTrue if the key is registered.

register

Registers a function to be called with a specific key

register(string $key, string $function) : boolean
static
since

1.6

Arguments

$key

stringThe name of the key

$function

stringFunction or method

Response

booleanTrue if the function is callable

script

Write a element

script(string $file, boolean $framework = false, boolean $relative = false, boolean $path_only = false, boolean $detect_browser = true, boolean $detect_debug = true) : mixed
static
see \JHtml::stylesheet()
since

1.5

Arguments

$file

stringpath to file.

$framework

booleanload the JS framework.

$relative

booleanpath to file is relative to /media folder.

$path_only

booleanreturn the path to the file only.

$detect_browser

booleandetect browser to include specific browser js files.

$detect_debug

booleandetect debug to search for compressed files if debug is on.

Response

mixednothing if $path_only is false, null, path or array of path if specific js browser files were detected.

setFormatOptions

Set format related options.

setFormatOptions(array $options) : void
static

Updates the formatOptions array with all valid values in the passed array.

see \JHtml::formatOptions
since

1.5

Arguments

$options

arrayOption key/value pairs.

stylesheet

Write a element

stylesheet(string $file, array $attribs = array(), boolean $relative = false, boolean $path_only = false, boolean $detect_browser = true, boolean $detect_debug = true) : mixed
static
see \JBrowser
since

1.5

Arguments

$file

stringpath to file

$attribs

arrayattributes to be added to the stylesheet

$relative

booleanpath to file is relative to /media folder

$path_only

booleanreturn the path to the file only

$detect_browser

booleandetect browser to include specific browser css files

                               will try to include file, file_*browser*, file_*browser*_*major*, file_*browser*_*major*_*minor*
                               <table>
                                  <tr><th>Navigator</th>                  <th>browser</th>    <th>major.minor</th></tr>

                                  <tr><td>Safari 3.0.x</td>               <td>konqueror</td>    <td>522.x</td></tr>
                                  <tr><td>Safari 3.1.x and 3.2.x</td>     <td>konqueror</td>    <td>525.x</td></tr>
                                  <tr><td>Safari 4.0 to 4.0.2</td>        <td>konqueror</td>    <td>530.x</td></tr>
                                  <tr><td>Safari 4.0.3 to 4.0.4</td>      <td>konqueror</td>    <td>531.x</td></tr>
                                  <tr><td>iOS 4.0 Safari</td>             <td>konqueror</td>    <td>532.x</td></tr>
                                  <tr><td>Safari 5.0</td>                 <td>konqueror</td>    <td>533.x</td></tr>

                                  <tr><td>Google Chrome 1.0</td>          <td>konqueror</td>    <td>528.x</td></tr>
                                  <tr><td>Google Chrome 2.0</td>          <td>konqueror</td>    <td>530.x</td></tr>
                                  <tr><td>Google Chrome 3.0 and 4.x</td>  <td>konqueror</td>    <td>532.x</td></tr>
                                  <tr><td>Google Chrome 5.0</td>          <td>konqueror</td>    <td>533.x</td></tr>

                                  <tr><td>Internet Explorer 5.5</td>      <td>msie</td>        <td>5.5</td></tr>
                                  <tr><td>Internet Explorer 6.x</td>      <td>msie</td>        <td>6.x</td></tr>
                                  <tr><td>Internet Explorer 7.x</td>      <td>msie</td>        <td>7.x</td></tr>
                                  <tr><td>Internet Explorer 8.x</td>      <td>msie</td>        <td>8.x</td></tr>

                                  <tr><td>Firefox</td>                    <td>mozilla</td>    <td>5.0</td></tr>
                               </table>
                               a lot of others

$detect_debug

booleandetect debug to search for compressed files if debug is on

Response

mixednothing if $path_only is false, null, path or array of path if specific css browser files were detected

tooltip

Creates a tooltip with an image as button

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

1.5

Arguments

$tooltip

stringThe tip string.

$title

mixedThe 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.

$image

stringThe image for the tip, if no text is provided.

$text

stringThe text for the tip.

$href

stringAn URL that will be used to create the link.

$alt

stringThe alt attribute for img tag.

$class

stringCSS class for the tool tip.

Response

string

tooltipText

Converts a double colon seperated string or 2 separate strings to a string ready for bootstrap tooltips

tooltipText(string $title = '', string $content = '', integer $translate = 1, integer $escape = 1) : string
static
since

3.1.2

Arguments

$title

stringThe title of the tooltip (or combined '::' separated string).

$content

stringThe content to tooltip.

$translate

integerIf true will pass texts through JText.

$escape

integerIf true will pass texts through htmlspecialchars.

Response

stringThe tooltip string

unregister

Removes a key for a method from registry.

unregister(string $key) : boolean
static
since

1.6

Arguments

$key

stringThe name of the key

Response

booleanTrue if a set key is unset

Properties

formatOptions

Option values related to the generation of HTML output. Recognized options are:

fmtDepth, integer. The current indent depth.
formatOptions : array
static

fmtEol, string. The end of line string, default is linefeed.

fmtIndent, string. The string to use for indentation, default is
tab.
var
since

1.5

Type(s)

array

includePaths

An array to hold included paths

includePaths : array
static
var
since

1.5

Type(s)

array

registry

An array to hold method references

registry : array
static
var
since

1.6

Type(s)

array