S
Stanislav
Гость
XANDER-CAGE, Спасибо. Голову не включил сам, т.к. очень сильно пьян! )
а как я его там подключил? лень смотреть))frost444, улыбнул мод, особенно подключение js
Выложу, но точно не сегодня.krumax, выкладывай
а её там и небыло )krumax, куда дел кнопку обновления?? или я её не добавлял?
##############################################################
## Название мода: [Last added post] + addon
## Автор мода: frost444 http://f-trackers.com
## Версия мода: 1.0
## Описание: Вывод последних сообщений из форумов. Кеширование DataStore + вывод аватарки пользователя и пред просмотр поста на ajax возможная совместимость с модов подсветки ранга юзера по званию, обновление на аяксе и многое другое...
## Слоность установки: легкая
## Время на уствновку: 5 минут
## Изменяемые файлы: config.php
## index.php
## includes/datastore/build_cat_forums.php
## language/lang_russian/lang_main.php
## templates/default/page_header.tpl
## ajax.php
## Добавляемые файлы: отсутствуют
##############################################################
#
#-----[ OPEN ]---------------------------------
#
config.php
#
#-----[ FIND ]---------------------------------
#
END FILE
#
#-----[ AFTER, ADD ]---------------------------------
#
//Last_post
$bb_cfg['new_add_post_num'] = 5; // количество выводимых сообщений
$bb_cfg['title_lp_stext'] = 40; // сколько символов выводится в заглавии темы
$bb_cfg['new_add_post_ignor_f'] = '0'; //Форумы которые нужно игнорировать, строка должна выглядеть так '1,2,3,4'
$bb_cfg['new_add_post_col'] = '#FAA'; //цвет нового сообщения ( в состоянии теста )
$bb_cfg['no_avatar'] = 'images/avatars/gallery/noavatar.png'; // путь до noavatar.png
$bb_cfg['forum_lp_on'] = false; // включить или отключить вывод форума true|false
$bb_cfg['data_lp_on'] = true; // включить или отключить вывод форума true|false
$bb_cfg['ava_lp_on'] = true; // включить или отключить вывод форума true|false
#
#-----[ OPEN ]---------------------------------
#
index.php
#
#-----[ FIND ]---------------------------------
#
// Init userdata
$user->session_start();
#
#-----[ BEFORE, ADD ]---------------------------------
#
if ($bb_cfg['new_add_post_num'])
{
$datastore->enqueue('new_added_post');
}
#
#-----[ FIND ]---------------------------------
#
// Build index page
foreach ($cat_forums as $cid => $c)
{
#
#-----[ BEFORE, ADD ]---------------------------------
#
if($bb_cfg['new_add_post_num'])
{
$template -> assign_vars(array(
'NEW_ADD_POST_ON' => true,
));
$new_added_post = $datastore->get('new_added_post');
foreach ($new_added_post as $new_post)
{
$user_avatar = $bb_cfg['no_avatar'];
if($new_post['user_allowavatar'])
{
switch($new_post['user_avatar_type'])
{
case USER_AVATAR_UPLOAD:
$user_avatar = ($bb_cfg['allow_avatar_upload']) ? $bb_cfg['avatar_path'] .'/'. $new_post['user_avatar'] : '';
break;
case USER_AVATAR_REMOTE:
$user_avatar = ($bb_cfg['allow_avatar_remote']) ? $new_post['user_avatar'] .'" alt="'. $lang['Avatar'] : '';
break;
case USER_AVATAR_GALLERY:
$user_avatar = ($bb_cfg['allow_avatar_local']) ? $bb_cfg['avatar_gallery_path'] .'/'. $new_post['user_avatar'] : '';
break;
}
}
$template -> assign_block_vars('newaddpost',array(
'LP_USER_AVA' => '<img src="'. $user_avatar .'" align="left" height="32" width="32" style="padding-right: 3px;">',
'TOPIC_TITLE' => addslashes(str_short($new_post['topic_title'], $bb_cfg['title_lp_stext'])),
'POST_ID' => $new_post['post_id'],
'TOPIC_ID' => $new_post['topic_id'],
'FORUM' => $new_post['forum_name'],
'FORUM_ON' => $bb_cfg['forum_lp_on'],
'NEW_P_CLASS' => (is_unread($new_post['topic_last_post_time'], $new_post['topic_id'], $new_post['forum_id'])) ? $bb_cfg['new_add_post_col'] : '',
'FORUM_ID' => $new_post['forum_id'],
'AUTOR_POST' => $new_post['username'],
'AUTOR_POST_ID' => $new_post['user_id'],
'POST_TIME' => date('Y-m-d H:i', $new_post['topic_last_post_time']),
'URL_NEW_POST' => append_sid(BB_ROOT ."viewtopic.$phpEx?". POST_POST_URL ."=". $new_post['topic_last_post_id'] ."#". $new_post['topic_last_post_id']),
)) ;
}
}
#
#-----[ OPEN ]---------------------------------
#
includes/datastore/build_cat_forums.php
#
#-----[ FIND ]---------------------------------
#
bb_update_config(array('active_ads' => serialize($ad_block_assignment)));
#
#-----[ AFTER, ADD ]---------------------------------
#
if($bb_cfg['new_add_post_num'])
{
$porno_forums = $bb_cfg['porno_forums'] ? $bb_cfg['porno_forums'] : '0';
$trash_forums = $bb_cfg['trash_forum_id'] ? $bb_cfg['trash_forum_id'] : '0';
$ignor_forum = $bb_cfg['new_add_post_ignor_f'];
$data = $db->fetch_rowset("SELECT
tr.topic_id, tr.forum_id, tr.poster_id, tr.post_id,
t.*, f.*, u.user_id, u.username, u.user_avatar, u.user_avatar_type, u.user_allowavatar
FROM
". POSTS_TABLE ." tr
LEFT JOIN ". TOPICS_TABLE ." t ON tr.post_id = t.topic_last_post_id
AND t.forum_id NOT IN($ignor_forum, $porno_forums, $trash_forums)
LEFT JOIN ". FORUMS_TABLE ." f ON tr.forum_id = f.forum_id
AND f.auth_read = ". AUTH_ALL ."
LEFT JOIN ". USERS_TABLE ." u ON tr.poster_id = u.user_id
AND u.username = u.username
ORDER BY
t.topic_last_post_time DESC
LIMIT 0,".$bb_cfg['new_add_post_num']);
$this->store('new_added_post', $data);
}
#
#-----[ OPEN ]---------------------------------
#
ajax.php
#
#-----[ FIND ]---------------------------------
#
'view_post' => array('guest'),
#
#-----[ AFTER, ADD ]---------------------------------
#
'last_post' => array('guest'),
#
#-----[ FIND LAST ]---------------------------------
#
}
#
#-----[ BEFORE, ADD ]---------------------------------
#
function last_post()
{
global $db, $bb_cfg, $lang, $userdata, $phpEx, $datastore;
$mode = (string) $this->request['mode'];
if($mode == 'update_lp')
{
$porno_forums = $bb_cfg['porno_forums'] ? $bb_cfg['porno_forums'] : '0';
$trash_forums = $bb_cfg['trash_forum_id'] ? $bb_cfg['trash_forum_id'] : '0';
$ignor_forum = $bb_cfg['new_add_post_ignor_f'];
$limit = $bb_cfg['new_add_post_num'];
$message = '';
$datastore->update('cat_forums');
$sql = $db->query("SELECT tr.topic_id, tr.forum_id, tr.poster_id, tr.post_id,
t.*, f.*, u.user_id, u.username, u.user_avatar, u.user_avatar_type, u.user_allowavatar
FROM
". POSTS_TABLE ." tr
LEFT JOIN ". TOPICS_TABLE ." t ON tr.post_id = t.topic_last_post_id
AND t.forum_id NOT IN($ignor_forum, $porno_forums, $trash_forums)
LEFT JOIN ". FORUMS_TABLE ." f ON tr.forum_id = f.forum_id
AND f.auth_read = ". AUTH_ALL ."
LEFT JOIN ". USERS_TABLE ." u ON tr.poster_id = u.user_id
AND u.username = u.username
ORDER BY
t.topic_last_post_time DESC LIMIT 0, $limit");
while ($row = $db->sql_fetchrow($sql))
{
$user_avatar = $bb_cfg['no_avatar'];
if($row['user_allowavatar'])
{
switch($row['user_avatar_type'])
{
case USER_AVATAR_UPLOAD:
$user_avatar = ($bb_cfg['allow_avatar_upload']) ? $bb_cfg['avatar_path'] .'/'. $row['user_avatar'] : '';
break;
case USER_AVATAR_REMOTE:
$user_avatar = ($bb_cfg['allow_avatar_remote']) ? $row['user_avatar'] .'" alt="'. $lang['Avatar'] : '';
break;
case USER_AVATAR_GALLERY:
$user_avatar = ($bb_cfg['allow_avatar_local']) ? $bb_cfg['avatar_gallery_path'] .'/'. $row['user_avatar'] : '';
break;
}
}
$user_avatars = '<img src="'. $user_avatar .'" align="left" height="32" width="32" style="padding-right: 3px;">';
$topic_title = addslashes(str_short($row['topic_title'], $bb_cfg['title_lp_stext']));
$post_id = $row['post_id'];
$topic_id = $row['topic_id'];
$forum = $row['forum_name'];
//$new_p_class = (is_unread($row['topic_last_post_time'], $row['topic_id'], $row['forum_id'])) ? $bb_cfg['new_add_post_col'] : '';
$forum_id = $row['forum_id'];
$autor_post = $row['username'];
$autor_post_id = $row['user_id'];
$post_time = create_date('Y-m-d H:i', $row['topic_last_post_time']);
$url_new_post = append_sid(BB_ROOT ."viewtopic.$phpEx?". POST_POST_URL ."=". $row['topic_last_post_id'] ."#". $row['topic_last_post_id']);
$message .= '<script type="text/javascript" src="misc/js/jtip.js"></script>';
$message .= '<table cellspacing="0" border="0"><tr>';
$message .= ($bb_cfg['ava_lp_on']) ? '<td style="border-bottom: 1px solid #C3CBD1; background-color: ">'.$user_avatars.'</td>' : '';
$message .= '<td class="f_titles" style="border-bottom: 1px solid #C3CBD1; background-color:">';
$message .= '<div><a href="viewtopic.php?t='.$topic_id.'" style="font-size:11px">'.$topic_title.'</a></div>';
$message .= '<div style="font-size:10px"><a href="profile.php?mode=viewprofile&u='.$autor_post_id.'">'.$autor_post.'</a>';
$message .= ($bb_cfg['data_lp_on']) ? ' '.$post_time. '' : '';
$message .= ' <a href="'.$url_new_post.'">>></a></div>';
$message .= ($bb_cfg['forum_lp_on']) ? '<div style="font-size:10px">'.$lang['FORUM'].': <a href="viewforum.php?f='.$forum_id.'">'.$forum.'</a></div>' : '';
$message .= '<div class="tCenter"><a href="http://'.$bb_cfg['server_name'].''.$bb_cfg['script_path'].'viewpost.php?id='.$post_id .'" class="jTip" name="'.$forum.'" id="post_'.$post_id .'">'.$lang['PREVIEW'].'</a></div>';
$message .= '</td></tr></table>';
}
}
$this->response['message'] = $message;
$this->response['mode'] = $mode;
}
#
#-----[ OPEN ]---------------------------------
#
language/lang_russian/lang_main.php
#
#-----[ FIND ]---------------------------------
#
END FILE
#
#-----[ AFTER, ADD ]---------------------------------
#
$lang['LAST_ADD_POST'] = 'Последние сообщения';
#
#-----[ OPEN ]---------------------------------
#
templates/default/page_header.tpl
#
#------------[ FIND ]-------------------------------
#
<script type="text/javascript" src="{#BB_ROOT}misc/js/jquery.pack.js?v={$bb_cfg['js_ver']}"></script>
#
#-----[ AFTER, ADD ]---------------------------------
#
<script type="text/javascript" src="{#BB_ROOT}misc/js/jtip.js?v={$bb_cfg['js_ver']}"></script>
#
#------------[ FIND ]-------------------------------
#
<link rel="stylesheet" href="{STYLESHEET}?v={$bb_cfg['css_ver']}" type="text/css">
#
#-----[ AFTER, ADD ]---------------------------------
#
<link rel="stylesheet" href="./templates/default/css/jtip.css" type="text/css">
#
#-----[ FIND ]---------------------------------
#
<?php if (!empty($bb_cfg['sidebar1_static_content_path'])) include($bb_cfg['sidebar1_static_content_path']); ?>
#
#-----[ BEFORE, ADD ]---------------------------------
#
<script type="text/javascript">
ajax.callback.last_post = function(data) {
$('#'+data.mode).html(data.message);
};
</script>
<!-- IF NEW_ADD_POST_ON -->
<h3></h3>
<div class="spacer"> </div>
<table cellpadding="1" cellspacing="0" border="0" class="attachtable"><tr><td>
<table width="100%" cellspacing="0" border="0">
<tr class="cat_title"><td style="border-bottom: 1px solid #C3CBD1;"><b>{L_LAST_ADD_POST}</b></td></tr>
</table>
<table id="update_lp" cellspacing="0" border="0" width="auto">
<!-- BEGIN newaddpost -->
<tr>
<td style="border-bottom: 1px solid #C3CBD1; background-color: {newaddpost.NEW_P_CLASS}">{newaddpost.LP_USER_AVA}</td>
<td class="f_titles" style="border-bottom: 1px solid #C3CBD1; background-color: {newaddpost.NEW_P_CLASS}">
<div><a href="viewtopic.php?t={newaddpost.TOPIC_ID}" style="font-size:11px">{newaddpost.TOPIC_TITLE}</a></div>
<div style="font-size:10px"><a href="profile.php?mode=viewprofile&u={newaddpost.AUTOR_POST_ID}">{newaddpost.AUTOR_POST}</a> {newaddpost.POST_TIME} <a href="{newaddpost.URL_NEW_POST}">>></a></div>
<!-- IF newaddpost.FORUM_ON -->
<div style="font-size:10px"> {L_FORUM}: <a href="viewforum.php?f={newaddpost.FORUM_ID}">{newaddpost.FORUM}</a></div>
<!-- ENDIF -->
<div style="font-size:10px" align="center"><a href="http://{$bb_cfg['server_name']}{$bb_cfg['script_path']}viewpost.php?id={newaddpost.POST_ID}" class="jTip" name="{newaddpost.TITLE}" id="post_{newaddpost.POST_ID}">Пред.просмотр</a></div>
</td>
</tr>
<!-- END newaddpost -->
</table>
<a class="txtb" href="#" onclick="ajax.exec({action : 'last_post', mode: 'update_lp'}); return false;">[Обновить]</a>
</td></tr></table>
<!-- ENDIF -->
#
#-----[ SAVE/CLOSE ALL FILES/UPDATE DataStore ]-------------
#
# EoM