API16

Difference between revisions of "JHtml/"

From Joomla! Documentation

< API16:JHtml
(New page: ===Description=== Class loader method <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Descr...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JHtml/_|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JHtml/_}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 91: Line 91:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JHtml/_|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JHtml/_}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 106: Line 106:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Revision as of 21:55, 13 May 2013

The "API16" 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]

static _($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]

public static function _($type)
{
        $type = preg_replace('#[^A-Z0-9_\.]#i', '', $type);

        // Check to see if we need to load a helper file
        $parts = explode('.', $type);

        $prefix = (count($parts) == 3 ? array_shift($parts) : 'JHtml');
        $file   = (count($parts) == 2 ? array_shift($parts) : '');
        $func   = array_shift($parts);

        $key = strtolower($prefix.'.'.$file.'.'.$func);

        if (array_key_exists($key, self::$registry))
        {
                $function = self::$registry[$key];
                $args = func_get_args();
                // remove function name from arguments
                array_shift($args);
                return JHtml::call($function, $args);
        }

        $className = $prefix.ucfirst($file);

        if (!class_exists($className))
        {
                jimport('joomla.filesystem.path');
                if ($path = JPath::find(JHtml::$includePaths, strtolower($file).'.php'))
                {
                        require_once $path;

                        if (!class_exists($className))
                        {
                                JError::raiseError(500, $className.'::' .$func. ' not found in file.');
                                return false;
                        }
                }
                else
                {
                        JError::raiseError(500, $prefix.$file . ' not supported. File not found.');
                        return false;
                }
        }

        $toCall = array($className, $func);
        if (is_callable($toCall))
        {
                JHtml::register($key, $toCall);
                $args = func_get_args();
                // remove function name from arguments
                array_shift($args);
                return JHtml::call($toCall, $args);
        }
        else
        {
                JError::raiseError(500, $className.'::'.$func.' not supported.');
                return false;
        }
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />