Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/joomla4/grid.php.tar

home/lmsyaran/public_html/libraries/cms/html/grid.php000064400000024501151156270370016775
0ustar00<?php
/**
 * @package     Joomla.Libraries
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @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;
		}
	}
}
home/lmsyaran/public_html/libraries/joomla/grid/grid.php000064400000022631151156323140017451
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Grid

 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * JGrid class to dynamically generate HTML tables
 *
 * @since       1.7.3
 * @deprecated  4.0 This class will be removed without any replacement
 */
class JGrid
{
	/**
	 * Array of columns
	 * @var array
	 * @since 1.7.3
	 */
	protected $columns = array();

	/**
	 * Current active row
	 * @var int
	 * @since 1.7.3
	 */
	protected $activeRow = 0;

	/**
	 * Rows of the table (including header and footer rows)
	 * @var array
	 * @since 1.7.3
	 */
	protected $rows = array();

	/**
	 * Header and Footer row-IDs
	 * @var array
	 * @since 1.7.3
	 */
	protected $specialRows = array('header' => array(),
'footer' => array());

	/**
	 * Associative array of attributes for the table-tag
	 * @var array
	 * @since 1.7.3
	 */
	protected $options;

	/**
	 * Constructor for a JGrid object
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 *
	 * @since 1.7.3
	 */
	public function __construct($options = array())
	{
		$this->setTableOptions($options, true);
	}

	/**
	 * Magic function to render this object as a table.
	 *
	 * @return  string
	 *
	 * @since 1.7.3
	 */
	public function __toString()
	{
		return $this->toString();
	}

	/**
	 * Method to set the attributes for a table-tag
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 * @param   bool   $replace  Replace possibly existing attributes
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setTableOptions($options = array(), $replace = false)
	{
		if ($replace)
		{
			$this->options = $options;
		}
		else
		{
			$this->options = array_merge($this->options, $options);
		}

		return $this;
	}

	/**
	 * Get the Attributes of the current table
	 *
	 * @return  array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getTableOptions()
	{
		return $this->options;
	}

	/**
	 * Add new column name to process
	 *
	 * @param   string  $name  Internal column name
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addColumn($name)
	{
		$this->columns[] = $name;

		return $this;
	}

	/**
	 * Returns the list of internal columns
	 *
	 * @return  array List of internal columns
	 *
	 * @since 1.7.3
	 */
	public function getColumns()
	{
		return $this->columns;
	}

	/**
	 * Delete column by name
	 *
	 * @param   string  $name  Name of the column to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteColumn($name)
	{
		$index = array_search($name, $this->columns);

		if ($index !== false)
		{
			unset($this->columns[$index]);
			$this->columns = array_values($this->columns);
		}

		return $this;
	}

	/**
	 * Method to set a whole range of columns at once
	 * This can be used to re-order the columns, too
	 *
	 * @param   array  $columns  List of internal column names
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setColumns($columns)
	{
		$this->columns = array_values($columns);

		return $this;
	}

	/**
	 * Adds a row to the table and sets the currently
	 * active row to the new row
	 *
	 * @param   array  $options  Associative array of attributes for the row
	 * @param   int    $special  1 for a new row in the header, 2 for a new
row in the footer
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addRow($options = array(), $special = false)
	{
		$this->rows[]['_row'] = $options;
		$this->activeRow = count($this->rows) - 1;

		if ($special)
		{
			if ($special === 1)
			{
				$this->specialRows['header'][] = $this->activeRow;
			}
			else
			{
				$this->specialRows['footer'][] = $this->activeRow;
			}
		}

		return $this;
	}

	/**
	 * Method to get the attributes of the currently active row
	 *
	 * @return array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getRowOptions()
	{
		return $this->rows[$this->activeRow]['_row'];
	}

	/**
	 * Method to set the attributes of the currently active row
	 *
	 * @param   array  $options  Associative array of attributes
	 *
	 * @return JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowOptions($options)
	{
		$this->rows[$this->activeRow]['_row'] = $options;

		return $this;
	}

	/**
	 * Get the currently active row ID
	 *
	 * @return  int ID of the currently active row
	 *
	 * @since 1.7.3
	 */
	public function getActiveRow()
	{
		return $this->activeRow;
	}

