示例#1
0
 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;
 }
示例#2
0
文件: index.php 项目: ASDAFF/bitrix-5
 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)));
     }
 }
示例#3
0
        $arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
    }
    if (empty($arError)) {
        $GLOBALS["APPLICATION"]->ResetException();
        $arSmileSet = CSmileSet::getById($ID);
        $arFields = array("STRING_ID" => $_REQUEST["STRING_ID"], "SORT" => $_REQUEST["SORT"], "PARENT_ID" => $parentId, "LANG" => array());
        if (in_array($arSmileSet["STRING_ID"], array('bitrix_main'))) {
            unset($arFields['STRING_ID']);
        }
        foreach ($arLang as $key => $val) {
            $arFields["LANG"][$key] = $_REQUEST["NAME"][$key];
        }
        if ($ID > 0) {
            CSmileSet::update($ID, $arFields);
        } else {
            $ID = CSmileSet::add($arFields);
        }
        if ($e = $GLOBALS["APPLICATION"]->GetException()) {
            $arError[] = array("id" => "", "text" => $e->getString());
        } else {
            LocalRedirect(isset($_REQUEST['IMPORT']) ? "smile_import.php?lang=" . LANG . "&SET_ID=" . $ID : (strlen($save) > 0 ? "smile_set.php?GALLERY_ID=" . $parentId . "&lang=" . LANG . "&" . GetFilterParams("filter_", false) : "smile_set_edit.php?GALLERY_ID=" . $parentId . "&lang=" . LANG . "&ID=" . $ID . "&" . 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['NAME'])) {
        foreach ($arFields['NAME'] as $key => $value) {
            $arFields['NAME'][htmlspecialcharsbx($key)] = htmlspecialcharsbx($value);