Actions

API15

JToolBar/loadButtonType

From Joomla! Documentation

< API15:JToolBar
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Loads a button type

[<! removed edit link to red link >]

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

Syntax

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

Returns

object

Defined in

libraries/joomla/html/toolbar.php

Importing

jimport( 'joomla.html.toolbar' );

Source Body

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

<CodeExamplesForm />