function textParser($strLang = False, $pathToSmile = false) { global $DB; static $arSmiles = array(); $strLang = $strLang === false ? LANGUAGE_ID : $strLang; $pathToSmile = $pathToSmile === false ? "/bitrix/images/forum/smile/" : $pathToSmile; $id = md5($pathToSmile . "|" . $pathToSmile); if (!is_set($arSmiles, $id)) { $arCollection = $arPattern = $arReplacement = array(); $db_res = CForumSmile::GetByType("S", $strLang); foreach ($db_res as $key => $val) { $tok = strtok($val["TYPING"], " "); while ($tok) { $row = array("TYPING" => $tok, "IMAGE" => stripslashes($val["IMAGE"]), "DESCRIPTION" => stripslashes($val["NAME"])); $tok = str_replace(array(chr(34), chr(39), "<", ">"), array("\v", "\f", "<", ">"), $tok); $code = preg_quote(str_replace(array("\\"), array("\"), $tok)); $patt = preg_quote($tok, "/"); $image = preg_quote($row["IMAGE"]); $description = preg_quote(htmlspecialcharsbx($row["DESCRIPTION"], ENT_QUOTES), "/"); $arReplacement[] = "\$this->convert_emoticon('{$code}', '{$image}', '{$description}')"; $arPattern[] = "/(?<=[^\\w&]){$patt}(?=.\\W|\\W.|\\W\$)/ei" . BX_UTF_PCRE_MODIFIER; $arCollection[] = $row; $tok = strtok(" "); } } $arSmiles[$id] = array("smiles" => $arCollection, "pattern" => $arPattern, "replace" => $arReplacement); } $this->smiles = $arSmiles[$id]["smiles"]; $this->preg_smiles = array("pattern" => $arSmiles[$id]["pattern"], "replace" => $arSmiles[$id]["replace"]); $this->path_to_smile = ""; }
protected static function getIcon($iconTyping) { if (!is_array(self::$icons)) { $result = array(); $smiles = CForumSmile::GetByType(CSmile::TYPE_ICON, LANGUAGE_ID); foreach ($smiles as $smile) { $result[$smile["TYPING"]] = $smile["IMAGE"]; } self::$icons = $result; } return array_key_exists($iconTyping, self::$icons) ? self::$icons[$iconTyping] : ''; }
$arResult["REVIEW_TEXT"] = htmlspecialcharsEx($arResult["~REVIEW_TEXT"]); $arResult["REVIEW_USE_SMILES"] = $arResult["~REVIEW_USE_SMILES"]; $arResult["REVIEW_FILES"] = array(); foreach ($_REQUEST["FILES"] as $key => $val): if (intVal($val) <= 0) return false; $arResult["REVIEW_FILES"][$val] = CFile::GetFileArray($val); endforeach; // Form Info $arResult["SHOW_PANEL_ATTACH_IMG"] = (in_array($arResult["FORUM"]["ALLOW_UPLOAD"], array("A", "F", "Y")) ? "Y" : "N"); $arResult["TRANSLIT"] = (LANGUAGE_ID=="ru" ? "Y" : " N"); if ($arResult["FORUM"]["ALLOW_SMILES"] == "Y"): $arResult["ForumPrintSmilesList"] = ($arResult["FORUM"]["ALLOW_SMILES"] == "Y" ? ForumPrintSmilesList(3, LANGUAGE_ID, $arParams["PATH_TO_SMILE"], $arParams["CACHE_TIME"]) : ""); $arResult["SMILES"] = CForumSmile::GetByType("S", LANGUAGE_ID); endif; $arResult["CAPTCHA_CODE"] = ""; if ($arParams["USE_CAPTCHA"] == "Y" && !$USER->IsAuthorized()) { include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/captcha.php"); $cpt = new CCaptcha(); $captchaPass = COption::GetOptionString("main", "captcha_password", ""); if (strLen($captchaPass) <= 0) { $captchaPass = randString(10); COption::SetOptionString("main", "captcha_password", $captchaPass); } $cpt->SetCodeCrypt($captchaPass); $arResult["CAPTCHA_CODE"] = htmlspecialcharsbx($cpt->GetCodeCrypt());
function ForumPrintSmilesList($num_cols, $strLang = false, $strPath2Icons = false) { $num_cols = intVal($num_cols); $num_cols = $num_cols > 0 ? $num_cols : 3; $strLang = $strLang === false ? LANGUAGE_ID : $strLang; $strPath2Icons = empty($strPath2Icons) ? "/bitrix/images/forum/smile/" : $strPath2Icons; $arSmile = CForumSmile::GetByType("S", $strLang); $res_str = ""; $ind = 0; foreach ($arSmile as $res) { if ($ind == 0) { $res_str .= "<tr align=\"center\">"; } $res_str .= "<td width=\"" . IntVal(100 / $num_cols) . "%\">"; $strTYPING = strtok($res['TYPING'], " "); $res_str .= "<img src=\"" . $strPath2Icons . $res['IMAGE'] . "\" alt=\"" . $res['NAME'] . "\" title=\"" . $res['NAME'] . "\" border=\"0\""; if (IntVal($res['IMAGE_WIDTH']) > 0) { $res_str .= " width=\"" . $res['IMAGE_WIDTH'] . "\""; } if (IntVal($res['IMAGE_HEIGHT']) > 0) { $res_str .= " height=\"" . $res['IMAGE_HEIGHT'] . "\""; } $res_str .= " class=\"smiles-list\" alt=\"smile" . $strTYPING . "\" onclick=\"if(emoticon){emoticon('" . $strTYPING . "');}\" name=\"smile\" id='" . $strTYPING . "' "; $res_str .= "/> </td>\n"; $ind++; if ($ind >= $num_cols) { $ind = 0; $res_str .= "</tr>"; } } if ($ind < $num_cols) { for ($i = 0; $i < $num_cols - $ind; $i++) { $res_str .= "<td> </td>"; } } return $res_str; }