1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
convertorspregreplacehelper.php
См. документацию.
1<?php
2
4
6{
7 private $codeMessage = "";
8 private $quoteOpened = 0;
9 private $quoteClosed = 0;
10 private $quoteError = 0;
11 private $quoteTableClass = "";
12 private $quoteHeadClass = "";
13 private $quoteBodyClass = "";
14 private $linkClass = "";
15 private $linkTarget = "_self";
16 private $codeTableClass = "";
17 private $codeHeadClass = "";
18 private $codeBodyClass = "";
19 private $codeTextClass = "";
20
21 function __construct($codeMessage = "")
22 {
23 $this->codeMessage = $codeMessage;
24 }
25
26 public function convertCodeTagForEmail($match)
27 {
28 $text = is_array($match)? $match[2]: $match;
29 if ($text == '')
30 return '';
31
32 $text = str_replace(array("<",">"), array("&lt;","&gt;"), $text);
33 $text = preg_replace("#^(.*?)$#", " \\1", $text);
34
35 $s1 = "--------------- ".$this->codeMessage." -------------------";
36 $s2 = str_repeat("-", mb_strlen($s1));
37 $text = "\n\n>".$s1."\n".$text."\n>".$s2."\n\n";
38
39 return $text;
40 }
41
42 public function checkQuoteError()
43 {
44 return (($this->quoteOpened == $this->quoteClosed) && ($this->quoteError == 0));
45 }
46
47 public function setQuoteClasses($tableClass, $headClass, $bodyClass)
48 {
49 $this->quoteTableClass = $tableClass;
50 $this->quoteHeadClass = $headClass;
51 $this->quoteBodyClass = $bodyClass;
52 }
53
54 public function convertOpenQuoteTag($match)
55 {
56 $this->quoteOpened++;
57 return "<table class='".$this->quoteTableClass."' width='95%' border='0' cellpadding='3' cellspacing='1'><tr><td class='".$this->quoteHeadClass."'>".GetMessage("CONV_MAIN_QUOTE")."</td></tr><tr><td class='".$this->quoteBodyClass."'>";
58 }
59
60 public function convertCloseQuoteTag()
61 {
62 if ($this->quoteOpened == 0)
63 {
64 $this->quoteError++;
65 return '';
66 }
67 $this->quoteClosed++;
68 return "</td></tr></table>";
69 }
70
71 public function convertQuoteTag($match)
72 {
73 $this->quoteOpened = 0;
74 $this->quoteClosed = 0;
75 $this->quoteError = 0;
76
77 $str = $match[0];
78 $str = preg_replace_callback("#\\[quote\\]#i", array($this, "convertOpenQuoteTag"), $str);
79 $str = preg_replace_callback("#\\[/quote\\]#i", array($this, "convertCloseQuoteTag"), $str);
80
81 if ($this->checkQuoteError())
82 return $str;
83 else
84 return $match[0];
85 }
86
87 public static function extractUrl($match)
88 {
89 return extract_url(str_replace('@', chr(11), $match[1]));
90 }
91
92 public function setLinkClass($linkClass)
93 {
94 $this->linkClass = $linkClass;
95 }
96
97 public function setLinkTarget($linkTarget)
98 {
99 $this->linkTarget = $linkTarget;
100 }
101
108 public function setEvents($event1="", $event2="", $event3="")
109 {
110 }
111
116 public function setScript($script)
117 {
118 }
119
120 public function convertToMailTo($match)
121 {
122 $s = $match[1];
123 $s = "<a class=\"".$this->linkClass."\" href=\"mailto:".delete_special_symbols($s)."\" title=\"".GetMessage("CONV_MAIN_MAILTO")."\">".$s."</a>";
124 return $s;
125 }
126
127 public function convertToHref($match)
128 {
129 $url = $match[1];
130
131 $target = $this->linkTarget == '_self'? '': ' target="'.$this->linkTarget.'"';
132
133 $s = "<a class=\"".$this->linkClass."\" href=\"".delete_special_symbols($url)."\"".$target.">".$url."</a>";
134
135 return $s;
136 }
137
138 public function setCodeClasses($tableClass, $headClass, $bodyClass, $textAreaClass)
139 {
140 $this->codeTableClass = $tableClass;
141 $this->codeHeadClass = $headClass;
142 $this->codeBodyClass = $bodyClass;
143 $this->codeTextClass = $textAreaClass;
144 }
145
146 public function convertCodeTagForHtmlBefore($text = "")
147 {
148 if (is_array($text))
149 $text = $text[2];
150 if ($text == '')
151 return '';
152
153 $text = str_replace(chr(2), "", $text);
154 $text = str_replace("\n", chr(4), $text);
155 $text = str_replace("\r", chr(5), $text);
156 $text = str_replace(" ", chr(6), $text);
157 $text = str_replace("\t", chr(7), $text);
158 $text = str_replace("http", "!http!", $text);
159 $text = str_replace("https", "!https!", $text);
160 $text = str_replace("ftp", "!ftp!", $text);
161 $text = str_replace("@", "!@!", $text);
162
163 $text = str_replace(Array("[","]"), array(chr(16), chr(17)), $text);
164
165 $return = "[code]".$text."[/code]";
166
167 return $return;
168 }
169
170 public function convertCodeTagForHtmlAfter($text = "")
171 {
172 if (is_array($text))
173 $text = $text[1];
174 if ($text == '')
175 return '';
176
177 $code_mess = GetMessage("CONV_MAIN_CODE");
178 $text = str_replace("!http!", "http", $text);
179 $text = str_replace("!https!", "https", $text);
180 $text = str_replace("!ftp!", "ftp", $text);
181 $text = str_replace("!@!", "@", $text);
182
183 $return = "<table class='".$this->codeTableClass."'><tr><td class='".$this->codeHeadClass."'>$code_mess</td></tr><tr><td class='".$this->codeBodyClass."'><textarea class='".$this->codeTextClass."' contentEditable=false cols=60 rows=15 wrap=virtual>$text</textarea></td></tr></table>";
184
185 return $return;
186 }
187}
setEvents($event1="", $event2="", $event3="")
__construct($codeMessage="")
Определения convertorspregreplacehelper.php:21
setQuoteClasses($tableClass, $headClass, $bodyClass)
Определения convertorspregreplacehelper.php:47
setCodeClasses($tableClass, $headClass, $bodyClass, $textAreaClass)
$str
Определения commerceml2.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
extract_url($s)
Определения tools.php:2411
delete_special_symbols($text, $replace="")
Определения tools.php:2337
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$text
Определения template_pdf.php:79
$url
Определения iframe.php:7