Subversion Repositories oidplus

Rev

Rev 1215 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1215 Rev 1219
Line 37... Line 37...
37
         * @var string
37
         * @var string
38
         */
38
         */
39
        private $htmlMessage;
39
        private $htmlMessage;
40
 
40
 
41
        /**
41
        /**
42
         * @param $html
-
 
43
         * @return string
-
 
44
         */
-
 
45
        private static function htmlToText($html) {
-
 
46
                $html = str_replace("\n", "", $html);
-
 
47
                $html = str_ireplace('<br', "\n<br", $html);
-
 
48
                $html = str_ireplace('<p', "\n\n<p", $html);
-
 
49
                $html = strip_tags($html);
-
 
50
                $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
-
 
51
                return $html;
-
 
52
        }
-
 
53
 
-
 
54
        /**
-
 
55
         * @param string $message
42
         * @param string $message
56
         * @param string|null $title
43
         * @param string|null $title
57
         */
44
         */
58
        public function __construct(string $message, string $title=null) {
45
        public function __construct(string $message, string $title=null) {
59
                $this->htmlTitle = $title;
46
                $this->htmlTitle = $title;
60
                if ($title) {
47
                if ($title) {
61
                        $title = strip_tags($title);
48
                        $title = strip_tags($title);
62
                        $title_text = self::htmlToText($title);
49
                        $title_text = html_to_text($title);
63
                } else {
50
                } else {
64
                        $title_text = $title;
51
                        $title_text = $title;
65
                }
52
                }
66
 
53
 
67
                $this->htmlMessage = $message;
54
                $this->htmlMessage = $message;
68
                $message_text = self::htmlToText($message);
55
                $message_text = html_to_text($message);
69
 
56
 
70
                parent::__construct($message_text, $title_text);
57
                parent::__construct($message_text, $title_text);
71
        }
58
        }
72
 
59
 
73
        /**
60
        /**