| Current Path : /var/tmp/ |
| Current File : //var/tmp/phpDVlTNP |
<?php
/**
* @package Joomla.Libraries
* @subpackage Class
*
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Composer\Autoload\ClassLoader;
/**
* Decorate Composer ClassLoader for Joomla!
*
* For backward compatibility due to class aliasing in the CMS, the loadClass() method was modified to call
* the JLoader::applyAliasFor() method.
*
* @since 3.4
*/
class JClassLoader
{
/**
* The composer class loader
*
* @var ClassLoader
* @since 3.4
*/
private $loader;
/**
* Constructor
*
* @param ClassLoader $loader Composer autoloader
*
* @since 3.4
*/
public function __construct(ClassLoader $loader)
{
$this->loader = $loader;
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
*
* @return boolean|null True if loaded, null otherwise
*
* @since 3.4
*/
public function loadClass($class)
{
if ($result = $this->loader->loadClass($class))
{
JLoader::applyAliasFor($class);
}
return $result;
}
}
; Joomla! Project
; (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8
JLIB_HTML_DATE_RELATIVE_DAYS="%s days ago"
JLIB_HTML_DATE_RELATIVE_DAYS_1="%s day ago"
JLIB_HTML_DATE_RELATIVE_DAYS_0="%s days ago"
JLIB_HTML_DATE_RELATIVE_HOURS="%s hours ago"
JLIB_HTML_DATE_RELATIVE_HOURS_1="%s hour ago"
JLIB_HTML_DATE_RELATIVE_HOURS_0="%s hours ago"
JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE="Less than a minute ago"
JLIB_HTML_DATE_RELATIVE_MINUTES="%s minutes ago"
JLIB_HTML_DATE_RELATIVE_MINUTES_1="%s minute ago"
JLIB_HTML_DATE_RELATIVE_MINUTES_0="%s minutes ago"
JLIB_HTML_DATE_RELATIVE_WEEKS="%s weeks ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_1="%s week ago"
JLIB_HTML_DATE_RELATIVE_WEEKS_0="%s weeks ago"
<!DOCTYPE html><title></title>
<!DOCTYPE html><title></title>
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Extended Utility class for all HTML drawing classes.
*
* @since 1.6
*/
abstract class JHtmlAccess
{
/**
* A cached array of the asset groups
*
* @var array
* @since 1.6
*/
protected static $asset_groups = null;
/**
* Displays a list of the available access view levels
*
* @param string $name The form field name.
* @param string $selected The name of the selected section.
* @param string $attribs Additional attributes to add to the select field.
* @param mixed $params True to add "All Sections" option or an array of options
* @param mixed $id The form field id or false if not used
*
* @return string The required HTML for the SELECT tag.
*
* @see JFormFieldAccessLevel
* @since 1.6
*/
public static function level($name, $selected, $attribs = '', $params = true, $id = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('a.id', 'value') . ', ' . $db->quoteName('a.title', 'text'))
->from($db->quoteName('#__viewlevels', 'a'))
->group($db->quoteName(array('a.id', 'a.title', 'a.ordering')))
->order($db->quoteName('a.ordering') . ' ASC')
->order($db->quoteName('title') . ' ASC');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// If params is an array, push these options to the array
if (is_array($params))
{
$options = array_merge($params, $options);
}
// If all levels is allowed, push it into the array.
elseif ($params)
{
array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
}
return JHtml::_(
'select.genericlist',
$options,
$name,
array(
'list.attr' => $attribs,
'list.select' => $selected,
'id' => $id,
)
);
}
/**
* Displays a list of the available user groups.
*
* @param string $name The form field name.
* @param string $selected The name of the selected section.
* @param string $attribs Additional attributes to add to the select field.
* @param boolean $allowAll True to add "All Groups" option.
* @param mixed $id The form field id
*
* @return string The required HTML for the SELECT tag.
*
* @see JFormFieldUsergroup
* @since 1.6
*/
public static function usergroup($name, $selected, $attribs = '', $allowAll = true, $id = false)
{
$options = array_values(JHelperUsergroups::getInstance()->getAll());
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$options[$i]->value = $options[$i]->id;
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->title;
}
// If all usergroups is allowed, push it into the array.
if ($allowAll)
{
array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_GROUPS')));
}
return JHtml::_('select.genericlist', $options, $name, array('list.attr' => $attribs, 'list.select' => $selected, 'id' => $id));
}
/**
* Returns a UL list of user groups with checkboxes
*
* @param string $name The name of the checkbox controls array
* @param array $selected An array of the checked boxes
* @param boolean $checkSuperAdmin If false only super admins can add to super admin groups
*
* @return string
*
* @since 1.6
*/
public static function usergroups($name, $selected, $checkSuperAdmin = false)
{
static $count;
$count++;
$isSuperAdmin = JFactory::getUser()->authorise('core.admin');
$groups = array_values(JHelperUsergroups::getInstance()->getAll());
$html = array();
for ($i = 0, $n = count($groups); $i < $n; $i++)
{
$item = &$groups[$i];
// If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin
if ((!$checkSuperAdmin) || $isSuperAdmin || (!JAccess::checkGroup($item->id, 'core.admin')))
{
// Setup the variable attributes.
$eid = $count . 'group_' . $item->id;
// Don't call in_array unless something is selected
$checked = '';
if ($selected)
{
$checked = in_array($item->id, $selected) ? ' checked="checked"' : '';
}
$rel = ($item->parent_id > 0) ? ' rel="' . $count . 'group_' . $item->parent_id . '"' : '';
// Build the HTML for the item.
$html[] = ' <div class="control-group">';
$html[] = ' <div class="controls">';
$html[] = ' <label class="checkbox" for="' . $eid . '">';
$html[] = ' <input type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"';
$html[] = ' ' . $checked . $rel . ' />';
$html[] = ' ' . JLayoutHelper::render('joomla.html.treeprefix', array('level' => $item->level + 1)) . $item->title;
$html[] = ' </label>';
$html[] = ' </div>';
$html[] = ' </div>';
}
}
return implode("\n", $html);
}
/**
* Returns a UL list of actions with checkboxes
*
* @param string $name The name of the checkbox controls array
* @param array $selected An array of the checked boxes
* @param string $component The component the permissions apply to
* @param string $section The section (within a component) the permissions apply to
*
* @return string
*
* @see JAccess
* @since 1.6
*/
public static function actions($name, $selected, $component, $section = 'global')
{
static $count;
$count++;
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml',
"/access/section[@name='" . $section . "']/"
);
$html = array();
$html[] = '<ul class="checklist access-actions">';
for ($i = 0, $n = count($actions); $i < $n; $i++)
{
$item = &$actions[$i];
// Setup the variable attributes.
$eid = $count . 'action_' . $item->id;
$checked = in_array($item->id, $selected) ? ' checked="checked"' : '';
// Build the HTML for the item.
$html[] = ' <li>';
$html[] = ' <input type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"';
$html[] = ' ' . $checked . ' />';
$html[] = ' <label for="' . $eid . '">';
$html[] = ' ' . JText::_($item->title);
$html[] = ' </label>';
$html[] = ' </li>';
}
$html[] = '</ul>';
return implode("\n", $html);
}
/**
* Gets a list of the asset groups as an array of JHtml compatible options.
*
* @return mixed An array or false if an error occurs
*
* @since 1.6
*/
public static function assetgroups()
{
if (empty(static::$asset_groups))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value, a.title AS text')
->from($db->quoteName('#__viewlevels') . ' AS a')
->group('a.id, a.title, a.ordering')
->order('a.ordering ASC');
$db->setQuery($query);
static::$asset_groups = $db->loadObjectList();
}
return static::$asset_groups;
}
/**
* Displays a Select list of the available asset groups
*
* @param string $name The name of the select element
* @param mixed $selected The selected asset group id
* @param string $attribs Optional attributes for the select field
* @param array $config An array of options for the control
*
* @return mixed An HTML string or null if an error occurs
*
* @since 1.6
*/
public static function assetgrouplist($name, $selected, $attribs = null, $config = array())
{
static $count;
$options = static::assetgroups();
if (isset($config['title']))
{
array_unshift($options, JHtml::_('select.option', '', $config['title']));
}
return JHtml::_(
'select.genericlist',
$options,
$name,
array(
'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count),
'list.attr' => $attribs === null ? 'class="inputbox" size="3"' : $attribs,
'list.select' => (int) $selected,
)
);
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* HTML utility class for building a dropdown menu
*
* @since 3.2
*/
abstract class JHtmlActionsDropdown
{
/**
* @var string HTML markup for the dropdown list
* @since 3.2
*/
protected static $dropDownList = array();
/**
* Method to render current dropdown menu
*
* @param string $item An item to render.
*
* @return string HTML markup for the dropdown list
*
* @since 3.2
*/
public static function render($item = '')
{
$html = array();
$html[] = '<button data-toggle="dropdown" class="dropdown-toggle btn btn-micro">';
$html[] = '<span class="caret"></span>';
if ($item)
{
$html[] = '<span class="element-invisible">' . JText::sprintf('JACTIONS', $item) . '</span>';
}
$html[] = '</button>';
$html[] = '<ul class="dropdown-menu">';
$html[] = implode('', static::$dropDownList);
$html[] = '</ul>';
static::$dropDownList = null;
return implode('', $html);
}
/**
* Append a publish item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function publish($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'publish';
static::addCustomItem(JText::_('JTOOLBAR_PUBLISH'), 'publish', $id, $task);
}
/**
* Append an unpublish item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function unpublish($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNPUBLISH'), 'unpublish', $id, $task);
}
/**
* Append a feature item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function feature($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'featured';
static::addCustomItem(JText::_('JFEATURE'), 'featured', $id, $task);
}
/**
* Append an unfeature item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function unfeature($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'unfeatured';
static::addCustomItem(JText::_('JUNFEATURE'), 'unfeatured', $id, $task);
}
/**
* Append an archive item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function archive($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'archive';
static::addCustomItem(JText::_('JTOOLBAR_ARCHIVE'), 'archive', $id, $task);
}
/**
* Append an unarchive item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function unarchive($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNARCHIVE'), 'unarchive', $id, $task);
}
/**
* Append a duplicate item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function duplicate($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'duplicate';
static::addCustomItem(JText::_('JTOOLBAR_DUPLICATE'), 'copy', $id, $task);
}
/**
* Append a trash item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function trash($id, $prefix = '')
{
$task = ($prefix ? $prefix . '.' : '') . 'trash';
static::addCustomItem(JText::_('JTOOLBAR_TRASH'), 'trash', $id, $task);
}
/**
* Append an untrash item to the current dropdown menu
*
* @param string $id ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.2
*/
public static function untrash($id, $prefix = '')
{
self::publish($id, $prefix);
}
/**
* Writes a divider between dropdown items
*
* @return void
*
* @since 3.0
*/
public static function divider()
{
static::$dropDownList[] = '<li class="divider"></li>';
}
/**
* Append a custom item to current dropdown menu.
*
* @param string $label The label of the item.
* @param string $icon The icon classname.
* @param string $id The item id.
* @param string $task The task.
*
* @return void
*
* @since 3.2
*/
public static function addCustomItem($label, $icon = '', $id = '', $task = '')
{
static::$dropDownList[] = '<li>'
. '<a href = "javascript://" onclick="listItemTask(\'' . $id . '\', \'' . $task . '\')">'
. ($icon ? '<span class="icon-' . $icon . '" aria-hidden="true"></span> ' : '')
. $label
. '</a>'
. '</li>';
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class working with administrator language select lists
*
* @since 3.8.0
*/
abstract class JHtmlAdminLanguage
{
/**
* Cached array of the administrator language items.
*
* @var array
* @since 3.8.0
*/
protected static $items = null;
/**
* Get a list of the available administrator language items.
*
* @param boolean $all True to include All (*)
* @param boolean $translate True to translate All
*
* @return string
*
* @since 3.8.0
*/
public static function existing($all = false, $translate = false)
{
if (empty(static::$items))
{
$languages = array();
$admin_languages = JLanguageHelper::getKnownLanguages(JPATH_ADMINISTRATOR);
foreach ($admin_languages as $tag => $language)
{
$languages[$tag] = $language['nativeName'];
}
ksort($languages);
static::$items = $languages;
}
if ($all)
{
$all_option = array(new JObject(array('value' => '*', 'text' => $translate ? JText::alt('JALL', 'language') : 'JALL_LANGUAGE')));
return array_merge($all_option, static::$items);
}
else
{
return static::$items;
}
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Extended Utility class for batch processing widgets.
*
* @since 1.7
*
* @deprecated 4.0 Use JLayout directly
*/
abstract class JHtmlBatch
{
/**
* Display a batch widget for the access level selector.
*
* @return string The necessary HTML for the widget.
*
* @since 1.7
*
* @deprecated 4.0 instead of JHtml::_('batch.access'); use JLayoutHelper::render('joomla.html.batch.access', array());
*/
public static function access()
{
JLog::add('The use of JHtml::_("batch.access") is deprecated use JLayout instead.', JLog::WARNING, 'deprecated');
return JLayoutHelper::render('joomla.html.batch.access', array());
}
/**
* Displays a batch widget for moving or copying items.
*
* @param string $extension The extension that owns the category.
*
* @return string The necessary HTML for the widget.
*
* @since 1.7
*
* @deprecated 4.0 instead of JHtml::_('batch.item'); use JLayoutHelper::render('joomla.html.batch.item', array('extension' => 'com_XXX'));
*/
public static function item($extension)
{
$displayData = array('extension' => $extension);
JLog::add('The use of JHtml::_("batch.item") is deprecated use JLayout instead.', JLog::WARNING, 'deprecated');
return JLayoutHelper::render('joomla.html.batch.item', $displayData);
}
/**
* Display a batch widget for the language selector.
*
* @return string The necessary HTML for the widget.
*
* @since 2.5
*
* @deprecated 4.0 instead of JHtml::_('batch.language'); use JLayoutHelper::render('joomla.html.batch.language', array());
*/
public static function language()
{
JLog::add('The use of JHtml::_("batch.language") is deprecated use JLayout instead.', JLog::WARNING, 'deprecated');
return JLayoutHelper::render('joomla.html.batch.language', array());
}
/**
* Display a batch widget for the user selector.
*
* @param boolean $noUser Choose to display a "no user" option
*
* @return string The necessary HTML for the widget.
*
* @since 2.5
*
* @deprecated 4.0 instead of JHtml::_('batch.user'); use JLayoutHelper::render('joomla.html.batch.user', array());
*/
public static function user($noUser = true)
{
$displayData = array('noUser' => $noUser);
JLog::add('The use of JHtml::_("batch.user") is deprecated use JLayout instead.', JLog::WARNING, 'deprecated');
return JLayoutHelper::render('joomla.html.batch.user', $displayData);
}
/**
* Display a batch widget for the tag selector.
*
* @return string The necessary HTML for the widget.
*
* @since 3.1
*
* @deprecated 4.0 instead of JHtml::_('batch.tag'); use JLayoutHelper::render('joomla.html.batch.tag', array());
*/
public static function tag()
{
JLog::add('The use of JHtml::_("batch.tag") is deprecated use JLayout instead.', JLog::WARNING, 'deprecated');
return JLayoutHelper::render('joomla.html.batch.tag', array());
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class for JavaScript behaviors
*
* @since 1.5
*/
abstract class JHtmlBehavior
{
/**
* Array containing information for loaded files
*
* @var array
* @since 2.5
*/
protected static $loaded = array();
/**
* Method to load the MooTools framework into the document head
*
* If debugging mode is on an uncompressed version of MooTools is included for easier debugging.
*
* @param boolean $extras Flag to determine whether to load MooTools More in addition to Core
* @param mixed $debug Is debugging mode on? [optional]
*
* @return void
*
* @since 1.6
* @deprecated 4.0 Update scripts to jquery
*/
public static function framework($extras = false, $debug = null)
{
$type = $extras ? 'more' : 'core';
// Only load once
if (!empty(static::$loaded[__METHOD__][$type]))
{
return;
}
JLog::add('JHtmlBehavior::framework is deprecated. Update to jquery scripts.', JLog::WARNING, 'deprecated');
// If no debugging value is set, use the configuration setting
if ($debug === null)
{
$debug = JDEBUG;
}
if ($type !== 'core' && empty(static::$loaded[__METHOD__]['core']))
{
static::framework(false, $debug);
}
JHtml::_('script', 'system/mootools-' . $type . '.js', array('version' => 'auto', 'relative' => true, 'detectDebug' => $debug));
// Keep loading core.js for BC reasons
static::core();
static::$loaded[__METHOD__][$type] = true;
return;
}
/**
* Method to load core.js into the document head.
*
* Core.js defines the 'Joomla' namespace and contains functions which are used across extensions
*
* @return void
*
* @since 3.3
*/
public static function core()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
JHtml::_('form.csrf');
JHtml::_('script', 'system/core.js', array('version' => 'auto', 'relative' => true));
// Add core and base uri paths so javascript scripts can use them.
JFactory::getDocument()->addScriptOptions('system.paths', array('root' => JUri::root(true), 'base' => JUri::base(true)));
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for image captions.
*
* @param string $selector The selector for which a caption behaviour is to be applied.
*
* @return void
*
* @since 1.5
*
* @Deprecated 4.0 Use native HTML figure tags.
*/
public static function caption($selector = 'img.caption')
{
JLog::add('JHtmlBehavior::caption is deprecated. Use native HTML figure tags.', JLog::WARNING, 'deprecated');
// Only load once
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/caption.js', array('version' => 'auto', 'relative' => true));
// Attach caption to document
JFactory::getDocument()->addScriptDeclaration(
"jQuery(window).on('load', function() {
new JCaption('" . $selector . "');
});"
);
// Set static array
static::$loaded[__METHOD__][$selector] = true;
}
/**
* Add unobtrusive JavaScript support for form validation.
*
* To enable form validation the form tag must have class="form-validate".
* Each field that needs to be validated needs to have class="validate".
* Additional handlers can be added to the handler for username, password,
* numeric and email. To use these add class="validate-email" and so on.
*
* @return void
*
* @since 1.5
*
* @Deprecated 3.4 Use formvalidator instead
*/
public static function formvalidation()
{
JLog::add('The use of formvalidation is deprecated use formvalidator instead.', JLog::WARNING, 'deprecated');
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include MooTools framework
static::framework();
// Load the new jQuery code
static::formvalidator();
}
/**
* Add unobtrusive JavaScript support for form validation.
*
* To enable form validation the form tag must have class="form-validate".
* Each field that needs to be validated needs to have class="validate".
* Additional handlers can be added to the handler for username, password,
* numeric and email. To use these add class="validate-email" and so on.
*
* @return void
*
* @since 3.4
*/
public static function formvalidator()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include core
static::core();
// Include jQuery
JHtml::_('jquery.framework');
// Add validate.js language strings
JText::script('JLIB_FORM_FIELD_INVALID');
JHtml::_('script', 'system/punycode.js', array('version' => 'auto', 'relative' => true));
JHtml::_('script', 'system/validate.js', array('version' => 'auto', 'relative' => true));
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for submenu switcher support
*
* @return void
*
* @since 1.5
*
* @deprecated 4.0 No replacement, only used in Hathor.
*/
public static function switcher()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/switcher.js', array('framework' => true, 'version' => 'auto', 'relative' => true));
$script = "
document.switcher = null;
jQuery(function($){
var toggler = document.getElementById('submenu');
var element = document.getElementById('config-document');
if (element) {
document.switcher = new JSwitcher(toggler, element);
}
});";
JFactory::getDocument()->addScriptDeclaration($script);
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for a combobox effect.
*
* Note that this control is only reliable in absolutely positioned elements.
* Avoid using a combobox in a slider or dynamic pane.
*
* @return void
*
* @since 1.5
*/
public static function combobox()
{
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include core
static::core();
JHtml::_('script', 'system/combobox.js', array('version' => 'auto', 'relative' => true));
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for a hover tooltips.
*
* Add a title attribute to any element in the form
* title="title::text"
*
* Uses the core Tips class in MooTools.
*
* @param string $selector The class selector for the tooltip.
* @param array $params An array of options for the tooltip.
* Options for the tooltip can be:
* - maxTitleChars integer The maximum number of characters in the tooltip title (defaults to 50).
* - offsets object The distance of your tooltip from the mouse (defaults to {'x': 16, 'y': 16}).
* - showDelay integer The millisecond delay the show event is fired (defaults to 100).
* - hideDelay integer The millisecond delay the hide hide is fired (defaults to 100).
* - className string The className your tooltip container will get.
* - fixed boolean If set to true, the toolTip will not follow the mouse.
* - onShow function The default function for the show event, passes the tip element
* and the currently hovered element.
* - onHide function The default function for the hide event, passes the currently
* hovered element.
*
* @return void
*
* @since 1.5
*
* @deprecated 4.0 Use JHtmlBootstrap::tooltip() instead.
*/
public static function tooltip($selector = '.hasTip', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (isset(static::$loaded[__METHOD__][$sig]))
{
return;
}
// Include MooTools framework
static::framework(true);
// Setup options object
$opt['maxTitleChars'] = isset($params['maxTitleChars']) && $params['maxTitleChars'] ? (int) $params['maxTitleChars'] : 50;
// Offsets needs an array in the format: array('x'=>20, 'y'=>30)
$opt['offset'] = isset($params['offset']) && is_array($params['offset']) ? $params['offset'] : null;
$opt['showDelay'] = isset($params['showDelay']) ? (int) $params['showDelay'] : null;
$opt['hideDelay'] = isset($params['hideDelay']) ? (int) $params['hideDelay'] : null;
$opt['className'] = isset($params['className']) ? $params['className'] : null;
$opt['fixed'] = isset($params['fixed']) && $params['fixed'];
$opt['onShow'] = isset($params['onShow']) ? '\\' . $params['onShow'] : null;
$opt['onHide'] = isset($params['onHide']) ? '\\' . $params['onHide'] : null;
$options = JHtml::getJSObject($opt);
// Include jQuery
JHtml::_('jquery.framework');
// Attach tooltips to document
JFactory::getDocument()->addScriptDeclaration(
"jQuery(function($) {
$('$selector').each(function() {
var title = $(this).attr('title');
if (title) {
var parts = title.split('::', 2);
var mtelement = document.id(this);
mtelement.store('tip:title', parts[0]);
mtelement.store('tip:text', parts[1]);
}
});
var JTooltips = new Tips($('$selector').get(), $options);
});"
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
return;
}
/**
* Add unobtrusive JavaScript support for modal links.
*
* @param string $selector The selector for which a modal behaviour is to be applied.
* @param array $params An array of parameters for the modal behaviour.
* Options for the modal behaviour can be:
* - ajaxOptions
* - size
* - shadow
* - overlay
* - onOpen
* - onClose
* - onUpdate
* - onResize
* - onShow
* - onHide
*
* @return void
*
* @since 1.5
* @deprecated 4.0 Use the modal equivalent from bootstrap
*/
public static function modal($selector = 'a.modal', $params = array())
{
$document = JFactory::getDocument();
// Load the necessary files if they haven't yet been loaded
if (!isset(static::$loaded[__METHOD__]))
{
// Include MooTools framework
static::framework(true);
// Load the JavaScript and css
JHtml::_('script', 'system/modal.js', array('framework' => true, 'version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'system/modal.css', array('version' => 'auto', 'relative' => true));
}
$sig = md5(serialize(array($selector, $params)));
if (isset(static::$loaded[__METHOD__][$sig]))
{
return;
}
JLog::add('JHtmlBehavior::modal is deprecated. Use the modal equivalent from bootstrap.', JLog::WARNING, 'deprecated');
// Setup options object
$opt['ajaxOptions'] = isset($params['ajaxOptions']) && is_array($params['ajaxOptions']) ? $params['ajaxOptions'] : null;
$opt['handler'] = isset($params['handler']) ? $params['handler'] : null;
$opt['parseSecure'] = isset($params['parseSecure']) ? (bool) $params['parseSecure'] : null;
$opt['closable'] = isset($params['closable']) ? (bool) $params['closable'] : null;
$opt['closeBtn'] = isset($params['closeBtn']) ? (bool) $params['closeBtn'] : null;
$opt['iframePreload'] = isset($params['iframePreload']) ? (bool) $params['iframePreload'] : null;
$opt['iframeOptions'] = isset($params['iframeOptions']) && is_array($params['iframeOptions']) ? $params['iframeOptions'] : null;
$opt['size'] = isset($params['size']) && is_array($params['size']) ? $params['size'] : null;
$opt['shadow'] = isset($params['shadow']) ? $params['shadow'] : null;
$opt['overlay'] = isset($params['overlay']) ? $params['overlay'] : null;
$opt['onOpen'] = isset($params['onOpen']) ? $params['onOpen'] : null;
$opt['onClose'] = isset($params['onClose']) ? $params['onClose'] : null;
$opt['onUpdate'] = isset($params['onUpdate']) ? $params['onUpdate'] : null;
$opt['onResize'] = isset($params['onResize']) ? $params['onResize'] : null;
$opt['onMove'] = isset($params['onMove']) ? $params['onMove'] : null;
$opt['onShow'] = isset($params['onShow']) ? $params['onShow'] : null;
$opt['onHide'] = isset($params['onHide']) ? $params['onHide'] : null;
// Include jQuery
JHtml::_('jquery.framework');
if (isset($params['fullScreen']) && (bool) $params['fullScreen'])
{
$opt['size'] = array('x' => '\\jQuery(window).width() - 80', 'y' => '\\jQuery(window).height() - 80');
}
$options = JHtml::getJSObject($opt);
// Attach modal behavior to document
$document
->addScriptDeclaration(
"
jQuery(function($) {
SqueezeBox.initialize(" . $options . ");
initSqueezeBox();
$(document).on('subform-row-add', initSqueezeBox);
function initSqueezeBox(event, container)
{
SqueezeBox.assign($(container || document).find('" . $selector . "').get(), {
parse: 'rel'
});
}
});
window.jModalClose = function () {
SqueezeBox.close();
};
// Add extra modal close functionality for tinyMCE-based editors
document.onreadystatechange = function () {
if (document.readyState == 'interactive' && typeof tinyMCE != 'undefined' && tinyMCE)
{
if (typeof window.jModalClose_no_tinyMCE === 'undefined')
{
window.jModalClose_no_tinyMCE = typeof(jModalClose) == 'function' ? jModalClose : false;
jModalClose = function () {
if (window.jModalClose_no_tinyMCE) window.jModalClose_no_tinyMCE.apply(this, arguments);
tinyMCE.activeEditor.windowManager.close();
};
}
if (typeof window.SqueezeBoxClose_no_tinyMCE === 'undefined')
{
if (typeof(SqueezeBox) == 'undefined') SqueezeBox = {};
window.SqueezeBoxClose_no_tinyMCE = typeof(SqueezeBox.close) == 'function' ? SqueezeBox.close : false;
SqueezeBox.close = function () {
if (window.SqueezeBoxClose_no_tinyMCE) window.SqueezeBoxClose_no_tinyMCE.apply(this, arguments);
tinyMCE.activeEditor.windowManager.close();
};
}
}
};
"
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
return;
}
/**
* JavaScript behavior to allow shift select in grids
*
* @param string $id The id of the form for which a multiselect behaviour is to be applied.
*
* @return void
*
* @since 1.7
*/
public static function multiselect($id = 'adminForm')
{
// Only load once
if (isset(static::$loaded[__METHOD__][$id]))
{
return;
}
// Include core
static::core();
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/multiselect.js', array('version' => 'auto', 'relative' => true));
// Attach multiselect to document
JFactory::getDocument()->addScriptDeclaration(
"jQuery(document).ready(function() {
Joomla.JMultiSelect('" . $id . "');
});"
);
// Set static array
static::$loaded[__METHOD__][$id] = true;
return;
}
/**
* Add unobtrusive javascript support for a collapsible tree.
*
* @param string $id An index
* @param array $params An array of options.
* @param array $root The root node
*
* @return void
*
* @since 1.5
*
* @deprecated 4.0 No replacement, not used since 3.0.
*/
public static function tree($id, $params = array(), $root = array())
{
// Include MooTools framework
static::framework();
JHtml::_('script', 'system/mootree.js', array('framework' => true, 'version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'system/mootree.css', array('version' => 'auto', 'relative' => true));
if (isset(static::$loaded[__METHOD__][$id]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
// Setup options object
$opt['div'] = array_key_exists('div', $params) ? $params['div'] : $id . '_tree';
$opt['mode'] = array_key_exists('mode', $params) ? $params['mode'] : 'folders';
$opt['grid'] = array_key_exists('grid', $params) ? '\\' . $params['grid'] : true;
$opt['theme'] = array_key_exists('theme', $params) ? $params['theme'] : JHtml::_('image', 'system/mootree.gif', '', array(), true, true);
// Event handlers
$opt['onExpand'] = array_key_exists('onExpand', $params) ? '\\' . $params['onExpand'] : null;
$opt['onSelect'] = array_key_exists('onSelect', $params) ? '\\' . $params['onSelect'] : null;
$opt['onClick'] = array_key_exists('onClick', $params) ? '\\' . $params['onClick']
: '\\function(node){ window.open(node.data.url, node.data.target != null ? node.data.target : \'_self\'); }';
$options = JHtml::getJSObject($opt);
// Setup root node
$rt['text'] = array_key_exists('text', $root) ? $root['text'] : 'Root';
$rt['id'] = array_key_exists('id', $root) ? $root['id'] : null;
$rt['color'] = array_key_exists('color', $root) ? $root['color'] : null;
$rt['open'] = array_key_exists('open', $root) ? '\\' . $root['open'] : true;
$rt['icon'] = array_key_exists('icon', $root) ? $root['icon'] : null;
$rt['openicon'] = array_key_exists('openicon', $root) ? $root['openicon'] : null;
$rt['data'] = array_key_exists('data', $root) ? $root['data'] : null;
$rootNode = JHtml::getJSObject($rt);
$treeName = array_key_exists('treeName', $params) ? $params['treeName'] : '';
$js = ' jQuery(function(){
tree' . $treeName . ' = new MooTreeControl(' . $options . ',' . $rootNode . ');
tree' . $treeName . '.adopt(\'' . $id . '\');})';
// Attach tooltips to document
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
// Set static array
static::$loaded[__METHOD__][$id] = true;
return;
}
/**
* Add unobtrusive JavaScript support for a calendar control.
*
* @return void
*
* @since 1.5
*
* @deprecated 4.0
*/
public static function calendar()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
JLog::add('JHtmlBehavior::calendar is deprecated as the static assets are being loaded in the relative layout.', JLog::WARNING, 'deprecated');
$document = JFactory::getDocument();
$tag = JFactory::getLanguage()->getTag();
$attribs = array('title' => JText::_('JLIB_HTML_BEHAVIOR_GREEN'), 'media' => 'all');
JHtml::_('stylesheet', 'system/calendar-jos.css', array('version' => 'auto', 'relative' => true), $attribs);
JHtml::_('script', $tag . '/calendar.js', array('version' => 'auto', 'relative' => true));
JHtml::_('script', $tag . '/calendar-setup.js', array('version' => 'auto', 'relative' => true));
$translation = static::calendartranslation();
if ($translation)
{
$document->addScriptDeclaration($translation);
}
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for a color picker.
*
* @return void
*
* @since 1.7
*
* @deprecated 4.0 Use directly the field or the layout
*/
public static function colorpicker()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/jquery.minicolors.min.js', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'jui/jquery.minicolors.css', array('version' => 'auto', 'relative' => true));
JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function (){
jQuery('.minicolors').each(function() {
jQuery(this).minicolors({
control: jQuery(this).attr('data-control') || 'hue',
format: jQuery(this).attr('data-validate') === 'color'
? 'hex'
: (jQuery(this).attr('data-format') === 'rgba'
? 'rgb'
: jQuery(this).attr('data-format'))
|| 'hex',
keywords: jQuery(this).attr('data-keywords') || '',
opacity: jQuery(this).attr('data-format') === 'rgba' ? true : false || false,
position: jQuery(this).attr('data-position') || 'default',
theme: 'bootstrap'
});
});
});
"
);
static::$loaded[__METHOD__] = true;
}
/**
* Add unobtrusive JavaScript support for a simple color picker.
*
* @return void
*
* @since 3.1
*
* @deprecated 4.0 Use directly the field or the layout
*/
public static function simplecolorpicker()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/jquery.simplecolors.min.js', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'jui/jquery.simplecolors.css', array('version' => 'auto', 'relative' => true));
JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function (){
jQuery('select.simplecolors').simplecolors();
});
"
);
static::$loaded[__METHOD__] = true;
}
/**
* Keep session alive, for example, while editing or creating an article.
*
* @return void
*
* @since 1.5
*/
public static function keepalive()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
$session = JFactory::getSession();
// If the handler is not 'Database', we set a fixed, small refresh value (here: 5 min)
$refreshTime = 300;
if ($session->storeName === 'database')
{
$lifeTime = $session->getExpire();
$refreshTime = $lifeTime <= 60 ? 45 : $lifeTime - 60;
// The longest refresh period is one hour to prevent integer overflow.
if ($refreshTime > 3600 || $refreshTime <= 0)
{
$refreshTime = 3600;
}
}
// If we are in the frontend or logged in as a user, we can use the ajax component to reduce the load
$uri = 'index.php' . (JFactory::getApplication()->isClient('site') || !JFactory::getUser()->guest ? '?option=com_ajax&format=json' : '');
// Include core and polyfill for browsers lower than IE 9.
static::core();
static::polyfill('event', 'lt IE 9');
// Add keepalive script options.
JFactory::getDocument()->addScriptOptions('system.keepalive', array('interval' => $refreshTime * 1000, 'uri' => JRoute::_($uri)));
// Add script.
JHtml::_('script', 'system/keepalive.js', array('version' => 'auto', 'relative' => true));
static::$loaded[__METHOD__] = true;
return;
}
/**
* Highlight some words via Javascript.
*
* @param array $terms Array of words that should be highlighted.
* @param string $start ID of the element that marks the begin of the section in which words
* should be highlighted. Note this element will be removed from the DOM.
* @param string $end ID of the element that end this section.
* Note this element will be removed from the DOM.
* @param string $className Class name of the element highlights are wrapped in.
* @param string $tag Tag that will be used to wrap the highlighted words.
*
* @return void
*
* @since 2.5
*/
public static function highlighter(array $terms, $start = 'highlighter-start', $end = 'highlighter-end', $className = 'highlight', $tag = 'span')
{
$sig = md5(serialize(array($terms, $start, $end)));
if (isset(static::$loaded[__METHOD__][$sig]))
{
return;
}
$terms = array_filter($terms, 'strlen');
// Nothing to Highlight
if (empty($terms))
{
static::$loaded[__METHOD__][$sig] = true;
return;
}
// Include core
static::core();
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('script', 'system/highlighter.js', array('version' => 'auto', 'relative' => true));
foreach ($terms as $i => $term)
{
$terms[$i] = JFilterOutput::stringJSSafe($term);
}
$document = JFactory::getDocument();
$document->addScriptDeclaration("
jQuery(function ($) {
var start = document.getElementById('" . $start . "');
var end = document.getElementById('" . $end . "');
if (!start || !end || !Joomla.Highlighter) {
return true;
}
highlighter = new Joomla.Highlighter({
startElement: start,
endElement: end,
className: '" . $className . "',
onlyWords: false,
tag: '" . $tag . "'
}).highlight([\"" . implode('","', $terms) . "\"]);
$(start).remove();
$(end).remove();
});
");
static::$loaded[__METHOD__][$sig] = true;
return;
}
/**
* Break us out of any containing iframes
*
* @return void
*
* @since 1.5
*
* @deprecated 4.0 Add a X-Frame-Options HTTP Header with the SAMEORIGIN value instead.
*/
public static function noframes()
{
JLog::add(__METHOD__ . ' is deprecated, add a X-Frame-Options HTTP Header with the SAMEORIGIN value instead.', JLog::WARNING, 'deprecated');
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Include core
static::core();
// Include jQuery
JHtml::_('jquery.framework');
$js = 'jQuery(function () {
if (top == self) {
document.documentElement.style.display = "block";
}
else
{
top.location = self.location;
}
// Firefox fix
jQuery("input[autofocus]").focus();
})';
$document = JFactory::getDocument();
$document->addStyleDeclaration('html { display:none }');
$document->addScriptDeclaration($js);
JFactory::getApplication()->setHeader('X-Frame-Options', 'SAMEORIGIN');
static::$loaded[__METHOD__] = true;
}
/**
* Internal method to get a JavaScript object notation string from an array
*
* @param array $array The array to convert to JavaScript object notation
*
* @return string JavaScript object notation representation of the array
*
* @since 1.5
* @deprecated 4.0 - Use JHtml::getJSObject() instead.
*/
protected static function _getJSObject($array = array())
{
JLog::add('JHtmlBehavior::_getJSObject() is deprecated. JHtml::getJSObject() instead..', JLog::WARNING, 'deprecated');
return JHtml::getJSObject($array);
}
/**
* Add unobtrusive JavaScript support to keep a tab state.
*
* Note that keeping tab state only works for inner tabs if in accordance with the following example:
*
* ```
* parent tab = permissions
* child tab = permission-<identifier>
* ```
*
* Each tab header `<a>` tag also should have a unique href attribute
*
* @return void
*
* @since 3.2
*
* @deprecated 4.0 In Joomla 4 use the custom element joomla-tab.
*/
public static function tabstate()
{
JLog::add('JHtmlBehavior::tabstate is deprecated. In Joomla 4 use the custom element joomla-tab.', JLog::WARNING, 'deprecated');
if (isset(self::$loaded[__METHOD__]))
{
return;
}
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('behavior.polyfill', array('filter','xpath'));
JHtml::_('script', 'system/tabs-state.js', array('version' => 'auto', 'relative' => true));
self::$loaded[__METHOD__] = true;
}
/**
* Add javascript polyfills.
*
* @param string|array $polyfillTypes The polyfill type(s). Examples: event, array('event', 'classlist').
* @param string $conditionalBrowser An IE conditional expression. Example: lt IE 9 (lower than IE 9).
*
* @return void
*
* @since 3.7.0
*/
public static function polyfill($polyfillTypes = null, $conditionalBrowser = null)
{
if ($polyfillTypes === null)
{
return;
}
foreach ((array) $polyfillTypes as $polyfillType)
{
$sig = md5(serialize(array($polyfillType, $conditionalBrowser)));
// Only load once
if (isset(static::$loaded[__METHOD__][$sig]))
{
continue;
}
// If include according to browser.
$scriptOptions = array('version' => 'auto', 'relative' => true);
$scriptOptions = $conditionalBrowser !== null ? array_replace($scriptOptions, array('conditional' => $conditionalBrowser)) : $scriptOptions;
JHtml::_('script', 'system/polyfill.' . $polyfillType . '.js', $scriptOptions);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
}
}
/**
* Internal method to translate the JavaScript Calendar
*
* @return string JavaScript that translates the object
*
* @since 1.5
*/
protected static function calendartranslation()
{
static $jsscript = 0;
// Guard clause, avoids unnecessary nesting
if ($jsscript)
{
return false;
}
$jsscript = 1;
// To keep the code simple here, run strings through JText::_() using array_map()
$callback = array('JText', '_');
$weekdays_full = array_map(
$callback, array(
'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY',
)
);
$weekdays_short = array_map(
$callback,
array(
'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN',
)
);
$months_long = array_map(
$callback, array(
'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE',
'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER',
)
);
$months_short = array_map(
$callback, array(
'JANUARY_SHORT', 'FEBRUARY_SHORT', 'MARCH_SHORT', 'APRIL_SHORT', 'MAY_SHORT', 'JUNE_SHORT',
'JULY_SHORT', 'AUGUST_SHORT', 'SEPTEMBER_SHORT', 'OCTOBER_SHORT', 'NOVEMBER_SHORT', 'DECEMBER_SHORT',
)
);
// This will become an object in Javascript but define it first in PHP for readability
$today = " " . JText::_('JLIB_HTML_BEHAVIOR_TODAY') . " ";
$text = array(
'INFO' => JText::_('JLIB_HTML_BEHAVIOR_ABOUT_THE_CALENDAR'),
'ABOUT' => "DHTML Date/Time Selector\n"
. "(c) dynarch.com 20022005 / Author: Mihai Bazon\n"
. "For latest version visit: http://www.dynarch.com/projects/calendar/\n"
. "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details."
. "\n\n"
. JText::_('JLIB_HTML_BEHAVIOR_DATE_SELECTION')
. JText::_('JLIB_HTML_BEHAVIOR_YEAR_SELECT')
. JText::_('JLIB_HTML_BEHAVIOR_MONTH_SELECT')
. JText::_('JLIB_HTML_BEHAVIOR_HOLD_MOUSE'),
'ABOUT_TIME' => "\n\n"
. "Time selection:\n"
. " Click on any of the time parts to increase it\n"
. " or Shiftclick to decrease it\n"
. " or click and drag for faster selection.",
'PREV_YEAR' => JText::_('JLIB_HTML_BEHAVIOR_PREV_YEAR_HOLD_FOR_MENU'),
'PREV_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_PREV_MONTH_HOLD_FOR_MENU'),
'GO_TODAY' => JText::_('JLIB_HTML_BEHAVIOR_GO_TODAY'),
'NEXT_MONTH' => JText::_('JLIB_HTML_BEHAVIOR_NEXT_MONTH_HOLD_FOR_MENU'),
'SEL_DATE' => JText::_('JLIB_HTML_BEHAVIOR_SELECT_DATE'),
'DRAG_TO_MOVE' => JText::_('JLIB_HTML_BEHAVIOR_DRAG_TO_MOVE'),
'PART_TODAY' => $today,
'DAY_FIRST' => JText::_('JLIB_HTML_BEHAVIOR_DISPLAY_S_FIRST'),
'WEEKEND' => JFactory::getLanguage()->getWeekEnd(),
'CLOSE' => JText::_('JLIB_HTML_BEHAVIOR_CLOSE'),
'TODAY' => JText::_('JLIB_HTML_BEHAVIOR_TODAY'),
'TIME_PART' => JText::_('JLIB_HTML_BEHAVIOR_SHIFT_CLICK_OR_DRAG_TO_CHANGE_VALUE'),
'DEF_DATE_FORMAT' => "%Y%m%d",
'TT_DATE_FORMAT' => JText::_('JLIB_HTML_BEHAVIOR_TT_DATE_FORMAT'),
'WK' => JText::_('JLIB_HTML_BEHAVIOR_WK'),
'TIME' => JText::_('JLIB_HTML_BEHAVIOR_TIME'),
);
return 'Calendar._DN = ' . json_encode($weekdays_full) . ';'
. ' Calendar._SDN = ' . json_encode($weekdays_short) . ';'
. ' Calendar._FD = 0;'
. ' Calendar._MN = ' . json_encode($months_long) . ';'
. ' Calendar._SMN = ' . json_encode($months_short) . ';'
. ' Calendar._TT = ' . json_encode($text) . ';';
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class for Bootstrap elements.
*
* @since 3.0
*/
abstract class JHtmlBootstrap
{
/**
* @var array Array containing information for loaded files
* @since 3.0
*/
protected static $loaded = array();
/**
* Add javascript support for the Bootstrap affix plugin
*
* @param string $selector Unique selector for the element to be affixed.
* @param array $params An array of options.
* Options for the affix plugin can be:
* - offset number|function|object Pixels to offset from screen when calculating position of scroll.
* If a single number is provided, the offset will be applied in both top
* and left directions. To listen for a single direction, or multiple
* unique offsets, just provide an object offset: { x: 10 }.
* Use a function when you need to dynamically provide an offset
* (useful for some responsive designs).
*
* @return void
*
* @since 3.1
*
* @deprecated 4.0 Bootstrap 4.0 dropped this so will Joomla.
*/
public static function affix($selector = 'affix', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded[__METHOD__][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['offset'] = isset($params['offset']) ? $params['offset'] : 10;
$options = JHtml::getJSObject($opt);
// Attach affix to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('#' . $selector) . ').affix(' . $options . '); });'
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
}
return;
}
/**
* Add javascript support for Bootstrap alerts
*
* @param string $selector Common class for the alerts
*
* @return void
*
* @since 3.0
*/
public static function alert($selector = 'alert')
{
// Only load once
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Attach the alerts to the document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('.' . $selector) . ').alert(); });'
);
static::$loaded[__METHOD__][$selector] = true;
return;
}
/**
* Add javascript support for Bootstrap buttons
*
* @param string $selector Common class for the buttons
*
* @return void
*
* @since 3.1
*/
public static function button($selector = 'button')
{
// Only load once
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Attach the button to the document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('.' . $selector) . ').button(); });'
);
static::$loaded[__METHOD__][$selector] = true;
return;
}
/**
* Add javascript support for Bootstrap carousels
*
* @param string $selector Common class for the carousels.
* @param array $params An array of options for the carousel.
* Options for the carousel can be:
* - interval number The amount of time to delay between automatically cycling an item.
* If false, carousel will not automatically cycle.
* - pause string Pauses the cycling of the carousel on mouseenter and resumes the cycling
* of the carousel on mouseleave.
*
* @return void
*
* @since 3.0
*/
public static function carousel($selector = 'carousel', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded[__METHOD__][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['interval'] = isset($params['interval']) ? (int) $params['interval'] : 5000;
$opt['pause'] = isset($params['pause']) ? $params['pause'] : 'hover';
$options = JHtml::getJSObject($opt);
// Attach the carousel to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('.' . $selector) . ').carousel(' . $options . '); });'
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
}
return;
}
/**
* Add javascript support for Bootstrap dropdowns
*
* @param string $selector Common class for the dropdowns
*
* @return void
*
* @since 3.0
*/
public static function dropdown($selector = 'dropdown-toggle')
{
// Only load once
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Attach the dropdown to the document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('.' . $selector) . ').dropdown(); });'
);
static::$loaded[__METHOD__][$selector] = true;
return;
}
/**
* Method to load the Bootstrap JavaScript framework into the document head
*
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
*
* @param mixed $debug Is debugging mode on? [optional]
*
* @return void
*
* @since 3.0
*/
public static function framework($debug = null)
{
// Only load once
if (!empty(static::$loaded[__METHOD__]))
{
return;
}
// Load jQuery
JHtml::_('jquery.framework');
// If no debugging value is set, use the configuration setting
if ($debug === null)
{
$debug = JDEBUG;
}
JHtml::_('script', 'jui/bootstrap.min.js', array('version' => 'auto', 'relative' => true, 'detectDebug' => $debug));
static::$loaded[__METHOD__] = true;
return;
}
/**
* Add javascript support for Bootstrap modals
*
* @param string $selector The ID selector for the modal.
* @param array $params An array of options for the modal.
* Options for the modal can be:
* - backdrop boolean Includes a modal-backdrop element.
* - keyboard boolean Closes the modal when escape key is pressed.
* - show boolean Shows the modal when initialized.
* - remote string An optional remote URL to load
*
* @return void
*
* @since 3.0
* @deprecated 4.0 This method was used by the old renderModal() implementation.
* Since the new implementation it is unneeded and the broken JS it was injecting could create issues
* As a case, please see: https://github.com/joomla/joomla-cms/pull/6918
*/
public static function modal($selector = 'modal', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded[__METHOD__][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['backdrop'] = isset($params['backdrop']) ? (boolean) $params['backdrop'] : true;
$opt['keyboard'] = isset($params['keyboard']) ? (boolean) $params['keyboard'] : true;
$opt['show'] = isset($params['show']) ? (boolean) $params['show'] : false;
$opt['remote'] = isset($params['remote']) ? $params['remote'] : '';
$options = JHtml::getJSObject($opt);
// Attach the modal to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('#' . $selector) . ').modal(' . $options . '); });'
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
}
return;
}
/**
* Method to render a Bootstrap modal
*
* @param string $selector The ID selector for the modal.
* @param array $params An array of options for the modal.
* Options for the modal can be:
* - title string The modal title
* - backdrop mixed A boolean select if a modal-backdrop element should be included (default = true)
* The string 'static' includes a backdrop which doesn't close the modal on click.
* - keyboard boolean Closes the modal when escape key is pressed (default = true)
* - closeButton boolean Display modal close button (default = true)
* - animation boolean Fade in from the top of the page (default = true)
* - footer string Optional markup for the modal footer
* - url string URL of a resource to be inserted as an `<iframe>` inside the modal body
* - height string height of the `<iframe>` containing the remote resource
* - width string width of the `<iframe>` containing the remote resource
* @param string $body Markup for the modal body. Appended after the `<iframe>` if the URL option is set
*
* @return string HTML markup for a modal
*
* @since 3.0
*/
public static function renderModal($selector = 'modal', $params = array(), $body = '')
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
$layoutData = array(
'selector' => $selector,
'params' => $params,
'body' => $body,
);
return JLayoutHelper::render('joomla.modal.main', $layoutData);
}
/**
* Add javascript support for Bootstrap popovers
*
* Use element's Title as popover content
*
* @param string $selector Selector for the popover
* @param array $params An array of options for the popover.
* Options for the popover can be:
* animation boolean apply a css fade transition to the popover
* html boolean Insert HTML into the popover. If false, jQuery's text method will be used to insert
* content into the dom.
* placement string|function how to position the popover - top | bottom | left | right
* selector string If a selector is provided, popover objects will be delegated to the specified targets.
* trigger string how popover is triggered - hover | focus | manual
* title string|function default title value if `title` tag isn't present
* content string|function default content value if `data-content` attribute isn't present
* delay number|object delay showing and hiding the popover (ms) - does not apply to manual trigger type
* If a number is supplied, delay is applied to both hide/show
* Object structure is: delay: { show: 500, hide: 100 }
* container string|boolean Appends the popover to a specific element: { container: 'body' }
*
* @return void
*
* @since 3.0
*/
public static function popover($selector = '.hasPopover', $params = array())
{
// Only load once
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
$opt['animation'] = isset($params['animation']) ? $params['animation'] : null;
$opt['html'] = isset($params['html']) ? $params['html'] : true;
$opt['placement'] = isset($params['placement']) ? $params['placement'] : null;
$opt['selector'] = isset($params['selector']) ? $params['selector'] : null;
$opt['title'] = isset($params['title']) ? $params['title'] : null;
$opt['trigger'] = isset($params['trigger']) ? $params['trigger'] : 'hover focus';
$opt['content'] = isset($params['content']) ? $params['content'] : null;
$opt['delay'] = isset($params['delay']) ? $params['delay'] : null;
$opt['container'] = isset($params['container']) ? $params['container'] : 'body';
$options = JHtml::getJSObject($opt);
$initFunction = 'function initPopovers (event, container) { ' .
'$(container || document).find(' . json_encode($selector) . ').popover(' . $options . ');' .
'}';
// Attach the popover to the document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ initPopovers(); $("body").on("subform-row-add", initPopovers); ' . $initFunction . ' });'
);
static::$loaded[__METHOD__][$selector] = true;
return;
}
/**
* Add javascript support for Bootstrap ScrollSpy
*
* @param string $selector The ID selector for the ScrollSpy element.
* @param array $params An array of options for the ScrollSpy.
* Options for the ScrollSpy can be:
* - offset number Pixels to offset from top when calculating position of scroll.
*
* @return void
*
* @since 3.0
*/
public static function scrollspy($selector = 'navbar', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded[__METHOD__][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['offset'] = isset($params['offset']) ? (int) $params['offset'] : 10;
$options = JHtml::getJSObject($opt);
// Attach ScrollSpy to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode('#' . $selector) . ').scrollspy(' . $options . '); });'
);
// Set static array
static::$loaded[__METHOD__][$sig] = true;
}
return;
}
/**
* Add javascript support for Bootstrap tooltips
*
* Add a title attribute to any element in the form
* title="title::text"
*
* @param string $selector The ID selector for the tooltip.
* @param array $params An array of options for the tooltip.
* Options for the tooltip can be:
* - animation boolean Apply a CSS fade transition to the tooltip
* - html boolean Insert HTML into the tooltip. If false, jQuery's text method will be used to insert
* content into the dom.
* - placement string|function How to position the tooltip - top | bottom | left | right
* - selector string If a selector is provided, tooltip objects will be delegated to the specified targets.
* - title string|function Default title value if `title` tag isn't present
* - trigger string How tooltip is triggered - hover | focus | manual
* - delay integer Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type
* If a number is supplied, delay is applied to both hide/show
* Object structure is: delay: { show: 500, hide: 100 }
* - container string|boolean Appends the popover to a specific element: { container: 'body' }
*
* @return void
*
* @since 3.0
*/
public static function tooltip($selector = '.hasTooltip', $params = array())
{
if (!isset(static::$loaded[__METHOD__][$selector]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['animation'] = isset($params['animation']) ? (boolean) $params['animation'] : null;
$opt['html'] = isset($params['html']) ? (boolean) $params['html'] : true;
$opt['placement'] = isset($params['placement']) ? (string) $params['placement'] : null;
$opt['selector'] = isset($params['selector']) ? (string) $params['selector'] : null;
$opt['title'] = isset($params['title']) ? (string) $params['title'] : null;
$opt['trigger'] = isset($params['trigger']) ? (string) $params['trigger'] : null;
$opt['delay'] = isset($params['delay']) ? (is_array($params['delay']) ? $params['delay'] : (int) $params['delay']) : null;
$opt['container'] = isset($params['container']) ? $params['container'] : 'body';
$opt['template'] = isset($params['template']) ? (string) $params['template'] : null;
$onShow = isset($params['onShow']) ? (string) $params['onShow'] : null;
$onShown = isset($params['onShown']) ? (string) $params['onShown'] : null;
$onHide = isset($params['onHide']) ? (string) $params['onHide'] : null;
$onHidden = isset($params['onHidden']) ? (string) $params['onHidden'] : null;
$options = JHtml::getJSObject($opt);
// Build the script.
$script = array('$(container).find(' . json_encode($selector) . ').tooltip(' . $options . ')');
if ($onShow)
{
$script[] = 'on("show.bs.tooltip", ' . $onShow . ')';
}
if ($onShown)
{
$script[] = 'on("shown.bs.tooltip", ' . $onShown . ')';
}
if ($onHide)
{
$script[] = 'on("hide.bs.tooltip", ' . $onHide . ')';
}
if ($onHidden)
{
$script[] = 'on("hidden.bs.tooltip", ' . $onHidden . ')';
}
$initFunction = 'function initTooltips (event, container) { ' .
'container = container || document;' .
implode('.', $script) . ';' .
'}';
// Attach tooltips to document
JFactory::getDocument()
->addScriptDeclaration('jQuery(function($){ initTooltips(); $("body").on("subform-row-add", initTooltips); ' . $initFunction . ' });');
// Set static array
static::$loaded[__METHOD__][$selector] = true;
}
return;
}
/**
* Loads js and css files needed by Bootstrap Tooltip Extended plugin
*
* @param boolean $extended If true, bootstrap-tooltip-extended.js and .css files are loaded
*
* @return void
*
* @since 3.6
*
* @deprecated 4.0 No replacement, use Bootstrap tooltips.
*/
public static function tooltipExtended($extended = true)
{
if ($extended)
{
JHtml::_('script', 'jui/bootstrap-tooltip-extended.min.js', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'jui/bootstrap-tooltip-extended.css', array('version' => 'auto', 'relative' => true));
}
}
/**
* Add javascript support for Bootstrap typeahead
*
* @param string $selector The selector for the typeahead element.
* @param array $params An array of options for the typeahead element.
* Options for the tooltip can be:
* - source array, function The data source to query against. May be an array of strings or a function.
* The function is passed two arguments, the query value in the input field and the
* process callback. The function may be used synchronously by returning the data
* source directly or asynchronously via the process callback's single argument.
* - items number The max number of items to display in the dropdown.
* - minLength number The minimum character length needed before triggering autocomplete suggestions
* - matcher function The method used to determine if a query matches an item. Accepts a single argument,
* the item against which to test the query. Access the current query with this.query.
* Return a boolean true if query is a match.
* - sorter function Method used to sort autocomplete results. Accepts a single argument items and has
* the scope of the typeahead instance. Reference the current query with this.query.
* - updater function The method used to return selected item. Accepts a single argument, the item and
* has the scope of the typeahead instance.
* - highlighter function Method used to highlight autocomplete results. Accepts a single argument item and
* has the scope of the typeahead instance. Should return html.
*
* @return void
*
* @since 3.0
*
* @deprecated 4.0 Bootstrap 4.0 dropped this so will Joomla.
*/
public static function typeahead($selector = '.typeahead', $params = array())
{
if (!isset(static::$loaded[__METHOD__][$selector]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['source'] = isset($params['source']) ? $params['source'] : null;
$opt['items'] = isset($params['items']) ? (int) $params['items'] : 8;
$opt['minLength'] = isset($params['minLength']) ? (int) $params['minLength'] : 1;
$opt['matcher'] = isset($params['matcher']) ? (string) $params['matcher'] : null;
$opt['sorter'] = isset($params['sorter']) ? (string) $params['sorter'] : null;
$opt['updater'] = isset($params['updater']) ? (string) $params['updater'] : null;
$opt['highlighter'] = isset($params['highlighter']) ? (int) $params['highlighter'] : null;
$options = JHtml::getJSObject($opt);
// Attach typehead to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode($selector) . ').typeahead(' . $options . '); });'
);
// Set static array
static::$loaded[__METHOD__][$selector] = true;
}
return;
}
/**
* Add javascript support for Bootstrap accordions and insert the accordion
*
* @param string $selector The ID selector for the tooltip.
* @param array $params An array of options for the tooltip.
* Options for the tooltip can be:
* - parent selector If selector then all collapsible elements under the specified parent will be closed when this
* collapsible item is shown. (similar to traditional accordion behavior)
* - toggle boolean Toggles the collapsible element on invocation
* - active string Sets the active slide during load
*
* - onShow function This event fires immediately when the show instance method is called.
* - onShown function This event is fired when a collapse element has been made visible to the user
* (will wait for css transitions to complete).
* - onHide function This event is fired immediately when the hide method has been called.
* - onHidden function This event is fired when a collapse element has been hidden from the user
* (will wait for css transitions to complete).
*
* @return string HTML for the accordian
*
* @since 3.0
*/
public static function startAccordion($selector = 'myAccordian', $params = array())
{
if (!isset(static::$loaded[__METHOD__][$selector]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['parent'] = isset($params['parent']) ? ($params['parent'] == true ? '#' . $selector : $params['parent']) : false;
$opt['toggle'] = isset($params['toggle']) ? (boolean) $params['toggle'] : !($opt['parent'] === false || isset($params['active']));
$onShow = isset($params['onShow']) ? (string) $params['onShow'] : null;
$onShown = isset($params['onShown']) ? (string) $params['onShown'] : null;
$onHide = isset($params['onHide']) ? (string) $params['onHide'] : null;
$onHidden = isset($params['onHidden']) ? (string) $params['onHidden'] : null;
$options = JHtml::getJSObject($opt);
$opt['active'] = isset($params['active']) ? (string) $params['active'] : '';
// Build the script.
$script = array();
$script[] = "jQuery(function($){";
$script[] = "\t$('#" . $selector . "').collapse(" . $options . ")";
if ($onShow)
{
$script[] = "\t.on('show', " . $onShow . ")";
}
if ($onShown)
{
$script[] = "\t.on('shown', " . $onShown . ")";
}
if ($onHide)
{
$script[] = "\t.on('hideme', " . $onHide . ")";
}
if ($onHidden)
{
$script[] = "\t.on('hidden', " . $onHidden . ")";
}
$parents = array_key_exists(__METHOD__, static::$loaded) ? array_filter(array_column(static::$loaded[__METHOD__], 'parent')) : array();
if ($opt['parent'] && empty($parents))
{
$script[] = "
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var \$this = $(this), href
var parent = \$this.attr('data-parent')
var \$parent = parent && $(parent)
if (\$parent) \$parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not(\$this).addClass('collapsed')
})";
}
$script[] = "});";
// Attach accordion to document
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
// Set static array
static::$loaded[__METHOD__][$selector] = $opt;
return '<div id="' . $selector . '" class="accordion">';
}
}
/**
* Close the current accordion
*
* @return string HTML to close the accordian
*
* @since 3.0
*/
public static function endAccordion()
{
return '</div>';
}
/**
* Begins the display of a new accordion slide.
*
* @param string $selector Identifier of the accordion group.
* @param string $text Text to display.
* @param string $id Identifier of the slide.
* @param string $class Class of the accordion group.
*
* @return string HTML to add the slide
*
* @since 3.0
*/
public static function addSlide($selector, $text, $id, $class = '')
{
$in = (static::$loaded[__CLASS__ . '::startAccordion'][$selector]['active'] == $id) ? ' in' : '';
$collapsed = (static::$loaded[__CLASS__ . '::startAccordion'][$selector]['active'] == $id) ? '' : ' collapsed';
$parent = static::$loaded[__CLASS__ . '::startAccordion'][$selector]['parent'] ?
' data-parent="' . static::$loaded[__CLASS__ . '::startAccordion'][$selector]['parent'] . '"' : '';
$class = (!empty($class)) ? ' ' . $class : '';
$html = '<div class="accordion-group' . $class . '">'
. '<div class="accordion-heading">'
. '<strong><a href="#' . $id . '" data-toggle="collapse"' . $parent . ' class="accordion-toggle' . $collapsed . '">'
. $text
. '</a></strong>'
. '</div>'
. '<div class="accordion-body collapse' . $in . '" id="' . $id . '">'
. '<div class="accordion-inner">';
return $html;
}
/**
* Close the current slide
*
* @return string HTML to close the slide
*
* @since 3.0
*/
public static function endSlide()
{
return '</div></div></div>';
}
/**
* Creates a tab pane
*
* @param string $selector The pane identifier.
* @param array $params The parameters for the pane
*
* @return string
*
* @since 3.1
*/
public static function startTabSet($selector = 'myTab', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded[__METHOD__][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['active'] = (isset($params['active']) && $params['active']) ? (string) $params['active'] : '';
// Attach tabs to document
JFactory::getDocument()
->addScriptDeclaration(JLayoutHelper::render('libraries.cms.html.bootstrap.starttabsetscript', array('selector' => $selector)));
// Set static array
static::$loaded[__METHOD__][$sig] = true;
static::$loaded[__METHOD__][$selector]['active'] = $opt['active'];
}
return JLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => $selector));
}
/**
* Close the current tab pane
*
* @return string HTML to close the pane
*
* @since 3.1
*/
public static function endTabSet()
{
return JLayoutHelper::render('libraries.cms.html.bootstrap.endtabset');
}
/**
* Begins the display of a new tab content panel.
*
* @param string $selector Identifier of the panel.
* @param string $id The ID of the div element
* @param string $title The title text for the new UL tab
*
* @return string HTML to start a new panel
*
* @since 3.1
*/
public static function addTab($selector, $id, $title)
{
static $tabScriptLayout = null;
static $tabLayout = null;
$tabScriptLayout = $tabScriptLayout === null ? new JLayoutFile('libraries.cms.html.bootstrap.addtabscript') : $tabScriptLayout;
$tabLayout = $tabLayout === null ? new JLayoutFile('libraries.cms.html.bootstrap.addtab') : $tabLayout;
$active = (static::$loaded['JHtmlBootstrap::startTabSet'][$selector]['active'] == $id) ? ' active' : '';
// Inject tab into UL
JFactory::getDocument()
->addScriptDeclaration($tabScriptLayout->render(array('selector' => $selector, 'id' => $id, 'active' => $active, 'title' => $title)));
return $tabLayout->render(array('id' => $id, 'active' => $active));
}
/**
* Close the current tab content panel
*
* @return string HTML to close the pane
*
* @since 3.1
*/
public static function endTab()
{
return JLayoutHelper::render('libraries.cms.html.bootstrap.endtab');
}
/**
* Creates a tab pane
*
* @param string $selector The pane identifier.
* @param array $params The parameters for the pane
*
* @return string
*
* @since 3.0
* @deprecated 4.0 Use JHtml::_('bootstrap.startTabSet') instead.
*/
public static function startPane($selector = 'myTab', $params = array())
{
$sig = md5(serialize(array($selector, $params)));
if (!isset(static::$loaded['JHtmlBootstrap::startTabSet'][$sig]))
{
// Include Bootstrap framework
JHtml::_('bootstrap.framework');
// Setup options object
$opt['active'] = isset($params['active']) ? (string) $params['active'] : '';
// Attach tab to document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){
$(' . json_encode('#' . $selector . ' a') . ').click(function (e) {
e.preventDefault();
$(this).tab("show");
});
});'
);
// Set static array
static::$loaded['JHtmlBootstrap::startTabSet'][$sig] = true;
static::$loaded['JHtmlBootstrap::startTabSet'][$selector]['active'] = $opt['active'];
}
return '<div class="tab-content" id="' . $selector . 'Content">';
}
/**
* Close the current tab pane
*
* @return string HTML to close the pane
*
* @since 3.0
* @deprecated 4.0 Use JHtml::_('bootstrap.endTabSet') instead.
*/
public static function endPane()
{
return '</div>';
}
/**
* Begins the display of a new tab content panel.
*
* @param string $selector Identifier of the panel.
* @param string $id The ID of the div element
*
* @return string HTML to start a new panel
*
* @since 3.0
* @deprecated 4.0 Use JHtml::_('bootstrap.addTab') instead.
*/
public static function addPanel($selector, $id)
{
$active = (static::$loaded['JHtmlBootstrap::startTabSet'][$selector]['active'] == $id) ? ' active' : '';
return '<div id="' . $id . '" class="tab-pane' . $active . '">';
}
/**
* Close the current tab content panel
*
* @return string HTML to close the pane
*
* @since 3.0
* @deprecated 4.0 Use JHtml::_('bootstrap.endTab') instead.
*/
public static function endPanel()
{
return '</div>';
}
/**
* Loads CSS files needed by Bootstrap
*
* @param boolean $includeMainCss If true, main bootstrap.css files are loaded
* @param string $direction rtl or ltr direction. If empty, ltr is assumed
* @param array $attribs Optional array of attributes to be passed to JHtml::_('stylesheet')
*
* @return void
*
* @since 3.0
*/
public static function loadCss($includeMainCss = true, $direction = 'ltr', $attribs = array())
{
// Load Bootstrap main CSS
if ($includeMainCss)
{
JHtml::_('stylesheet', 'jui/bootstrap.min.css', array('version' => 'auto', 'relative' => true), $attribs);
JHtml::_('stylesheet', 'jui/bootstrap-responsive.min.css', array('version' => 'auto', 'relative' => true), $attribs);
JHtml::_('stylesheet', 'jui/bootstrap-extended.css', array('version' => 'auto', 'relative' => true), $attribs);
}
// Load Bootstrap RTL CSS
if ($direction === 'rtl')
{
JHtml::_('stylesheet', 'jui/bootstrap-rtl.css', array('version' => 'auto', 'relative' => true), $attribs);
}
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Utility class for categories
*
* @since 1.5
*/
abstract class JHtmlCategory
{
/**
* Cached array of the category items.
*
* @var array
* @since 1.5
*/
protected static $items = array();
/**
* Returns an array of categories for the given extension.
*
* @param string $extension The extension option e.g. com_something.
* @param array $config An array of configuration options. By default, only
* published and unpublished categories are returned.
*
* @return array
*
* @since 1.5
*/
public static function options($extension, $config = array('filter.published' => array(0, 1)))
{
$hash = md5($extension . '.' . serialize($config));
if (!isset(static::$items[$hash]))
{
$config = (array) $config;
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$query = $db->getQuery(true)
->select('a.id, a.title, a.level, a.language')
->from('#__categories AS a')
->where('a.parent_id > 0');
// Filter on extension.
$query->where('extension = ' . $db->quote($extension));
// Filter on user access level
$query->where('a.access IN (' . $groups . ')');
// Filter on the published state
if (isset($config['filter.published']))
{
if (is_numeric($config['filter.published']))
{
$query->where('a.published = ' . (int) $config['filter.published']);
}
elseif (is_array($config['filter.published']))
{
$config['filter.published'] = ArrayHelper::toInteger($config['filter.published']);
$query->where('a.published IN (' . implode(',', $config['filter.published']) . ')');
}
}
// Filter on the language
if (isset($config['filter.language']))
{
if (is_string($config['filter.language']))
{
$query->where('a.language = ' . $db->quote($config['filter.language']));
}
elseif (is_array($config['filter.language']))
{
foreach ($config['filter.language'] as &$language)
{
$language = $db->quote($language);
}
$query->where('a.language IN (' . implode(',', $config['filter.language']) . ')');
}
}
// Filter on the access
if (isset($config['filter.access']))
{
if (is_string($config['filter.access']))
{
$query->where('a.access = ' . $db->quote($config['filter.access']));
}
elseif (is_array($config['filter.access']))
{
foreach ($config['filter.access'] as &$access)
{
$access = $db->quote($access);
}
$query->where('a.access IN (' . implode(',', $config['filter.access']) . ')');
}
}
$query->order('a.lft');
$db->setQuery($query);
$items = $db->loadObjectList();
// Assemble the list options.
static::$items[$hash] = array();
foreach ($items as &$item)
{
$repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
$item->title = str_repeat('- ', $repeat) . $item->title;
if ($item->language !== '*')
{
$item->title .= ' (' . $item->language . ')';
}
static::$items[$hash][] = JHtml::_('select.option', $item->id, $item->title);
}
}
return static::$items[$hash];
}
/**
* Returns an array of categories for the given extension.
*
* @param string $extension The extension option.
* @param array $config An array of configuration options. By default, only published and unpublished categories are returned.
*
* @return array Categories for the extension
*
* @since 1.6
*/
public static function categories($extension, $config = array('filter.published' => array(0, 1)))
{
$hash = md5($extension . '.' . serialize($config));
if (!isset(static::$items[$hash]))
{
$config = (array) $config;
$user = JFactory::getUser();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id, a.title, a.level, a.parent_id, a.language')
->from('#__categories AS a')
->where('a.parent_id > 0');
// Filter on extension.
$query->where('extension = ' . $db->quote($extension));
// Filter on user level.
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
// Filter on the published state
if (isset($config['filter.published']))
{
if (is_numeric($config['filter.published']))
{
$query->where('a.published = ' . (int) $config['filter.published']);
}
elseif (is_array($config['filter.published']))
{
$config['filter.published'] = ArrayHelper::toInteger($config['filter.published']);
$query->where('a.published IN (' . implode(',', $config['filter.published']) . ')');
}
}
$query->order('a.lft');
$db->setQuery($query);
$items = $db->loadObjectList();
// Assemble the list options.
static::$items[$hash] = array();
foreach ($items as &$item)
{
$repeat = ($item->level - 1 >= 0) ? $item->level - 1 : 0;
$item->title = str_repeat('- ', $repeat) . $item->title;
if ($item->language !== '*')
{
$item->title .= ' (' . $item->language . ')';
}
static::$items[$hash][] = JHtml::_('select.option', $item->id, $item->title);
}
// Special "Add to root" option:
static::$items[$hash][] = JHtml::_('select.option', '1', JText::_('JLIB_HTML_ADD_TO_ROOT'));
}
return static::$items[$hash];
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class to fire onContentPrepare for non-article based content.
*
* @since 1.5
*/
abstract class JHtmlContent
{
/**
* Fire onContentPrepare for content that isn't part of an article.
*
* @param string $text The content to be transformed.
* @param array $params The content params.
* @param string $context The context of the content to be transformed.
*
* @return string The content after transformation.
*
* @since 1.5
*/
public static function prepare($text, $params = null, $context = 'text')
{
if ($params === null)
{
$params = new JObject;
}
$article = new stdClass;
$article->text = $text;
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array($context, &$article, &$params, 0));
return $article->text;
}
/**
* Returns an array of months.
*
* @param Registry $state The state object.
*
* @return array
*
* @since 3.9.0
*/
public static function months($state)
{
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
foreach ($state as $key => $value)
{
$model->setState($key, $value);
}
$model->setState('filter.category_id', $state->get('category.id'));
$model->setState('list.start', 0);
$model->setState('list.limit', -1);
$model->setState('list.direction', 'asc');
$model->setState('list.filter', '');
$items = array();
foreach ($model->countItemsByMonth() as $item)
{
$date = new JDate($item->d);
$items[] = JHtml::_('select.option', $item->d, $date->format('F Y') . ' [' . $item->c . ']');
}
return $items;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class working with content language select lists
*
* @since 1.6
*/
abstract class JHtmlContentLanguage
{
/**
* Cached array of the content language items.
*
* @var array
* @since 1.6
*/
protected static $items = null;
/**
* Get a list of the available content language items.
*
* @param boolean $all True to include All (*)
* @param boolean $translate True to translate All
*
* @return string
*
* @see JFormFieldContentLanguage
* @since 1.6
*/
public static function existing($all = false, $translate = false)
{
if (empty(static::$items))
{
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('a.lang_code AS value, a.title AS text, a.title_native')
->from('#__languages AS a')
->where('a.published >= 0')
->order('a.title');
// Set the query and load the options.
$db->setQuery($query);
static::$items = $db->loadObjectList();
}
if ($all)
{
$all_option = array(new JObject(array('value' => '*', 'text' => $translate ? JText::alt('JALL', 'language') : 'JALL_LANGUAGE')));
return array_merge($all_option, static::$items);
}
else
{
return static::$items;
}
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Extended Utility class for handling date display.
*
* @since 2.5
*/
abstract class JHtmlDate
{
/**
* Function to convert a static time into a relative measurement
*
* @param string $date The date to convert
* @param string $unit The optional unit of measurement to return
* if the value of the diff is greater than one
* @param string $time An optional time to compare to, defaults to now
* @param string $format An optional format for the JHtml::date output
*
* @return string The converted time string
*
* @since 2.5
*/
public static function relative($date, $unit = null, $time = null, $format = null)
{
if ($time === null)
{
// Get now
$time = new JDate('now');
}
// Get the difference in seconds between now and the time
$diff = strtotime($time) - strtotime($date);
// Less than a minute
if ($diff < 60)
{
return JText::_('JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE');
}
// Round to minutes
$diff = round($diff / 60);
// 1 to 59 minutes
if ($diff < 60 || $unit === 'minute')
{
return JText::plural('JLIB_HTML_DATE_RELATIVE_MINUTES', $diff);
}
// Round to hours
$diff = round($diff / 60);
// 1 to 23 hours
if ($diff < 24 || $unit === 'hour')
{
return JText::plural('JLIB_HTML_DATE_RELATIVE_HOURS', $diff);
}
// Round to days
$diff = round($diff / 24);
// 1 to 6 days
if ($diff < 7 || $unit === 'day')
{
return JText::plural('JLIB_HTML_DATE_RELATIVE_DAYS', $diff);
}
// Round to weeks
$diff = round($diff / 7);
// 1 to 4 weeks
if ($diff <= 4 || $unit === 'week')
{
return JText::plural('JLIB_HTML_DATE_RELATIVE_WEEKS', $diff);
}
// Over a month, return the absolute time
return JHtml::_('date', $date, $format);
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Extended Utility class for render debug information.
*
* @since 3.7.0
*/
abstract class JHtmlDebug
{
/**
* xdebug.file_link_format from the php.ini.
*
* Make this property public to support test.
*
* @var string
*
* @since 3.7.0
*/
public static $xdebugLinkFormat;
/**
* Replaces the Joomla! root with "JROOT" to improve readability.
* Formats a link with a special value xdebug.file_link_format
* from the php.ini file.
*
* @param string $file The full path to the file.
* @param string $line The line number.
*
* @return string
*
* @throws \InvalidArgumentException
*
* @since 3.7.0
*/
public static function xdebuglink($file, $line = '')
{
if (static::$xdebugLinkFormat === null)
{
static::$xdebugLinkFormat = ini_get('xdebug.file_link_format');
}
$link = str_replace(JPATH_ROOT, 'JROOT', JPath::clean($file));
$link .= $line ? ':' . $line : '';
if (static::$xdebugLinkFormat)
{
$href = static::$xdebugLinkFormat;
$href = str_replace('%f', $file, $href);
$href = str_replace('%l', $line, $href);
$html = JHtml::_('link', $href, $link);
}
else
{
$html = $link;
}
return $html;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* HTML utility class for building a dropdown menu
*
* @since 3.0
*/
abstract class JHtmlDropdown
{
/**
* @var array Array containing information for loaded files
* @since 3.0
*/
protected static $loaded = array();
/**
* @var string HTML markup for the dropdown list
* @since 3.0
*/
protected static $dropDownList = null;
/**
* Method to inject needed script
*
* @return void
*
* @since 3.0
*/
public static function init()
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Depends on Bootstrap
JHtml::_('bootstrap.framework');
JFactory::getDocument()->addScriptDeclaration("
(function($){
$(document).ready(function (){
$('.has-context')
.mouseenter(function (){
$('.btn-group',$(this)).show();
})
.mouseleave(function (){
$('.btn-group',$(this)).hide();
$('.btn-group',$(this)).removeClass('open');
});
contextAction =function (cbId, task)
{
$('input[name=\"cid[]\"]').removeAttr('checked');
$('#' + cbId).attr('checked','checked');
Joomla.submitbutton(task);
}
});
})(jQuery);
"
);
// Set static array
static::$loaded[__METHOD__] = true;
return;
}
/**
* Method to start a new dropdown menu
*
* @return void
*
* @since 3.0
*/
public static function start()
{
// Only start once
if (isset(static::$loaded[__METHOD__]) && static::$loaded[__METHOD__] == true)
{
return;
}
$dropDownList = '<div class="btn-group" style="margin-left:6px;display:none">
<a href="#" data-toggle="dropdown" class="dropdown-toggle btn btn-mini">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">';
static::$dropDownList = $dropDownList;
static::$loaded[__METHOD__] = true;
return;
}
/**
* Method to render current dropdown menu
*
* @return string HTML markup for the dropdown list
*
* @since 3.0
*/
public static function render()
{
$dropDownList = static::$dropDownList;
$dropDownList .= '</ul></div>';
static::$dropDownList = null;
static::$loaded['JHtmlDropdown::start'] = false;
return $dropDownList;
}
/**
* Append an edit item to the current dropdown menu
*
* @param integer $id Record ID
* @param string $prefix Task prefix
* @param string $customLink The custom link if dont use default Joomla action format
*
* @return void
*
* @since 3.0
*/
public static function edit($id, $prefix = '', $customLink = '')
{
static::start();
if (!$customLink)
{
$option = JFactory::getApplication()->input->getCmd('option');
$link = 'index.php?option=' . $option;
}
else
{
$link = $customLink;
}
$link .= '&task=' . $prefix . 'edit&id=' . $id;
$link = JRoute::_($link);
static::addCustomItem(JText::_('JACTION_EDIT'), $link);
return;
}
/**
* Append a publish item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function publish($checkboxId, $prefix = '')
{
$task = $prefix . 'publish';
static::addCustomItem(JText::_('JTOOLBAR_PUBLISH'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append an unpublish item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function unpublish($checkboxId, $prefix = '')
{
$task = $prefix . 'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNPUBLISH'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append a featured item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function featured($checkboxId, $prefix = '')
{
$task = $prefix . 'featured';
static::addCustomItem(JText::_('JFEATURED'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append an unfeatured item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function unfeatured($checkboxId, $prefix = '')
{
$task = $prefix . 'unfeatured';
static::addCustomItem(JText::_('JUNFEATURED'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append an archive item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function archive($checkboxId, $prefix = '')
{
$task = $prefix . 'archive';
static::addCustomItem(JText::_('JTOOLBAR_ARCHIVE'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append an unarchive item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function unarchive($checkboxId, $prefix = '')
{
$task = $prefix . 'unpublish';
static::addCustomItem(JText::_('JTOOLBAR_UNARCHIVE'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append a trash item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function trash($checkboxId, $prefix = '')
{
$task = $prefix . 'trash';
static::addCustomItem(JText::_('JTOOLBAR_TRASH'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append an untrash item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function untrash($checkboxId, $prefix = '')
{
$task = $prefix . 'publish';
static::addCustomItem(JText::_('JTOOLBAR_UNTRASH'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Append a checkin item to the current dropdown menu
*
* @param string $checkboxId ID of corresponding checkbox of the record
* @param string $prefix The task prefix
*
* @return void
*
* @since 3.0
*/
public static function checkin($checkboxId, $prefix = '')
{
$task = $prefix . 'checkin';
static::addCustomItem(JText::_('JTOOLBAR_CHECKIN'), 'javascript:void(0)', 'onclick="contextAction(\'' . $checkboxId . '\', \'' . $task . '\')"');
return;
}
/**
* Writes a divider between dropdown items
*
* @return void
*
* @since 3.0
*/
public static function divider()
{
static::$dropDownList .= '<li class="divider"></li>';
return;
}
/**
* Append a custom item to current dropdown menu
*
* @param string $label The label of item
* @param string $link The link of item
* @param string $linkAttributes Custom link attributes
* @param string $className Class name of item
* @param boolean $ajaxLoad True if using ajax load when item clicked
* @param string $jsCallBackFunc Javascript function name, called when ajax load successfully
*
* @return void
*
* @since 3.0
*/
public static function addCustomItem($label, $link = 'javascript:void(0)', $linkAttributes = '', $className = '', $ajaxLoad = false,
$jsCallBackFunc = null)
{
static::start();
if ($ajaxLoad)
{
$href = ' href = "javascript:void(0)" onclick="loadAjax(\'' . $link . '\', \'' . $jsCallBackFunc . '\')"';
}
else
{
$href = ' href = "' . $link . '" ';
}
$dropDownList = static::$dropDownList;
$dropDownList .= '<li class="' . $className . '"><a ' . $linkAttributes . $href . ' >';
$dropDownList .= $label;
$dropDownList .= '</a></li>';
static::$dropDownList = $dropDownList;
return;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class for cloaking email addresses
*
* @since 1.5
*/
abstract class JHtmlEmail
{
/**
* Simple JavaScript email cloaker
*
* By default replaces an email with a mailto link with email cloaked
*
* @param string $mail The -mail address to cloak.
* @param boolean $mailto True if text and mailing address differ
* @param string $text Text for the link
* @param boolean $email True if text is an email address
*
* @return string The cloaked email.
*
* @since 1.5
*/
public static function cloak($mail, $mailto = true, $text = '', $email = true)
{
// Handle IDN addresses: punycode for href but utf-8 for text displayed.
if ($mailto && (empty($text) || $email))
{
// Use dedicated $text whereas $mail is used as href and must be punycoded.
$text = JStringPunycode::emailToUTF8($text ?: $mail);
}
elseif (!$mailto)
{
// In that case we don't use link - so convert $mail back to utf-8.
$mail = JStringPunycode::emailToUTF8($mail);
}
// Convert mail
$mail = static::convertEncoding($mail);
// Random hash
$rand = md5($mail . mt_rand(1, 100000));
// Split email by @ symbol
$mail = explode('@', $mail);
$mail_parts = explode('.', $mail[1]);
if ($mailto)
{
// Special handling when mail text is different from mail address
if ($text)
{
// Convert text - here is the right place
$text = static::convertEncoding($text);
if ($email)
{
// Split email by @ symbol
$text = explode('@', $text);
$text_parts = explode('.', $text[1]);
$tmpScript = "var addy_text" . $rand . " = '" . @$text[0] . "' + '@' + '" . implode("' + '.' + '", @$text_parts)
. "';";
}
else
{
$tmpScript = "var addy_text" . $rand . " = '" . $text . "';";
}
$tmpScript .= "document.getElementById('cloak" . $rand . "').innerHTML += '<a ' + path + '\'' + prefix + ':' + addy"
. $rand . " + '\'>'+addy_text" . $rand . "+'<\/a>';";
}
else
{
$tmpScript = "document.getElementById('cloak" . $rand . "').innerHTML += '<a ' + path + '\'' + prefix + ':' + addy"
. $rand . " + '\'>' +addy" . $rand . "+'<\/a>';";
}
}
else
{
$tmpScript = "document.getElementById('cloak" . $rand . "').innerHTML += addy" . $rand . ";";
}
$script = "
document.getElementById('cloak" . $rand . "').innerHTML = '';
var prefix = 'ma' + 'il' + 'to';
var path = 'hr' + 'ef' + '=';
var addy" . $rand . " = '" . @$mail[0] . "' + '@';
addy" . $rand . " = addy" . $rand . " + '" . implode("' + '.' + '", $mail_parts) . "';
$tmpScript
";
// TODO: Use inline script for now
$inlineScript = "<script type='text/javascript'>" . $script . "</script>";
return '<span id="cloak' . $rand . '">' . JText::_('JLIB_HTML_CLOAKING') . '</span>' . $inlineScript;
}
/**
* Convert encoded text
*
* @param string $text Text to convert
*
* @return string The converted text.
*
* @since 1.5
*/
protected static function convertEncoding($text)
{
$text = html_entity_decode($text);
// Replace vowels with character encoding
$text = str_replace('a', 'a', $text);
$text = str_replace('e', 'e', $text);
$text = str_replace('i', 'i', $text);
$text = str_replace('o', 'o', $text);
$text = str_replace('u', 'u', $text);
$text = htmlentities($text, ENT_QUOTES, 'UTF-8', false);
return $text;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Utility class for form elements
*
* @since 1.5
*/
abstract class JHtmlForm
{
/**
* Array containing information for loaded files.
*
* @var array
*
* @since 3.8.0
*/
protected static $loaded = array();
/**
* Displays a hidden token field to reduce the risk of CSRF exploits
*
* Use in conjunction with JSession::checkToken()
*
* @param array $attribs Input element attributes.
*
* @return string A hidden input field with a token
*
* @see JSession::checkToken()
* @since 1.5
*/
public static function token(array $attribs = array())
{
$attributes = '';
if ($attribs !== array())
{
$attributes .= ' ' . ArrayHelper::toString($attribs);
}
return '<input type="hidden" name="' . JSession::getFormToken() . '" value="1"' . $attributes . ' />';
}
/**
* Add CSRF form token to Joomla script options that developers can get it by Javascript.
*
* @param string $name The script option key name.
*
* @return void
*
* @since 3.8.0
*/
public static function csrf($name = 'csrf.token')
{
if (isset(static::$loaded[__METHOD__][$name]))
{
return;
}
/** @var JDocumentHtml $doc */
$doc = JFactory::getDocument();
if (!$doc instanceof JDocumentHtml || $doc->getType() !== 'html')
{
return;
}
$doc->addScriptOptions($name, JSession::getFormToken());
static::$loaded[__METHOD__][$name] = true;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Utility class for form related behaviors
*
* @since 3.0
*/
abstract class JHtmlFormbehavior
{
/**
* @var array Array containing information for loaded files
* @since 3.0
*/
protected static $loaded = array();
/**
* Method to load the Chosen JavaScript framework and supporting CSS into the document head
*
* If debugging mode is on an uncompressed version of Chosen is included for easier debugging.
*
* @param string $selector Class for Chosen elements.
* @param mixed $debug Is debugging mode on? [optional]
* @param array $options the possible Chosen options as name => value [optional]
*
* @return void
*
* @since 3.0
*/
public static function chosen($selector = '.advancedSelect', $debug = null, $options = array())
{
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// If no debugging value is set, use the configuration setting
if ($debug === null)
{
$debug = JDEBUG;
}
// Default settings
if (!isset($options['disable_search_threshold']))
{
$options['disable_search_threshold'] = 10;
}
// Allow searching contains space in query
if (!isset($options['search_contains']))
{
$options['search_contains'] = true;
}
if (!isset($options['allow_single_deselect']))
{
$options['allow_single_deselect'] = true;
}
if (!isset($options['placeholder_text_multiple']))
{
$options['placeholder_text_multiple'] = JText::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS');
}
if (!isset($options['placeholder_text_single']))
{
$options['placeholder_text_single'] = JText::_('JGLOBAL_SELECT_AN_OPTION');
}
if (!isset($options['no_results_text']))
{
$options['no_results_text'] = JText::_('JGLOBAL_SELECT_NO_RESULTS_MATCH');
}
$displayData = array(
'debug' => $debug,
'options' => $options,
'selector' => $selector,
);
JLayoutHelper::render('joomla.html.formbehavior.chosen', $displayData);
static::$loaded[__METHOD__][$selector] = true;
return;
}
/**
* Method to load the AJAX Chosen library
*
* If debugging mode is on an uncompressed version of AJAX Chosen is included for easier debugging.
*
* @param Registry $options Options in a Registry object
* @param mixed $debug Is debugging mode on? [optional]
*
* @return void
*
* @since 3.0
*/
public static function ajaxchosen(Registry $options, $debug = null)
{
// Retrieve options/defaults
$selector = $options->get('selector', '.tagfield');
$type = $options->get('type', 'GET');
$url = $options->get('url', null);
$dataType = $options->get('dataType', 'json');
$jsonTermKey = $options->get('jsonTermKey', 'term');
$afterTypeDelay = $options->get('afterTypeDelay', '500');
$minTermLength = $options->get('minTermLength', '3');
// Ajax URL is mandatory
if (!empty($url))
{
if (isset(static::$loaded[__METHOD__][$selector]))
{
return;
}
// Requires chosen to work
static::chosen($selector, $debug);
$displayData = array(
'url' => $url,
'debug' => $debug,
'options' => $options,
'selector' => $selector,
'type' => $type,
'dataType' => $dataType,
'jsonTermKey' => $jsonTermKey,
'afterTypeDelay' => $afterTypeDelay,
'minTermLength' => $minTermLength,
);
JLayoutHelper::render('joomla.html.formbehavior.ajaxchosen', $displayData);
static::$loaded[__METHOD__][$selector] = true;
}
return;
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class for creating HTML Grids
*
* @since 1.5
*/
abstract class JHtmlGrid
{
/**
* Display a boolean setting widget.
*
* @param integer $i The row index.
* @param integer $value The value of the boolean field.
* @param string $taskOn Task to turn the boolean setting on.
* @param string $taskOff Task to turn the boolean setting off.
*
* @return string The boolean setting widget.
*
* @since 1.6
*
* @deprecated 4.0 This is only used in hathor and will be removed without replacement
*/
public static function boolean($i, $value, $taskOn = null, $taskOff = null)
{
// Load the behavior.
static::behavior();
JHtml::_('bootstrap.tooltip');
// Build the title.
$title = $value ? JText::_('JYES') : JText::_('JNO');
$title = JHtml::_('tooltipText', $title, JText::_('JGLOBAL_CLICK_TO_TOGGLE_STATE'), 0);
// Build the <a> tag.
$bool = $value ? 'true' : 'false';
$task = $value ? $taskOff : $taskOn;
$toggle = (!$task) ? false : true;
if ($toggle)
{
return '<a class="grid_' . $bool . ' hasTooltip" title="' . $title . '" rel="{id:\'cb' . $i . '\', task:\'' . $task
. '\'}" href="#toggle"></a>';
}
else
{
return '<a class="grid_' . $bool . '"></a>';
}
}
/**
* Method to sort a column in a grid
*
* @param string $title The link title
* @param string $order The order field for the column
* @param string $direction The current direction
* @param string $selected The selected ordering
* @param string $task An optional task override
* @param string $newDirection An optional direction for the new column
* @param string $tip An optional text shown as tooltip title instead of $title
* @param string $form An optional form selector
*
* @return string
*
* @since 1.5
*/
public static function sort($title, $order, $direction = 'asc', $selected = '', $task = null, $newDirection = 'asc', $tip = '', $form = null)
{
JHtml::_('behavior.core');
JHtml::_('bootstrap.popover');
$direction = strtolower($direction);
$icon = array('arrow-up-3', 'arrow-down-3');
$index = (int) ($direction === 'desc');
if ($order != $selected)
{
$direction = $newDirection;
}
else
{
$direction = $direction === 'desc' ? 'asc' : 'desc';
}
if ($form)
{
$form = ', document.getElementById(\'' . $form . '\')';
}
$html = '<a href="#" onclick="Joomla.tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\'' . $form . ');return false;"'
. ' class="hasPopover" title="' . htmlspecialchars(JText::_($tip ?: $title)) . '"'
. ' data-content="' . htmlspecialchars(JText::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN')) . '" data-placement="top">';
if (isset($title['0']) && $title['0'] === '<')
{
$html .= $title;
}
else
{
$html .= JText::_($title);
}
if ($order == $selected)
{
$html .= '<span class="icon-' . $icon[$index] . '"></span>';
}
$html .= '</a>';
return $html;
}
/**
* Method to check all checkboxes in a grid
*
* @param string $name The name of the form element
* @param string $tip The text shown as tooltip title instead of $tip
* @param string $action The action to perform on clicking the checkbox
*
* @return string
*
* @since 3.1.2
*/
public static function checkall($name = 'checkall-toggle', $tip = 'JGLOBAL_CHECK_ALL', $action = 'Joomla.checkAll(this)')
{
JHtml::_('behavior.core');
JHtml::_('bootstrap.tooltip');
return '<input type="checkbox" name="' . $name . '" value="" class="hasTooltip" title="' . JHtml::_('tooltipText', $tip)
. '" onclick="' . $action . '" />';
}
/**
* Method to create a checkbox for a grid row.
*
* @param integer $rowNum The row index
* @param integer $recId The record id
* @param boolean $checkedOut True if item is checked out
* @param string $name The name of the form element
* @param string $stub The name of stub identifier
*
* @return mixed String of html with a checkbox if item is not checked out, null if checked out.
*
* @since 1.5
*/
public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb')
{
return $checkedOut ? '' : '<input type="checkbox" id="' . $stub . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="Joomla.isChecked(this.checked);" />';
}
/**
* Displays a checked out icon.
*
* @param object &$row A data object (must contain checkedout as a property).
* @param integer $i The index of the row.
* @param string $identifier The property name of the primary key or index of the row.
*
* @return string
*
* @since 1.5
*/
public static function checkedOut(&$row, $i, $identifier = 'id')
{
$user = JFactory::getUser();
$userid = $user->get('id');
if ($row instanceof JTable)
{
$result = $row->isCheckedOut($userid);
}
else
{
$result = false;
}
if ($result)
{
return static::_checkedOut($row);
}
else
{
if ($identifier === 'id')
{
return JHtml::_('grid.id', $i, $row->$identifier);
}
else
{
return JHtml::_('grid.id', $i, $row->$identifier, $result, $identifier);
}
}
}
/**
* Method to create a clickable icon to change the state of an item
*
* @param mixed $value Either the scalar value or an object (for backward compatibility, deprecated)
* @param integer $i The index
* @param string $img1 Image for a positive or on value
* @param string $img0 Image for the empty or off value
* @param string $prefix An optional prefix for the task
*
* @return string
*
* @since 1.5
*/
public static function published($value, $i, $img1 = 'tick.png', $img0 = 'publish_x.png', $prefix = '')
{
if (is_object($value))
{
$value = $value->published;
}
$img = $value ? $img1 : $img0;
$task = $value ? 'unpublish' : 'publish';
$alt = $value ? JText::_('JPUBLISHED') : JText::_('JUNPUBLISHED');
$action = $value ? JText::_('JLIB_HTML_UNPUBLISH_ITEM') : JText::_('JLIB_HTML_PUBLISH_ITEM');
return '<a href="#" onclick="return listItemTask(\'cb' . $i . '\',\'' . $prefix . $task . '\')" title="' . $action . '">'
. JHtml::_('image', 'admin/' . $img, $alt, null, true) . '</a>';
}
/**
* Method to create a select list of states for filtering
* By default the filter shows only published and unpublished items
*
* @param string $filterState The initial filter state
* @param string $published The JText string for published
* @param string $unpublished The JText string for Unpublished
* @param string $archived The JText string for Archived
* @param string $trashed The JText string for Trashed
*
* @return string
*
* @since 1.5
*/
public static function state($filterState = '*', $published = 'JPUBLISHED', $unpublished = 'JUNPUBLISHED', $archived = null, $trashed = null)
{
$state = array('' => '- ' . JText::_('JLIB_HTML_SELECT_STATE') . ' -', 'P' => JText::_($published), 'U' => JText::_($unpublished));
if ($archived)
{
$state['A'] = JText::_($archived);
}
if ($trashed)
{
$state['T'] = JText::_($trashed);
}
return JHtml::_(
'select.genericlist',
$state,
'filter_state',
array(
'list.attr' => 'class="inputbox" size="1" onchange="Joomla.submitform();"',
'list.select' => $filterState,
'option.key' => null,
)
);
}
/**
* Method to create an icon for saving a new ordering in a grid
*
* @param array $rows The array of rows of rows
* @param string $image The image [UNUSED]
* @param string $task The task to use, defaults to save order
*
* @return string
*
* @since 1.5
*/
public static function order($rows, $image = 'filesave.png', $task = 'saveorder')
{
return '<a href="javascript:saveorder('
. (count($rows) - 1) . ', \'' . $task . '\')" rel="tooltip" class="saveorder btn btn-micro pull-right" title="'
. JText::_('JLIB_HTML_SAVE_ORDER') . '"><span class="icon-menu-2"></span></a>';
}
/**
* Method to create a checked out icon with optional overlib in a grid.
*
* @param object &$row The row object
* @param boolean $overlib True if an overlib with checkout information should be created.
*
* @return string HTMl for the icon and overlib
*
* @since 1.5
*/
protected static function _checkedOut(&$row, $overlib = true)
{
$hover = '';
if ($overlib)
{
JHtml::_('bootstrap.tooltip');
$date = JHtml::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1'));
$time = JHtml::_('date', $row->checked_out_time, 'H:i');
$hover = '<span class="editlinktip hasTooltip" title="' . JHtml::_('tooltipText', 'JLIB_HTML_CHECKED_OUT', $row->editor)
. '<br />' . $date . '<br />' . $time . '">';
}
return $hover . JHtml::_('image', 'admin/checked_out.png', null, null, true) . '</span>';
}
/**
* Method to build the behavior script and add it to the document head.
*
* @return void
*
* @since 1.6
*
* @deprecated 4.0 This is only used in hathor and will be removed without replacement
*/
public static function behavior()
{
static $loaded;
if (!$loaded)
{
// Include jQuery
JHtml::_('jquery.framework');
// Build the behavior script.
$js = '
jQuery(function($){
$actions = $(\'a.move_up, a.move_down, a.grid_true, a.grid_false, a.grid_trash\');
$actions.each(function(){
$(this).on(\'click\', function(){
args = JSON.decode(this.rel);
listItemTask(args.id, args.task);
});
});
$(\'input.check-all-toggle\').each(function(){
$(this).on(\'click\', function(){
if (this.checked) {
$(this).closest(\'form\').find(\'input[type="checkbox"]\').each(function(){
this.checked = true;
})
}
else {
$(this).closest(\'form\').find(\'input[type="checkbox"]\').each(function(){
this.checked = false;
})
}
});
});
});';
// Add the behavior to the document head.
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
$loaded = true;
}
}
}
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
/**
* Utility class for icons.
*
* @since 2.5
*/
abstract class JHtmlIcons
{
/**
* Method to generate html code for a list of buttons
*
* @param array $buttons Array of buttons
*
* @return string
*
* @since 2.5
*/
public static function buttons($buttons)
{
$html = array();
foreach ($buttons as $button)
{
$html[] = JHtml::_('icons.button', $button);
}
return implode($html);
}
/**
* Method to generate html code for a list of buttons
*
* @param array $button Button properties
*
* @return string
*
* @since 2.5
*/
public static function button($button)
{
if (isset($button['access']))
{
if (is_bool($button['access']))
{
if ($button['access'] == false)
{
return '';
}
}
else
{
// Get the user object to verify permissions
$user = JFactory::getUser();
// Take each pair of permission, context values.
for ($i = 0, $n = count($button['access']); $i < $n; $i += 2)
{
if (!$user->authorise($button['access'][$i], $button['access'][$i + 1]))
{
return '';
}
}
}
}
// Instantiate a new JLayoutFile instance and render the layout
$layout = new JLayoutFile('joomla.quickicons.icon');
return $layout->render($button);
}
}
<!DOCTYPE html><title></title>
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Utility class for creating HTML Grids
*
* @since 1.6
*/
abstract class JHtmlJGrid
{
/**
* Returns an action on a grid
*
* @param integer $i The row index
* @param string $task The task to fire
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display [unused - @deprecated 4.0]
* @param string $activeTitle An optional active tooltip to display if $enable is true
* @param string $inactiveTitle An optional inactive tooltip to display if $enable is true
* @param boolean $tip An optional setting for tooltip
* @param string $activeClass An optional active HTML class
* @param string $inactiveClass An optional inactive HTML class
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function action($i, $task, $prefix = '', $text = '', $activeTitle = '', $inactiveTitle = '', $tip = false, $activeClass = '',
$inactiveClass = '', $enabled = true, $translate = true, $checkbox = 'cb')
{
if (is_array($prefix))
{
$options = $prefix;
$activeTitle = array_key_exists('active_title', $options) ? $options['active_title'] : $activeTitle;
$inactiveTitle = array_key_exists('inactive_title', $options) ? $options['inactive_title'] : $inactiveTitle;
$tip = array_key_exists('tip', $options) ? $options['tip'] : $tip;
$activeClass = array_key_exists('active_class', $options) ? $options['active_class'] : $activeClass;
$inactiveClass = array_key_exists('inactive_class', $options) ? $options['inactive_class'] : $inactiveClass;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$translate = array_key_exists('translate', $options) ? $options['translate'] : $translate;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
if ($tip)
{
JHtml::_('bootstrap.tooltip');
$title = $enabled ? $activeTitle : $inactiveTitle;
$title = $translate ? JText::_($title) : $title;
$title = JHtml::_('tooltipText', $title, '', 0);
}
if ($enabled)
{
$html[] = '<a class="btn btn-micro' . ($activeClass === 'publish' ? ' active' : '') . ($tip ? ' hasTooltip' : '') . '"';
$html[] = ' href="javascript:void(0);" onclick="return listItemTask(\'' . $checkbox . $i . '\',\'' . $prefix . $task . '\')"';
$html[] = $tip ? ' title="' . $title . '"' : '';
$html[] = '>';
$html[] = '<span class="icon-' . $activeClass . '" aria-hidden="true"></span>';
$html[] = '</a>';
}
else
{
$html[] = '<a class="btn btn-micro disabled jgrid' . ($tip ? ' hasTooltip' : '') . '"';
$html[] = $tip ? ' title="' . $title . '"' : '';
$html[] = '>';
if ($activeClass === 'protected')
{
$html[] = '<span class="icon-lock"></span>';
}
else
{
$html[] = '<span class="icon-' . $inactiveClass . '"></span>';
}
$html[] = '</a>';
}
return implode($html);
}
/**
* Returns a state on a grid
*
* @param array $states array of value/state. Each state is an array of the form
* (task, text, active title, inactive title, tip (boolean), HTML active class, HTML inactive class)
* or ('task'=>task, 'text'=>text, 'active_title'=>active title,
* 'inactive_title'=>inactive title, 'tip'=>boolean, 'active_class'=>html active class,
* 'inactive_class'=>html inactive class)
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param boolean $translate An optional setting for translation.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb')
{
if (is_array($prefix))
{
$options = $prefix;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$translate = array_key_exists('translate', $options) ? $options['translate'] : $translate;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
$state = ArrayHelper::getValue($states, (int) $value, $states[0]);
$task = array_key_exists('task', $state) ? $state['task'] : $state[0];
$text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : '');
$activeTitle = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : '');
$inactiveTitle = array_key_exists('inactive_title', $state) ? $state['inactive_title'] : (array_key_exists(3, $state) ? $state[3] : '');
$tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false);
$activeClass = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : '');
$inactiveClass = array_key_exists('inactive_class', $state) ? $state['inactive_class'] : (array_key_exists(6, $state) ? $state[6] : '');
return static::action(
$i, $task, $prefix, $text, $activeTitle, $inactiveTitle, $tip,
$activeClass, $inactiveClass, $enabled, $translate, $checkbox
);
}
/**
* Returns a published state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @param string $publishUp An optional start publishing date.
* @param string $publishDown An optional finish publishing date.
*
* @return string The HTML markup
*
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function published($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $publishUp = null, $publishDown = null)
{
if (is_array($prefix))
{
$options = $prefix;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
$states = array(
1 => array('unpublish', 'JPUBLISHED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JPUBLISHED', true, 'publish', 'publish'),
0 => array('publish', 'JUNPUBLISHED', 'JLIB_HTML_PUBLISH_ITEM', 'JUNPUBLISHED', true, 'unpublish', 'unpublish'),
2 => array('unpublish', 'JARCHIVED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JARCHIVED', true, 'archive', 'archive'),
-2 => array('publish', 'JTRASHED', 'JLIB_HTML_PUBLISH_ITEM', 'JTRASHED', true, 'trash', 'trash'),
);
// Special state for dates
if ($publishUp || $publishDown)
{
$nullDate = JFactory::getDbo()->getNullDate();
$nowDate = JFactory::getDate()->toUnix();
$tz = JFactory::getUser()->getTimezone();
$publishUp = ($publishUp != $nullDate) ? JFactory::getDate($publishUp, 'UTC')->setTimeZone($tz) : false;
$publishDown = ($publishDown != $nullDate) ? JFactory::getDate($publishDown, 'UTC')->setTimeZone($tz) : false;
// Create tip text, only we have publish up or down settings
$tips = array();
if ($publishUp)
{
$tips[] = JText::sprintf('JLIB_HTML_PUBLISHED_START', JHtml::_('date', $publishUp, JText::_('DATE_FORMAT_LC5'), 'UTC'));
}
if ($publishDown)
{
$tips[] = JText::sprintf('JLIB_HTML_PUBLISHED_FINISHED', JHtml::_('date', $publishDown, JText::_('DATE_FORMAT_LC5'), 'UTC'));
}
$tip = empty($tips) ? false : implode('<br />', $tips);
// Add tips and special titles
foreach ($states as $key => $state)
{
// Create special titles for published items
if ($key == 1)
{
$states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_ITEM';
if ($publishUp > $nullDate && $nowDate < $publishUp->toUnix())
{
$states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_PENDING_ITEM';
$states[$key][5] = $states[$key][6] = 'pending';
}
if ($publishDown > $nullDate && $nowDate > $publishDown->toUnix())
{
$states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_EXPIRED_ITEM';
$states[$key][5] = $states[$key][6] = 'expired';
}
}
// Add tips to titles
if ($tip)
{
$states[$key][1] = JText::_($states[$key][1]);
$states[$key][2] = JText::_($states[$key][2]) . '<br />' . $tip;
$states[$key][3] = JText::_($states[$key][3]) . '<br />' . $tip;
$states[$key][4] = true;
}
}
return static::state($states, $value, $i, array('prefix' => $prefix, 'translate' => !$tip), $enabled, true, $checkbox);
}
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
}
/**
* Returns an isDefault state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @see JHtmlJGrid::state()
* @since 1.6
*/
public static function isdefault($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb')
{
if (is_array($prefix))
{
$options = $prefix;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
$states = array(
0 => array('setDefault', '', 'JLIB_HTML_SETDEFAULT_ITEM', '', 1, 'unfeatured', 'unfeatured'),
1 => array('unsetDefault', 'JDEFAULT', 'JLIB_HTML_UNSETDEFAULT_ITEM', 'JDEFAULT', 1, 'featured', 'featured'),
);
return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox);
}
/**
* Returns an array of standard published state filter options.
*
* @param array $config An array of configuration options.
* This array can contain a list of key/value pairs where values are boolean
* and keys can be taken from 'published', 'unpublished', 'archived', 'trash', 'all'.
* These pairs determine which values are displayed.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function publishedOptions($config = array())
{
// Build the active state filter options.
$options = array();
if (!array_key_exists('published', $config) || $config['published'])
{
$options[] = JHtml::_('select.option', '1', 'JPUBLISHED');
}
if (!array_key_exists('unpublished', $config) || $config['unpublished'])
{
$options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED');
}
if (!array_key_exists('archived', $config) || $config['archived'])
{
$options[] = JHtml::_('select.option', '2', 'JARCHIVED');
}
if (!array_key_exists('trash', $config) || $config['trash'])
{
$options[] = JHtml::_('select.option', '-2', 'JTRASHED');
}
if (!array_key_exists('all', $config) || $config['all'])
{
$options[] = JHtml::_('select.option', '*', 'JALL');
}
return $options;
}
/**
* Returns a checked-out icon
*
* @param integer $i The row index.
* @param string $editorName The name of the editor.
* @param string $time The time that the object was checked out.
* @param string|array $prefix An optional task prefix or an array of options
* @param boolean $enabled True to enable the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function checkedout($i, $editorName, $time, $prefix = '', $enabled = false, $checkbox = 'cb')
{
JHtml::_('bootstrap.tooltip');
if (is_array($prefix))
{
$options = $prefix;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
$text = $editorName . '<br />' . JHtml::_('date', $time, JText::_('DATE_FORMAT_LC')) . '<br />' . JHtml::_('date', $time, 'H:i');
$activeTitle = JHtml::_('tooltipText', JText::_('JLIB_HTML_CHECKIN'), $text, 0);
$inactiveTitle = JHtml::_('tooltipText', JText::_('JLIB_HTML_CHECKED_OUT'), $text, 0);
return static::action(
$i, 'checkin', $prefix, JText::_('JLIB_HTML_CHECKED_OUT'), html_entity_decode($activeTitle, ENT_QUOTES, 'UTF-8'),
html_entity_decode($inactiveTitle, ENT_QUOTES, 'UTF-8'), true, 'checkedout', 'checkedout', $enabled, false, $checkbox
);
}
/**
* Creates an order-up action icon.
*
* @param integer $i The row index.
* @param string $task An optional task to fire.
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb')
{
if (is_array($prefix))
{
$options = $prefix;
$text = array_key_exists('text', $options) ? $options['text'] : $text;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
}
return static::action($i, $task, $prefix, $text, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox);
}
/**
* Creates an order-down action icon.
*
* @param integer $i The row index.
* @param string $task An optional task to fire.
* @param string|array $prefix An optional task prefix or an array of options
* @param string $text An optional text to display
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The HTML markup
*
* @since 1.6
*/
public static function orderDown($i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb')
{
if (is_array($prefix))
{
$options = $prefix;
$text = array_key_exists('text', $options) ? $options['text'] : $text;
$enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
$checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
$prefix = array_key_exists('prefix',