	/**
	 * Set the currently active row
	 *
	 * @param   int  $id  ID of the row to be set to current
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setActiveRow($id)
	{
		$this->activeRow = (int) $id;

		return $this;
	}

	/**
	 * Set cell content for a specific column for the
	 * currently active row
	 *
	 * @param   string  $name     Name of the column
	 * @param   string  $content  Content for the cell
	 * @param   array   $option   Associative array of attributes for the
td-element
	 * @param   bool    $replace  If false, the content is appended to the
current content of the cell
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowCell($name, $content, $option = array(), $replace =
true)
	{
		if ($replace || !isset($this->rows[$this->activeRow][$name]))
		{
			$cell = new stdClass;
			$cell->options = $option;
			$cell->content = $content;
			$this->rows[$this->activeRow][$name] = $cell;
		}
		else
		{
			$this->rows[$this->activeRow][$name]->content .= $content;
			$this->rows[$this->activeRow][$name]->options = $option;
		}

		return $this;
	}

	/**
	 * Get all data for a row
	 *
	 * @param   int  $id  ID of the row to return
	 *
	 * @return  array Array of columns of a table row
	 *
	 * @since 1.7.3
	 */
	public function getRow($id = false)
	{
		if ($id === false)
		{
			$id = $this->activeRow;
		}

		if (isset($this->rows[(int) $id]))
		{
			return $this->rows[(int) $id];
		}
		else
		{
			return false;
		}
	}

	/**
	 * Get the IDs of all rows in the table
	 *
	 * @param   int  $special  false for the standard rows, 1 for the header
rows, 2 for the footer rows
	 *
	 * @return  array Array of IDs
	 *
	 * @since 1.7.3
	 */
	public function getRows($special = false)
	{
		if ($special)
		{
			if ($special === 1)
			{
				return $this->specialRows['header'];
			}
			else
			{
				return $this->specialRows['footer'];
			}
		}

		return array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));
	}

	/**
	 * Delete a row from the object
	 *
	 * @param   int  $id  ID of the row to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteRow($id)
	{
		unset($this->rows[$id]);

		if (in_array($id, $this->specialRows['header']))
		{
			unset($this->specialRows['header'][array_search($id,
$this->specialRows['header'])]);
		}

		if (in_array($id, $this->specialRows['footer']))
		{
			unset($this->specialRows['footer'][array_search($id,
$this->specialRows['footer'])]);
		}

		if ($this->activeRow == $id)
		{
			end($this->rows);
			$this->activeRow = key($this->rows);
		}

		return $this;
	}

	/**
	 * Render the HTML table
	 *
	 * @return  string The rendered HTML table
	 *
	 * @since 1.7.3
	 */
	public function toString()
	{
		$output = array();
		$output[] = '<table' .
$this->renderAttributes($this->getTableOptions()) . '>';

		if (count($this->specialRows['header']))
		{
			$output[] =
$this->renderArea($this->specialRows['header'],
'thead', 'th');
		}

		if (count($this->specialRows['footer']))
		{
			$output[] =
$this->renderArea($this->specialRows['footer'],
'tfoot');
		}

		$ids = array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));

		if (count($ids))
		{
			$output[] = $this->renderArea($ids);
		}

		$output[] = '</table>';

		return implode('', $output);
	}

	/**
	 * Render an area of the table
	 *
	 * @param   array   $ids   IDs of the rows to render
	 * @param   string  $area  Name of the area to render. Valid: tbody,
tfoot, thead
	 * @param   string  $cell  Name of the cell to render. Valid: td, th
	 *
	 * @return string The rendered table area
	 *
	 * @since 1.7.3
	 */
	protected function renderArea($ids, $area = 'tbody', $cell =
'td')
	{
		$output = array();
		$output[] = '<' . $area . ">\n";

		foreach ($ids as $id)
		{
			$output[] = "\t<tr" .
$this->renderAttributes($this->rows[$id]['_row']) .
">\n";

			foreach ($this->getColumns() as $name)
			{
				if (isset($this->rows[$id][$name]))
				{
					$column = $this->rows[$id][$name];
					$output[] = "\t\t<" . $cell .
$this->renderAttributes($column->options) . '>' .
$column->content . '</' . $cell . ">\n";
				}
			}

			$output[] = "\t</tr>\n";
		}

		$output[] = '</' . $area . '>';

		return implode('', $output);
	}

	/**
	 * Renders an HTML attribute from an associative array
	 *
	 * @param   array  $attributes  Associative array of attributes
	 *
	 * @return  string The HTML attribute string
	 *
	 * @since 1.7.3
	 */
	protected function renderAttributes($attributes)
	{
		if (count((array) $attributes) == 0)
		{
			return '';
		}

		$return = array();

		foreach ($attributes as $key => $option)
		{
			$return[] = $key . '="' . $option . '"';
		}

		return ' ' . implode(' ', $return);
	}
}
home/lmsyaran/public_html/j3/htaccess.back/cms/html/grid.php000064400000024501151156763400020032
0ustar00<?php
/**
 * @package     Joomla.Libraries
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @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;
		}
	}
}
home/lmsyaran/public_html/j3/libraries/joomla/grid/grid.php000064400000022631151157060410017764
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Grid

 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * JGrid class to dynamically generate HTML tables
 *
 * @since       1.7.3
 * @deprecated  4.0 This class will be removed without any replacement
 */
