14 private $postUrl =
"";
15 private $textType =
"";
24 $type = $this->textType = (
$type ==
'html' ?
'html' :
'text');
25 $this->arNowiki =
array();
26 $this->arLink =
array();
27 $this->arLinkExists =
array();
29 $this->arVersionFile =
array();
31 if (!is_array($this->arFile))
32 $this->arFile =
array();
33 foreach ($this->arFile as $_k => $file)
35 if (!is_numeric($file) && !is_numeric($_k))
37 $this->arVersionFile[$_k] = $file;
38 unset($this->arFile[$_k]);
44 $this->postUrl = (CMain::IsHTTPS() ?
"https://" :
"http://").
$_SERVER[
"HTTP_HOST"].
$arParams[
"POST_URL"];
47 $text = preg_replace_callback(
"/(\{\{\{(.*)\}\}\})/imsUu",
array(&$this,
'_codeCallback'),
$text);
48 $text = preg_replace_callback(
"/(\[CODE\](.*)\[\/CODE\])/imsUu",
array(&$this,
'_codeCallback'),
$text);
51 $text = preg_replace_callback(
'/(<nowiki>(.*)<\/nowiki>)/isUu',
array(&$this,
'_noWikiCallback'),
$text);
53 #if($this->textType == "html")
54 # $text = CWikiUtils::htmlspecialchars_decode($text);
57 $text = str_replace(
"'''",
"'''",
$text);
58 $text = str_replace(
"''",
"''",
$text);
61 '/\'{3}(.*)\'{2}(.+)\'{2}(.*)\'{3}/imUu',
62 '/\'{3}(.+)\'{3}/imUu',
63 '/\'{2}(.+)\'{2}/imUu'
66 '<b>\\1<i>\\2</i>\\3</b>',
73 $text = preg_replace(
'/-----*/u',
'\\1<hr />',
$text );
78 $_H = str_repeat(
'=',
$i);
79 $text = preg_replace(
'/^\s*'.$_H.
'(.+?)'.$_H.
'\s*$/miUu',
'<H'.$i.
'>\\1</H'.
$i.
'>',
$text);
87 $text = preg_replace_callback(
'/\[((http|https|ftp)(.+))( (.+))?\]/iUu',
array(&$this,
'_processExternalLinkCallback'),
$text);
91 $text = preg_replace_callback(
'/\[?\[(:)?(File|'.
GetMessage(
'FILE_NAME').
'):(.+)\]\]?/iUu',
array(&$this,
'_processFileCallback'),
$text);
97 if (!empty($this->arNowiki))
98 $text = preg_replace_callback(
'/(##NOWIKI(\d+)##)/isUu',
array(&$this,
'_noWikiReturnCallback'),
$text);
101 $text = preg_replace_callback(
'/(##NOWIKI(\d+)##)/isUu',
array(&$this,
'_noWikiReturn2Callback'),
$text);
105 $text = preg_replace(
"/(<\s*\/?(h(\d+)|li|ul|ol|p|table|tbody|td|tr|hr|div|span)\s*>)\s*(<\s*br\s*\/*\s*>){0,1}(\s*(\r*\n)\s*){1,2}/ism",
"$1##NN##",
$text);
106 $text = preg_replace(
"/(<\s*(ul)\s*>)\s*(<\s*br\s*\/*\s*>){0,1}(\s*(\r*\n)\s*){1,2}/ism",
"$1##NN##",
$text);
107 $text = preg_replace(
"/<\s*br\s*\/*\s*>\s*(\r*\n)/ismU",
"##BR##",
$text);
109 $text = preg_replace(
"/##NN##/ismU",
"\n",
$text);
110 $text = preg_replace(
"/##BR##/ismU",
"<br />\n",
$text);
114 $text = preg_replace_callback(
'/(##CODE(\d+)##)/isUu',
array(&$this,
'_codeReturnCallback'),
$text);
123 $ret = preg_replace(
"/(<\s*br\s*\/*\s*>)*\s*(\r)*\n/ism",
"<br />\n",
$text);
129 $ret = preg_replace(
"/<\s*br\s*\/*>((\r)*\n)*/ism",
"\n",
$text);
135 $arWhiteTags =
array(
136 'a' =>
array(
'href',
'title',
'name',
'style',
'id',
'class',
'shape',
'coords',
'alt',
'target'),
137 'b' =>
array(
'style',
'id',
'class'),
138 'br' =>
array(
'style',
'id',
'class'),
139 'big' =>
array(
'style',
'id',
'class'),
140 'caption' =>
array(
'style',
'id',
'class'),
141 'code' =>
array(
'style',
'id',
'class'),
143 'del' =>
array(
'title',
'style',
'id',
'class'),
144 'div' =>
array(
'title',
'style',
'id',
'class',
'align'),
145 'dt' =>
array(
'style',
'id',
'class'),
146 'dd' =>
array(
'style',
'id',
'class'),
147 'font' =>
array(
'color',
'size',
'face',
'style',
'id',
'class'),
148 'h1' =>
array(
'id',
'class',
'align'),
149 'h2' =>
array(
'id',
'class',
'align'),
150 'h3' =>
array(
'id',
'class',
'align'),
151 'h4' =>
array(
'id',
'class',
'align'),
152 'h5' =>
array(
'id',
'class',
'align'),
153 'h6' =>
array(
'id',
'class',
'align'),
154 'hr' =>
array(
'style',
'id',
'class'),
155 'i' =>
array(
'style',
'id',
'class'),
156 'img' =>
array(
'src',
'alt',
'height',
'width',
'title'),
157 'ins' =>
array(
'title',
'style',
'id',
'class'),
158 'li' =>
array(
'style',
'id',
'class'),
160 'map' =>
array(
'shape',
'coords',
'href',
'alt',
'title',
'style',
'id',
'class',
'name'),
162 'ol' =>
array(
'style',
'id',
'class'),
163 'p' =>
array(
'style',
'id',
'class',
'align'),
164 'pre' =>
array(
'style',
'id',
'class'),
165 's' =>
array(
'style',
'id',
'class'),
166 'small' =>
array(
'style',
'id',
'class'),
167 'strong' =>
array(
'style',
'id',
'class'),
168 'span' =>
array(
'title',
'style',
'id',
'class',
'align'),
169 'sub' =>
array(
'style',
'id',
'class'),
170 'sup' =>
array(
'style',
'id',
'class'),
171 'table' =>
array(
'border',
'width',
'style',
'id',
'class',
'cellspacing',
'cellpadding'),
172 'tbody' =>
array(
'align',
'valign',
'style',
'id',
'class'),
173 'td' =>
array(
'width',
'height',
'style',
'id',
'class',
'align',
'valign',
'colspan',
'rowspan'),
174 'tfoot' =>
array(
'align',
'valign',
'style',
'id',
'class',
'align',
'valign'),
175 'th' =>
array(
'width',
'height',
'style',
'id',
'class',
'colspan',
'rowspan'),
176 'thead' =>
array(
'align',
'valign',
'style',
'id',
'class'),
177 'tr' =>
array(
'align',
'valign',
'style',
'id',
'class'),
178 'ul' =>
array(
'style',
'id',
'class'),
179 'blockquote' =>
array(),
180 'u' =>
array(
'style',
'id',
'class')
187 $Sanitizer->
AddTags($arWhiteTags);
190 if(method_exists($Sanitizer,
"ApplyDoubleEncode"))
191 $Sanitizer->ApplyDoubleEncode(
false);
200 static $sImageAlign =
'';
209 if (is_numeric($sFile) && in_array($sFile, $this->arFile))
211 $arFile = CFile::GetFileArray($sFile);
216 $sFileName =
$arFile[
'ORIGINAL_NAME'];
219 else if (isset($this->arVersionFile[mb_strtolower($sFile)]))
221 $sPath = $this->arVersionFile[mb_strtolower($sFile)];
224 else if (!empty($this->arFile))
227 '@ID' => implode(
',', $this->arFile)
231 while(
$arFile = $rsFile->Fetch())
233 if (
$arFile[
'ORIGINAL_NAME'] == $sFile)
238 $sPath = CFile::GetFileSRC(
$arFile);
239 $sFileName =
$arFile[
'ORIGINAL_NAME'];
248 if (CFile::IsImage($sName))
252 $imageFile = CFile::MakeFileArray($sPath);
253 $checkRes = CFile::CheckImageFile($imageFile);
255 if($checkRes !=
null)
259 $sReturn =
'<a href="'.htmlspecialcharsbx($sPath).
'" title="'.($s =
htmlspecialcharsbx($sFileName)).
'">'.$s.
'</a>';
262 $sReturn = CFile::ShowImage($sFile,
263 COption::GetOptionString(
'wiki',
'image_max_width', 600),
264 COption::GetOptionString(
'wiki',
'image_max_height', 600),
265 'border="0" align="'.$sImageAlign.
'"'
272 $sReturn =
'<a href="'.htmlspecialcharsbx($sPath).
'" title="'.($s =
htmlspecialcharsbx($sName)).
'">'.$s.
'</a>';
274 $sReturn =
'<img src="'.htmlspecialcharsbx($sPath).
'" alt="'.
htmlspecialcharsbx($sFileName).
'"/>';
277 else if (mb_strpos($sPath,
'http://') === 0)
278 $sReturn =
' [ <a href="'.htmlspecialcharsbx($sFile).
'" title="'.
GetMessage(
'FILE_FILE_DOWNLOAD').
'">'.
GetMessage(
'FILE_DOWNLOAD').
'</a> ] ';
281 $sReturn =
'['.GetMessage(
'FILE_NAME').
':'.
htmlspecialcharsbx((is_numeric($sFile) || empty($sFileName) ? $sFile : $sFileName)).
']';
289 $sName = $sTitle = $sLink;
294 $sTitle = strip_tags($sTitle);
296 $sReturn =
'<a href="'.htmlspecialcharsbx($sLink).
'" title="'.
htmlspecialcharsbx($sName).
'">'.$sTitle.
'</a>';
303 $text = preg_replace_callback(
'/\[\[(.+)(\|(.*))?\]\]/iUu',
array(&$this,
'_processInternalLinkPrepareCallback'),
$text);
304 $text = preg_replace(
'/(##Category##)(\s)*((\r*)\n)*/',
"",
$text);
306 if (!empty($this->arLink))
315 $rsElement = CIBlockElement::GetList(
array(),
$arFilter,
false,
false, Array());
316 while($obElement = $rsElement->GetNextElement())
323 $text = preg_replace_callback(
'/(##LINK(\d+)##)/isUu',
array(&$this,
'_processInternalLinkCallback'),
$text);
331 $sName = $sTitle = $sLink;
340 return '##Category##';
343 $sTitle = strip_tags($sTitle);
346 $sReturn =
'<a ##LINK'.$i.
'## title="'.$sTitle.
'">'.$sName.
'</a>';
355 if (in_array(mb_strtolower($this->arLink[
$matches[2]]), $this->arLinkExists))
357 $sURL = CComponentEngine::MakePathFromTemplate(
$arParams[
'PATH_TO_POST'],
359 'wiki_name' => rawurlencode($this->arLink[
$matches[2]]),
363 $sReturn =
'href="'.$sURL.
'"';
368 CComponentEngine::MakePathFromTemplate(
371 'wiki_name' => rawurlencode($this->arLink[
$matches[2]]),
378 $sReturn =
'href="'.$sURL.
'" class="wiki_red"';
388 if (preg_match_all(
'/<H(?<level>\d)(?<parameters>.*)>(?<innerHtml>.*)<\/H\g<level>>/isUu',
$text,
$matches, PREG_SET_ORDER))
394 $iCurrentTocLevel = 0;
396 $iRealPrevItemTocLevel = 1;
398 $iPrevItemTocLevel = 0;
400 $iRealItemTocLevel = 1;
404 foreach (
$matches as $_m => $arMatch)
406 $iRealItemTocLevel = (int)$arMatch[
'level'];
407 $sItemToc = trim($arMatch[
'innerHtml']);
409 if ($bfirst && $iRealPrevItemTocLevel < $iRealItemTocLevel)
411 else if ($iCurrentTocLevel == 1 && $iRealItemTocLevel < $iRealPrevItemTocLevel)
412 $iItemTocLevel = $iCurrentTocLevel;
413 else if ($iRealItemTocLevel > $iRealPrevItemTocLevel)
414 $iItemTocLevel = $iCurrentTocLevel + 1;
415 else if ($iRealItemTocLevel < $iRealPrevItemTocLevel)
417 $_delta = $iRealPrevItemTocLevel - $iRealItemTocLevel;
418 $iItemTocLevel = $iCurrentTocLevel - $_delta;
419 if ($iItemTocLevel < 1)
423 $iItemTocLevel = $iCurrentTocLevel;
426 $iCurrentNumTocLevel = $bfirst ? 1 : $iItemTocLevel;
427 $aNumToc[$iCurrentNumTocLevel] = !isset($aNumToc[$iCurrentNumTocLevel]) ? 1 : $aNumToc[$iCurrentNumTocLevel] + 1;
428 if ($iItemTocLevel < $iPrevItemTocLevel)
430 for (
$i = $iItemTocLevel + 1;
$i <= $iPrevItemTocLevel;
$i++)
435 if ($iItemTocLevel > $iCurrentTocLevel || empty($sToc))
440 else if ($iItemTocLevel < $iCurrentTocLevel)
442 if ($iItemTocLevel <= 0)
445 if ($iCurrentTocLevel > 1)
447 for (
$i = 0;
$i < ($iCurrentTocLevel - $iItemTocLevel);
$i++)
453 if ($iCurrentTocLevel > 1)
454 $iCurrentTocLevel = $iItemTocLevel;
458 $iRealPrevItemTocLevel = $iRealItemTocLevel;
459 $iPrevItemTocLevel = $iItemTocLevel;
461 $sNumToc = implode(
'.', $aNumToc);
462 $sItemTocId = str_replace(
array(
'%',
'+',
'.F2',
'..'),
array(
'.',
'.',
'_',
'.'), rawurlencode($sItemToc.$sNumToc));
463 $sToc .=
'<li><a href="';
466 $sToc.= $this->postUrl;
468 $sToc .=
'#'.$sItemTocId.
'">'.$sNumToc.
' '.strip_tags($sItemToc).
'</a></li>';
469 $matches[$_m][
'innerHtml'] = $sItemToc;
470 $matches[$_m][
'tocId'] = $sItemTocId;
473 for (
$i = $iCurrentTocLevel;
$i > 0;
$i--)
479 $sReplase =
'<H'.$arMatch[
'level'].$arMatch[
'parameters'].
'><span id="'.$arMatch[
'tocId'].
'">'.$arMatch[
'innerHtml'].
'</span></H'.$arMatch[
'level'].
'>';
481 $sReplase = $sToc.
'<br/>'.$sReplase;
483 $text = preg_replace(
'/'.preg_quote($arMatch[0],
'/').
'/u', $sReplase,
$text, 1);
498 if($this->textType ==
"html")
501 $this->arCode[] = $codeText;
503 return '##CODE'.$i.
'##';
511 return '##NOWIKI'.$i.
'##';
516 return '<pre><code>'.$this->arCode[
$matches[2]].
'</code></pre>';
521 return $this->arNowiki[
$matches[2]];
526 return '<nowiki>'.htmlspecialcharsbx($this->arNowiki[
$matches[2]]).
'</nowiki>';
537 $text = preg_replace(
'/--~~~~*/u',
'\\1--'.$userLogin.
' '.ConvertTimeStamp(
false,
'FULL'),
$text );
541 $textWithoutNowiki = preg_replace(
'/(<nowiki>(.*)<\/nowiki>)/isUu',
'',
$text);
542 if (preg_match_all(
'/\[\[(Category|'.
GetMessage(
'CATEGORY_NAME').
'):(.+)\]\]/iUu', $textWithoutNowiki,
$matches))
553 $text = preg_replace(
'/\[\[(Category|'.
GetMessage(
'CATEGORY_NAME').
'):(.+)\]\]/iUu',
'',
$text);
557 $text = preg_replace(
'/\[((http|https|ftp)(.+))( (.+))?\]/iUu',
'\\1\\2 \\5',
$text);
559 $text = preg_replace(
'/\[\[(.+(?!:))(\|(.*))?\]\]/iUu',
'\\1\\2',
$text);
562 for(
$i = 6;
$i >= 1;
$i--)
564 $_H = str_repeat(
'=',
$i);
565 $text = preg_replace(
'/'.$_H.
'(.*?)'.$_H.
'/miUu',
'\\1',
$text);
static urlAddParams($url, $add_params, $options=[])
_processFileCallback($matches)
_codeReturnCallback($matches)
processInternalLink($text)
_noWikiReturnCallback($matches)
_processExternalLinkCallback($matches)
_noWikiReturn2Callback($matches)
Parse($text, $type='text', $arFile=array(), $arParams=array())
_processInternalLinkCallback($matches)
_noWikiCallback($matches)
parseBeforeSave($text, &$arCat=array(), $nameTemplate="")
_processInternalLinkPrepareCallback($matches)
static htmlspecialchars_decode($str)
static GetUserLogin($arUserData=array(), $nameTemplate="")
static IsCategoryPage($NAME, &$CATEGORY_NAME)
static htmlspecialcharsback($str, $end=true)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
bx_basename($path, $ext="")
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"