API15

JToolBar/loadButtonType

From Joomla! Documentation

< API15:JToolBar
Revision as of 13:55, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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]

Loads a button type

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

& loadButtonType($type, $new=false)
Parameter Name Default Value Description
$type buttonType
$new false

Returns[edit]

object

Defined in[edit]

libraries/joomla/html/toolbar.php

Importing[edit]

jimport( 'joomla.html.toolbar' );

Source Body[edit]

function & loadButtonType($type, $new = false)
{
        $false = false;

        $signature = md5($type);
        if (isset ($this->_buttons[$signature]) && $new === false) {
                return $this->_buttons[$signature];
        }

        if (!class_exists('JButton'))
        {
                JError::raiseWarning( 'SOME_ERROR_CODE', 'Could not load button base class.' );
                return $false;
        }

        $buttonClass = 'JButton'.$type;
        if (!class_exists($buttonClass))
        {
                if (isset ($this->_buttonPath)) {
                        $dirs = $this->_buttonPath;
                } else {
                        $dirs = array ();
                }

                $file = JFilterInput::clean(str_replace('_', DS, strtolower($type)).'.php', 'path');

                jimport('joomla.filesystem.path');
                if ($buttonFile = JPath::find($dirs, $file)) {
                        include_once $buttonFile;
                } else {
                        JError::raiseWarning('SOME_ERROR_CODE', "Could not load module $buttonClass ($buttonFile).");
                        return $false;
                }
        }

        if (!class_exists($buttonClass))
        {
                //return        JError::raiseError( 'SOME_ERROR_CODE', "Module file $buttonFile does not contain class $buttonClass." );
                return $false;
        }
        $this->_buttons[$signature] = new $buttonClass($this);

        return $this->_buttons[$signature];
}

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

Examples[edit]

<CodeExamplesForm />