class JGrid
{
	/**
	 * Array of columns
	 * @var array
	 * @since 1.7.3
	 */
	protected $columns = array();

	/**
	 * Current active row
	 * @var int
	 * @since 1.7.3
	 */
	protected $activeRow = 0;

	/**
	 * Rows of the table (including header and footer rows)
	 * @var array
	 * @since 1.7.3
	 */
	protected $rows = array();

	/**
	 * Header and Footer row-IDs
	 * @var array
	 * @since 1.7.3
	 */
	protected $specialRows = array('header' => array(),
'footer' => array());

	/**
	 * Associative array of attributes for the table-tag
	 * @var array
	 * @since 1.7.3
	 */
	protected $options;

	/**
	 * Constructor for a JGrid object
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 *
	 * @since 1.7.3
	 */
	public function __construct($options = array())
	{
		$this->setTableOptions($options, true);
	}

	/**
	 * Magic function to render this object as a table.
	 *
	 * @return  string
	 *
	 * @since 1.7.3
	 */
	public function __toString()
	{
		return $this->toString();
	}

	/**
	 * Method to set the attributes for a table-tag
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 * @param   bool   $replace  Replace possibly existing attributes
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setTableOptions($options = array(), $replace = false)
	{
		if ($replace)
		{
			$this->options = $options;
		}
		else
		{
			$this->options = array_merge($this->options, $options);
		}

		return $this;
	}

	/**
	 * Get the Attributes of the current table
	 *
	 * @return  array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getTableOptions()
	{
		return $this->options;
	}

	/**
	 * Add new column name to process
	 *
	 * @param   string  $name  Internal column name
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addColumn($name)
	{
		$this->columns[] = $name;

		return $this;
	}

	/**
	 * Returns the list of internal columns
	 *
	 * @return  array List of internal columns
	 *
	 * @since 1.7.3
	 */
	public function getColumns()
	{
		return $this->columns;
	}

