diff options
author | Urban Müller | 2021-11-09 16:14:34 +0100 |
---|---|---|
committer | Urban Müller | 2021-11-09 16:14:34 +0100 |
commit | 9a743ca0f69d11a5bee037aeb2573100d9c073ff (patch) | |
tree | 44b70b2bfd875adaece2c3b8b4d34910041b194c /it_xml.class | |
parent | 00a99269fcc70cd5710a0268ec045261e97d52dc (diff) | |
download | itools-9a743ca0f69d11a5bee037aeb2573100d9c073ff.tar.gz itools-9a743ca0f69d11a5bee037aeb2573100d9c073ff.tar.bz2 itools-9a743ca0f69d11a5bee037aeb2573100d9c073ff.zip |
allow generic it_error params
Diffstat (limited to 'it_xml.class')
-rw-r--r-- | it_xml.class | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/it_xml.class b/it_xml.class index 2a138d7..24970ba 100644 --- a/it_xml.class +++ b/it_xml.class @@ -26,7 +26,8 @@ class it_xml * @param $xmldata XML string or filehandle (result from fopen) to parse * @param $p associative array * @param $p['forcearray'] xml tags to ALWAYS return as array - * @param $p['safety'] 2 causes program abort with invalid xml, 1 (default) causes error report, 0 just returns false + * @param $p['safety'] OBSOLETE, see it_error. (0 = ignore errs, 1 = report errs, 2 = abort on errs) + * @param $p['it_error'] Parameters for it_errors on parsing problems * @param $p['encoding'] Output character encoding (utf-8, iso-8859-1 or us-ascii, default: ini_get('default_charset') * @param $p['prefix'] Optional prefix for class names * @param $p['lowercase'] Lowercase all tag and attribute names @@ -53,7 +54,8 @@ static function create($xmldata, $p = array()) function from_xml($xmldata, $p) { - $this->_p = $p + array('encoding' => ini_get('default_charset'), 'safety' => 1); + $p += ['encoding' => ini_get('default_charset'), 'it_error' => !$p['safety'] ? false : ($p['safety'] == 2 ? ['fatal' => true] : [])]; + $this->_p = $p; $this->_arrayforce = array_flip((array)$this->_p['forcearray']); $this->_stack = array(); unset($this->error); @@ -94,16 +96,13 @@ function from_xml($xmldata, $p) if ($this->error) { - if ($this->_p['safety'] >= 2) - it::fatal(array('title' => $this->error, 'body' => $xmlorig)); - else if ($this->_p['safety'] >= 1) - it::error(array('title' => $this->error, 'body' => $xmlorig)); + it::error((array)$p['it_error'] + ['title' => $this->error, 'body' => $xmlorig]); if ($this->_p['factory']) $GLOBALS['IT_XML_ERROR'] = $this->error; } - unset($this->_arrayforce, $this->_p['safety'], $this->_p['factory'], $this->_stack); + unset($this->_arrayforce, $this->_p['safety'], $this->_p['it_error'], $this->_p['factory'], $this->_stack); xml_parser_free($parser); return empty($this->error); |