function.preference.php 519 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php

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

	if( $info = $prefslib->getPreference( $params['name'] ) ) {
		if( isset($params['label']) ) {
			$info['name'] = $params['label'];
		}

		$smarty->assign( 'p', $info );
		return $smarty->fetch( 'prefs/' . $info['type'] . '.tpl' );
	} else {
		return tr( 'Preference %0 is not defined.', $params['name'] );
	}
}