<commit_before><?php

//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;
}

/*
 * smarty_function_button: Display a Tikiwiki button
 *
 * params will be used as params for as smarty self_link params, except those special params specific to smarty button :
 *	- _text: Text that will be shown in the button
 */
function smarty_function_button($params, &$smarty) {
	if ( ! is_array($params) || ! isset($params['_text']) ) return;
	global $tikilib, $prefs, $auto_query_args;
	$auto_query_args_orig = null;

	require_once $smarty->_get_plugin_filepath('block', 'self_link');
	
	$url_args = array();
	if ( ! empty($params['href']) ) {
		if ( ( $pos = strpos($params['href'], '?') ) !== false ) {
			$params['_script'] = substr($params['href'], 0, $pos);
			parse_str($tikilib->htmldecode(substr($params['href'], $pos+1)), $url_args);
			$params = array_merge($params, $url_args);
		} else {
			$params['_script'] = $params['href'];
		}
		unset($params['href']);
		if ( !empty($params['_auto_args']) ) {
			$auto_query_args_orig = $auto_query_args;
			$auto_query_args = explode(',', $params['_auto_args']);
		} else {
			$params['_noauto'] = 'y';
		}
	}

  // Remove params that does not start with a '_', since we don't want them to modify the URL
	foreach ( $params as $k => $v ) {
		if ( $k[0] != '_' ) unset($params[$k]);
	}

	$html = smarty_block_self_link(
		$params,
		$params['_text'],
		$smarty,
		false
	);

	if ( $auto_query_args_orig !== null ) $auto_query_args = $auto_query_args_orig;
	return '<span class="button">'.$html.'</span>';
}<commit_msg>[FIX] smarty button: fix param cleaning position that was destroying too much params...<commit_after><?php

//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;
}

/*
 * smarty_function_button: Display a Tikiwiki button
 *
 * params will be used as params for as smarty self_link params, except those special params specific to smarty button :
 *	- _text: Text that will be shown in the button
 *	- _auto_args: comma separated list of URL arguments that will be kept from _REQUEST (like $auto_query_args)
 */
function smarty_function_button($params, &$smarty) {
	if ( ! is_array($params) || ! isset($params['_text']) ) return;
	global $tikilib, $prefs, $auto_query_args;
	$auto_query_args_orig = null;

	require_once $smarty->_get_plugin_filepath('block', 'self_link');
	
	// Remove params that does not start with a '_', since we don't want them to modify the URL
	foreach ( $params as $k => $v ) {
		if ( $k[0] != '_' && $k != 'href' ) unset($params[$k]);
	}

	$url_args = array();
	if ( ! empty($params['href']) ) {
		if ( ( $pos = strpos($params['href'], '?') ) !== false ) {
			$params['_script'] = substr($params['href'], 0, $pos);
			parse_str($tikilib->htmldecode(substr($params['href'], $pos+1)), $url_args);
			$params = array_merge($params, $url_args);
		} else {
			$params['_script'] = $params['href'];
		}
		unset($params['href']);
		if ( !empty($params['_auto_args']) ) {
			$auto_query_args_orig = $auto_query_args;
			$auto_query_args = explode(',', $params['_auto_args']);
		} else {
			$params['_noauto'] = 'y';
		}
	}

	$html = smarty_block_self_link(
		$params,
		$params['_text'],
		$smarty,
		false
	);

	if ( $auto_query_args_orig !== null ) $auto_query_args = $auto_query_args_orig;
	return '<span class="button">'.$html.'</span>';
}
{'fraction_non_alphanumeric': 0.17885044642857142, 'fraction_numerical': 0.0016741071428571428, 'mean_word_length': 4.6545741324921135, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6326568', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1243, 'n_words': 311}