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))); } }
public static function convertGallery() { global $DB; $arLang = array(); $arLang2 = array(); $arLang3 = 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_GALLERY_NAME'])) { $arLang[$lid] = $MESS['MAIN_SMILE_DEF_GALLERY_NAME']; } if ($MESS && isset($MESS['MAIN_SMILE_DEF_SET_NAME'])) { $arLang2[$lid] = $MESS['MAIN_SMILE_DEF_SET_NAME']; } if ($MESS && isset($MESS['MAIN_SMILE_USER_GALLERY_NAME'])) { $arLang3[$lid] = $MESS['MAIN_SMILE_USER_GALLERY_NAME']; } } $smileGalleryId = 0; $gallery = CSmileGallery::getByStringId('bitrix'); if (!$gallery) { $smileGalleryId = CSmileGallery::add(array('STRING_ID' => 'bitrix', 'LANG' => $arLang)); } else { $smileGalleryId = $gallery['ID']; } if (COption::GetOptionInt("main", "smile_gallery_converted", 0) == 0) { $res = $DB->Query('SELECT * FROM b_smile'); $smileOriginalSet = array('smile_smile.png' => array('TYPING' => ':) :-)', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_wink.png' => array('TYPING' => ';) ;-)', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_biggrin.png' => array('TYPING' => ':D :-D', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_cool.png' => array('TYPING' => '8) 8-)', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_sad.png' => array('TYPING' => ':( :-(', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_neutral.png' => array('TYPING' => ':| :-|', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_redface.png' => array('TYPING' => ':oops:', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_cry.png' => array('TYPING' => ':cry: :~(', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_evil.png' => array('TYPING' => ':evil: >:-<', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_eek.png' => array('TYPING' => ':o :-o :shock:', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_confuse.png' => array('TYPING' => ':/ :-/', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_kiss.png' => array('TYPING' => ':{} :-{}', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_idea.png' => array('TYPING' => ':idea:', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_question.png' => array('TYPING' => ':?:', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16'), 'smile_exclaim.png' => array('TYPING' => ':!:', 'IMAGE_WIDTH' => '16', 'IMAGE_HEIGHT' => '16')); $smileCount = 0; $smileOriginalCount = 0; while ($smile = $res->fetch()) { if ($smile['TYPE'] != CSmile::TYPE_SMILE) { continue; } if ($smileOriginalSet[$smile['IMAGE']] && $smileOriginalSet[$smile['IMAGE']]['IMAGE_WIDTH'] == $smile['IMAGE_WIDTH'] && $smileOriginalSet[$smile['IMAGE']]['IMAGE_HEIGHT'] == $smile['IMAGE_HEIGHT'] && $smileOriginalSet[$smile['IMAGE']]['TYPING'] == $smile['TYPING']) { $smileOriginalCount++; } $smileCount++; } if (!(($smileCount == 0 || $smileCount == 15) && $smileCount == $smileOriginalCount)) { $smileCustomGalleryId = 0; $smileSet = CSmileGallery::getByStringId('bitrix_convert'); if (!$smileSet) { $smileCustomGalleryId = CSmileGallery::add(array('STRING_ID' => 'bitrix_convert', 'SORT' => 300, 'LANG' => $arLang3)); } else { $smileCustomGalleryId = $smileSet['ID']; } CSmileGallery::setDefaultId($smileCustomGalleryId); $DB->Query("UPDATE b_smile_set SET PARENT_ID = " . $smileCustomGalleryId . " WHERE TYPE = 'G' AND PARENT_ID = 0"); } else { $smileSet = CSmileSet::getByStringId('main'); if ($smileSet) { CSmileSet::delete($smileSet['ID']); } } COption::SetOptionInt("main", "smile_gallery_converted", 1); } if ($smileGalleryId) { $smileSet = CSmileSet::getByStringId('bitrix_main'); if ($smileSet) { $smileSetId = $smileSet['ID']; CSmile::deleteBySet($smileSet['ID']); } else { $smileSetId = CSmileSet::add(array('STRING_ID' => 'bitrix_main', 'PARENT_ID' => $smileGalleryId, 'LANG' => $arLang2)); } CSmile::import(array('FILE' => $_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/main/install/smiles/smiles_default.zip', 'SET_ID' => $smileSetId, 'IMPORT_IF_FILE_EXISTS' => 'Y')); } return false; }