- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/functions.php
- Класс: CSocNetTextParser
- Вызов: CSocNetTextParser::convert_to_rss
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"), $arParams = array())
{
global $DB;
if (empty($arAllow))
$arAllow = array(
"HTML" => "N",
"ANCHOR" => "Y",
"BIU" => "Y",
"IMG" => "Y",
"QUOTE" => "Y",
"CODE" => "Y",
"FONT" => "Y",
"LIST" => "Y",
"SMILES" => "Y",
"NL2BR" => "N");
$this->quote_error = 0;
$this->quote_open = 0;
$this->quote_closed = 0;
$this->code_error = 0;
$this->code_open = 0;
$this->code_closed = 0;
$bAllowSmiles = $arAllow["SMILES"];
if ($arAllow["HTML"]!="Y")
{
$text = preg_replace(
array(
"#^(.+?)|>).*?$#is".BX_UTF_PCRE_MODIFIER,
"#^(.+?)[cut[s]*(/]|]).*?$#is".BX_UTF_PCRE_MODIFIER),
"\1", $text);
$arAllow["SMILES"] = "N";
$text = $this->convert($text, $arAllow, "rss");
}
else
{
if ($arAllow["NL2BR"]=="Y")
$text = str_replace("n", "
", $text);
}
if ($arParams["SERVER_NAME"] == '')
{
$dbSite = CSite::GetByID(SITE_ID);
$arSite = $dbSite->Fetch();
$arParams["SERVER_NAME"] = htmlspecialcharsEx($arSite["SERVER_NAME"]);
if ($arParams["SERVER_NAME"] == '')
{
if (defined("SITE_SERVER_NAME") && SITE_SERVER_NAME <> '')
$arParams["SERVER_NAME"] = SITE_SERVER_NAME;
else
$arParams["SERVER_NAME"] = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
}
}
if ($bAllowSmiles == "Y")
{
if (count($this->smiles) > 0)
{
foreach ($this->smiles as $a_id => $row)
{
$code = preg_quote(str_replace("'", "\'", $row["TYPING"]), "/");
$image = preg_quote(str_replace("'", "\'", $row["IMAGE"]));
$description = preg_quote(htmlspecialcharsbx($row["DESCRIPTION"], ENT_QUOTES), "/");
$this->matchType = $code;
$this->matchType2 = $image;
$this->matchType3 = $description;
$this->matchType4 = "http://".$arParams["SERVER_NAME"];
$text = preg_replace_callback(
"/(?<=[^w&])$code(?=.W|W.|W$)/i",
array($this, "convert_emoticon_callback"),
$text
);
}
}
}
return trim($text);
}