Portal Secure Messaging Audits
[openemr.git] / library / html2pdf / _class / exception.class.php
blobcab5ca427ec0f1fab5048145db02b8db67d29824
1 <?php
2 /**
3 * HTML2PDF Library - HTML2PDF Exception
5 * HTML => PDF convertor
6 * distributed under the LGPL License
8 * @package Html2pdf
9 * @author Laurent MINGUET <webmaster@html2pdf.fr>
10 * @copyright 2016 Laurent MINGUET
12 class HTML2PDF_exception extends exception
14 protected $_tag = null;
15 protected $_html = null;
16 protected $_other = null;
17 protected $_image = null;
18 protected $_messageHtml = '';
20 /**
21 * generate a HTML2PDF exception
23 * @param int $err error number
24 * @param mixed $other additionnal informations
25 * @param string $html additionnal informations
27 * @return HTML2PDF_exception
29 final public function __construct($err = 0, $other = null, $html = '')
31 // read the error
32 switch($err)
34 case 1: // Unsupported tag
35 $msg = (HTML2PDF_locale::get('err01'));
36 $msg = str_replace('[[OTHER]]', $other, $msg);
37 $this->_tag = $other;
38 break;
40 case 2: // too long sentence
41 $msg = (HTML2PDF_locale::get('err02'));
42 $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
43 $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
44 $msg = str_replace('[[OTHER_2]]', $other[2], $msg);
45 break;
47 case 3: // closing tag in excess
48 $msg = (HTML2PDF_locale::get('err03'));
49 $msg = str_replace('[[OTHER]]', $other, $msg);
50 $this->_tag = $other;
51 break;
53 case 4: // tags closed in the wrong order
54 $msg = (HTML2PDF_locale::get('err04'));
55 $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
56 break;
58 case 5: // unclosed tag
59 $msg = (HTML2PDF_locale::get('err05'));
60 $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
61 break;
63 case 6: // image can not be loaded
64 $msg = (HTML2PDF_locale::get('err06'));
65 $msg = str_replace('[[OTHER]]', $other, $msg);
66 $this->_image = $other;
67 break;
69 case 7: // too big TD content
70 $msg = (HTML2PDF_locale::get('err07'));
71 break;
73 case 8: // SVG tag not in DRAW tag
74 $msg = (HTML2PDF_locale::get('err08'));
75 $msg = str_replace('[[OTHER]]', $other, $msg);
76 $this->_tag = $other;
77 break;
79 case 9: // deprecated
80 $msg = (HTML2PDF_locale::get('err09'));
81 $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
82 $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
83 $this->_tag = $other[0];
84 break;
86 case 0: // specific error
87 default:
88 $msg = $other;
89 break;
92 // create the HTML message
93 $this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'."\n";
94 $this->_messageHtml.= HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>'."\n";
95 $this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>'."\n";
96 $this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>'."\n";
97 $this->_messageHtml.= '<br>'."\n";
98 $this->_messageHtml.= $msg."\n";
100 // create the text message
101 $msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg);
103 // add the optionnal html content
104 if ($html) {
105 $this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
106 $this->_html = $html;
107 $msg.= ' HTML : ...'.trim($html).'...';
110 // save the other informations
111 $this->_other = $other;
113 // construct the exception
114 parent::__construct($msg, $err);
118 * get the message as string
120 * @access public
121 * @return string $messageHtml
123 public function __toString()
125 return $this->_messageHtml;
129 * get the html tag name
131 * @access public
132 * @return string $tagName
134 public function getTAG()
136 return $this->_tag;
140 * get the optional html code
142 * @access public
143 * @return string $html
145 public function getHTML()
147 return $this->_html;
151 * get the optional other informations
153 * @access public
154 * @return mixed $other
156 public function getOTHER()
158 return $this->_other;
162 * get the image source
164 * @access public
165 * @return string $imageSrc
167 public function getIMAGE()
169 return $this->_image;