[RC] Glance v.2
-
- phpBB 1.4.4
- Сообщения: 111
- Стаж: 19 лет 10 месяцев
- Откуда: Германия
Вот так вроде вызледит красивее. только это для отдельной страници больше подходит.
glance.php
glance_boby
lang_main
только проверти, нет ли уже таких словечек в файле
glance.php
Код: Выделить всё
<?php
/***************************************************************************
* glance.php
* -------------------
* begin : Monday, Jun 14, 2004
* copyright : Xpert
* contact : www.phpbbguru.net, xpert@phpbbguru.net
* version : 2.0.2
*
* $Id: glance.php,v 2.0.2 2005/01/18 21:54 xpert Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
// Getting basic data
$recent_nm = intval($board_config['glance_recent']);
$user_lastvisit = $userdata['user_lastvisit'];
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
// Auth check
$is_auth_read = array();
$is_auth_read = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
$unauthed = '0';
while ( list($forum_id, $auth_mode) = each($is_auth_read) )
{
if ( !$auth_mode['auth_read'] )
{
$unauthed .= ',' . $forum_id;
}
}
unset($is_auth_read);
// Getting recent topics
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_replies, t.topic_type, t.topic_vote, t.topic_status, t.topic_moved_id, p.post_time, p.post_username, p2.poster_id, u.username, u.user_id
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS p2
WHERE t.forum_id NOT IN (" . $unauthed . ")
AND p2.post_id = t.topic_first_post_id
AND u.user_id = p2.poster_id
AND p.topic_id = t.topic_id
AND p.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY p.post_time DESC
LIMIT " . $recent_nm;
$result = $db->sql_query($sql) or message_die(GENERAL_ERROR, "Could not query recent topics information", "", __LINE__, __FILE__, $sql);
$latest_topics = array();
while ( $topic_row = $db->sql_fetchrow($result) )
{
$topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title'];
$latest_topics[] = $topic_row;
}
$db->sql_freeresult($result);
// Template routines
$template->set_filenames(array(
'glance_output' => 'glance_body.tpl')
);
for ( $i = 0; $i < count($latest_topics); $i++ )
{
$unread_topic = false;
$topic_id = $latest_topics[$i]['topic_id'];
if ( $userdata['session_logged_in'] )
{
if ( $latest_topics[$i]['post_time'] > $user_lastvisit)
{
if( empty($tracking_topics[$topic_id]) || ($tracking_topics[$topic_id] < $latest_topics[$i]['post_time']) )
{
$unread_topic = true;
}
}
}
$newest_code = ( $unread_topic ) ? '&view=newest' : '';
$topic = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "") . '" class="genmed">' . $latest_topics[$i]['topic_title'] .'</a>';
$post_time = create_date($board_config['default_dateformat'], $latest_topics[$i]['post_time'], $board_config['board_timezone']);
$post_poster =( $latest_topics[$i]['user_id'] == ANONYMOUS ) ? ( ($latest_topics[$i]['post_username'] != '' ) ? $latest_topics[$i]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $latest_topics[$i]['user_id']) . '" class="gensmall">' . $latest_topics[$i]['username'] . '</a> ';
$last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $latest_topics[$i]['topic_last_post_id']) . '#' . $latest_topics[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
$topic_type =$latest_topics[$i]['topic_type'];
if( $topic_type == POST_ANNOUNCE )
{
$topic_type = '[' . $lang['Topic_Announcement'] . ']' . ' ';
}
else if( $topic_type == POST_STICKY )
{
$topic_type = '[' . $lang['Topic_Sticky'] . ']' . ' ';
}
else
{
$topic_type = '';
}
if($latest_topics[$i]['topic_vote'] )
{
$topic_type .= '[' . $lang['Topic_Poll'] . ']'. ' ';
}
if($latest_topics[$i]['topic_status'] == TOPIC_MOVED )
{
$topic_type = '[' . $lang['Topic_Moved'] . ']'. ' ';
$topic_id =$latest_topics[$i]['topic_moved_id'];
$folder_image = $images['folder'];
$folder_alt = $lang['Topics_Moved'];
$newest_post_img = '';
}
else
{
if($latest_topics[$i]['topic_type'] == POST_ANNOUNCE )
{
$folder = $images['folder_announce'];
$folder_new = $images['folder_announce_new'];
}
else if($latest_topics[$i]['topic_type'] == POST_STICKY )
{
$folder = $images['folder_sticky'];
$folder_new = $images['folder_sticky_new'];
}
else if($latest_topics[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
else
{
if($replies >= $board_config['hot_threshold'])
{
$folder = $images['folder_hot'];
$folder_new = $images['folder_hot_new'];
}
else
{
$folder = $images['folder'];
$folder_new = $images['folder_new'];
}
}
$newest_post_img = '';
if( $userdata['session_logged_in'] )
{
if($latest_topics[$i]['post_time'] > $userdata['user_lastvisit'] )
{
if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) )
{
if( $tracking_topics[$topic_id] >=$latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
if( !empty($tracking_forums[$forum_id]) )
{
if( $tracking_forums[$forum_id] >=$latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >=$latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
if( $unread_topics )
{
$folder_image = $folder_new;
$folder_alt = $lang['New_posts'];
$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
else
{
$folder_image = $folder;
$folder_alt = ($latest_topics[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$newest_post_img = '';
}
}
else
{
$folder_image = $folder_new;
$folder_alt = ($latest_topics[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
}
else
{
$folder_image = $folder;
$folder_alt = ($latest_topics[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$newest_post_img = '';
}
}
else
{
$folder_image = $folder;
$folder_alt = ($latest_topics[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$newest_post_img = '';
}
}
$replies = $latest_topics[$i]['topic_replies'];
if( ( $replies + 1 ) > $board_config['posts_per_page'] )
{
$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
{
$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>';
if( $times == 1 && $total_pages > 4 )
{
$goto_page .= ' ... ';
$times = $total_pages - 3;
$j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
}
else if ( $times < $total_pages )
{
$goto_page .= ', ';
}
$times++;
}
$goto_page .= ' ] ';
}
else
{
$goto_page = '';
}
if ($latest_topics[$i]['poster_id'] != -1)
{
$poster = '<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $latest_topics[$i]['poster_id']) . '" class="gensmall">'.$latest_topics[$i]['username'].'</a>';
}
else
{
$poster = $lang['Guest'];
}
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('recent', array(
'ROW_CLASS' => $row_class,
'POST_TIME' => $post_time,
'POST_POSTER' => $post_poster,
'GOTO_PAGE' => $goto_page,
'TOPIC' => $topic,
'TOPIC_TYPE' => $topic_type,
'TOPIC_FOLDER_IMG' => $folder_image,
'NEWEST_POST_IMG' => $newest_post_img,
'LAST_POST_IMG' => $last_post_url,
'POSTER' => $poster,
'TOPIC_REPLIES' => $latest_topics[$i]['topic_replies'])
);
}
$template->assign_vars(array(
'L_AUTHOR' => $lang['Author'],
'L_REPLIES' => $lang['Replies'],
'L_TOPICS' => $lang['Topics'],
'L_LASTPOST' => $lang['Last_Post'])
);
$template->assign_var_from_handle('GLANCE_OUTPUT', 'glance_output');
?>
Код: Выделить всё
<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
<tr>
<th colspan="2" align="center" height="25" class="thCornerL" nowrap="nowrap"> {L_TOPICS} </th>
<th width="50" align="center" class="thTop" nowrap="nowrap"> {L_REPLIES} </th>
<th width="100" align="center" class="thTop" nowrap="nowrap"> {L_AUTHOR} </th>
<th align="center" class="thCornerR" nowrap="nowrap"> {L_LASTPOST} </th>
</tr>
<!-- BEGIN recent -->
<tr>
<td class="{recent.ROW_CLASS}" align="center" valign="middle" width="20"><img src="{recent.TOPIC_FOLDER_IMG}" alt="{recent.L_TOPIC_FOLDER_ALT}" title="{recent.L_TOPIC_FOLDER_ALT}" /></td>
<td class="{recent.ROW_CLASS}" width="100%">{recent.NEWEST_POST_IMG}<span class="gensmall">{recent.TOPIC_TYPE}</span>{recent.TOPIC}<br />
<span class="gensmall"> {recent.GOTO_PAGE}</span></td>
<td class="{recent.ROW_CLASS}" align="center" valign="middle"><span class="postdetails">{recent.TOPIC_REPLIES}</span></td>
<td class="{recent.ROW_CLASS}" align="center" valign="middle"><span class="name">{recent.POSTER}</span></td>
<td class="{recent.ROW_CLASS}" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{recent.POST_TIME}</br>
{recent.POST_POSTER}</span>{recent.LAST_POST_IMG}</td>
</tr>
<!-- END recent -->
</table>
только проверти, нет ли уже таких словечек в файле
Код: Выделить всё
$lang['Author'] = 'Автор';
$lang['Replies'] = 'Ответов';
$lang['Topics'] = 'Темы';
$lang['Last_Post'] = 'Последнее сообщение';
"От судьбы не уйдешь, а если ушел - значит, не судьба!"
-
- phpBB 1.4.4
- Сообщения: 111
- Стаж: 19 лет 10 месяцев
- Откуда: Германия
-
- Бывший член :)
- Сообщения: 2925
- Стаж: 19 лет 11 месяцев
- Благодарил (а): 19 раз
- Поблагодарили: 30 раз
- Забанен: Бессрочно
MAzZY писал(а):А как сделать, чтобы по стрелке выполнялся переход не на последнее сообщение в теме, а на первое непрочитанное, а уж при его отсутствии - на последнее в теме?
VVVas писал(а):А стрелка так и работает вообще-то.
Вот, что я хочуMAzZY писал(а):Вот и я думаю, что так должно быть. Но у меня всегда бросает именно на последний пост темы. В чем проблема?
-
- phpBB 1.4.4
- Сообщения: 111
- Стаж: 19 лет 10 месяцев
- Откуда: Германия
-
- phpBB 1.4.4
- Сообщения: 111
- Стаж: 19 лет 10 месяцев
- Откуда: Германия
Странно!MAzZY писал(а):sergejjjjjjjjjjj, проблема именно в том, что работает не так. Я написал об этом выше

короче вот что.
это выводит ссылку на первый пост в теме
Код: Выделить всё
$u_forum_link = append_sid('index.' . $phpEx . '?' . POST_FORUM_URL . '=' . $latest_topics[$i]['forum_id']);
Код: Выделить всё
$last_post = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $latest_topics[$i]['topic_last_post_id']) . '#' . $latest_topics[$i]['topic_last_post_id'] . '"><img src="' . $topic_img . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '"/></a>';
или вот тут перепутали
Вот как должно быть
Код: Выделить всё
'U_FORUM_LINK' => $u_forum_link,
'LAST_POST' => $last_post,
"От судьбы не уйдешь, а если ушел - значит, не судьба!"
-
- Бывший член :)
- Сообщения: 2925
- Стаж: 19 лет 11 месяцев
- Благодарил (а): 19 раз
- Поблагодарили: 30 раз
- Забанен: Бессрочно
Что-то я не понял.
Вот мой glance.php:
Здесь есть , но нигде нет
Вот мой glance.php:
Код: Выделить всё
<?php
/***************************************************************************
* glance.php
* -------------------
* begin : Monday, Jun 14, 2004
* copyright : Xpert
* contact : www.phpbbguru.net, xpert@phpbbguru.net
* version : 2.0.2
*
* $Id: glance.php,v 2.0.2 2005/01/18 21:54 xpert Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
// Getting basic data
$recent_nm = intval($board_config['glance_recent']);
$glance_anno_post = intval($board_config['glance_anno_post']);
$user_lastvisit = $userdata['user_lastvisit'];
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
// Auth check
$is_auth_read = array();
$is_auth_read = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
$unauthed = '0';
while ( list($forum_id, $auth_mode) = each($is_auth_read) )
{
if ( !$auth_mode['auth_read'] )
{
$unauthed .= ',' . $forum_id;
}
}
unset($is_auth_read);
// Getting recent topics
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_replies, p.post_time
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p
WHERE t.forum_id NOT IN (" . $unauthed . ")
AND p.topic_id = t.topic_id
AND p.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY p.post_time DESC
LIMIT " . $recent_nm;
$result = $db->sql_query($sql) or message_die(GENERAL_ERROR, "Could not query recent topics information", "", __LINE__, __FILE__, $sql);
$latest_topics = array();
while ( $topic_row = $db->sql_fetchrow($result) )
{
$topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title'];
$latest_topics[] = $topic_row;
}
$db->sql_freeresult($result);
// Template routines
$template->set_filenames(array(
'glance_output' => 'glance_body.tpl')
);
for ( $i = 0; $i < count($latest_topics); $i++ )
{
$unread_topic = false;
$topic_id = $latest_topics[$i]['topic_id'];
if ( $userdata['session_logged_in'] )
{
if ( $latest_topics[$i]['post_time'] > $user_lastvisit)
{
if( empty($tracking_topics[$topic_id]) || ($tracking_topics[$topic_id] < $latest_topics[$i]['post_time']) )
{
$unread_topic = true;
}
}
}
$newest_code = ( $unread_topic ) ? '&view=newest' : '';
$topic_link = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id" . $newest_code);
$topic_img = ( $unread_topic ) ? $images['icon_newest_reply'] : $images['icon_latest_reply'];
$last_post = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $latest_topics[$i]['topic_last_post_id']) . '#' . $latest_topics[$i]['topic_last_post_id'] . '"><img src="' . $topic_img . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '"/></a>';
$template->assign_block_vars('recent', array(
'LAST_POST' => $last_post,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => $latest_topics[$i]['topic_title'],
'TOPIC_REPLIES' => $latest_topics[$i]['topic_replies'])
);
}
// Announcement text
if ( $glance_anno_post )
{
$sql = "SELECT * FROM " . POSTS_TEXT_TABLE . " WHERE post_id = $glance_anno_post";
$result = $db->sql_query($sql) or message_die(GENERAL_ERROR, 'Could not obtain announcement information', '', __LINE__, __FILE__, $sql);
$announcement = $db->sql_fetchrow($result);
$announcement_text = bbencode_second_pass($announcement['post_text'], $announcement['bbcode_uid']);
$announcement_text = str_replace("\n", "\n<br />\n", $announcement_text);
}
else
{
$announcement_text = '';
}
$template->assign_vars(array(
'ANNO_TITLE' => $lang['Glance_anno'],
'ANNO_TEXT' => $announcement_text,
'RECENT_TITLE' => $lang['Glance_recent'])
);
$template->assign_var_from_handle('GLANCE_OUTPUT', 'glance_output');
?>
Код: Выделить всё
$last_post =
Код: Выделить всё
$u_forum_link
-
- Former team member
- Сообщения: 4463
- Стаж: 20 лет 5 месяцев
- Поблагодарили: 1 раз
смотреть чуть внимательнейMAzZY писал(а):, но нигде нет
Код: Выделить всё
$topic_link = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id" . $newest_code);
-
- phpBB Guru
- Сообщения: 5484
- Стаж: 21 год 1 месяц
- Поблагодарили: 2 раза
Эх... ну когда же я до кровати доберусь...
1. Стрелочка всегда показывает на последний пост темы. Если в теме есть новые сообщения, она оранжевая, иначе белая.
2. Если в теме есть непрочитанные сообщения, ссылка ведет на первое непрочитанное сообщение. Иначе - на начало темы.
1. Стрелочка всегда показывает на последний пост темы. Если в теме есть новые сообщения, она оранжевая, иначе белая.
2. Если в теме есть непрочитанные сообщения, ссылка ведет на первое непрочитанное сообщение. Иначе - на начало темы.
Эксперт - это человек, который избегает мелких ошибок на пути к грандиозному провалу.
Любая более-менее сложная задача имеет несколько простых, изящных, лёгких для понимания неправильных решений
Любая более-менее сложная задача имеет несколько простых, изящных, лёгких для понимания неправильных решений
-
- Бывший член :)
- Сообщения: 2925
- Стаж: 19 лет 11 месяцев
- Благодарил (а): 19 раз
- Поблагодарили: 30 раз
- Забанен: Бессрочно
Мне не к спеху, просто оно действительно не работает.Xpert писал(а):ну когда же я до кровати доберусь
Повторю еще раз: у меня вне зависимости от количества новых сообщений в теме, ссылка ведет именно на последнее сообщение в этой темеXpert писал(а):Если в теме есть непрочитанные сообщения, ссылка ведет на первое непрочитанное сообщение. Иначе - на начало темы.
-
- phpBB 1.4.4
- Сообщения: 111
- Стаж: 19 лет 10 месяцев
- Откуда: Германия
попробуйте заменить вот чтоMAzZY писал(а):Мне не к спеху, просто оно действительно не работает.Xpert писал(а):ну когда же я до кровати доберусь
Повторю еще раз: у меня вне зависимости от количества новых сообщений в теме, ссылка ведет именно на последнее сообщение в этой темеXpert писал(а):Если в теме есть непрочитанные сообщения, ссылка ведет на первое непрочитанное сообщение. Иначе - на начало темы.
Код: Выделить всё
= append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id" . $newest_code);
Код: Выделить всё
= append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $latest_topics[$i]['forum_id']);

"От судьбы не уйдешь, а если ушел - значит, не судьба!"