- md5
- 2787dae237f6b680a104978e23916600
- sha1
- 3065fb5e6e6b6ad60a4acd3cc7deddd70ebb2440
- sha256
- e4b8dbbb86e3b0d1b479b18d06d9091b3b899057a459ac4a2796e2626f334f93
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Toolbar;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Layout\FileLayout;
/**
* Button base class
*
* The JButton is the base class for all JButton types
*
* @since 3.0
*/
abstract class ToolbarButton
{
/**
* element name
*
* This has to be set in the final renderer classes.
*
* @var string
*/
protected $_name = null;
/**
* reference to the object that instantiated the element
*
* @var \JButton
*/
protected $_parent = null;
/**
* Constructor
*
* @param object $parent The parent
*/
public function __construct($parent = null)
{
$this->_parent = $parent;
}
/**
* Get the element name
*
* @return string type of the parameter
*
* @since 3.0
*/
public function getName()
{
return $this->_name;
}
/**
* Get the HTML to render the button
*
* @param array &$definition Parameters to be passed
*
* @return string
*
* @since 3.0
*/
public function render(&$definition)
{
/*
* Initialise some variables
*/
$id = call_user_func_array(array(&$this, 'fetchId'), $definition);
$action = call_user_func_array(array(&$this, 'fetchButton'), $definition);
// Build id attribute
if ($id)
{
$id = ' id="' . $id . '"';
}
// Build the HTML Button
$options = array();
$options['id'] = $id;
$options['action'] = $action;
$layout = new FileLayout('joomla.toolbar.base');
return $layout->render($options);
}
/**
* Method to get the CSS class name for an icon identifier
*
* Can be redefined in the final class
*
* @param string $identifier Icon identification string
*
* @return string CSS class name
*
* @since 3.0
*/
public function fetchIconClass($identifier)
{
// It's an ugly hack, but this allows templates to define the icon classes for the toolbar
$layout = new FileLayout('joomla.toolbar.iconclass');
return $layout->render(array('icon' => $identifier));
}
/**
* Get the button
*
* Defined in the final button class
*
* @return string
*
* @since 3.0
*/
abstract public function fetchButton();
}
The same content is in 30 releases, Joomla 3.9.15-rc to 3.10.0-alpha1. See them all, or every version of this file.