- md5
- 4c11fdfb8a4044529c0ecfd588283f33
- sha1
- ca6e1dfb13327fae3ec2651fd429a40913464c95
- sha256
- 86af1ae65a78d5d2c5f427b4da450cea77a1605f58a43f095cdf3454aff4ddaf
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
* @package Joomla.Administrator
* @subpackage com_messages
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* JHtml administrator messages class.
*
* @since 1.6
*/
class JHtmlMessages
{
/**
* Get the HTML code of the state switcher
*
* @param int $value The state value
* @param int $i Row number
* @param boolean $canChange Can the user change the state?
*
* @return string
*
* @since 1.6
*
* @deprecated 4.0 Use JHtmlMessages::status() instead
*/
public static function state($value = 0, $i = 0, $canChange = false)
{
// Log deprecated message
JLog::add(
'JHtmlMessages::state() is deprecated. Use JHtmlMessages::status() instead.',
JLog::WARNING,
'deprecated'
);
// Note: $i is required but has to be an optional argument in the function call due to argument order
if (null === $i)
{
throw new InvalidArgumentException('$i is a required argument in JHtmlMessages::state');
}
// Note: $canChange is required but has to be an optional argument in the function call due to argument order
if (null === $canChange)
{
throw new InvalidArgumentException('$canChange is a required argument in JHtmlMessages::state');
}
return static::status($i, $value, $canChange);
}
/**
* Get the HTML code of the state switcher
*
* @param int $i Row number
* @param int $value The state value
* @param boolean $canChange Can the user change the state?
*
* @return string
*
* @since 3.4
*/
public static function status($i, $value = 0, $canChange = false)
{
// Array of image, task, title, action.
$states = array(
-2 => array('trash', 'messages.unpublish', 'JTRASHED', 'COM_MESSAGES_MARK_AS_UNREAD'),
1 => array('publish', 'messages.unpublish', 'COM_MESSAGES_OPTION_READ', 'COM_MESSAGES_MARK_AS_UNREAD'),
0 => array('unpublish', 'messages.publish', 'COM_MESSAGES_OPTION_UNREAD', 'COM_MESSAGES_MARK_AS_READ'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[0]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return listItemTask(\'cb' . $i . '\',\'' . $state[1] . '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '" title="' . JHtml::tooltipText($state[3]) . '"><span class="icon-' . $icon . '"></span></a>';
}
return $html;
}
}
The same content is in 2 releases, Joomla 3.7.0-alpha2 to 3.7.0-beta1. See them all, or every version of this file.