0byt3m1n1-V2
Path:
/
home
/
magalijoj
/
www
/
blog
/
inc
/
core
/
[
Home
]
File: class.dc.error.php
<?php # ***** BEGIN LICENSE BLOCK ***** # This file is part of DotClear. # Copyright (c) 2005 Olivier Meunier and contributors. All rights # reserved. # # DotClear is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # DotClear is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with DotClear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ***** END LICENSE BLOCK ***** /** @ingroup DC_CORE @brief Error class dcError is a very simple error class, with a stack. Call dcError::add to add an error in stack. In administration area, errors are automatically displayed. */ class dcError { protected $errors = array(); ///< <b>array</b> Errors stack protected $flag = false; ///< <b>boolean</b> True if stack is not empty protected $html_list = "<ul>\n%s</ul>\n"; ///< <b>string</b> HTML errors list pattern protected $html_item = "<li>%s</li>\n"; ///< <b>string</b> HTML error item pattern /** Object constructor. */ public function __construct() { $this->code = 0; $this->msg = ''; } /** Object string representation. Returns errors stack. @return <b>string</b> */ public function __toString() { $res = ''; foreach ($this->errors as $msg) { $res .= $msg."\n"; } return $res; } /** Adds an error to stack. @param msg <b>string</b> Error message */ public function add($msg) { $this->flag = true; $this->errors[] = $msg; } /** Returns the value of <var>flag</var> property. @return <b>boolean</b> True if errors stack is not empty */ public function flag() { return $this->flag; } /** Resets errors stack. */ public function reset() { $this->flag = false; $this->errors = array(); } /** Returns <var>errors</var> property. @return <b>array</b> */ public function getErrors() { return $this->errors; } /** Sets <var>list</var> and <var>item</var> properties. @param list <b>string</b> HTML errors list pattern @param item <b>string</b> HTML error item pattern */ public function setHTMLFormat($list,$item) { $this->html_list = $list; $this->html_item = $item; } /** Returns errors stack as HTML. @return <b>string</b> */ public function toHTML() { $res = ''; if ($this->flag) { foreach ($this->errors as $msg) { $res .= sprintf($this->html_item,$msg); } $res = sprintf($this->html_list,$res); } return $res; } } ?>
©
2018.