- md5
- 4dd0ae2d9b25edd24007830f23526ffe
- sha1
- 9cfb225bcffe2815d045dfb596c8c9add09fec2a
- sha256
- 618bcc05fc86150c1d48827c751528efe7043d4972da9c19bc39225dd5fabbde
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Toolbar\Button;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Toolbar\ToolbarButton;
/**
* Renders a standard button
*
* @since 3.0
*/
class StandardButton extends ToolbarButton
{
/**
* Button type
*
* @var string
*/
protected $_name = 'Standard';
/**
* Fetch the HTML for the button
*
* @param string $type Unused string.
* @param string $name The name of the button icon class.
* @param string $text Button text.
* @param string $task Task associated with the button.
* @param boolean $list True to allow lists
* @param boolean $group Does the button belong to a group?
*
* @return string HTML string for the button
*
* @since 3.0
*/
public function fetchButton($type = 'Standard', $name = '', $text = '', $task = '', $list = true, $group = false)
{
// Store all data to the options array for use with JLayout
$options = array();
$options['text'] = \JText::_($text);
$options['class'] = $this->fetchIconClass($name);
$options['doTask'] = $this->_getCommand($options['text'], $task, $list);
$options['group'] = $group;
$options['id'] = $this->fetchId('Standard', $name);
$options['btnClass'] = 'button-' . $name;
if ($options['id'])
{
$options['id'] = ' id="' . $options['id'] . '"';
}
switch ($name)
{
case 'apply':
case 'new':
$options['btnClass'] .= ' btn btn-sm btn-success';
break;
case 'save':
case 'save-new':
case 'save-copy':
case 'save-close':
case 'publish':
$options['btnClass'] .= ' btn btn-sm btn-outline-success';
break;
case 'unpublish':
$options['btnClass'] .= ' btn btn-sm btn-outline-danger';
break;
case 'featured':
$options['btnClass'] .= ' btn btn-sm btn-outline-warning';
break;
case 'cancel':
$options['btnClass'] .= ' btn btn-sm btn-danger';
break;
case 'trash':
$options['btnClass'] .= ' btn btn-sm btn-outline-danger';
break;
default:
$options['btnClass'] .= ' btn btn-sm btn-outline-primary';
}
// Instantiate a new JLayoutFile instance and render the layout
$layout = new FileLayout('joomla.toolbar.standard');
return $layout->render($options);
}
/**
* Get the button CSS Id
*
* @param string $type Unused string.
* @param string $name Name to be used as apart of the id
* @param string $text Button text
* @param string $task The task associated with the button
* @param boolean $list True to allow use of lists
* @param boolean $hideMenu True to hide the menu on click
*
* @return string Button CSS Id
*
* @since 3.0
*/
public function fetchId($type = 'Standard', $name = '', $text = '', $task = '', $list = true, $hideMenu = false)
{
return $this->_parent->getName() . '-' . $name;
}
/**
* Get the JavaScript command for the button
*
* @param string $name The task name as seen by the user
* @param string $task The task used by the application
* @param boolean $list True is requires a list confirmation.
*
* @return string JavaScript command string
*
* @since 3.0
*/
protected function _getCommand($name, $task, $list)
{
\JText::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
\JText::script('ERROR');
$cmd = "Joomla.submitbutton('" . $task . "');";
if ($list)
{
$messages = "{'error': [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}";
$alert = "Joomla.renderMessages(" . $messages . ")";
$cmd = "if (document.adminForm.boxchecked.value == 0) { " . $alert . " } else { " . $cmd . " }";
}
return $cmd;
}
}
No other release has this exact content. See every version of this file.