JHTML/
From Joomla! Documentation
< API15:JHTML
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Class loader method
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
_($type)
Parameter Name | Default Value | Description |
---|---|---|
$type | The name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers. |
Defined in[edit]
libraries/joomla/html/html.php
Importing[edit]
jimport( 'joomla.html.html' );
Source Body[edit]
function _( $type )
{
//Initialise variables
$prefix = 'JHTML';
$file = '';
$func = $type;
// Check to see if we need to load a helper file
$parts = explode('.', $type);
switch(count($parts))
{
case 3 :
{
$prefix = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] );
$file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] );
$func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[2] );
} break;
case 2 :
{
$file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] );
$func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] );
} break;
}
$className = $prefix.ucfirst($file);
if (!class_exists( $className ))
{
jimport('joomla.filesystem.path');
if ($path = JPath::find(JHTML::addIncludePath(), strtolower($file).'.php'))
{
require_once $path;
if (!class_exists( $className ))
{
JError::raiseWarning( 0, $className.'::' .$func. ' not found in file.' );
return false;
}
}
else
{
JError::raiseWarning( 0, $prefix.$file . ' not supported. File not found.' );
return false;
}
}
if (is_callable( array( $className, $func ) ))
{
$temp = func_get_args();
array_shift( $temp );
$args = array();
foreach ($temp as $k => $v) {
$args[] = &$temp[$k];
}
return call_user_func_array( array( $className, $func ), $args );
}
else
{
JError::raiseWarning( 0, $className.'::'.$func.' not supported.' );
return false;
}
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]