JToolBar/loadButtonType
From Joomla! Documentation
< API16:JToolBar
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]
Loads a button type.
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]
public function loadButtonType($type, $new = 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::getInstance()->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];
}
Examples[edit]
Code Examples[edit]