Return to Snippet

Revision: 4680
at January 15, 2008 10:13 by LoRd1990


Initial Code
<?php
class errors{
	private $_data='';
	private $_handlingStarted=0;
	private $_error=0;

	function __construct()
	{
		$this->_data='<script type="text/javascript"><!--'."\n";
		$this->start();
		return true;
	}
	
	function started(){
		return($this->_handlingStarted);
	}
	
	function start(){
		$this->_handlingStarted=1;
	}
	
	function isError(){
		return $this->_error;
	}

 	function appendJSError($text){
		if(!$this->started()) return ERRORS_STREAM_NSET;
 		$this->_error=1;
		$this->_data.='alert("'.$text.'");'."\n";
 	}

 	function redirect($url){
    if(!$this->started()) return ERRORS_STREAM_NSET;
 		$this->_data.='window.location.href=\''.$url.'\';'."\n";
 	}

	function stopHandling()
	{
		$this->_data.='--></script>'."\n";
	}

	function outputData()
	{
    if(!$this->started()) return ERRORS_STREAM_NSET;
		$this->stopHandling();
		return $this->_data;
	}
}
?>

Initial URL
http://e-code.tnt43.com

Initial Description


Initial Title
Show messages about errors using generating JavaScript.

Initial Tags
javascript, js, php

Initial Language
PHP