... // errors define('TWE_SYNTAX', 0x0100); // null, HTML syntax error (for future strict bases) define('TWE_TOO_MANY_ATTRS', 0x0200); // tag_name, too many attrs in tag .. // internal errors define('TWE_FILE_NOT_FOUND', 0x1000); // param1 = file define('TWE_BAD_SIGNATURE', 0x2000); // param1 = language, param2 = signature define('TWE_LANG_NOT_FOUND', 0x3000); // param1 = language // indexes to ErrorArray define('TWE_ERRNO', 0); // error value define('TWE_PARAM1', 1); // parameter 1 define('TWE_PARAM2', 2); // parameter 2 define('TWE_POSIT', 3); // position in source define('TWE_CODE', 4); // piece of bad code class TW_errors { var $IsError; var $ErrorArray; var $identifier; /* class constructor */ function TW_errors($options = 0) { $this->IsError = 0; $this->ErrorArray = null; $this->identifier = 0; } function is_error() { return $this->IsError; } function get_err_array() { return $this->ErrorArray; } function get_comments() { return $this->get_by_mask(0x000f); } function get_warnings() { return $this->get_by_mask(0x00f0); } function get_errors() { return $this->get_by_mask(0x0f00); } function get_internal() { return $this->get_by_mask(0xf000); } function get_by_mask($mask) { $ErrTemp = null; foreach($this->ErrorArray as $key => $value) { if($value[TWE_ERRNO] & $mask) $ErrTemp[$key] = $value; } return $ErrTemp; } /* Input: * id: error id, * lang: error_language_array * * Outupt: * error text or null */ function get_error_text ( $id, &$lang ) { if( in_array($id, $this->ErrorArray) ) { $errno = $this->ErrorArray[$id][TWE_ERRNO]; if( in_array($errno,$lang) ) return sprintf( $lang[$errno], $this->ErrorArray[$id][TWE_PARAM1], $this->ErrorArray[$id][TWE_PARAM2] ); else return sprintf( "Please translate errno 0x%x.",$errno ); } return null; } } // END class TW_errors ?>