API16

JToolBar/loadButtonType: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JToolBar/loadButtonType}}
 


===Syntax===
===Syntax===
Line 79: Line 79:




{{subst:SeeAlso:JToolBar/loadButtonType}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=loadButtonType
  category=loadButtonType
  category=JToolBar
  category=JToolBar
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:13, 25 March 2017

Description

Loads a button type.



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

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

Code Examples