- md5
- 6041d652fec348301931524aeb5d5c87
- sha1
- 8c9115a193dc861edcfb1e8d7edf64ef14b2d954
- sha256
- 205e9e27946abbd42b5764753598eb4fb8b1bf977e69fd16c10010c5dd593112
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
<?php
/**
* @package Joomla.Libraries
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
/**
* HTML utility class for creating a sortable table list
*
* @since 3.0
*/
abstract class JHtmlSortablelist
{
/**
* @var array Array containing information for loaded files
* @since 3.0
*/
protected static $loaded = array();
/**
* Method to load the Sortable script and make table sortable
*
* @param string $tableId DOM id of the table
* @param string $formId DOM id of the form
* @param string $sortDir Sort direction
* @param string $saveOrderingUrl Save ordering url, ajax-load after an item dropped
* @param boolean $proceedSaveOrderButton Set whether a save order button is displayed
* @param boolean $nestedList Set whether the list is a nested list
*
* @return void
*
* @since 3.0
*
* @throws InvalidArgumentException
*/
public static function sortable($tableId, $formId, $sortDir = 'asc', $saveOrderingUrl = null, $proceedSaveOrderButton = true, $nestedList = false)
{
// Only load once
if (isset(static::$loaded[__METHOD__]))
{
return;
}
// Note: $i is required but has to be an optional argument in the function call due to argument order
if ($saveOrderingUrl === null)
{
throw new InvalidArgumentException(sprintf('$saveOrderingUrl is a required argument in %s()', __METHOD__));
}
// Depends on Joomla.getOptions()
HTMLHelper::_('behavior.core');
// Depends on jQuery UI
HTMLHelper::_('jquery.ui', array('core', 'sortable'));
HTMLHelper::_('script', 'legacy/sortablelist.min.js', false, true);
HTMLHelper::_('stylesheet', 'legacy/sortablelist.css', false, true, false);
// Attach sortable to document
Factory::getDocument()->addScriptOptions(
'sortable-list',
array(
'id' => '#' . $tableId . ' tbody',
'formId' => $formId,
'direction' => $sortDir,
'url' => $saveOrderingUrl,
'options' => '',
'nestedList' => $nestedList,
'button' => $proceedSaveOrderButton
)
);
// Set static array
static::$loaded[__METHOD__] = true;
}
}
No other release has this exact content. See every version of this file.