⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paterrormanager.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
	/**	* translate an error level	*	* returns the human-readable name for an error level,	* e.g. E_ERROR will be translated to 'Error'.	*	* @access	public	* @param	integer		error level	* @return	string		human-readable representation	*/	function translateErrorLevel( $level )	{		if( isset( $GLOBALS['_pat_errorLevels'][$level] ) )		{			return	$GLOBALS['_pat_errorLevels'][$level];		}		return	'Unknown error level';	}	/**	* setErrorClass	*	* In order to autoload this class, the filename containing that class must be	* named like the class itself; with an appending ".php". Although the file must be stored	* in the same directory as patErrorManager.php (this file)	*	* @access public	* @param string $name classname	* @return boolean $result true on success	*/    function setErrorClass( $name )    {		// include old error-class		if( $name !== $GLOBALS['_pat_errorClass'] && !class_exists( $GLOBALS['_pat_errorClass'] ) )		{			include_once dirname( __FILE__ ) . '/' . $GLOBALS['_pat_errorClass'] . '.php';		}		$GLOBALS['_pat_errorClass']	=	$name;		return true;    }	/**	* add error codes to be ingored	*	* @static	* @access public	* @param mixed $codes either an array of error code or a single code that will be ignored in future	* @return boolean $result true on success	*/    function addIgnore( $codes )    {		if( !is_array( $codes ) )		{			$codes	=	array( $codes );		}		$codes							=	array_merge( $GLOBALS['_pat_errorIgnores'], $codes );		$GLOBALS['_pat_errorIgnores']	=	array_unique( $codes );		return true;    }	/**	* removeIgnore	*	*	* @static	* @access public	* @return boolean $result true on success	*/    function removeIgnore( $codes )    {		if( !is_array( $codes ) )		{			$codes	=	array( $codes );		}		foreach( $codes as $code )		{			$index	=	array_search( $code, $GLOBALS['_pat_errorIgnores'] );			if( $index === false )			{				continue;			}			unset( $GLOBALS['_pat_errorIgnores'][$index] );		}		// reorder the codes		$GLOBALS['_pat_errorIgnores']	=	array_values( $GLOBALS['_pat_errorIgnores'] );		return true;    }	/**	* recieve all registerd error codes that will be ignored	*	* @static	* @access public	* @return array $codes list of error codes	*/    function getIgnore()    {		return $GLOBALS['_pat_errorIgnores'];    }	/**	* empty list of errors to be ignored	*	* @static	* @access public	* @return boolean $result true on success	*/    function clearIgnore()    {		$GLOBALS['_pat_errorIgnores']	=	array();		return true;    }	/**	* add expected errors to stack	*	* @static	* @access public	* @param mixed $codes either an array of error code or a single code that will be ignored in future	* @return boolean $result true on success	*/    function pushExpect( $codes )    {		if( !is_array( $codes ) )		{			$codes	=	array( $codes );		}		array_push( $GLOBALS['_pat_errorExpects'], $codes );		return true;    }	/**	* remove top of error-codes from stack	*	* @static	* @access public	* @return boolean $result true on success	*/    function popExpect()    {		if( empty( $GLOBALS['_pat_errorExpects'] ) )		{			return false;		}		array_pop( $GLOBALS['_pat_errorExpects'] );		return true;    }	/**	* recieve all registerd error codes that will be ignored	*	* @static	* @access public	* @return array $codes list of error codes	*/    function getExpect()    {		return $GLOBALS['_pat_errorExpects'];    }	/**	* empty list of errors to be ignored	*	* @static	* @access public	* @return boolean $result true on success	*/    function clearExpect()    {		$GLOBALS['_pat_errorExpects']	=	array();		return true;    }	/**	* handleError: Ignore	* Does nothing	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorIgnore( &$error, $options )    {		return $error;    }	/**	* handleError: Echo	* display error message	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorEcho( &$error, $options )    {		$level_human	=	patErrorManager::translateErrorLevel( $error->getLevel() );		if( isset( $_SERVER['HTTP_HOST'] ) )		{			// output as html			echo "<br /><b>pat-$level_human</b>: " . $error->getMessage() . "<br />\n";		}		else		{			// output as simple text			if( defined( 'STDERR' ) )			{				fwrite( STDERR, "pat-$level_human: " . $error->getMessage() . "\n" );			}			else			{				echo "pat-$level_human: " . $error->getMessage() . "\n";			}		}		return $error;    }	/**	* handleError: Verbose	* display verbose output for developing purpose	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorVerbose( &$error, $options )    {		$level_human	=	patErrorManager::translateErrorLevel( $error->getLevel() );		$info			=	$error->getInfo();		if( isset( $_SERVER['HTTP_HOST'] ) )		{			// output as html			echo "<br /><b>pat-$level_human</b>: " . $error->getMessage() . "<br />\n";			if( $info != null )			{				echo "&nbsp;&nbsp;&nbsp;" . $error->getInfo() . "<br />\n";			}			echo $error->getBacktrace( true );		}		else		{			// output as simple text			echo "pat-$level_human: " . $error->getMessage() . "\n";			if( $info != null )			{				echo "    " . $error->getInfo() . "\n";			}		}		return $error;    }	/**	* handleError: die	* display error-message and die	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorDie( &$error, $options )    {		$level_human	=	patErrorManager::translateErrorLevel( $error->getLevel() );		if( isset( $_SERVER['HTTP_HOST'] ) )		{			// output as html			jexit( "<br /><b>pat-$level_human</b> " . $error->getMessage() . "<br />\n" );		}		else		{			// output as simple text			if( defined( 'STDERR' ) )			{				fwrite( STDERR, "pat-$level_human " . $error->getMessage() . "\n" );			}			else			{				jexit( "pat-$level_human " . $error->getMessage() . "\n" );			}		}		return $error;    }	/**	* handleError: trigger	* trigger php-error	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorTrigger( &$error, $options )    {		switch( $error->getLevel() )		{			case	E_NOTICE:				$level	=	E_USER_NOTICE;				break;			case	E_WARNING:				$level	=	E_USER_WARNING;				break;			case	E_NOTICE:				$level =	E_NOTICE;				break;			default:				$level	=	E_USER_ERROR;				break;		}		trigger_error( $error->getMessage(), $level );		return $error;    }	/**	* handleError: callback	* forward error to custom handler	*	* @access private	* @param object $error patError-Object	* @param array $options options for handler	* @return object $error error-object	* @see raise()	*/    function &handleErrorCallback( &$error, $options )    {		$opt	= $options['options'];		$result = &call_user_func( $opt, $error );		return $result;    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -