AJAX загрузка смайлов в модальном окне по клику DLE

создаем файл smiles.php в папке ajax

<?php
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
define('DATALIFEENGINE', true);
define( 'ROOT_DIR', substr( dirname(  __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );
include ENGINE_DIR.'/data/config.php';
date_default_timezone_set ( $config['date_adjust'] );
if ($config['http_home_url'] == "") {
$config['http_home_url'] = explode("engine/ajax/smiles.php", $_SERVER['PHP_SELF']);
$config['http_home_url'] = reset($config['http_home_url']);
$config['http_home_url'] = "http://".$_SERVER['HTTP_HOST'].$config['http_home_url'];
}
require_once ENGINE_DIR.'/classes/mysql.php';
require_once ENGINE_DIR.'/data/dbconfig.php';
require_once ROOT_DIR.'/language/'.$config['langs'].'/adminpanel.lng';
require_once ENGINE_DIR.'/inc/include/functions.inc.php';
dle_session();
$config['charset'] = ($lang['charset'] != '') ? $lang['charset'] : $config['charset'];
@header("Content-type: text/html; charset=".$config['charset']);
//$parse = new ParseFilter();
if($_REQUEST['emo']=='b_emo'){
$i = 0;
$output = "<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>";
$smilies = explode(",", $config['smilies']);
$count_smilies = count($smilies);
foreach($smilies as $smile)
{
$i++;
$smile = trim($smile);
$sm_image ="";
if( file_exists( ROOT_DIR . "/engine/data/emoticons/" . $smile . ".png" ) ) {
if( file_exists( ROOT_DIR . "/engine/data/emoticons/" . $smile . "@2x.png" ) ) {
$sm_image = "<img alt="{$smile}" class="emoji" src="{$config['http_home_url']}engine/data/emoticons/{$smile}.png" srcset="{$config['http_home_url']}engine/data/emoticons/{$smile}@2x.png 2x" />";
} else {
$sm_image = "<img alt="{$smile}" class="emoji" src="{$config['http_home_url']}engine/data/emoticons/{$smile}.png" />";	
}
} elseif ( file_exists( ROOT_DIR . "/engine/data/emoticons/" . $smile . ".gif" ) ) {
if( file_exists( ROOT_DIR . "/engine/data/emoticons/" . $smile . "@2x.gif" ) ) {
$sm_image = "<img alt="{$smile}" class="emoji" src="{$config['http_home_url']}engine/data/emoticons/{$smile}.gif" srcset="{$config['http_home_url']}engine/data/emoticons/{$smile}@2x.gif 2x" />";
} else {
$sm_image = "<img alt="{$smile}" class="emoji" src="{$config['http_home_url']}engine/data/emoticons/{$smile}.gif" />";	
}
}
$output .= "<td style="padding:5px;" align="center"><a href="#" onclick="dle_smiley(':$smile:'); return false;">{$sm_image}</a></td>";
if ($i%12 == 0 AND $i < $count_smilies) $output .= "</tr><tr>";
}
$output .= "</tr></table>";	
echo $output;
}
?>

в файле bbcode.php
меняем

<b id="b_emo" class="bb-btn" onclick="show_bb_dropdown(this)" title="{$lang['bb_t_emo']}" tabindex="-1"></b>
<ul class="bb-pane-dropdown" id="emo_response">
<li>{$output}</li>
</ul>

на

<b id="b_emo" data-smiles-id="b_emo" class="bb-btn" onclick="showSmiles('b_emo')" title="{$lang['bb_t_emo']}" tabindex="-1"></b>
<div style="display:none" id="b_emo_response"></div>

fullstory.tpl

<script>
function showSmiles( event ){
//ShowLoading('');
$.get(dle_root + "engine/ajax/smiles.php", { emo: event}, function(data){
//HideLoading('');
//console.log(data);
$("#"+event+"_response").html(data).dialog({
autoOpen: true,
show: 'fade',
hide: 'fade',
width: 550,
buttons: {"Закрыть" : function() {
$(this).dialog("close");
}}
});		
});
}	
</script>
Обновлено: 12/12/2016 — 18:11

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *