Location: PHPKode > projects > phpCAMALEO > common/fun2inc/form_errors.inc
<?PHP
/***************************************************************************
 *                            form_errors.inc
 *
 *	begin		: June 2004
 *	version		: 3 October 2006
 *	copyright	: (C) 2004,2006 grandolini.net
 *
 *	Build the error messages string
 *
 ***************************************************************************/

if(!function_exists('BuildErrorString'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Prepare error string
	function BuildErrorString($msg,$class=1000) 
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		global $error_msg; if(strspn($msg,'0123456789')==strlen($msg)) { $msg_txt=$error_msg[$msg].' ('.$msg.')'; } else { $msg_txt=$msg; }
		return('<fieldset class="err"><legend class="err" align="center">&nbsp;<img src="img/warning.gif" alt="WARNING!" />&nbsp;'.$error_msg[$class].'&nbsp;</legend>'.$msg_txt.'</fieldset>');
	}
}
if(!function_exists('show_error_msg'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Return error message
	function show_error_msg($msg,$form_name,$focus,$number,$xtra='')
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		global $error_msg; if(strspn($msg,'0123456789')==strlen($msg)) { $msg_txt=$error_msg[$msg].' ('.$msg.')'; } else { $msg_txt=$msg; }
		//v2//	$tmp = '<script type="text/javascript">'
		//v2//			."document.forms['$form_name'].$focus.setAttribute('id', 'rev'); "
		//v2//			."first_i_field='$focus'; " #."document.forms['$form_name'].elements['$focus'].focus(); "
		//v2//			."var errDisplay=document.getElementById('err_$number'); errDisplay.innerHTML='&nbsp;$msg_txt&nbsp;$xtra'; "
		//v2//			.'</script>';
		$tmp = '<script type="text/javascript">'
				."document.forms['$form_name'].$focus.setAttribute('id', 'rev'); "
				."first_i_field='$focus'; " #."document.forms['$form_name'].elements['$focus'].focus(); "
				."infotips('$msg_txt&nbsp;$xtra'); "
				.'</script>';
		return($tmp);
	}
}
if(!function_exists('BuildConfirmString'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	#	Prepare confirmation string
	function BuildConfirmString($tmp)
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		global $error_msg; 
		return('<fieldset class="form"><legend class="form" align="center">&nbsp;<img src="img/smile.gif" alt="SMILE =)" />&nbsp;'.$error_msg[1999].'&nbsp;</legend><div align="center">&nbsp;'.$error_msg[$tmp].'&nbsp;</div></fieldset>');
	}
}
?>
Return current item: phpCAMALEO