protected function initSmiles() { if (static::$defSmiles === null) { $smiles = CSmile::getByType(); $arSmiles = array(); foreach ($smiles as $smile) { $arTypings = explode(" ", $smile["TYPING"]); foreach ($arTypings as $typing) { $arSmiles[] = array_merge($smile, array('TYPING' => $typing, 'IMAGE' => CSmile::PATH_TO_SMILE . $smile["SET_ID"] . "/" . $smile["IMAGE"], 'DESCRIPTION' => $smile["NAME"], 'DESCRIPTION_DECODE' => 'Y')); } } static::$defSmiles = $arSmiles; } $this->smiles = static::$defSmiles; }
protected function initSmiles() { if (!array_key_exists($this->smilesGallery, self::$repoSmiles)) { $smiles = CSmile::getByGalleryId(CSmile::TYPE_SMILE, $this->smilesGallery); $arSmiles = array(); foreach ($smiles as $smile) { $arTypings = explode(" ", $smile["TYPING"]); foreach ($arTypings as $typing) { $arSmiles[] = array_merge($smile, array('TYPING' => $typing, 'IMAGE' => CSmile::PATH_TO_SMILE . $smile["SET_ID"] . "/" . $smile["IMAGE"], 'DESCRIPTION' => $smile["NAME"], 'DESCRIPTION_DECODE' => 'Y')); } } self::$repoSmiles[$this->smilesGallery] = $arSmiles; } $this->smiles = self::$repoSmiles[$this->smilesGallery]; }
private static function InstallSmiles() { global $DBType; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_io.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_file.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/file.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/" . $DBType . "/file.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/archive.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/csv_data.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/file_temp.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/smile.php"; $result = CSmileSet::getByStringId('main'); if (!empty($result)) { return false; } $arLang = array(); $langs = CLanguage::GetList($b = "", $o = ""); while ($language = $langs->Fetch()) { $lid = $language["LID"]; $MESS = IncludeModuleLangFile(__FILE__, $lid, true); if ($MESS && isset($MESS['MAIN_SMILE_DEF_SET_NAME'])) { $arLang[$lid] = $MESS['MAIN_SMILE_DEF_SET_NAME']; } } $smileSetId = CSmileSet::add(array('STRING_ID' => 'main', 'LANG' => $arLang)); if (intval($smileSetId) > 0) { CSmile::import(array('FILE' => $_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/main/install/smiles/smiles_default.zip', 'SET_ID' => intval($smileSetId))); } }
continue; CSmile::update($ID, Array( 'LANG' => Array( LANGUAGE_ID => $arFields['NAME'] ), 'SORT' => $arFields['SORT'], 'TYPING' => $arFields['TYPING'], )); } } $dbResultList = CSmile::getList(Array( 'SELECT' => Array('ID', 'SET_ID', 'SET_NAME', 'TYPE', 'NAME', 'SORT', 'TYPING', 'IMAGE', 'IMAGE_WIDTH', 'IMAGE_HEIGHT'), 'FILTER' => $arFilter, 'ORDER' => array($by => $order), 'NAV_PARAMS' => array("nPageSize"=>CAdminResult::GetNavSize($sTableID)), 'RETURN_RES' => 'Y' )); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SMILE_NAV"))); $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, "align"=>"right"), array("id"=>"NAME", "content"=>GetMessage("SMILE_NAME"), "default"=>true), array("id"=>"TYPING", "content"=>GetMessage("SMILE_TYPING"), "default"=>true), array("id"=>"ICON", "content"=>GetMessage("SMILE_ICON"), "default"=>true),
public static function PrepareSmiles() { $arResult = Array(); $arSmile = CSmile::getByType(CSmile::TYPE_SMILE); $arSmileSet = CSmileSet::getListCache(); foreach ($arSmile as $smile) { $typing = explode(" ", $smile['TYPING']); if (isset($arResult['SMILE'][$typing[0]])) continue; $arResult['SMILE'][$typing[0]] = Array( 'SET_ID' => $smile['SET_ID'], 'NAME' => $smile['NAME'], 'IMAGE' => CSmile::PATH_TO_SMILE.$smile["SET_ID"]."/".$smile["IMAGE"], 'TYPING' => $typing[0], 'WIDTH' => $smile['IMAGE_WIDTH'], 'HEIGHT' => $smile['IMAGE_HEIGHT'], ); } foreach ($arSmileSet as $key => $value) { unset($value['STRING_ID']); unset($value['SORT']); if (empty($value['NAME'])) $value['NAME'] = GetMessage('IM_SMILE_SET_EMPTY', Array('#ID#' => $key)); $arResult['SMILE_SET'][$key] = $value; } return $arResult; }
$res = CFile::CheckFile($_FILES["IMPORT"], 500000, false, 'zip'); if (strLen($res) > 0) { $arError[] = array("id" => "IMPORT", "text" => $res); } elseif (file_exists($sUploadDir . $fileName)) { $arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE")); } elseif (!@copy($_FILES["IMPORT"]["tmp_name"], $sUploadDir . $fileName)) { $arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_COPY_FILE")); } else { @chmod($sUploadDir . $fileName, BX_FILE_PERMISSIONS); } } elseif (empty($_FILES["IMPORT"]["tmp_name"])) { $arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE")); } if (empty($arError)) { $GLOBALS["APPLICATION"]->ResetException(); $importCount = CSmile::import(array('FILE' => $sUploadDir . $fileName, 'SET_ID' => intval($_REQUEST['SET_ID']))); if ($e = $GLOBALS["APPLICATION"]->GetException()) { $arError[] = array("id" => "", "text" => $e->getString()); @unlink($sUploadDir . $fileName); } else { @unlink($sUploadDir . $fileName); $bImportComplete = true; } } $e = new CAdminException($arError); $message = new CAdminMessage(GetMessage("ERROR_IMPORT_SMILE"), $e); $bInitVars = true; } $arSmile = array("SET_ID" => isset($_REQUEST['SET_ID']) ? $_REQUEST['SET_ID'] : 0); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; if ($bImportComplete) {
public static function delete($id) { global $DB, $CACHE_MANAGER; $id = intval($id); $res = $DB->Query("SELECT ID, TYPE FROM b_smile_set WHERE ID = " . $id); if ($smileSet = $res->Fetch()) { $DB->Query("DELETE FROM b_smile_set WHERE ID = " . $smileSet['ID'], true); $DB->Query("DELETE FROM b_smile_lang WHERE TYPE = '" . $smileSet['TYPE'] . "' AND SID = " . $smileSet['ID'], true); CSmile::deleteBySet($smileSet['ID']); } $CACHE_MANAGER->CleanDir("b_smile_set"); return true; }
static function getSmiles($type, $lang) { $type = $type == "I" ? CSmile::TYPE_ICON : CSmile::TYPE_SMILE; $key = "new_" . $type . "_" . $lang; if (!array_key_exists($key, self::$smiles)) { $smiles = CSmile::getByGalleryId($type, COption::GetOptionInt("forum", "smile_gallery_id", 0), $lang); $result = array(); foreach ($smiles as $smile) { if ($smile['HIDDEN'] == 'Y') { continue; } $result[] = array('SET_ID' => $smile['SET_ID'], 'NAME' => $smile['NAME'], 'IMAGE' => ($smile['TYPE'] == CSmile::TYPE_SMILE ? CSmile::PATH_TO_SMILE : CSmile::PATH_TO_ICON) . $smile["SET_ID"] . "/" . $smile["IMAGE"], 'TYPING' => $smile['TYPING'], 'WIDTH' => $smile['IMAGE_WIDTH'], 'HEIGHT' => $smile['IMAGE_HEIGHT']); } self::$smiles[$key] = $result; } return self::$smiles[$key]; }
<tr> <td width="40%"><?php echo GetMessage("SMILE_STRING_ID"); ?> :</td> <td width="60%"> <input type="text" name="STRING_ID" value="<?php echo $arSmileSet["STRING_ID"]; ?> " size="40" /> </td> </tr> <?php } if ($ID > 0) { $arSmiles = CSmile::getList(array('SELECT' => array('SET_ID', 'NAME', 'TYPE', 'IMAGE', 'IMAGE_WIDTH', 'IMAGE_HEIGHT'), 'FILTER' => array('PARENT_ID' => $ID), 'ORDER' => array($by => $order), 'NAV_PARAMS' => array("nTopCount" => 12))); } else { $arSmiles = array(); } if (count($arSmiles) > 0) { ?> <tr> <td><?php echo GetMessage("SMILE_SMILE_EXAMPLE"); ?> :</td> <td> <?php foreach ($arSmiles as $smile) { ?> <img src="<?php
public static function delete($id) { global $DB; $id = intval($id); $DB->Query("DELETE FROM b_smile_set WHERE ID = " . $id, true); $DB->Query("DELETE FROM b_smile_lang WHERE TYPE = '" . self::TYPE_SET . "' AND SID = " . $id, true); CSmile::deleteBySet($id); return true; }
LocalRedirect(strlen($apply) > 0 ? "smile_edit.php?lang=" . LANG . "&ID=" . $ID . "&" . GetFilterParams("filter_", false) : (strlen($save_and_add) > 0 ? "smile_edit.php?lang=" . LANG . "&TYPE=" . ($arSmile['TYPE'] == CSmile::TYPE_ICON ? CSmile::TYPE_ICON : CSmile::TYPE_SMILE) . "&SET_ID=" . intval($_REQUEST['SET_ID']) . "&" . GetFilterParams("filter_", false) : "smile.php?SET_ID=" . intval($_REQUEST['SET_ID']) . "&lang=" . LANG . "&" . GetFilterParams("filter_", false))); } } $e = new CAdminException($arError); $message = new CAdminMessage($ID > 0 ? GetMessage("ERROR_EDIT_SMILE") : GetMessage("ERROR_ADD_SMILE"), $e); $bInitVars = true; } if ($bInitVars && !empty($arFields)) { if (isset($arFields['LANG'])) { foreach ($arFields['LANG'] as $key => $value) { $arFields['LANG'][htmlspecialcharsbx($key)] = htmlspecialcharsbx($value); } } $arSmile = array("SORT" => isset($arFields['SORT']) ? intval($arFields['SORT']) : 300, "TYPE" => isset($arFields['TYPE']) ? htmlspecialcharsbx($arFields['TYPE']) : CSmile::TYPE_SMILE, "TYPING" => isset($arFields['TYPING']) ? htmlspecialcharsbx($arFields['TYPING']) : "", "HIDDEN" => isset($arFields['HIDDEN']) ? $arFields['HIDDEN'] : "N", "IMAGE" => "", "IMAGE_DEFINITION" => isset($arFields['IMAGE_DEFINITION']) ? $arFields['IMAGE_DEFINITION'] : CSmile::IMAGE_SD, "SET_ID" => isset($arFields['SET_ID']) ? intval($arFields['SET_ID']) : 0, "LANG" => isset($arFields['LANG']) ? $arFields['LANG'] : array()); } elseif ($ID > 0) { $arSmile = CSmile::getById($ID, CSmile::GET_ALL_LANGUAGE); $arSmile['LANG'] = $arSmile['NAME']; } else { if (isset($_REQUEST['LANG'])) { foreach ($_REQUEST['LANG'] as $key => $value) { $_REQUEST['LANG'][htmlspecialcharsbx($key)] = htmlspecialcharsbx($value); } } $arSmile = array("SORT" => isset($_REQUEST['SORT']) ? intval($_REQUEST['SORT']) : 300, "TYPE" => isset($_REQUEST['TYPE']) ? htmlspecialcharsbx($_REQUEST['TYPE']) : CSmile::TYPE_SMILE, "TYPING" => isset($_REQUEST['TYPING']) ? htmlspecialcharsbx($_REQUEST['TYPING']) : "", "HIDDEN" => isset($_REQUEST['HIDDEN']) ? "Y" : "N", "IMAGE" => "", "IMAGE_DEFINITION" => isset($_REQUEST['IMAGE_DEFINITION']) ? $_REQUEST['IMAGE_DEFINITION'] : CSmile::IMAGE_SD, "SET_ID" => isset($_REQUEST['SET_ID']) ? intval($_REQUEST['SET_ID']) : 0, "LANG" => isset($_REQUEST['LANG']) ? $_REQUEST['LANG'] : array()); } $smileSet = CSmileSet::getById($arSmile['SET_ID']); $arSmile['PARENT_ID'] = $smileSet['PARENT_ID']; require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aMenu = array(array("TEXT" => GetMessage("SMILE_BTN_BACK"), "LINK" => "/bitrix/admin/smile.php?SET_ID=" . $arSmile['SET_ID'] . "&lang=" . LANG . "&" . GetFilterParams("filter_", false), "ICON" => "btn_list")); if ($ID > 0) { $aMenu[] = array("SEPARATOR" => "Y");