	/**
	 * Delete column by name
	 *
	 * @param   string  $name  Name of the column to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteColumn($name)
	{
		$index = array_search($name, $this->columns);

		if ($index !== false)
		{
			unset($this->columns[$index]);
			$this->columns = array_values($this->columns);
		}

		return $this;
	}

	/**
	 * Method to set a whole range of columns at once
	 * This can be used to re-order the columns, too
	 *
	 * @param   array  $columns  List of internal column names
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setColumns($columns)
	{
		$this->columns = array_values($columns);

		return $this;
	}

	/**
	 * Adds a row to the table and sets the currently
	 * active row to the new row
	 *
	 * @param   array  $options  Associative array of attributes for the row
	 * @param   int    $special  1 for a new row in the header, 2 for a new
row in the footer
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addRow($options = array(), $special = false)
	{
		$this->rows[]['_row'] = $options;
		$this->activeRow = count($this->rows) - 1;

		if ($special)
		{
			if ($special === 1)
			{
				$this->specialRows['header'][] = $this->activeRow;
			}
			else
			{
				$this->specialRows['footer'][] = $this->activeRow;
			}
		}

		return $this;
	}

	/**
	 * Method to get the attributes of the currently active row
	 *
	 * @return array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getRowOptions()
	{
		return $this->rows[$this->activeRow]['_row'];
	}

	/**
	 * Method to set the attributes of the currently active row
	 *
	 * @param   array  $options  Associative array of attributes
	 *
	 * @return JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowOptions($options)
	{
		$this->rows[$this->activeRow]['_row'] = $options;

		return $this;
	}

	/**
	 * Get the currently active row ID
	 *
	 * @return  int ID of the currently active row
	 *
	 * @since 1.7.3
	 */
	public function getActiveRow()
	{
		return $this->activeRow;
	}

	/**
	 * Set the currently active row
	 *
	 * @param   int  $id  ID of the row to be set to current
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setActiveRow($id)
	{
		$this->activeRow = (int) $id;

		return $this;
	}

	/**
	 * Set cell content for a specific column for the
	 * currently active row
	 *
	 * @param   string  $name     Name of the column
	 * @param   string  $content  Content for the cell
	 * @param   array   $option   Associative array of attributes for the
td-element
	 * @param   bool    $replace  If false, the content is appended to the
current content of the cell
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowCell($name, $content, $option = array(), $replace =
true)
	{
		if ($replace || !isset($this->rows[$this->activeRow][$name]))
		{
			$cell = new stdClass;
			$cell->options = $option;
			$cell->content = $content;
			$this->rows[$this->activeRow][$name] = $cell;
		}
		else
		{
			$this->rows[$this->activeRow][$name]->content .= $content;
			$this->rows[$this->activeRow][$name]->options = $option;
		}

		return $this;
	}

	/**
	 * Get all data for a row
	 *
	 * @param   int  $id  ID of the row to return
	 *
	 * @return  array Array of columns of a table row
	 *
	 * @since 1.7.3
	 */
	public function getRow($id = false)
	{
		if ($id === false)
		{
			$id = $this->activeRow;
		}

		if (isset($this->rows[(int) $id]))
		{
			return $this->rows[(int) $id];
		}
		else
		{
			return false;
		}
	}

