Location: PHPKode > scripts > Zquery > zquery/inc.zquery.class.php
<?php
/*
class to send $_GET or $_POST data via AJAX to a .php file as processor

function write_jquery() 
	includes the jquery javascript; this is a regular jquery minified plus other javascript to process the whole thing
	
function zget($process_url, $question='')
	calls javascript funtion for processing $_GET data
	1st argument is the .php file that will process the data
	2nd argument is (optional) the question will be asked.
	
function zpost($process_url, $form_id, $question='')
	calls javascript funtion for processing $_POST data
	1st argument is the .php file that will process the data
	2nd argument is the id of the form to process
	3rd argument is (optional) the question will be asked.
	
function zerr($msg)
	Send a message to screen as error (red coloured)
	
function zok($msg)
	Send a message to screen as succeed (green coloured)
	
function zjq($jq)
	let execute some extra javascript
	
function zdebug()
	if called, dumps to screen the values inside $_SESSION, $_POST and $_GET
	
function zload($url, $tagid)
	if called, dumps to screen inside the given $tagid (e.g. DIV or SPAN tag) the data outputted by the file given as $URL
	
function zpost_and_show($processor,$formid,$tagid, $question='')
	if called, processes with POST methode a form and dumps to screen inside the given $tagid (e.g. DIV or SPAN tag) the data outputted by the file given as $processor; it allows to ask a question before processing

function zget_and_show($processor,$formid,$tagid, $question='')
	if called, processes with GET methode via a link and  dumps to screen inside the given $tagid (e.g. DIV or SPAN tag) the data outputted by the file given as $processor; it allows to ask a question before processing
*/
class zquery
{
	var $jquery = 'zquery1.3.2.min.js';
	var $debug = FALSE;
	
	function write_jquery()
	{
		
		echo('<script language="javascript" src="'.$this->jquery.'">'.$js.'</script>').chr(10).chr(13);
		// for more browser comp
		echo('<style>'.chr(10).'body>div.zqueryWrapper {position: fixed}'.chr(10).'</style>');
		
	}
	
	function zget($process_url, $question='')
	{
		
		echo("$.getdata('{$process_url}', '{$question}')");
		
	}
	
	function zpost($process_url, $form_id, $question='')
	{
		
		echo("$.postdata('{$process_url}','{$form_id}','{$question}')");
		
	}
	
	function zerr($msg)
	{
		$this->zdebug();
		echo ('<script language="javascript">var zqueryError = true;</script>');
		echo (stripslashes($msg));
		// after some time, if no clicked the message disappers
		echo ('<script language="javascript">var zqueryTimeout = setTimeout( "$(\'#zqueryWrapper\').fadeOut(400);" , 10000);</script>');
	}
	
	function zok($msg)
	{
		
		$this->zdebug();
		echo ('<script language="javascript">var zqueryError = false;</script>');
		echo (stripslashes($msg));
		// after some time, if no clicked the message disappers
		echo ('<script language="javascript">var zqueryTimeout = setTimeout( "$(\'#zqueryWrapper\').fadeOut(400);" , 10000);</script>');
	}
	
	function zpost_and_show($processor,$formid,$tagid, $question='')
	{
		
		echo("$.postandshow('{$processor}','{$formid}','{$tagid}','{$question}');");
		
	}
	
	function zget_and_show($processor,$tagid, $question='')
	{
		
		echo("$.getandshow('{$processor}','{$tagid}','{$question}');");
		
	}
	
	function zload($url, $tagid)
	{
		
		// hiding tag for later animation
		echo('<script language="javascript">$("#'.$tagid.'").css({\'display\' : \'none\'})</script>');
		
		// two lines below for avoiding IE caching
		(strpos($url, '?') !== false) ? $join = '&' : $join = '?';
		
		$nr = rand(1,1000);
		
		echo('<script language="javascript">$("#'.$tagid.'").load("'.$url.$join.'zqnr='.$nr.')")</script>');
		
		// animates the content
		echo('<script language="javascript">$("#'.$tagid.'").slideDown(800)</script>');
		
	}
	
	function zjq($jq)
	{
		echo ('<script language="javascript">'.stripslashes($jq).'</script>');
	}
	
	function zdebug_onoff($flag)
	{
		
		if($flag == TRUE) $this->debug = TRUE;
		
	}
	
	function zdebug()
	{
		if($this->debug == TRUE):
		
			echo('<p>Debugging mode is ON; if you do not want it remove in the code: ->zdebug_onoff(TRUE)</p>');
			echo('<pre style="text-align: left; background-color: #fff; font-family: Arial; font-size: 12px; padding:2px; line-height:20px; letter-spacing:1px;">');
			echo('<strong>SESSION</strong>').chr(10);
			print_r($_SESSION);
			echo('<br />').chr(10);
			echo('<strong>POST</strong>').chr(10);
			print_r($_POST);
			echo('<br />').chr(10);
			echo('<strong>GET</strong>').chr(10);
			print_r($_GET);
			echo('</pre>');
		
		endif;
	}
	
}
?>
Return current item: Zquery