Exemple #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;
 }
Exemple #2
0
IncludeModuleLangFile(__FILE__);
$sTableID = "tbl_smile_set";
$oSort = new CAdminSorting($sTableID, "ID", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$arFilterFields = array();
$lAdmin->InitFilter($arFilterFields);
$arFilter = array();
if ($arID = $lAdmin->GroupAction()) {
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        if ($_REQUEST['action'] == 'delete') {
            $arSmileSet = CSmileSet::getById($ID);
            if (!in_array($arSmileSet["STRING_ID"], array('bitrix_main'))) {
                CSmileSet::delete($ID);
            }
        }
    }
}
if ($lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        $ID = IntVal($ID);
        if ($ID <= 0) {
            continue;
        }
        CSmileSet::update($ID, array('LANG' => array(LANGUAGE_ID => $arFields['NAME']), 'STRING_ID' => $arFields['STRING_ID'], 'SORT' => $arFields['SORT']));
    }
}
if (isset($_REQUEST['GALLERY_ID'])) {
    $arFilter['PARENT_ID'] = intval($_REQUEST['GALLERY_ID']);