Esempio n. 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;
 }
Esempio n. 2
0
        $arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
    }
    if (empty($arError)) {
        $GLOBALS["APPLICATION"]->ResetException();
        $arSmileSet = CSmileGallery::getById($ID);
        $arFields = array("STRING_ID" => $_REQUEST["STRING_ID"], "SORT" => $_REQUEST["SORT"], "LANG" => array());
        if ($arSmileSet['STRING_ID'] == 'bitrix' || $_REQUEST["STRING_ID"] == 'bitrix') {
            unset($arFields['STRING_ID']);
        }
        foreach ($arLang as $key => $val) {
            $arFields["LANG"][$key] = $_REQUEST["NAME"][$key];
        }
        if ($ID > 0) {
            CSmileGallery::update($ID, $arFields);
        } else {
            $ID = CSmileGallery::add($arFields);
        }
        if ($e = $GLOBALS["APPLICATION"]->GetException()) {
            $arError[] = array("id" => "", "text" => $e->getString());
        } else {
            LocalRedirect(strlen($save) > 0 ? "smile_gallery.php?lang=" . LANG . "&" . GetFilterParams("filter_", false) : "smile_gallery_edit.php?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);