1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
functions.php
См. документацию.
1<?php
2
4
6{
7 public $bPublic = false;
8 public $bPreview = false;
9 public $pathToUserEntityId = false;
10 public $pathToUserEntityType = false;
11 public $smilesGallery = 0;
12 public $maxStringLen = 100;
13
14 public $blogImageSizeEvents = null;
15 public $arUserfields = [];
16
17 private $arImages = array();
18
19 public $showedImages = array();
20
21 public $isSonetLog = false;
22 public $MaxStringLen = null;
23
24// max sizes for show image in popup
27
28 public function __construct($strLang = False, $pathToSmile = false, $arParams = array())
29 {
30 parent::__construct();
31 global $CACHE_MANAGER;
32 if ($strLang===False)
33 $strLang = LANGUAGE_ID;
34
35 $this->imageWidth = \Bitrix\Blog\Util::getImageMaxWidth();
36 $this->imageHeight = \Bitrix\Blog\Util::getImageMaxHeight();
37 $this->showedImages = array();
38 $this->ajaxPage = $GLOBALS["APPLICATION"]->GetCurPageParam("", array("bxajaxid", "logout"));
39 $this->blogImageSizeEvents = GetModuleEvents("blog", "BlogImageSize", true);
40 $this->arUserfields = array();
41 $this->bPublic = (is_array($arParams) && ($arParams["bPublic"] ?? false));
42 $this->bPreview = (is_array($arParams) && ($arParams["bPreview"] ?? false));
43 $this->smilesGallery = \COption::GetOptionInt("blog", "smile_gallery_id", 0);
44 }
45
46 public function convert($text, $bPreview = True, $arImages = array(), $allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N", "SHORT_ANCHOR" => "N"), $arParams = Array())
47 {
48 if(!is_array($arParams) && $arParams <> '')
49 {
51 }
52 elseif(is_array($arParams))
53 {
54 $type = $arParams["type"] ?? '';
55 }
56 if (intval($arParams["imageWidth"] ?? 0) > 0)
57 {
58 $this->imageWidth = intval($arParams["imageWidth"]);
59 }
60 if (intval($arParams["imageHeight"] ?? 0) > 0)
61 {
62 $this->imageHeight = intval($arParams["imageHeight"]);
63 }
64 if (($arParams["pathToUser"] ?? '') <> '')
65 {
66 $this->pathToUser = $arParams["pathToUser"];
67 }
68 if (!empty($arParams["pathToUserEntityType"]) && $arParams["pathToUserEntityType"] <> '')
69 {
70 $this->pathToUserEntityType = $arParams["pathToUserEntityType"];
71 }
72 if (intval($arParams["pathToUserEntityId"] ?? 0) > 0)
73 {
74 $this->pathToUserEntityId = intval($arParams["pathToUserEntityId"]);
75 }
76 $this->parser_nofollow = COption::GetOptionString("blog", "parser_nofollow", "N");
77
78 $this->type = ($type == "rss" ? "rss" : "html");
79 $this->isSonetLog = $arParams["isSonetLog"] ?? false;
80
81 $this->allow = array(
82 "HTML" => (($allow["HTML"] ?? null) == "Y" ? "Y" : "N"),
83 "NL2BR" => (($allow["NL2BR"] ?? null) == "Y" ? "Y" : "N"),
84 "CODE" => (($allow["CODE"] ?? null) == "N" ? "N" : "Y"),
85 "VIDEO" => (($allow["VIDEO"] ?? null) == "N" ? "N" : "Y"),
86 "ANCHOR" => (($allow["ANCHOR"] ?? null) == "N" ? "N" : "Y"),
87 "BIU" => (($allow["BIU"] ?? null) == "N" ? "N" : "Y"),
88 "IMG" => (($allow["IMG"] ?? null) == "N" ? "N" : "Y"),
89 "QUOTE" => (($allow["QUOTE"] ?? null) == "N" ? "N" : "Y"),
90 "FONT" => (($allow["FONT"] ?? null) == "N" ? "N" : "Y"),
91 "LIST" => (($allow["LIST"] ?? null) == "N" ? "N" : "Y"),
92 "SMILES" => (($allow["SMILES"] ?? null) == "N" ? "N" : "Y"),
93 "TABLE" => (($allow["TABLE"] ?? null) == "N" ? "N" : "Y"),
94 "ALIGN" => (($allow["ALIGN"] ?? null) == "N" ? "N" : "Y"),
95 "CUT_ANCHOR" => (($allow["CUT_ANCHOR"] ?? null) == "Y" ? "Y" : "N"),
96 "SHORT_ANCHOR" => (($allow["SHORT_ANCHOR"] ?? null) == "Y" ? "Y" : "N"),
97 "USER" => (($allow["USER"] ?? null) == "N" ? "N" : "Y"),
98 "USER_LINK" => (($allow["USER_LINK"] ?? null) == "N" ? "N" : "Y"),
99 "TAG" => (($allow["TAG"] ?? null) == "N" ? "N" : "Y"),
100 'SPOILER' => (($allow['SPOILER'] ?? null) === 'N' ? 'N' : 'Y'),
101 "USERFIELDS" => (
102 (isset($allow["USERFIELDS"]) && is_array($allow["USERFIELDS"]))
103 ? $allow["USERFIELDS"]
104 : []
105 )
106 );
107 if (!empty($this->arUserfields))
108 $this->allow["USERFIELDS"] = array_merge($this->allow["USERFIELDS"], $this->arUserfields);
109
110 $this->arImages = $arImages;
111 $this->bPreview = $bPreview;
112
113 static $firstCall = true;
114 if ($firstCall)
115 {
116 $firstCall = false;
117 AddEventHandler("main", "TextParserBefore", Array("blogTextParser", "ParserCut"));
118 AddEventHandler("main", "TextParserBefore", Array("blogTextParser", "ParserBlogImageBefore"));
119 AddEventHandler("main", "TextParserAfterTags", Array("blogTextParser", "ParserBlogImage"));
120 AddEventHandler("main", "TextParserAfterTags", Array("blogTextParser", "ParserTag"));
121 AddEventHandler("main", "TextParserAfter", Array("blogTextParser", "ParserCutAfter"));
122 AddEventHandler("main", "TextParserVideoConvert", Array("blogTextParser", "blogConvertVideo"));
123 }
124
125 $attributes = !empty($arParams) && is_array($arParams) && isset($arParams["ATTRIBUTES"]) ? $arParams["ATTRIBUTES"] : [];
126 $text = $this->convertText($text, $attributes);
127
128 return trim($text);
129 }
130
131 public static function ParserCut(&$text, &$obj)
132 {
133 if (($obj instanceof blogTextParser) && $obj->bPreview)
134 {
135 $text = preg_replace("#^(.*?)<cut[\s]*(/>|>).*?$#is", "\\1", $text);
136 $text = preg_replace("#^(.*?)\[cut[\s]*(/\]|\]).*?$#is", "\\1", $text);
137 }
138 else
139 {
140 $text = preg_replace("#<cut[\s]*(/>|>)#is", "[cut]", $text);
141 }
142 }
143 public static function ParserCutAfter(&$text, &$obj)
144 {
145 if (!($obj instanceof blogTextParser) || !$obj->bPreview)
146 {
147 $text = preg_replace("#\[cut[\s]*(/\]|\])#is", "<a name=\"cut\"></a>", $text);
148 }
149 }
150
151 public static function ParserBlogImageBefore(&$text, &$obj = null)
152 {
153 $text = preg_replace("/\[img([^\]]*)id\s*=\s*([0-9]+)([^\]]*)\]/isu", "[imag id=\\1 \\2 \\3]", $text);
154 }
155
156 public static function ParserBlogImage(&$text, &$obj)
157 {
158 if(is_callable(array($obj, 'convert_blog_image')))
159 {
160 $text = preg_replace_callback(
161 "/\[imag([^\]]*)id\s*=\s*([0-9]+)([^\]]*)\]/isu",
162 array($obj, "convertBlogImage"),
163 $text
164 );
165 }
166 }
167
168 private function convertBlogImage($matches)
169 {
170 return $this->convert_blog_image($matches[1], $matches[2], $matches[3]);
171 }
172
173 private function convertBlogImageMail($matches)
174 {
175 return $this->convert_blog_image('', $matches[2], '', 'mail');
176 }
177
178 public static function ParserTag(&$text, &$obj)
179 {
180 if (
181 ($obj->allow["TAG"] ?? null) !== "N"
182 && is_callable(array($obj, 'convert_blog_tag'))
183 )
184 {
185 $text = preg_replace_callback(
186 "/\[tag(?:[^\]])*\](.+?)\[\/tag\]/isu",
187 array($obj, "convertBlogTag"),
188 $text
189 );
190 }
191 }
192
193 private function convertBlogTag($matches)
194 {
195 return $this->convert_blog_tag($matches[1]);
196 }
197
198 private function convert_blog_tag($name = "")
199 {
200 if($name == '')
201 return;
202 return "TAG [".$name."]";
203 }
204
205 function convert4im($text, $arImages = [])
206 {
207 $text = preg_replace(
208 [
209 "/\[(\/?)(code|quote)([^\]]*)\]/isu",
210 "/\\[url\\s*=\\s*(\\S+?)\\s*\\](.*?)\\[\\/url\\]/isu",
211 "/\\[(table)(.*?)\\]/isu",
212 "/\\[\\/table(.*?)\\]/isu"
213 ],
214 [
215 '',
216 "\\2",
217 "\n",
218 "\n",
219 ],
220 $text
221 );
222
223 return $this->convert4mail($text, $arImages);
224 }
225
226 public function convert4mail($text, $arImages = Array())
227 {
228 $text = parent::convert4mail($text);
229
230 $this->arImages = $arImages;
231
232 $text = preg_replace_callback(
233 "/\[img([^\]]*)id\s*=\s*([0-9]+)([^\]]*)\]/isu",
234 array($this, "convertBlogImageMail"),
235 $text
236 );
237
238 return $text;
239 }
240
241 private function convert_blog_image($p1 = "", $imageId = "", $p2 = "", $type = "html")
242 {
243 $imageId = intval($imageId);
244 if($imageId <= 0)
245 return;
246
247 $res = "";
248 if(intval($this->arImages[$imageId]) > 0)
249 {
250 $this->showedImages[] = $imageId;
251 if($f = CBlogImage::GetByID($imageId))
252 {
253 if(COption::GetOptionString("blog", "use_image_perm", "N") == "N")
254 {
255 if($db_img_arr = CFile::GetFileArray($this->arImages[$imageId]))
256 {
257 if(mb_substr($db_img_arr["SRC"], 0, 1) == "/")
258 $strImage = $this->serverName.$db_img_arr["SRC"];
259 else
260 $strImage = $db_img_arr["SRC"];
261
262 $strPar = "";
263 preg_match("/width\=([0-9]+)/isu", $p1, $width);
264 preg_match("/height\=([0-9]+)/isu", $p1, $height);
265 $width = intval($width[1]);
266 $height = intval($height[1]);
267
268 if($width <= 0)
269 {
270 preg_match("/width\=([0-9]+)/isu", $p2, $width);
271 $width = intval($width[1]);
272 }
273 if($height <= 0)
274 {
275 preg_match("/height\=([0-9]+)/isu", $p2, $height);
276 $height = intval($height[1]);
277 }
278
279 if(intval($width) <= 0)
280 $width = $db_img_arr["WIDTH"];
281 if(intval($height) <= 0)
282 $height= $db_img_arr["HEIGHT"];
283
284 if($width > $this->imageWidth || $height > $this->imageHeight)
285 {
286 $arFileTmp = CFile::ResizeImageGet(
287 $db_img_arr,
288 array("width" => $this->imageWidth, "height" => $this->imageHeight),
290 true
291 );
292 if(mb_substr($arFileTmp["src"], 0, 1) == "/")
293 $strImage = $this->serverName.$arFileTmp["src"];
294 else
295 $strImage = $arFileTmp["src"];
296 $width = $arFileTmp["width"];
297 $height = $arFileTmp["height"];
298 }
299
300 $sourceImage = $this->serverName."/bitrix/components/bitrix/blog/show_file.php?fid=".$imageId;
301// if original size bigger than limits - need resize
302 if($db_img_arr["WIDTH"] > blogTextParser::IMAGE_MAX_SHOWING_WIDTH)
303 $sourceImage .= "&width=".blogTextParser::IMAGE_MAX_SHOWING_WIDTH;
304 if($db_img_arr["HEIGHT"] > blogTextParser::IMAGE_MAX_SHOWING_HEIGHT)
305 $sourceImage .= "&height=".blogTextParser::IMAGE_MAX_SHOWING_HEIGHT;
306
307 $strPar = 'style=" width:'.$width.'px; height:'.$height.'px;"';
308 $strImage = preg_replace("'(?<!:)/+'s", "/", $strImage);
309 $sourceImage = preg_replace("'(?<!:)/+'s", "/", $sourceImage);
310
311 if($this->authorName <> '')
312 $strPar .= " data-bx-title=\"".$this->authorName."\"";
313
314 if ($this->isSonetLog)
315 {
316 $strImage = preg_replace("'(?<!:)/+'s", "/", $strImage);
317 $res = '[IMG]'.$strImage.'[/IMG]';
318 }
319 else
320 {
321
322 if($type == "mail")
323 $res = htmlspecialcharsbx($f["TITLE"])." (IMAGE: ".$strImage." )";
324 else
325 $res = '<img src="'.$strImage.'" title="" alt="'.htmlspecialcharsbx($f["TITLE"]).'" border="0"'.$strPar.' data-bx-image="'.$sourceImage.'" />';
326 }
327 }
328 }
329 else
330 {
331 preg_match("/width\=([0-9]+)/isu", $p1, $width);
332 preg_match("/height\=([0-9]+)/isu", $p1, $height);
333 $width = intval($width[1]);
334 $height = intval($height[1]);
335
336 if($width <= 0)
337 {
338 preg_match("/width\=([0-9]+)/isu", $p2, $width);
339 $width = intval($width[1]);
340 }
341 if($height <= 0)
342 {
343 preg_match("/height\=([0-9]+)/isu", $p2, $height);
344 $height = intval($height[1]);
345 }
346
347 if(intval($width) <= 0)
349 if(intval($height) <= 0)
350 $height = $this->imageHeight;
351
352 if($width > $this->imageWidth)
354 if($height > $this->imageHeight)
355 $height = $this->imageHeight;
356
357 $db_img_arr = CFile::GetFileArray($this->arImages[$imageId]);
358
359 $strImage = $this->serverName."/bitrix/components/bitrix/blog/show_file.php?fid=".$imageId."&width=".$width."&height=".$height;
360 $sourceImage = $this->serverName."/bitrix/components/bitrix/blog/show_file.php?fid=".$imageId;
361// if original size bigger than limits - need resize
362 if($db_img_arr["WIDTH"] > blogTextParser::IMAGE_MAX_SHOWING_WIDTH)
363 $sourceImage .= "&width=".blogTextParser::IMAGE_MAX_SHOWING_WIDTH;
364 if($db_img_arr["HEIGHT"] > blogTextParser::IMAGE_MAX_SHOWING_HEIGHT)
365 $sourceImage .= "&height=".blogTextParser::IMAGE_MAX_SHOWING_HEIGHT;
366
367 CFile::ScaleImage($db_img_arr["WIDTH"], $db_img_arr["HEIGHT"], Array("width" => $width, "height" => $height), BX_RESIZE_IMAGE_PROPORTIONAL, $bNeedCreatePicture, $arSourceSize, $arDestinationSize);
368
369 if ($this->isSonetLog)
370 {
371 $strImage = preg_replace("'(?<!:)/+'s", "/", $strImage);
372 $res = '[IMG]'.$strImage.'[/IMG]';
373 }
374 else
375 {
376 if($type == "mail")
377 $res = htmlspecialcharsbx($f["TITLE"])." (IMAGE: ".$strImage." )";
378 else
379 {
380 $strPar = ' width="'.$arDestinationSize["width"].'" height="'.$arDestinationSize["height"].'"';
381 if($this->authorName <> '')
382 $strPar .= " data-bx-title=\"".$this->authorName."\"";
383
384 $res = '<img src="'.$strImage.'" title="" alt="'.htmlspecialcharsbx($f["TITLE"]).'" border="0" data-bx-image="'.$sourceImage.'"'.$strPar.' />';
385 if(!empty($this->blogImageSizeEvents))
386 {
387 foreach($this->blogImageSizeEvents as $arEvent)
388 ExecuteModuleEventEx($arEvent, Array(&$res, $strImage, $db_img_arr, $f, $arDestinationSize));
389 }
390 }
391 }
392 }
393 return $res;
394 }
395 }
396 return $res;
397 }
398
399 public function convert_to_rss($text, $arImages = Array(), $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N"), $bPreview = true, $arParams = Array())
400 {
401 $arParams["type"] = "rss";
402 $text = $this->convert($text, $bPreview, $arImages, $arAllow, $arParams);
403 return trim($text);
404 }
405
406 function convert_open_tag($marker = "quote")
407 {
408 $marker = (mb_strtolower($marker) == "code" ? "code" : "quote");
409 $this->{$marker."_open"}++;
410 if ($this->type == "rss")
411 return "\n====".$marker."====\n";
412 return "<div class='blog-post-".$marker."' title=\"".GetMessage("BLOG_".mb_strtoupper($marker))."\"><table class='blog".$marker."'><tr><td>";
413 }
414
415 public static function blogConvertVideo(&$arParams)
416 {
417 $video = "";
418 $bEvents = false;
419 foreach(GetModuleEvents("blog", "videoConvert", true) as $arEvent)
420 {
421
422 $video = ExecuteModuleEventEx($arEvent, Array(&$arParams));
423 $bEvents = true;
424 }
425
426 if(!$bEvents)
427 {
428 ob_start();
429 $GLOBALS["APPLICATION"]->IncludeComponent(
430 "bitrix:player", "",
431 Array(
432 "PLAYER_TYPE" => "auto",
433 "USE_PLAYLIST" => "N",
434 "PATH" => $arParams["PATH"],
435 "WIDTH" => $arParams["WIDTH"],
436 "HEIGHT" => $arParams["HEIGHT"],
437 "PREVIEW" => $arParams["PREVIEW"],
438 "LOGO" => "",
439 "FULLSCREEN" => "Y",
440 "SKIN_PATH" => "/bitrix/components/bitrix/player/mediaplayer/skins",
441 "SKIN" => "bitrix.swf",
442 "CONTROLBAR" => "bottom",
443 "WMODE" => "transparent",
444 "HIDE_MENU" => "N",
445 "SHOW_CONTROLS" => "Y",
446 "SHOW_STOP" => "N",
447 "SHOW_DIGITS" => "Y",
448 "CONTROLS_BGCOLOR" => "FFFFFF",
449 "CONTROLS_COLOR" => "000000",
450 "CONTROLS_OVER_COLOR" => "000000",
451 "SCREEN_COLOR" => "000000",
452 "AUTOSTART" => "N",
453 "REPEAT" => "N",
454 "VOLUME" => "90",
455 "DISPLAY_CLICK" => "play",
456 "MUTE" => "N",
457 "HIGH_QUALITY" => "Y",
458 "ADVANCED_MODE_SETTINGS" => "N",
459 "BUFFER_LENGTH" => "10",
460 "DOWNLOAD_LINK" => "",
461 "DOWNLOAD_LINK_TARGET" => "_self"),
462 null,
463 array(
464 "HIDE_ICONS" => "Y"
465 )
466 );
467 $video = ob_get_contents();
468 ob_end_clean();
469 }
470 return $video;
471 }
472
473 public static function killAllTags($text)
474 {
475 if (method_exists("CTextParser", "clearAllTags"))
477
478 $text = strip_tags($text);
479 $text = preg_replace(
480 array(
481 "/<(\/)(quote|code)([^>]*)>/isu",
482 "/\[(\/)(code|quote|video|td|tr|th|table|tbody|thead|file|document|disk)([^\]]*)\]/isu",
483 "/\[(\/?)(\*)([^\]]*)\]/isu",
484 ),
485 " ",
486 $text);
487 $text = preg_replace(
488 array(
489 "/<(\/?)(quote|code|font|color|video)([^>]*)>/isu",
490 "/\[(\/?)(b|u|i|s|list|code|quote|font|color|url|img|video|td|tr|th|tbody|thead|table|file|document|disk|user|left|right|center|justify)([^\]]*)\]/isu"
491 ),
492 "",
493 $text);
494 return $text;
495 }
496
498 {
499 $classAdditional = (!empty($fields['CLASS_ADDITIONAL']) ? $fields['CLASS_ADDITIONAL'] : '');
500 $pathToUser = (!empty($fields['PATH_TO_USER']) ? $fields['PATH_TO_USER'] : '');
501 $userId = (!empty($fields['USER_ID']) ? $fields['USER_ID'] : '');
502 $userName = (!empty($fields['USER_NAME']) ? $fields['USER_NAME'] : '');
503
504 $anchorId = RandString(8);
505
506 return (
507 $this->allow["USER_LINK"] == "N"
508 ? $userName
509 : '<a class="blog-p-user-name' . $classAdditional . '" id="bp_'.$anchorId.'" href="'.CComponentEngine::MakePathFromTemplate($pathToUser, array("user_id" => $userId)).'" bx-tooltip-user-id="'.(!$this->bMobile ? $userId : '').'">'.$userName.'</a>'
510 );
511 }
512
513 private static function getEditorDefaultFeatures()
514 {
515 return array("Bold","Italic","Underline","SmileList","RemoveFormat","Quote","Code"/*,"Source"*/);
516 }
517
518 private static function getEditorExtendFeatures()
519 {
520 return array(
521 "EDITOR_USE_FONT" => array("FontList", "FontSizeList","ForeColor"),
522 "EDITOR_USE_LINK" => array("CreateLink"),
523 "EDITOR_USE_IMAGE" => array("UploadImage","Image"),
524 "EDITOR_USE_FORMAT" => array("Strike","Table","Justify","InsertOrderedList","InsertUnorderedList"),
525 "EDITOR_USE_VIDEO" => array("InputVideo")
526 );
527 }
528
529 public static function GetEditorToolbar($params, $arResult = null)
530 {
531 if(isset($params["blog"]))
532 {
533 $blog = $params["blog"];
534 }
535 else
536 {
537 $blog = array();
538 $params = array("EDITOR_FULL" => "Y");
539 }
540 $editorFull = isset($params["EDITOR_FULL"]) && $params["EDITOR_FULL"] == "Y";
541
542 $defaultFeatures = self::getEditorDefaultFeatures();
543 $extendFeatures = self::getEditorExtendFeatures();
544
545// if set FULL flag - use ALL features. If other - use features by blog settings
546 $result = $defaultFeatures;
547 if($editorFull)
548 {
549 foreach($extendFeatures as $key => $feature)
550 $result = array_merge($result, $feature);
551 }
552 else
553 {
554 foreach($extendFeatures as $key => $feature)
555 {
556// use feature name as key to can remove then later
557 if(isset($blog[$key]) && $blog[$key] == "Y")
558 foreach($feature as $f)
559 $result[$f] = $f;
560 }
561 }
562
563// UNSET not allowed by component settings features
564 if(is_array($arResult) && !$arResult["allowVideo"])
565 foreach($extendFeatures["EDITOR_USE_VIDEO"] as $f)
566 unset($result[$f]);
567
568 if(is_array($arResult) && $arResult["NoCommentUrl"])
569 foreach($extendFeatures["EDITOR_USE_LINK"] as $f)
570 unset($result[$f]);
571
572 if (LANGUAGE_ID == 'ru')
573 $result[] = 'Translit';
574
575 return $result;
576 }
577
578 public static function getEditorButtons($blog, $arResult)
579 {
580 $result = array();
581
582 // IMAGES or FILES
583 if(
584 is_array($arResult["COMMENT_PROPERTIES"]["DATA"])
585 && (
586 array_key_exists("UF_BLOG_COMMENT_FILE", $arResult["COMMENT_PROPERTIES"]["DATA"])
587 || array_key_exists("UF_BLOG_COMMENT_DOC", $arResult["COMMENT_PROPERTIES"]["DATA"])
588 )
589 && array_key_exists('EDITOR_USE_IMAGE', $blog) && $blog["EDITOR_USE_IMAGE"] === "Y"
590 )
591 {
592 $result[] = "UploadFile";
593 }
594
595 // VIDEO
596 if($arResult["allowVideo"] && (isset($blog["EDITOR_USE_VIDEO"]) && $blog["EDITOR_USE_VIDEO"] === "Y"))
597 {
598 $result[] = "InputVideo";
599 }
600
601 // LINK
602 if(!$arResult["NoCommentUrl"] && (isset($blog["EDITOR_USE_LINK"]) && $blog["EDITOR_USE_LINK"] === "Y"))
603 {
604 $result[] = 'CreateLink';
605 }
606
607 // OTHER for all
608 $result[] = "Quote";
609 $result[] = "BlogTag";
610
611 return $result;
612 }
613}
614
616{
617 public static function htmlspecialcharsExArray($array)
618 {
619 $res = Array();
620 if(!empty($array) && is_array($array))
621 {
622 foreach($array as $k => $v)
623 {
624 if(is_array($v))
625 {
626 foreach($v as $k1 => $v1)
627 {
628 $res[$k1] = htmlspecialcharsex($v1);
629 $res['~'.$k1] = $v1;
630 }
631 }
632 else
633 {
634 if (preg_match("/[;&<>\"]/", ($v ?? '')))
635 $res[$k] = htmlspecialcharsex($v);
636 else
637 $res[$k] = $v;
638 $res['~'.$k] = $v;
639 }
640 }
641 }
642 return $res;
643 }
644
645 public static function ResizeImage($aFile, $sizeX, $sizeY)
646 {
647 $arFile = CFile::ResizeImageGet($aFile, array("width"=>$sizeX, "height"=>$sizeY));
648
649 if(is_array($arFile))
650 return $arFile["src"];
651 else
652 return false;
653 }
654
655 public static function GetDateTimeFormat()
656 {
657 $timestamp = mktime(7,30,45,2,22,2007);
658 return array(
659 "d-m-Y H:i:s" => date("d-m-Y H:i:s", $timestamp),//"22-02-2007 7:30",
660 "m-d-Y H:i:s" => date("m-d-Y H:i:s", $timestamp),//"02-22-2007 7:30",
661 "Y-m-d H:i:s" => date("Y-m-d H:i:s", $timestamp),//"2007-02-22 7:30",
662 "d.m.Y H:i:s" => date("d.m.Y H:i:s", $timestamp),//"22.02.2007 7:30",
663 "m.d.Y H:i:s" => date("m.d.Y H:i:s", $timestamp),//"02.22.2007 7:30",
664 "j M Y H:i:s" => date("j M Y H:i:s", $timestamp),//"22 Feb 2007 7:30",
665 "M j, Y H:i:s" => date("M j, Y H:i:s", $timestamp),//"Feb 22, 2007 7:30",
666 "j F Y H:i:s" => date("j F Y H:i:s", $timestamp),//"22 February 2007 7:30",
667 "F j, Y H:i:s" => date("F j, Y H:i:s", $timestamp),//"February 22, 2007",
668 "d.m.y g:i A" => date("d.m.y g:i A", $timestamp),//"22.02.07 1:30 PM",
669 "d.m.y G:i" => date("d.m.y G:i", $timestamp),//"22.02.07 7:30",
670 "d.m.Y H:i:s" => date("d.m.Y H:i:s", $timestamp),//"22.02.2007 07:30",
671 );
672 }
673
674 public static function DeleteDoubleBR($text)
675 {
676 if(mb_strpos($text, "<br />\r<br />") !== false)
677 {
678 $text = str_replace("<br />\r<br />", "<br />", $text);
680 }
681 if(mb_strpos($text, "<br /><br />") !== false)
682 {
683 $text = str_replace("<br /><br />", "<br />", $text);
685 }
686
687 if(mb_strpos($text, "<br />") == 0 && mb_strpos($text, "<br />") !== false)
688 {
689 $text = mb_substr($text, 6);
690 }
691 return $text;
692 }
693
694 public static function blogUFfileEdit($arResult, $arParams)
695 {
696 $result = false;
697 if (mb_strpos($arParams['arUserField']['FIELD_NAME'], CBlogPost::UF_NAME) === 0 || mb_strpos($arParams['arUserField']['FIELD_NAME'], 'UF_BLOG_COMMENT_DOC') === 0)
698 {
700 'INPUT_NAME' => $arParams["arUserField"]["FIELD_NAME"],
701 'INPUT_NAME_UNSAVED' => 'FILE_NEW_TMP',
702 'INPUT_VALUE' => $arResult["VALUE"],
703 'MAX_FILE_SIZE' => intval($arParams['arUserField']['SETTINGS']['MAX_ALLOWED_SIZE']),
704 'MULTIPLE' => $arParams['arUserField']['MULTIPLE'],
705 'MODULE_ID' => 'uf',
706 'ALLOW_UPLOAD' => 'A',
707 );
708
709 $GLOBALS["APPLICATION"]->IncludeComponent('bitrix:main.file.input', 'drag_n_drop', $componentParams, false, Array("HIDE_ICONS" => "Y"));
710
711 $result = true;
712 }
713 return $result;
714 }
715
716 public static function blogUFfileShow($arResult, $arParams)
717 {
718 $result = false;
719 if ($arParams['arUserField']['FIELD_NAME'] == CBlogPost::UF_NAME || mb_strpos($arParams['arUserField']['FIELD_NAME'], 'UF_BLOG_COMMENT_DOC') === 0)
720 {
721 if (sizeof($arResult['VALUE']) > 0)
722 {
723 ?>
724 <div class="feed-com-files">
725 <div class="feed-com-files-title"><?=GetMessage('BLOG_FILES')?></div>
726 <div class="feed-com-files-cont">
727 <?
728 }
729 foreach ($arResult['VALUE'] as $fileID)
730 {
731 $arFile = CFile::GetFileArray($fileID);
732 if($arFile)
733 {
734 $name = $arFile['ORIGINAL_NAME'];
735 $ext = '';
736 $dotpos = mb_strrpos($name, ".");
737 if (($dotpos !== false) && ($dotpos + 1 < mb_strlen($name)))
738 $ext = mb_substr($name, $dotpos + 1);
739 if (mb_strlen($ext) < 3 || mb_strlen($ext) > 5)
740 $ext = '';
741 $arFile['EXTENSION'] = $ext;
742 $arFile['LINK'] = "/bitrix/components/bitrix/blog/show_file.php?bp_fid=".$fileID;
743 $arFile["FILE_SIZE"] = CFile::FormatSize($arFile["FILE_SIZE"]);
744 ?>
745 <div id="wdif-doc-<?=$arFile['ID']?>" class="feed-com-file-wrap">
746 <div class="feed-con-file-name-wrap">
747 <div class="feed-con-file-icon feed-file-icon-<?=htmlspecialcharsbx($arFile['EXTENSION'])?>"></div>
748 <a target="_blank" href="<?=htmlspecialcharsbx($arFile['LINK'])?>" class="feed-com-file-name"><?=htmlspecialcharsbx($arFile['ORIGINAL_NAME'])?></a>
749 <span class="feed-con-file-size">(<?=$arFile['FILE_SIZE']?>)</span>
750 </div>
751 </div>
752 <?
753 }
754 }
755 if (sizeof($arResult['VALUE']) > 0)
756 {
757 ?>
758 </div>
759 </div>
760 <?
761 }
762 $result = true;
763 }
764 return $result;
765 }
766}
$arParams
Определения access_dialog.php:21
$type
Определения options.php:106
$arResult
Определения generate_coupon.php:16
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getImageMaxWidth()
Определения util.php:23
static getImageMaxHeight()
Определения util.php:32
static GetByID($ID)
Определения blog_image.php:158
const UF_NAME
Определения blog_post.php:19
Определения functions.php:616
static blogUFfileEdit($arResult, $arParams)
Определения functions.php:694
static DeleteDoubleBR($text)
Определения functions.php:674
static blogUFfileShow($arResult, $arParams)
Определения functions.php:716
static ResizeImage($aFile, $sizeX, $sizeY)
Определения functions.php:645
static htmlspecialcharsExArray($array)
Определения functions.php:617
static GetDateTimeFormat()
Определения functions.php:655
static ResizeImageGet($file, $arSize, $resizeType=BX_RESIZE_IMAGE_PROPORTIONAL, $bInitSizes=false, $arFilters=false, $bImmediate=false, $jpgQuality=false)
Определения file.php:2242
static GetFileArray($fileId, $uploadDir=false)
Определения file.php:1207
static ScaleImage($sourceImageWidth, $sourceImageHeight, $arSize, $resizeType, &$bNeedCreatePicture, &$arSourceSize, &$arDestinationSize)
Определения file.php:2502
Определения textparser.php:21
$pathToUser
Определения textparser.php:75
$imageHeight
Определения textparser.php:27
convertText($text, $attributes=[])
Определения textparser.php:213
$type
Определения textparser.php:22
$allow
Определения textparser.php:40
$imageWidth
Определения textparser.php:26
static clearAllTags($text)
Определения textparser.php:2358
$pathToSmile
Определения textparser.php:110
Определения functions.php:6
convert4im($text, $arImages=[])
Определения functions.php:205
static killAllTags($text)
Определения functions.php:473
$showedImages
Определения functions.php:19
static blogConvertVideo(&$arParams)
Определения functions.php:415
$pathToUserEntityType
Определения functions.php:10
const IMAGE_MAX_SHOWING_HEIGHT
Определения functions.php:26
const IMAGE_MAX_SHOWING_WIDTH
Определения functions.php:25
render_user($fields)
Определения functions.php:497
$MaxStringLen
Определения functions.php:22
static ParserBlogImageBefore(&$text, &$obj=null)
Определения functions.php:151
convert($text, $bPreview=True, $arImages=array(), $allow=array("HTML"=> "N", "ANCHOR"=> "Y", "BIU"=> "Y", "IMG"=> "Y", "QUOTE"=> "Y", "CODE"=> "Y", "FONT"=> "Y", "LIST"=> "Y", "SMILES"=> "Y", "NL2BR"=> "N", "VIDEO"=> "Y", "TABLE"=> "Y", "CUT_ANCHOR"=> "N", "SHORT_ANCHOR"=> "N"), $arParams=Array())
Определения functions.php:46
static ParserBlogImage(&$text, &$obj)
Определения functions.php:156
static getEditorButtons($blog, $arResult)
Определения functions.php:578
static ParserCutAfter(&$text, &$obj)
Определения functions.php:143
$blogImageSizeEvents
Определения functions.php:14
$pathToUserEntityId
Определения functions.php:9
$bPublic
Определения functions.php:7
convert_open_tag($marker="quote")
Определения functions.php:406
static ParserCut(&$text, &$obj)
Определения functions.php:131
__construct($strLang=False, $pathToSmile=false, $arParams=array())
Определения functions.php:28
static GetEditorToolbar($params, $arResult=null)
Определения functions.php:529
$maxStringLen
Определения functions.php:12
convert_to_rss($text, $arImages=Array(), $arAllow=array("HTML"=> "N", "ANCHOR"=> "Y", "BIU"=> "Y", "IMG"=> "Y", "QUOTE"=> "Y", "CODE"=> "Y", "FONT"=> "Y", "LIST"=> "Y", "SMILES"=> "Y", "NL2BR"=> "N", "VIDEO"=> "Y", "TABLE"=> "Y", "CUT_ANCHOR"=> "N"), $bPreview=true, $arParams=Array())
Определения functions.php:399
static ParserTag(&$text, &$obj)
Определения functions.php:178
$smilesGallery
Определения functions.php:11
$arUserfields
Определения functions.php:15
convert4mail($text, $arImages=Array())
Определения functions.php:226
$isSonetLog
Определения functions.php:21
$bPreview
Определения functions.php:8
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$f
Определения component_props.php:52
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$componentParams
Определения group_wiki_index.php:20
const BX_RESIZE_IMAGE_PROPORTIONAL
Определения constants.php:11
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
Определения tools.php:5165
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$text
Определения template_pdf.php:79
else $userName
Определения order_form.php:75
$width
Определения html.php:68
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$matches
Определения index.php:22
$k
Определения template_pdf.php:567
$GLOBALS['_____370096793']
Определения update_client.php:1
$fields
Определения yandex_run.php:501