	/**
	 * Get the IDs of all rows in the table
	 *
	 * @param   int  $special  false for the standard rows, 1 for the header
rows, 2 for the footer rows
	 *
	 * @return  array Array of IDs
	 *
	 * @since 1.7.3
	 */
	public function getRows($special = false)
	{
		if ($special)
		{
			if ($special === 1)
			{
				return $this->specialRows['header'];
			}
			else
			{
				return $this->specialRows['footer'];
			}
		}

		return array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));
	}

	/**
	 * Delete a row from the object
	 *
	 * @param   int  $id  ID of the row to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteRow($id)
	{
		unset($this->rows[$id]);

		if (in_array($id, $this->specialRows['header']))
		{
			unset($this->specialRows['header'][array_search($id,
$this->specialRows['header'])]);
		}

		if (in_array($id, $this->specialRows['footer']))
		{
			unset($this->specialRows['footer'][array_search($id,
$this->specialRows['footer'])]);
		}

		if ($this->activeRow == $id)
		{
			end($this->rows);
			$this->activeRow = key($this->rows);
		}

		return $this;
	}

	/**
	 * Render the HTML table
	 *
	 * @return  string The rendered HTML table
	 *
	 * @since 1.7.3
	 */
	public function toString()
	{
		$output = array();
		$output[] = '<table' .
$this->renderAttributes($this->getTableOptions()) . '>';

		if (count($this->specialRows['header']))
		{
			$output[] =
$this->renderArea($this->specialRows['header'],
'thead', 'th');
		}

		if (count($this->specialRows['footer']))
		{
			$output[] =
$this->renderArea($this->specialRows['footer'],
'tfoot');
		}

		$ids = array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));

		if (count($ids))
		{
			$output[] = $this->renderArea($ids);
		}

		$output[] = '</table>';

		return implode('', $output);
	}

	/**
	 * Render an area of the table
	 *
	 * @param   array   $ids   IDs of the rows to render
	 * @param   string  $area  Name of the area to render. Valid: tbody,
tfoot, thead
	 * @param   string  $cell  Name of the cell to render. Valid: td, th
	 *
	 * @return string The rendered table area
	 *
	 * @since 1.7.3
	 */
	protected function renderArea($ids, $area = 'tbody', $cell =
'td')
	{
		$output = array();
		$output[] = '<' . $area . ">\n";

		foreach ($ids as $id)
		{
			$output[] = "\t<tr" .
$this->renderAttributes($this->rows[$id]['_row']) .
">\n";

			foreach ($this->getColumns() as $name)
			{
				if (isset($this->rows[$id][$name]))
				{
					$column = $this->rows[$id][$name];
					$output[] = "\t\t<" . $cell .
$this->renderAttributes($column->options) . '>' .
$column->content . '</' . $cell . ">\n";
				}
			}

			$output[] = "\t</tr>\n";
		}

		$output[] = '</' . $area . '>';

		return implode('', $output);
	}

	/**
	 * Renders an HTML attribute from an associative array
	 *
	 * @param   array  $attributes  Associative array of attributes
	 *
	 * @return  string The HTML attribute string
	 *
	 * @since 1.7.3
	 */
	protected function renderAttributes($attributes)
	{
		if (count((array) $attributes) == 0)
		{
			return '';
		}

		$return = array();

		foreach ($attributes as $key => $option)
		{
			$return[] = $key . '="' . $option . '"';
		}

		return ' ' . implode(' ', $return);
	}
}
home/lmsyaran/public_html/j3/libraries/cms/html/grid.php000064400000024501151157450320017305
0ustar00<?php
/**
 * @package     Joomla.Libraries
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @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;
		}
	}
}
home/lmsyaran/public_html/j3/htaccess.back/joomla/grid/grid.php000064400000022631151161001140020472
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Grid

 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * JGrid class to dynamically generate HTML tables
 *
 * @since       1.7.3
 * @deprecated  4.0 This class will be removed without any replacement
 */
class JGrid
{
	/**
	 * Array of columns
	 * @var array
	 * @since 1.7.3
	 */
	protected $columns = array();

	/**
	 * Current active row
	 * @var int
	 * @since 1.7.3
	 */
	protected $activeRow = 0;

	/**
	 * Rows of the table (including header and footer rows)
	 * @var array
	 * @since 1.7.3
	 */
	protected $rows = array();

	/**
	 * Header and Footer row-IDs
	 * @var array
	 * @since 1.7.3
	 */
	protected $specialRows = array('header' => array(),
'footer' => array());

	/**
	 * Associative array of attributes for the table-tag
	 * @var array
	 * @since 1.7.3
	 */
	protected $options;

	/**
	 * Constructor for a JGrid object
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 *
	 * @since 1.7.3
	 */
	public function __construct($options = array())
	{
		$this->setTableOptions($options, true);
	}

	/**
	 * Magic function to render this object as a table.
	 *
	 * @return  string
	 *
	 * @since 1.7.3
	 */
	public function __toString()
	{
		return $this->toString();
	}

