function CSocNetTextParser($strLang = False, $pathToSmile = false) { global $DB, $CACHE_MANAGER; static $arSmiles = array(); $this->smiles = array(); if ($strLang === False) { $strLang = LANGUAGE_ID; } $this->path_to_smile = $pathToSmile; if ($CACHE_MANAGER->Read(604800, "b_sonet_smile")) { $arSmiles = $CACHE_MANAGER->Get("b_sonet_smile"); } else { $db_res = CSocNetSmile::GetList(array("SORT" => "ASC"), array("SMILE_TYPE" => "S"), false, false, array("LANG_LID", "ID", "IMAGE", "DESCRIPTION", "TYPING", "SMILE_TYPE", "SORT")); while ($res = $db_res->Fetch()) { $tok = strtok($res['TYPING'], " "); while ($tok !== false) { $arSmiles[$res['LANG_LID']][] = array('TYPING' => $tok, 'IMAGE' => stripslashes($res['IMAGE']), 'DESCRIPTION' => stripslashes($res['NAME'])); $tok = strtok(" "); } } function sonet_sortlen($a, $b) { if (strlen($a["TYPING"]) == strlen($b["TYPING"])) { return 0; } return strlen($a["TYPING"]) > strlen($b["TYPING"]) ? -1 : 1; } foreach ($arSmiles as $LID => $arSmilesLID) { uasort($arSmilesLID, 'sonet_sortlen'); $arSmiles[$LID] = $arSmilesLID; } $CACHE_MANAGER->Set("b_sonet_smile", $arSmiles); } $this->smiles = $arSmiles[$strLang]; }
public function CSocNetTextParser($strLang = False, $pathToSmile = false) { global $DB, $CACHE_MANAGER; if ($strLang===False) $strLang = LANGUAGE_ID; $this->path_to_smile = $pathToSmile; $this->smiles = array(); if($CACHE_MANAGER->Read(604800, "b_sonet_smile")) { $arSmiles = $CACHE_MANAGER->Get("b_sonet_smile"); } else { $db_res = CSocNetSmile::GetList(array("SORT" => "ASC"), array("SMILE_TYPE" => "S"/*, "LANG_LID" => $strLang*/), false, false, Array("LANG_LID", "ID", "IMAGE", "DESCRIPTION", "TYPING", "SMILE_TYPE", "SORT")); while ($res = $db_res->Fetch()) { $tok = strtok($res['TYPING'], " "); while ($tok) { $arSmiles[$res['LANG_LID']][] = array('TYPING' => stripslashes($tok), 'IMAGE' => stripslashes($res['IMAGE']), 'DESCRIPTION'=>stripslashes($res['NAME'])); $tok = strtok(" "); } } $CACHE_MANAGER->Set("b_sonet_smile", $arSmiles); } $this->smiles = $arSmiles[$strLang]; }
public static function PrintSmilesList($num_cols, $strLang = False, $strPath2Icons = False, $cacheTime = False) { $res_str = ""; $arSmile = array(); $return_array = intVal($num_cols) > 0 ? false : true; if ($strLang === False) { $strLang = LANGUAGE_ID; } if ($strPath2Icons === False) { $strPath2Icons = "/bitrix/images/socialnetwork/smile/"; } $cache = new CPHPCache(); $cache_id = "socialnetwork_smiles_" . $strLang . preg_replace("/[^a-z0-9]/is", "_", $strPath2Icons); $cache_path = "/" . SITE_ID . "/socialnetwork/smiles/"; if ($cacheTime > 0 && $cache->InitCache($cacheTime, $cache_id, $cache_path)) { $res = $cache->GetVars(); $arSmile = $res["arSmile"]; } if (empty($arSmile)) { $db_res = CSocNetSmile::GetList(array("SORT" => "ASC"), array("TYPE" => "S", "LID" => LANGUAGE_ID)); if ($db_res && ($res = $db_res->Fetch())) { do { $arSmile[] = $res; } while ($res = $db_res->Fetch()); } if ($cacheTime > 0) { $cache->StartDataCache($cacheTime, $cache_id, $cache_path); $cache->EndDataCache(array("arSmile" => $arSmile)); } } if ($return_array) { return $arSmile; } $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 .= " 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; }
$strDirNameOld = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/images/socialnetwork/"; if ($arOldSmile["SMILE_TYPE"] == "I") { $strDirNameOld .= "icon"; } else { $strDirNameOld .= "smile"; } $strDirNameOld .= "/" . $arOldSmile["IMAGE"]; @unlink($strDirNameOld); } } $DB->Commit(); break; } } } $dbResultList = CSocNetSmile::GetList(array($by => $order), $arFilter); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); // установке параметров списка $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("PAGES"))); // заголовок списка $lAdmin->AddHeaders(array(array("id" => "ID", "content" => GetMessage("SMILE_ID"), "sort" => "ID", "default" => true), array("id" => "SORT", "content" => GetMessage("SMILE_SORT"), "sort" => "SORT", "default" => true), array("id" => "SMILE_TYPE", "content" => GetMessage('SMILE_TYPE'), "sort" => "SMILE_TYPE", "default" => true), array("id" => "NAME", "content" => GetMessage("SONET_NAME"), "sort" => "", "default" => true), array("id" => "TYPING", "content" => GetMessage("SONET_TYPING"), "sort" => "", "default" => true), array("id" => "ICON", "content" => GetMessage("SONET_SMILE_ICON"), "sort" => "", "default" => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); // построение списка while ($arSocNet = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arSocNet); $row->AddField("ID", '<a href="/bitrix/admin/socnet_smile_edit.php?ID=' . $f_ID . '&lang=' . LANGUAGE_ID . '" title="' . GetMessage("SONET_EDIT_DESCR") . '">' . $f_ID . '</a>'); $row->AddField("SORT", $f_SORT); $row->AddField("SMILE_TYPE", $f_SMILE_TYPE == "I" ? GetMessage("SMILE_TYPE_ICON") : GetMessage("SMILE_TYPE_SMILE")); $fieldShow = ""; if (in_array("NAME", $arVisibleColumns)) {
$arResult["GET_COMMENTS"] = $bGetComments ? "Y" : "N"; $arResult["CURRENT_PAGE_DATE"] = $current_page_date; $arResult["Smiles"] = array(); if (!isset($arResult["FatalError"])) { if (CModule::IncludeModule("forum")) { $arResult["Smiles"] = CForumSmile::GetByType("S", LANGUAGE_ID); foreach ($arResult["Smiles"] as $i => $arSmile) { list($type) = explode(" ", $arSmile["TYPING"]); $arResult["Smiles"][$i]["TYPE"] = str_replace("'", "\\'", $type); $arResult["Smiles"][$i]["TYPE"] = str_replace("\\", "\\\\", $arResult["Smiles"][$i]["TYPE"]); $arResult["Smiles"][$i]["IMAGE"] = "/bitrix/images/forum/smile/" . $arSmile["IMAGE"]; } } else { if ($GLOBALS["CACHE_MANAGER"]->Read(604800, "b_sonet_smile_" . LANGUAGE_ID)) { $arResult["Smiles"] = $GLOBALS["CACHE_MANAGER"]->Get("b_sonet_smile_" . LANGUAGE_ID); } else { $arResult["Smiles"] = array(); $rsSmile = CSocNetSmile::GetList(array("SORT" => "ASC"), array("SMILE_TYPE" => "S", "LANG_LID" => LANGUAGE_ID), false, false, array("ID", "IMAGE", "DESCRIPTION", "TYPING", "SMILE_TYPE", "SORT", "LANG_NAME")); while ($arSmile = $rsSmile->Fetch()) { list($type) = explode(" ", $arSmile["TYPING"]); $arSmile["TYPE"] = str_replace("'", "\\'", $type); $arSmile["TYPE"] = str_replace("\\", "\\\\", $arSmile["TYPE"]); $arSmile["NAME"] = $arSmile["LANG_NAME"]; $arSmile["IMAGE"] = "/bitrix/images/socialnetwork/smile/" . $arSmile["IMAGE"]; $arResult["Smiles"][] = $arSmile; } $GLOBALS["CACHE_MANAGER"]->Set("b_sonet_smile_" . LANGUAGE_ID, $arResult["Smiles"]); } } } $this->IncludeComponentTemplate();
function InstallDB($install_wizard = true) { global $DB, $DBType, $APPLICATION, $install_smiles; if (!$DB->Query("SELECT 'x' FROM b_sonet_group", true)) { $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/socialnetwork/install/db/" . $DBType . "/install.sql"); } if (!empty($errors)) { $APPLICATION->ThrowException(implode("", $errors)); return false; } RegisterModule("socialnetwork"); RegisterModuleDependences("search", "OnBeforeFullReindexClear", "socialnetwork", "CSocNetSearchReindex", "OnBeforeFullReindexClear"); RegisterModuleDependences("search", "OnBeforeIndexDelete", "socialnetwork", "CSocNetSearchReindex", "OnBeforeIndexDelete"); RegisterModuleDependences("search", "OnReindex", "socialnetwork", "CSocNetSearch", "OnSearchReindex"); RegisterModuleDependences("search", "OnSearchCheckPermissions", "socialnetwork", "CSocNetSearch", "OnSearchCheckPermissions"); RegisterModuleDependences("search", "OnBeforeIndexUpdate", "socialnetwork", "CSocNetSearch", "OnBeforeIndexUpdate"); RegisterModuleDependences("search", "OnAfterIndexAdd", "socialnetwork", "CSocNetSearch", "OnAfterIndexAdd"); RegisterModuleDependences("search", "OnSearchPrepareFilter", "socialnetwork", "CSocNetSearch", "OnSearchPrepareFilter"); RegisterModuleDependences("main", "OnUserDelete", "socialnetwork", "CSocNetUser", "OnUserDelete"); RegisterModuleDependences("main", "OnBeforeUserUpdate", "socialnetwork", "CSocNetUser", "OnBeforeUserUpdate"); RegisterModuleDependences("main", "OnAfterUserUpdate", "socialnetwork", "CSocNetUser", "OnAfterUserUpdate"); RegisterModuleDependences("main", "OnAfterUserAdd", "socialnetwork", "CSocNetUser", "OnAfterUserAdd"); RegisterModuleDependences("main", "OnAfterUserLogout", "socialnetwork", "CSocNetUser", "OnAfterUserLogout"); RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 100, "/modules/socialnetwork/prolog_before.php"); RegisterModuleDependences("main", "OnBeforeLangDelete", "socialnetwork", "CSocNetGroup", "OnBeforeLangDelete"); RegisterModuleDependences("socialnetwork", "OnSocNetLogFormatEvent", "socialnetwork", "CSocNetLog", "OnSocNetLogFormatEvent"); RegisterModuleDependences("photogallery", "OnAfterUpload", "socialnetwork", "CSocNetLogTools", "OnAfterPhotoUpload"); RegisterModuleDependences("photogallery", "OnAfterPhotoDrop", "socialnetwork", "CSocNetLogTools", "OnAfterPhotoDrop"); RegisterModuleDependences("photogallery", "OnBeforeSectionDrop", "socialnetwork", "CSocNetLogTools", "OnBeforeSectionDrop"); RegisterModuleDependences("photogallery", "OnAfterSectionDrop", "socialnetwork", "CSocNetLogTools", "OnAfterSectionDrop"); RegisterModuleDependences("photogallery", "OnAfterSectionEdit", "socialnetwork", "CSocNetLogTools", "OnAfterSectionEdit"); RegisterModuleDependences("main", "OnAuthProvidersBuildList", "socialnetwork", "CSocNetGroupAuthProvider", "GetProviders"); RegisterModuleDependences("im", "OnBeforeConfirmNotify", "socialnetwork", "CSocNetUserToGroup", "OnBeforeConfirmNotify"); RegisterModuleDependences("im", "OnBeforeConfirmNotify", "socialnetwork", "CSocNetUserRelations", "OnBeforeConfirmNotify"); RegisterModuleDependences("im", "OnGetNotifySchema", "socialnetwork", "CSocNetNotifySchema", "OnGetNotifySchema"); RegisterModuleDependences("pull", "OnGetDependentModule", "socialnetwork", "CSocNetPullSchema", "OnGetDependentModule"); RegisterModuleDependences("extranet", "OnUserInitialize", "socialnetwork", "CSocNetUser", "OnUserInitialize"); RegisterModuleDependences("blog", "OnBlogDelete", "socialnetwork", "CSocNetLogComments", "OnBlogDelete", 100); RegisterModuleDependences("blog", "OnBlogDelete", "socialnetwork", "CSocNetLog", "OnBlogDelete", 200); RegisterModuleDependences("blog", "OnBlogPostMentionNotifyIm", "socialnetwork", "CSocNetLogFollow", "OnBlogPostMentionNotifyIm"); CAgent::AddAgent("CSocNetMessages::SendEventAgent();", "socialnetwork", "N", 600); CAgent::AddAgent("CSocNetLog::ClearOldAgent();", "socialnetwork", "N", 43200); $arUserOptions = CUserOptions::GetOption("intranet", "~gadgets_sonet_user", false, 0); if (!is_array($arUserOptions) || count($arUserOptions) <= 0) { $sOptions = 'a:1:{s:7:"GADGETS";a:10:{s:18:"SONET_USER_LINKS@1";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:0;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:20:"SONET_USER_FRIENDS@2";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:1;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:21:"SONET_USER_BIRTHDAY@3";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:2;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:19:"SONET_USER_GROUPS@4";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:3;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:17:"SONET_USER_HEAD@5";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:4;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:19:"SONET_USER_HONOUR@6";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:5;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:20:"SONET_USER_ABSENCE@7";a:4:{s:6:"COLUMN";i:0;s:3:"ROW";i:6;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:17:"SONET_USER_DESC@8";a:4:{s:6:"COLUMN";i:1;s:3:"ROW";i:0;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}s:22:"SONET_USER_ACTIVITY@21";a:3:{s:6:"COLUMN";i:1;s:3:"ROW";i:1;s:4:"HIDE";s:1:"N";}s:7:"TASKS@9";a:4:{s:6:"COLUMN";i:1;s:3:"ROW";i:2;s:8:"USERDATA";N;s:4:"HIDE";s:1:"N";}}}'; $arOptions = unserialize($sOptions); CUserOptions::SetOption("intranet", "~gadgets_sonet_user", $arOptions, false, 0); $sOptions = 'a:1:{s:7:"GADGETS";a:7:{s:18:"SONET_GROUP_DESC@1";a:3:{s:6:"COLUMN";i:0;s:3:"ROW";i:0;s:4:"HIDE";s:1:"N";}s:16:"UPDATES_ENTITY@9";a:3:{s:6:"COLUMN";i:0;s:3:"ROW";i:1;s:4:"HIDE";s:1:"N";}s:7:"TASKS@4";a:3:{s:6:"COLUMN";i:0;s:3:"ROW";i:2;s:4:"HIDE";s:1:"N";}s:18:"SONET_GROUP_TAGS@5";a:3:{s:6:"COLUMN";i:0;s:3:"ROW";i:3;s:4:"HIDE";s:1:"N";}s:19:"SONET_GROUP_LINKS@6";a:3:{s:6:"COLUMN";i:1;s:3:"ROW";i:0;s:4:"HIDE";s:1:"N";}s:19:"SONET_GROUP_USERS@7";a:3:{s:6:"COLUMN";i:1;s:3:"ROW";i:1;s:4:"HIDE";s:1:"N";}s:18:"SONET_GROUP_MODS@8";a:3:{s:6:"COLUMN";i:1;s:3:"ROW";i:2;s:4:"HIDE";s:1:"N";}}}'; $arOptions = unserialize($sOptions); CUserOptions::SetOption("intranet", "~gadgets_sonet_group", $arOptions, false, 0); } $this->__SetLogFilter(); CModule::IncludeModule("socialnetwork"); if (CModule::IncludeModule("search")) { CSearch::ReIndexModule("socialnetwork"); } if ($install_smiles == "Y" || $install_wizard) { $dbSmile = CSocNetSmile::GetList(); if (!$dbSmile->Fetch()) { $arSmile = array(array("TYPING" => ":D :-D", "IMAGE" => "icon_biggrin.gif", "FICON_SMILE" => "FICON_BIGGRIN"), array("TYPING" => ":) :-)", "IMAGE" => "icon_smile.gif", "FICON_SMILE" => "FICON_SMILE"), array("TYPING" => ":( :-(", "IMAGE" => "icon_sad.gif", "FICON_SMILE" => "FICON_SAD"), array("TYPING" => ":o :-o :shock:", "IMAGE" => "icon_eek.gif", "FICON_SMILE" => "FICON_EEK"), array("TYPING" => "8) 8-)", "IMAGE" => "icon_cool.gif", "FICON_SMILE" => "FICON_COOL"), array("TYPING" => ":{} :-{}", "IMAGE" => "icon_kiss.gif", "FICON_SMILE" => "FICON_KISS"), array("TYPING" => ":oops:", "IMAGE" => "icon_redface.gif", "FICON_SMILE" => "FICON_REDFACE"), array("TYPING" => ":cry: :~(", "IMAGE" => "icon_cry.gif", "FICON_SMILE" => "FICON_CRY"), array("TYPING" => ":evil: >:-<", "IMAGE" => "icon_evil.gif", "FICON_SMILE" => "FICON_EVIL"), array("TYPING" => ";) ;-)", "IMAGE" => "icon_wink.gif", "FICON_SMILE" => "FICON_WINK"), array("TYPING" => ":!:", "IMAGE" => "icon_exclaim.gif", "FICON_SMILE" => "FICON_EXCLAIM"), array("TYPING" => ":?:", "IMAGE" => "icon_question.gif", "FICON_SMILE" => "FICON_QUESTION"), array("TYPING" => ":idea:", "IMAGE" => "icon_idea.gif", "FICON_SMILE" => "FICON_IDEA"), array("TYPING" => ":| :-|", "IMAGE" => "icon_neutral.gif", "FICON_SMILE" => "FICON_NEUTRAL")); $arLang = array(); $dbLangs = CLanguage::GetList($b = "", $o = "", array("ACTIVE" => "Y")); while ($arLangs = $dbLangs->Fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/socialnetwork/install/smiles.php", $arLangs["LID"]); foreach ($arSmile as $key => $val) { $arSmile[$key]["LANG"][] = array("LID" => $arLangs["LID"], "NAME" => GetMessage($val["FICON_SMILE"])); } } foreach ($arSmile as $val) { $val["SMILE_TYPE"] = "S"; $val["CLICKABLE"] = "Y"; $val["SORT"] = 150; $val["IMAGE_WIDTH"] = 16; $val["IMAGE_HEIGHT"] = 16; $id = CSocNetSmile::Add($val); } } } return true; }
$strErrorMessage .= GetMessage("ERROR_ADD_SMILE") . ". \n"; } } } if (strlen($strErrorMessage) > 0) { $bInitVars = True; } if (strlen($save) > 0 && strlen($strErrorMessage) <= 0) { LocalRedirect("socnet_smile.php?lang=" . LANG . "&" . GetFilterParams("filter_", false)); } } ClearVars("f_"); ClearVars("str_"); $str_SORT = 150; if ($ID > 0) { $db_smile = CSocNetSmile::GetList(array(), array("ID" => $ID)); $db_smile->ExtractFields("str_", True); $f_IMAGE = $str_IMAGE; $f_IMAGE_WIDTH = $str_IMAGE_WIDTH; $f_IMAGE_HEIGHT = $str_IMAGE_HEIGHT; $f_SMILE_TYPE = $str_SMILE_TYPE; } if ($bInitVars) { $DB->InitTableVarsForEdit("b_socnet_smile", "", "str_"); } $sDocTitle = $ID > 0 ? GetMessage("SONET_EDIT_RECORD", array("#ID#" => $ID)) : GetMessage("SONET_NEW_RECORD"); $APPLICATION->SetTitle($sDocTitle); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; /*********************************************************************/ /******************** BODY *****************************************/ /*********************************************************************/
function logTextParser($strLang = False, $pathToSmile = false) { $this->CTextParser(); global $CACHE_MANAGER; $this->MaxStringLen = 0; $this->smiles = array(); if ($strLang === False) $strLang = LANGUAGE_ID; $this->pathToSmile = $pathToSmile; if($CACHE_MANAGER->Read(604800, "b_sonet_smile")) $arSmiles = $CACHE_MANAGER->Get("b_sonet_smile"); else { $db_res = CSocNetSmile::GetList(array("SORT" => "ASC"), array("SMILE_TYPE" => "S"/*, "LANG_LID" => $strLang*/), false, false, Array("LANG_LID", "ID", "IMAGE", "DESCRIPTION", "TYPING", "SMILE_TYPE", "SORT")); while ($res = $db_res->Fetch()) { $tok = strtok($res['TYPING'], " "); while ($tok !== false) { $arSmiles[$res['LANG_LID']][] = array( 'TYPING' => $tok, 'IMAGE' => stripslashes($res['IMAGE']), // stripslashes is not needed here 'DESCRIPTION' => stripslashes($res['NAME']) // stripslashes is not needed here ); $tok = strtok(" "); } } function sonet_sortlen($a, $b) { if (strlen($a["TYPING"]) == strlen($b["TYPING"])) return 0; return (strlen($a["TYPING"]) > strlen($b["TYPING"])) ? -1 : 1; } foreach ($arSmiles as $LID => $arSmilesLID) { uasort($arSmilesLID, 'sonet_sortlen'); $arSmiles[$LID] = $arSmilesLID; } $CACHE_MANAGER->Set("b_sonet_smile", $arSmiles); } $this->smiles = $arSmiles[$strLang]; AddEventHandler("main", "TextParserAfterTags", Array(&$this, "ParserUser")); }