/* require_once("./lib/CAtcErr.php"); */ //////////////////////////////////////////////////////////////////////////////// class CAtcErr { private $m_ary_err; private $m_ary_note; //------------------------------------------------------------- function __construct(){ $this->m_ary_err = array(); $this->m_ary_note = array(); } ////////////////////////////////////////////////////////////////////////////// // ■エラーメッセージ登録 public function append($file, $line, $msg="") { $disp_file = ''; $disp_line = ''; //-------------------------------------------------------------------------- if($file != ''){ $disp_file = '['.basename($file).']'; } //-------------------------------------------------------------------------- if($line != ''){ $disp_line = '['.$line.']'; } //-------------------------------------------------------------------------- $this->m_ary_err[] = 'ERROR: '.$msg.' '.$disp_file.$disp_line; } ////////////////////////////////////////////////////////////////////////////// // ■正常系メッセージ登録 public function note($msg) { $this->m_ary_note[] = $msg; } ////////////////////////////////////////////////////////////////////////////// // ■全メッセージを出力 : echo出力 public function disp_array($is_plane=FALSE) { foreach($this->m_ary_err as $msg){ $disp_msg = mb_convert_encoding($msg, 'UTF-8', 'auto'); if($is_plane === TRUE){ echo $disp_msg."\n"; }else{ echo "
".$disp_msg."
\n"; } } foreach($this->m_ary_note as $msg){ $disp_msg = mb_convert_encoding($msg, 'UTF-8', 'auto'); if($is_plane === TRUE){ echo $disp_msg."\n"; }else{ echo "".$disp_msg."
\n"; } } } ////////////////////////////////////////////////////////////////////////////// // ■全メッセージを出力 : 文字列を返す。 public function get_array_all() { $ret = ''; foreach($this->m_ary_err as $disp_msg){ $ret .= "".$disp_msg."
\n"; } foreach($this->m_ary_note as $disp_msg){ $ret .= "".$disp_msg."
\n"; } return $ret; } ////////////////////////////////////////////////////////////////////////////// // ■エラー系メッセージを取得 public function get_array($is_plane=FALSE) { $html_ret = ""; foreach($this->m_ary_err as $msg){ $disp_msg = mb_convert_encoding($msg, 'UTF-8', 'auto'); if($is_plane === TRUE){ echo $disp_msg."\n"; }else{ $html_ret .= "".$disp_msg."
\n"; } } return $html_ret; } ////////////////////////////////////////////////////////////////////////////// // [static] public static function display($file, $line, $msg="") { if(strlen($file) > 0){ $fbody = basename($file); }else{ $fbody = ""; } $disp_msg = mb_convert_encoding($msg, 'UTF-8', 'auto'); echo "ERROR: ".$disp_msg." [".$fbody."][".$line."]
"; } ////////////////////////////////////////////////////////////////////////////// // [static] public static function dispL($line, $msg='') { echo "[{$line}] {$msg}
"; } ////////////////////////////////////////////////////////////////////////////// // [static] エラーメッセージを出力するだけのHTMLを出力 public static function dispErrorPage($disp_msg) { echo <<< EOM{$disp_msg}
EOM; } } ?>