	/**
	 * Method to set the attributes for a table-tag
	 *
	 * @param   array  $options  Associative array of attributes for the
table-tag
	 * @param   bool   $replace  Replace possibly existing attributes
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setTableOptions($options = array(), $replace = false)
	{
		if ($replace)
		{
			$this->options = $options;
		}
		else
		{
			$this->options = array_merge($this->options, $options);
		}

		return $this;
	}

	/**
	 * Get the Attributes of the current table
	 *
	 * @return  array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getTableOptions()
	{
		return $this->options;
	}

	/**
	 * Add new column name to process
	 *
	 * @param   string  $name  Internal column name
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addColumn($name)
	{
		$this->columns[] = $name;

		return $this;
	}

	/**
	 * Returns the list of internal columns
	 *
	 * @return  array List of internal columns
	 *
	 * @since 1.7.3
	 */
	public function getColumns()
	{
		return $this->columns;
	}

	/**
	 * Delete column by name
	 *
	 * @param   string  $name  Name of the column to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteColumn($name)
	{
		$index = array_search($name, $this->columns);

		if ($index !== false)
		{
			unset($this->columns[$index]);
			$this->columns = array_values($this->columns);
		}

		return $this;
	}

	/**
	 * Method to set a whole range of columns at once
	 * This can be used to re-order the columns, too
	 *
	 * @param   array  $columns  List of internal column names
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setColumns($columns)
	{
		$this->columns = array_values($columns);

		return $this;
	}

	/**
	 * Adds a row to the table and sets the currently
	 * active row to the new row
	 *
	 * @param   array  $options  Associative array of attributes for the row
	 * @param   int    $special  1 for a new row in the header, 2 for a new
row in the footer
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function addRow($options = array(), $special = false)
	{
		$this->rows[]['_row'] = $options;
		$this->activeRow = count($this->rows) - 1;

		if ($special)
		{
			if ($special === 1)
			{
				$this->specialRows['header'][] = $this->activeRow;
			}
			else
			{
				$this->specialRows['footer'][] = $this->activeRow;
			}
		}

		return $this;
	}

	/**
	 * Method to get the attributes of the currently active row
	 *
	 * @return array Associative array of attributes
	 *
	 * @since 1.7.3
	 */
	public function getRowOptions()
	{
		return $this->rows[$this->activeRow]['_row'];
	}

	/**
	 * Method to set the attributes of the currently active row
	 *
	 * @param   array  $options  Associative array of attributes
	 *
	 * @return JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowOptions($options)
	{
		$this->rows[$this->activeRow]['_row'] = $options;

		return $this;
	}

	/**
	 * Get the currently active row ID
	 *
	 * @return  int ID of the currently active row
	 *
	 * @since 1.7.3
	 */
	public function getActiveRow()
	{
		return $this->activeRow;
	}

	/**
	 * Set the currently active row
	 *
	 * @param   int  $id  ID of the row to be set to current
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setActiveRow($id)
	{
		$this->activeRow = (int) $id;

		return $this;
	}

	/**
	 * Set cell content for a specific column for the
	 * currently active row
	 *
	 * @param   string  $name     Name of the column
	 * @param   string  $content  Content for the cell
	 * @param   array   $option   Associative array of attributes for the
td-element
	 * @param   bool    $replace  If false, the content is appended to the
current content of the cell
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function setRowCell($name, $content, $option = array(), $replace =
true)
	{
		if ($replace || !isset($this->rows[$this->activeRow][$name]))
		{
			$cell = new stdClass;
			$cell->options = $option;
			$cell->content = $content;
			$this->rows[$this->activeRow][$name] = $cell;
		}
		else
		{
			$this->rows[$this->activeRow][$name]->content .= $content;
			$this->rows[$this->activeRow][$name]->options = $option;
		}

		return $this;
	}

	/**
	 * Get all data for a row
	 *
	 * @param   int  $id  ID of the row to return
	 *
	 * @return  array Array of columns of a table row
	 *
	 * @since 1.7.3
	 */
	public function getRow($id = false)
	{
		if ($id === false)
		{
			$id = $this->activeRow;
		}

		if (isset($this->rows[(int) $id]))
		{
			return $this->rows[(int) $id];
		}
		else
		{
			return false;
		}
	}

