<commit_before><?php
// (c) Copyright 2002-2014 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

/**
 * Class Table_Code_Other
 *
 *Creates code for standard jQuery functions needed outside of the main Tablesorter functions
 *
 * @package Tiki
 * @subpackage Table
 * @uses Table_Code_Manager
 */
class Table_Code_Other extends Table_Code_Manager
{

	public function setCode()
	{
		$smarty = TikiLib::lib('smarty');
		$smarty->loadPlugin('smarty_function_icon');
		$jq = array();
		//column selector
		if (parent::$s['colselect']['type'] === true) {
			$htmlbefore[] = '<button id="' . parent::$s['colselect']['button']['id']
				. '" type="button" class="btn btn-default btn-sm" title="' . parent::$s['colselect']['button']['text']
				. '" style="margin-right:3px">' . smarty_function_icon(['name' => 'columns'], $smarty) . '</button>';
			$jq[] = '$(\'button#' . parent::$s['colselect']['button']['id'] . '\').popover({'
				. $this->nt2 . 'placement: \'auto right\','
				. $this->nt2 . 'html: true,'
				. $this->nt2 . 'content: \'<div id="' . parent::$s['colselect']['div']['id'] . '"></div>\''
				. $this->nt . '}).on(\'shown.bs.popover\', function () {'
				. $this->nt2 . '$.tablesorter.columnSelector.attachTo( $(\'' . parent::$tid
				. '\'), \'#' . parent::$s['colselect']['div']['id'] . '\');'
				. $this->nt . '});';
		}

			//reset sort button
		$sr = '';
		$x = array('reset' => '', 'savereset' => '');
		$s = parent::$s['sorts'];
		$s = isset($s['type']) && $s['type'] !== true && array_key_exists($s['type'], $x) ? $s : false;
		if ($s) {
			if ($s['type'] === 'savereset') {
				$sr = '.trigger(\'saveSortReset\')';
			}
			$jq[] = '$(\'button#' . $s['reset']['id'] . '\').click(function(){$(\'' . parent::$tid
				.'\').trigger(\'sortReset\')' . $sr . ';});';
			$htmlbefore[] = '<button id="' . $s['reset']['id']
				. '" type="button" class="btn btn-default btn-sm tips" title=":' . $s['reset']['text']
				.  '" style="margin-right:3px">' . smarty_function_icon(['name' => 'sort'], $smarty) . '</button>';
		}

		//filters
		if (parent::$filters) {
			$f = parent::$s['filters'];
			//reset button
			if ($f['type'] === 'reset') {
				$htmlbefore[] = '<button id="' . $f['reset']['id']
					. '" type="button" class="btn btn-default btn-sm tips" title=":' . $f['reset']['text'] . '">'
					. smarty_function_icon(['name' => 'filter'], $smarty) . '</button>';
			}

			//external dropdowns
			$options = array_column($f['external'], 'options');
			if (count($options) > 0) {
				foreach($f['external'] as $key => $info) {
					$xopt[] = ' value="" selected disabled>' . tr('Select a filter');
					foreach($info['options'] as $label => $val) {
						$xopt[] = ' value="' . $val . '">' . $label;
					}
					//create dropdown
					$divr[] = $this->iterate(
						$xopt,
						'<select id="' . $f['external'][$key]['id'] . '" class="form-control ts-external-select">',
						'</select>',
						'<option',
						'</option>',
						''
					);
					//trigger table update and filter when dropdown value is changed
					$jq[] = '$(\'#' . $f['external'][$key]['id'] . '\').bind(\'change\', function(e){'
						. $this->nt2 . '$(\'' . parent::$tid .'\').trigger(\'search\', [ [this.value] ]);'
						. $this->nt . '});';
					//filter-reset also clears any external dropdown filter (column filters cleared by tablesorter)
					if ($f['type'] === 'reset') {
						$reset[] = 'if ($(\'#' . $f['external'][$key]['id'] . '\').prop(\'selectedIndex\') != 0) {'
							. $this->nt3 . '$(\'#' . $f['external'][$key]['id'] . ' option\')[0].selected = true;'
							. $this->nt3 . '$(\'#' . $f['external'][$key]['id'] . '\').change();'
							. $this->nt2 . '}';
					}
				}
				unset($key, $info);
				if ($f['type'] === 'reset' && count($reset) > 0) {
					$jq[] = $this->iterate(
						$reset,
						'$(\'#' . $f['reset']['id'] . '\').click(function(){',
						$this->nt . '});',
						$this->nt2,
						'',
						''
					);
				}
				$htmlbefore[] = $this->iterate($divr, '<div style="float:right">', '</div>', '', '', '');
			}
		}


		$p = parent::$s['pager'];
		//pager controls
		if (parent::$pager) {
			$pagerdiv = array(
				'<div class="btn-group">',
					'<div class="btn-group">',
					'	<label for="gotoPage" class="selectlabels">Page</label>',
					'	<select id="gotoPage" class="gotoPage form-control"></select>',
					'</div>',
				'</div>',
				'<div class="btn-group middle">',
				'	<span class="first tips" title=":' . tr('First page') . '">',
				'		' . smarty_function_icon(['name' => 'backward_step'], $smarty),
				'	</span>',
				'	<span class="prev tips" title=":' . tr('Previous page') . '">',
				'		' . smarty_function_icon(['name' => 'backward'], $smarty),
				'	</span>',
				'	<span class="pagedisplay">',
				'	</span>',
				'	<span class="next tips" title=":' . tr('Next page') . '">',
				'		' . smarty_function_icon(['name' => 'forward'], $smarty),
				'	</span>',
				'	<span class="last tips" title=":' . tr('First page') . '">',
				'		' . smarty_function_icon(['name' => 'forward_step'], $smarty),
				'	</span>',
				'</div>',
			);
			foreach ($p['expand'] as $option) {
				$sel = $p['max'] === $option ? ' selected="selected"' : '';
				$opt[] = $sel . ' value="' . $option . '">' . $option;
			}
			unset($option);
			if (isset($opt)) {
				$pagerdiv[] = $this->iterate(
					$opt,
					'<div class="btn-group"><label for="pagesize" class="selectlabels">Rows</label><select id="pagesize" class="pagesize form-control">',
					'</select></div>',
					'<option',
					'</option>',
					''
				);
			}
			//put all pager controls in a div
			$pagerstring = $this->iterate(
				$pagerdiv,
				'<div id="' . $p['controls']['id'] . '" class="ts-pager ts-pager-top btn-toolbar">',
				'</div>',
				'',
				'',
				''
			);<commit_msg>[FIX] tablesorter: Fix wording for "last page" pager icon tooltip.<commit_after><?php
// (c) Copyright 2002-2014 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
	header('location: index.php');
	exit;
}

/**
 * Class Table_Code_Other
 *
 *Creates code for standard jQuery functions needed outside of the main Tablesorter functions
 *
 * @package Tiki
 * @subpackage Table
 * @uses Table_Code_Manager
 */
class Table_Code_Other extends Table_Code_Manager
{

	public function setCode()
	{
		$smarty = TikiLib::lib('smarty');
		$smarty->loadPlugin('smarty_function_icon');
		$jq = array();
		//column selector
		if (parent::$s['colselect']['type'] === true) {
			$htmlbefore[] = '<button id="' . parent::$s['colselect']['button']['id']
				. '" type="button" class="btn btn-default btn-sm" title="' . parent::$s['colselect']['button']['text']
				. '" style="margin-right:3px">' . smarty_function_icon(['name' => 'columns'], $smarty) . '</button>';
			$jq[] = '$(\'button#' . parent::$s['colselect']['button']['id'] . '\').popover({'
				. $this->nt2 . 'placement: \'auto right\','
				. $this->nt2 . 'html: true,'
				. $this->nt2 . 'content: \'<div id="' . parent::$s['colselect']['div']['id'] . '"></div>\''
				. $this->nt . '}).on(\'shown.bs.popover\', function () {'
				. $this->nt2 . '$.tablesorter.columnSelector.attachTo( $(\'' . parent::$tid
				. '\'), \'#' . parent::$s['colselect']['div']['id'] . '\');'
				. $this->nt . '});';
		}

			//reset sort button
		$sr = '';
		$x = array('reset' => '', 'savereset' => '');
		$s = parent::$s['sorts'];
		$s = isset($s['type']) && $s['type'] !== true && array_key_exists($s['type'], $x) ? $s : false;
		if ($s) {
			if ($s['type'] === 'savereset') {
				$sr = '.trigger(\'saveSortReset\')';
			}
			$jq[] = '$(\'button#' . $s['reset']['id'] . '\').click(function(){$(\'' . parent::$tid
				.'\').trigger(\'sortReset\')' . $sr . ';});';
			$htmlbefore[] = '<button id="' . $s['reset']['id']
				. '" type="button" class="btn btn-default btn-sm tips" title=":' . $s['reset']['text']
				.  '" style="margin-right:3px">' . smarty_function_icon(['name' => 'sort'], $smarty) . '</button>';
		}

		//filters
		if (parent::$filters) {
			$f = parent::$s['filters'];
			//reset button
			if ($f['type'] === 'reset') {
				$htmlbefore[] = '<button id="' . $f['reset']['id']
					. '" type="button" class="btn btn-default btn-sm tips" title=":' . $f['reset']['text'] . '">'
					. smarty_function_icon(['name' => 'filter'], $smarty) . '</button>';
			}

			//external dropdowns
			$options = array_column($f['external'], 'options');
			if (count($options) > 0) {
				foreach($f['external'] as $key => $info) {
					$xopt[] = ' value="" selected disabled>' . tr('Select a filter');
					foreach($info['options'] as $label => $val) {
						$xopt[] = ' value="' . $val . '">' . $label;
					}
					//create dropdown
					$divr[] = $this->iterate(
						$xopt,
						'<select id="' . $f['external'][$key]['id'] . '" class="form-control ts-external-select">',
						'</select>',
						'<option',
						'</option>',
						''
					);
					//trigger table update and filter when dropdown value is changed
					$jq[] = '$(\'#' . $f['external'][$key]['id'] . '\').bind(\'change\', function(e){'
						. $this->nt2 . '$(\'' . parent::$tid .'\').trigger(\'search\', [ [this.value] ]);'
						. $this->nt . '});';
					//filter-reset also clears any external dropdown filter (column filters cleared by tablesorter)
					if ($f['type'] === 'reset') {
						$reset[] = 'if ($(\'#' . $f['external'][$key]['id'] . '\').prop(\'selectedIndex\') != 0) {'
							. $this->nt3 . '$(\'#' . $f['external'][$key]['id'] . ' option\')[0].selected = true;'
							. $this->nt3 . '$(\'#' . $f['external'][$key]['id'] . '\').change();'
							. $this->nt2 . '}';
					}
				}
				unset($key, $info);
				if ($f['type'] === 'reset' && count($reset) > 0) {
					$jq[] = $this->iterate(
						$reset,
						'$(\'#' . $f['reset']['id'] . '\').click(function(){',
						$this->nt . '});',
						$this->nt2,
						'',
						''
					);
				}
				$htmlbefore[] = $this->iterate($divr, '<div style="float:right">', '</div>', '', '', '');
			}
		}


		$p = parent::$s['pager'];
		//pager controls
		if (parent::$pager) {
			$pagerdiv = array(
				'<div class="btn-group">',
					'<div class="btn-group">',
					'	<label for="gotoPage" class="selectlabels">Page</label>',
					'	<select id="gotoPage" class="gotoPage form-control"></select>',
					'</div>',
				'</div>',
				'<div class="btn-group middle">',
				'	<span class="first tips" title=":' . tr('First page') . '">',
				'		' . smarty_function_icon(['name' => 'backward_step'], $smarty),
				'	</span>',
				'	<span class="prev tips" title=":' . tr('Previous page') . '">',
				'		' . smarty_function_icon(['name' => 'backward'], $smarty),
				'	</span>',
				'	<span class="pagedisplay">',
				'	</span>',
				'	<span class="next tips" title=":' . tr('Next page') . '">',
				'		' . smarty_function_icon(['name' => 'forward'], $smarty),
				'	</span>',
				'	<span class="last tips" title=":' . tr('Last page') . '">',
				'		' . smarty_function_icon(['name' => 'forward_step'], $smarty),
				'	</span>',
				'</div>',
			);
			foreach ($p['expand'] as $option) {
				$sel = $p['max'] === $option ? ' selected="selected"' : '';
				$opt[] = $sel . ' value="' . $option . '">' . $option;
			}
			unset($option);
			if (isset($opt)) {
				$pagerdiv[] = $this->iterate(
					$opt,
					'<div class="btn-group"><label for="pagesize" class="selectlabels">Rows</label><select id="pagesize" class="pagesize form-control">',
					'</select></div>',
					'<option',
					'</option>',
					''
				);
			}
			//put all pager controls in a div
			$pagerstring = $this->iterate(
				$pagerdiv,
				'<div id="' . $p['controls']['id'] . '" class="ts-pager ts-pager-top btn-toolbar">',
				'</div>',
				'',
				'',
				''
			);
{'fraction_non_alphanumeric': 0.271594953089615, 'fraction_numerical': 0.003720478809446781, 'mean_word_length': 3.055428009183339, 'pattern_counts': {'":': 12, '<': 93, '<?xml version=': 0, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298508', 'n_tokens_mistral': 5243, 'n_tokens_neox': 4380, 'n_words': 869}