<commit_before><?php
// (c) Copyright 2002-2011 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$

function smarty_function_preference( $params, $smarty ) {
	global $prefslib, $prefs, $user_overrider_prefs; require_once 'lib/prefslib.php';
	if ( ! isset( $params['name'] ) ) {
		return 'Preference name not specified.';
	}

	$source = null;
	if ( isset( $params['source'] ) ) {
		$source = $params['source'];
	}
	$get_pages = isset( $params['get_pages']) && $params['get_pages'] != 'n' ? true : false;

	if ( $info = $prefslib->getPreference( $params['name'], true, $source, $get_pages ) ) {
		if ( isset($params['label']) ) {
			$info['name'] = $params['label'];
		}
		if (in_array($params['name'], $user_overrider_prefs) && isset($prefs[$params['name']])) {
			$info['value'] = $prefs['site_' . $params['name']];
		}

		if (isset($params['visible']) && $params['visible'] == 'always') {
			// Modified preferences are never hidden, so pretend it's modified when forcing display
			$info['tags'][] = 'modified';
			$info['tagstring'] .= ' modified';
		}

		if ($get_pages) {
			if (count($info['pages']) > 0) {
			$pages_string = tra(' (found in ');
			foreach($info['pages'] as $pg) {
				$ct_string = $pg[1] > 1 ? '&amp;cookietab=' . $pg[1] : '';
				$pages_string .= '<a class="lm_result" href="tiki-admin.php?page='.$pg[0].$ct_string.'&amp;highlight='.$info['preference'].'">' . $pg[0] . '</a>, ';
			}
			$pages_string = substr($pages_string, 0, strlen($pages_string) - 2);
			$pages_string .= ')';
			} else {
				$pages_string = tra('(not found in an admin panel)');
			}
		} else {
			$pages_string = '';
		}
		$info['pages'] = $pages_string;

		$smarty->assign( 'p', $info );

		if ( isset( $params['mode'] ) && $params['mode'] == 'invert' ) {
			$smarty->assign( 'mode', 'invert' );
		} else {
			$smarty->assign( 'mode', 'normal' );
		}
		
		//we reset the codemirror/syntax vars so that they are blank because they are reused for other params
		$smarty->assign( 'codemirror' );
		$smarty->assign( 'syntax' );
		
		if ( !empty( $params['syntax'] ) ) {
			$smarty->assign( 'codemirror', 'true' );
			$smarty->assign( 'syntax', $params['syntax'] );
		}
		
		return $smarty->fetch( 'prefs/' . $info['type'] . '.tpl' );
	} else {
		$info = array(
			'value' => tra('Error'),
			'default_val' => tra('Error'),
			'name' => tr( 'Preference %0 is not defined', $params['name'] ),
			'tags' => array('modified', 'basic', 'all'),
			'tagstring' => 'modified basic all',
		);
		if (strpos($_SERVER["SCRIPT_NAME"], 'tiki-edit_perspective.php') !== false) {
			$info['hint'] = tra('Drag this out of the perspective and resave it.');
		}
		$smarty->assign( 'p', $info );
		return $smarty->fetch( 'prefs/text.tpl' );
	}
}
<commit_msg>[FIX] prefs: Don't use global (site_*) value for overridden preferences if being used in a perspective, i.e. $params['source'] is set (corrects r36751)<commit_after><?php
// (c) Copyright 2002-2011 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$

function smarty_function_preference( $params, $smarty ) {
	global $prefslib, $prefs, $user_overrider_prefs; require_once 'lib/prefslib.php';
	if ( ! isset( $params['name'] ) ) {
		return 'Preference name not specified.';
	}

	$source = null;
	if ( isset( $params['source'] ) ) {
		$source = $params['source'];
	}
	$get_pages = isset( $params['get_pages']) && $params['get_pages'] != 'n' ? true : false;

	if ( $info = $prefslib->getPreference( $params['name'], true, $source, $get_pages ) ) {
		if ( isset($params['label']) ) {
			$info['name'] = $params['label'];
		}
		if ($source === null && in_array($params['name'], $user_overrider_prefs) && isset($prefs[$params['name']])) {
			$info['value'] = $prefs['site_' . $params['name']];
		}

		if (isset($params['visible']) && $params['visible'] == 'always') {
			// Modified preferences are never hidden, so pretend it's modified when forcing display
			$info['tags'][] = 'modified';
			$info['tagstring'] .= ' modified';
		}

		if ($get_pages) {
			if (count($info['pages']) > 0) {
			$pages_string = tra(' (found in ');
			foreach($info['pages'] as $pg) {
				$ct_string = $pg[1] > 1 ? '&amp;cookietab=' . $pg[1] : '';
				$pages_string .= '<a class="lm_result" href="tiki-admin.php?page='.$pg[0].$ct_string.'&amp;highlight='.$info['preference'].'">' . $pg[0] . '</a>, ';
			}
			$pages_string = substr($pages_string, 0, strlen($pages_string) - 2);
			$pages_string .= ')';
			} else {
				$pages_string = tra('(not found in an admin panel)');
			}
		} else {
			$pages_string = '';
		}
		$info['pages'] = $pages_string;

		$smarty->assign( 'p', $info );

		if ( isset( $params['mode'] ) && $params['mode'] == 'invert' ) {
			$smarty->assign( 'mode', 'invert' );
		} else {
			$smarty->assign( 'mode', 'normal' );
		}
		
		//we reset the codemirror/syntax vars so that they are blank because they are reused for other params
		$smarty->assign( 'codemirror' );
		$smarty->assign( 'syntax' );
		
		if ( !empty( $params['syntax'] ) ) {
			$smarty->assign( 'codemirror', 'true' );
			$smarty->assign( 'syntax', $params['syntax'] );
		}
		
		return $smarty->fetch( 'prefs/' . $info['type'] . '.tpl' );
	} else {
		$info = array(
			'value' => tra('Error'),
			'default_val' => tra('Error'),
			'name' => tr( 'Preference %0 is not defined', $params['name'] ),
			'tags' => array('modified', 'basic', 'all'),
			'tagstring' => 'modified basic all',
		);
		if (strpos($_SERVER["SCRIPT_NAME"], 'tiki-edit_perspective.php') !== false) {
			$info['hint'] = tra('Drag this out of the perspective and resave it.');
		}
		$smarty->assign( 'p', $info );
		return $smarty->fetch( 'prefs/text.tpl' );
	}
}

{'fraction_non_alphanumeric': 0.21552587646076796, 'fraction_numerical': 0.00651085141903172, 'mean_word_length': 3.9430693069306932, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 43, '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': '7472940', 'n_tokens_mistral': 2367, 'n_tokens_neox': 2129, 'n_words': 509}