	/**
	 * Get the IDs of all rows in the table
	 *
	 * @param   int  $special  false for the standard rows, 1 for the header
rows, 2 for the footer rows
	 *
	 * @return  array Array of IDs
	 *
	 * @since 1.7.3
	 */
	public function getRows($special = false)
	{
		if ($special)
		{
			if ($special === 1)
			{
				return $this->specialRows['header'];
			}
			else
			{
				return $this->specialRows['footer'];
			}
		}

		return array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));
	}

	/**
	 * Delete a row from the object
	 *
	 * @param   int  $id  ID of the row to be deleted
	 *
	 * @return  JGrid This object for chaining
	 *
	 * @since 1.7.3
	 */
	public function deleteRow($id)
	{
		unset($this->rows[$id]);

		if (in_array($id, $this->specialRows['header']))
		{
			unset($this->specialRows['header'][array_search($id,
$this->specialRows['header'])]);
		}

		if (in_array($id, $this->specialRows['footer']))
		{
			unset($this->specialRows['footer'][array_search($id,
$this->specialRows['footer'])]);
		}

		if ($this->activeRow == $id)
		{
			end($this->rows);
			$this->activeRow = key($this->rows);
		}

		return $this;
	}

	/**
	 * Render the HTML table
	 *
	 * @return  string The rendered HTML table
	 *
	 * @since 1.7.3
	 */
	public function toString()
	{
		$output = array();
		$output[] = '<table' .
$this->renderAttributes($this->getTableOptions()) . '>';

		if (count($this->specialRows['header']))
		{
			$output[] =
$this->renderArea($this->specialRows['header'],
'thead', 'th');
		}

		if (count($this->specialRows['footer']))
		{
			$output[] =
$this->renderArea($this->specialRows['footer'],
'tfoot');
		}

		$ids = array_diff(array_keys($this->rows),
array_merge($this->specialRows['header'],
$this->specialRows['footer']));

		if (count($ids))
		{
			$output[] = $this->renderArea($ids);
		}

		$output[] = '</table>';

		return implode('', $output);
	}

	/**
	 * Render an area of the table
	 *
	 * @param   array   $ids   IDs of the rows to render
	 * @param   string  $area  Name of the area to render. Valid: tbody,
tfoot, thead
	 * @param   string  $cell  Name of the cell to render. Valid: td, th
	 *
	 * @return string The rendered table area
	 *
	 * @since 1.7.3
	 */
	protected function renderArea($ids, $area = 'tbody', $cell =
'td')
	{
		$output = array();
		$output[] = '<' . $area . ">\n";

		foreach ($ids as $id)
		{
			$output[] = "\t<tr" .
$this->renderAttributes($this->rows[$id]['_row']) .
">\n";

			foreach ($this->getColumns() as $name)
			{
				if (isset($this->rows[$id][$name]))
				{
					$column = $this->rows[$id][$name];
					$output[] = "\t\t<" . $cell .
$this->renderAttributes($column->options) . '>' .
$column->content . '</' . $cell . ">\n";
				}
			}

			$output[] = "\t</tr>\n";
		}

		$output[] = '</' . $area . '>';

		return implode('', $output);
	}

	/**
	 * Renders an HTML attribute from an associative array
	 *
	 * @param   array  $attributes  Associative array of attributes
	 *
	 * @return  string The HTML attribute string
	 *
	 * @since 1.7.3
	 */
	protected function renderAttributes($attributes)
	{
		if (count((array) $attributes) == 0)
		{
			return '';
		}

		$return = array();

		foreach ($attributes as $key => $option)
		{
			$return[] = $key . '="' . $option . '"';
		}

		return ' ' . implode(' ', $return);
	}
}