Page 1 sur 1
Mod At a Glance pour phpbb3
Publié : septembre 6, 2008, 8:25 pm
par Aurelienazerty
Comme vous avez pu le constater
dans cette discussion, j'ai adapté le mod
"At a Glance 2.2.1" pour phpbb2 vers phpbb3. Comme je n'ai rien trouvé sur internet, et que ça peut sûrement aider d'autre, voilà les fichier modifiés.
Code : Tout sélectionner
Mod At A glance: Permet d'afficher sur la page d'index du forum, les dernières actualité et les derniers sujet de discussion.
Le lien envoie directement sur le 1° sujet non lu.
Ficher
glance.php à mettre à à la racine du forum:
Code : Tout sélectionner
<?php
/***************************************************************************
* glance.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
* version : 2.2.1
*
***************************************************************************/
/* Edit your PREFERENCES in glance_config.php, NOT HERE. */
/************************* DO NOT EDIT BELOW THIS LINE *********************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
define('IN_GLANCE', true);
include($phpbb_root_path . 'glance_config.'.$phpEx);
//
// GET USER LAST VISIT
//
$glance_last_visit = $userdata['user_lastvisit'];
//
// MESSAGE TRACKING
//
//if ( !isset($tracking_topics) && $glance_track ) $tracking_topics = ( isset($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) : '';
$tracking_topics = array();
// CHECK FOR BAD WORDS
//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
//
// GET THE LATEST NEWS TOPIC
//
if ( $glance_num_news )
{
$news_data = $db->sql_fetchrow($result);
$sql_select = ", p.post_time";
$sql_from = ", " . POSTS_TABLE . " p";
$sql_where = " AND p.post_id = t.topic_last_post_id";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_time, t.forum_id" . $sql_select . "
FROM " . TOPICS_TABLE . " t" . $sql_from . "
WHERE t.forum_id = " . $glance_news_forum_id . $sql_where . "
AND t.topic_moved_id = 0
ORDER BY t.topic_first_post_id DESC
LIMIT " . $glance_num_news;
$latest_news = array();
$result = $db->sql_query($sql);
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_news[] = $topic_row;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
//
// GET THE LAST 5 TOPICS
//
if ( $glance_num_recent )
{
$unauthed_forums = array();
$sql = "SELECT forum_id, auth_view FROM " . FORUMS_TABLE . " WHERE forum_id <> " . $glance_news_forum_id;
$glance_auth_level = ( $glance_auth_read ) ? AUTH_VIEW : AUTH_ALL;
//$is_auth_ary = auth($glance_auth_level, AUTH_LIST_ALL, $userdata);
$forumsignore = '';
$notAllowedForums = array();
$notAllowedForums = array_keys($auth->acl_getf('!f_read', true));
if (sizeof($notAllowedForums)> 0) {
$forumsignore = implode(', ', $notAllowedForums);
} else {
$forumsignore= "-1";
}
if ( $num_forums = count($is_auth_ary) )
{
while ( list($forum_id, $auth_mod) = each($is_auth_ary) )
{
$unauthed = false;
if ( !$auth_mod['auth_view'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( !$glance_auth_read && !$auth_mod['auth_read'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( $unauthed )
{
$forumsignore .= $forum_id . ', ';
}
}
}
$sql = "SELECT t.topic_title, t.topic_id, p2.post_time, t.forum_id
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2
WHERE t.forum_id NOT IN (" . $forumsignore . "," . $glance_news_forum_id . ")
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY p2.post_time DESC
LIMIT " . $glance_num_recent;
$latest_topics = array();
$result = $db->sql_query($sql);
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;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
if ( $glance_num_news )
{
if ( !empty($latest_news) )
{
$bullet_pre = 'glance_news_bullet';
for ( $i = 0; $i < count($latest_news); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_news[$i]['topic_id'];
if ( $latest_news[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_news[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
$topic_link = $glance_forum_dir . 'viewtopic.php?t=' . $latest_news[$i]['topic_id'] . $newest_code;
$template->assign_block_vars('news', array(
'BULLET' => $$bullet_full,
'TOPIC_TITLE' => $latest_news[$i]['topic_title'],
'TOPIC_LINK' => $topic_link,
'TOPIC_TIME' => $user->format_date($latest_news[$i]['topic_time']))
);
}
}
else
{
$template->assign_block_vars('news', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
if ( $glance_num_recent )
{
$glance_info = 'counted recent';
$bullet_pre = 'glance_recent_bullet';
if ( !empty($latest_topics) )
{
for ( $i = 0; $i < count($latest_topics); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_topics[$i]['topic_id'];
if ( $latest_topics[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
$topic_id = $latest_topics[$i]['topic_id'];
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
//avant nico:
//$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
//Modif nico:
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '&view=latest';
//Post à pointer
$post = 0;
if ( $unread_topics && $glance_show_new_bullets ) {
//Récupérer le premier post non lu
$sql = "Select post_id
FROM `" . POSTS_TABLE . "`
where post_time >= ".$tracking_topics[$topic_id]."
AND topic_id = ".$topic_id."
ORDER by post_time ASC
limit 1";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["post_id"];
}
} else {
$sql = "Select max(post_id)
FROM `" . POSTS_TABLE . "`
where topic_id = ".$topic_id;
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["max(post_id)"];
}
}
$topic_link = $glance_forum_dir . 'viewtopic.php?p=' . $post . "#p".$post;
$template->assign_block_vars('recent', array(
'BULLET' => $$bullet_full,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => $latest_topics[$i]['topic_title'])
);
}
}
else
{
$template->assign_block_vars('recent', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
//Photos
$myUser = new user_site($user->data['user_id']);
$myUser->setSession_id($user->data['session_id']);
$myUser->setVariablePhpBB($user->data);
$myUser->setObjetPhpBB($user);
//var_dump($glance_num_recent);die;
$tab = photo_commentaire::getLastCommentaireForUser($myUser, $glance_num_recent / 2 - 1, true);
foreach ($tab as $resultat) {
$photo = new photo($resultat['photo_id']);
$contexte = $photo->contexte();
if (!empty($contexte)) {
$quoi = 'une photo';
} else {
$quoi = 'la photo';
$contexte = $photo->url();
}
$topic_link = 'http://www.team-azerty.com/images/view-' . $photo->photo_id() . '.html';
$topic_title = 'Commentaire sur ' . $quoi . ' ' . $contexte . ' ';
$template->assign_block_vars('recent', array(
'BULLET' => $$bullet_full,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => $topic_title)
);
}
if ( $glance_num_news )
{
$template->assign_block_vars('switch_glance_news', array());
}
if ( $glance_num_recent )
{
$template->assign_block_vars('switch_glance_recent', array());
}
$template->assign_vars(array(
'RECENT_HEADING' => $glance_recent_heading,
'NEWS_HEADING' => $glance_news_heading)
);
$template->assign_var('GLANCE_OUTPUT_YES', 'YES');
// THE END
?>
Ficher de configuration
glance_config.php à mettre également à la racine du forum
Code : Tout sélectionner
<?php
/***************************************************************************
* glance_config.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
*
***************************************************************************/
if ( !defined('IN_GLANCE') )
{
die("Hacking attempt");
}
/***************************************************************************
*
* *************** SET UP VARIABLES HERE ***********************/
// FORUM DIRECTORY
$glance_forum_dir = '';
// NEWS FORUM ID
$glance_news_forum_id = 0; // SET TO ZERO IF YOU DO NOT HAVE A NEWS FORUM
// NUMBER OF NEWS ARTICLES YOU WISH TO DISPLAY
$glance_num_news = 0; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED or DO NOT HAVE A NEWS FORUM
// NUMBER OF RECENT ARTICLES YOU WISH TO DISPLAY
$glance_num_recent = 10; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED
// NEWS HEADING
$glance_news_heading = 'Dernières brèves';
// RECENT TOPIC HEADING
$glance_recent_heading = 'Dernières discussions';
// NEWS BULLET OLD
$glance_news_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET OLD
$glance_recent_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// NEWS BULLET NEW
$glance_news_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET NEW
$glance_recent_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// TABLE WIDTH
$glance_table_width = 250;
// CHANGE THE BULLET IF A TOPIC IS NEW? (true / false)
$glance_show_new_bullets = true;
// MESSAGE TRACKING WILL TRACK TO SEE IF A USER HAS READ THE TOPIC DURING THEIR SESSION (true / false)
$glance_track = true;
// SHOW TOPICS THE USER CAN VIEW, BUT NOT READ? (true / false)
$glance_auth_read = true;
/************************* DO NOT EDIT BELOW THIS LINE *********************/
?>
Editer le fichier
index.php situé à la racine du forum
AvantCode : Tout sélectionner
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
Rajouter:
Code : Tout sélectionner
if ($user->data['is_registered']) include($phpbb_root_path . 'glance.'.$phpEx);
situé à la racine du forum.Comme il existe 2 thèmes par défaut et qu'ils n'ont rien à voir, voici
pour la template prosilver :
Modifier le fichier
/styles/prosilver/template/overall_header.html
Avant Code : Tout sélectionner
<!-- IF S_DISPLAY_SEARCH and not S_IN_SEARCH -->
<div id="search-box">
<form action="{U_SEARCH}" method="post" id="search">
<fieldset>
<input name="keywords" id="keywords" type="text" maxlength="128" title="{L_SEARCH_KEYWORDS}" class="inputbox search" value="<!-- IF SEARCH_WORDS-->{SEARCH_WORDS}<!-- ELSE -->{L_SEARCH_MINI}<!-- ENDIF -->" onclick="if(this.value=='{LA_SEARCH_MINI}')this.value='';" onblur="if(this.value=='')this.value='{LA_SEARCH_MINI}';" />
<input class="button2" value="{L_SEARCH}" type="submit" /><br />
<a href="{U_SEARCH}" title="{L_SEARCH_ADV_EXPLAIN}">{L_SEARCH_ADV}</a> {S_SEARCH_HIDDEN_FIELDS}
</fieldset>
</form>
</div>
<!-- ENDIF -->
Rajouter :
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
<!-- ENDIF -->
Ajouter le fichier
glance_body.html dans
/styles/prosilver/template/Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td >
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">{news.BULLET}<a href="{news.TOPIC_LINK}">{news.TOPIC_TITLE}</a><br>{news.TOPIC_TIME}</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >{recent.BULLET}<a href="{recent.TOPIC_LINK}">{recent.TOPIC_TITLE}</a></td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>
Modifier le fichier
/styles/prosilver/theme/common.css, à la fin ajouter :
Code : Tout sélectionner
#atGlanceBox {
color: #FFFFFF;
margin-top: 0px;
margin-right: 250px;
display: block;
float: right;
position: absolute;
right: 0px;
white-space: nowrap; /* For Opera */
}
#atGlanceBox a {
color: #ffffff;
}
#atGlanceBox a:hover {
color: #b8cdef;
}
Pour le thème
subsilver 2
Modifier le fichier
/styles/subsilver2/template/overall_header.html
Après Code : Tout sélectionner
<td width="100%" align="center"><h1>{SITENAME}</h1><span class="gen">{SITE_DESCRIPTION}</span></td>
Ajouter
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<td>
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
</td>
<!-- ENDIF -->
Ajouter le fichier glance_body.html dans
/styles/subsilver2/template/Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">
{news.BULLET}
<a href="{news.TOPIC_LINK}" class="forumlink">
{news.TOPIC_TITLE}
</a>
<br>
{news.TOPIC_TIME}
</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >
{recent.BULLET}
<a href="{recent.TOPIC_LINK}" class="genmed">
{recent.TOPIC_TITLE}
</a>
</td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>
Voilà. Graphiquement je trouve le rendu plus réussi sur subsilver 2. Mais c'est une question de goûts. je suis ouvert à toute amélioration pour prosilver.
Re: Mod At a Glance pour phpbb3
Publié : novembre 20, 2009, 9:20 pm
par TheCrewStyle
Hi, can you make this mod , that the visitors can see recent discussions?
Thanks for this great mod.
Later Edit:
I made that this mod will show in a block on index.
When a user starts a topic with a big title, the page is going to increase.
Look at this picture
http://img687.imageshack.us/i/234234212 ... 43423.png/
Can you make that when a topic title exceeds an amount of characters (let's say 80) go to a new line? Or to appear "..." after the 80 characters.
Thanks for your great work.
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 10:00 am
par TheCrewStyle
Somebody can help me?
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 10:57 am
par Arken
Well if you know a little bit of php, you could just add a parameter in glance_config.php (let's say $glance_max_topic_title_length) and use it in the glance.php to make a "substr" on the topic title when you have to display it.
I'm not the author of this mod and i don't know (barely) anything to phpBB so i can't help you any further.
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 12:12 pm
par TheCrewStyle
Hi, thanks for your reply and help, but my problem is that, i don't know php...
IF somebody can help me, please help.
Pas le temps
Publié : novembre 21, 2009, 12:37 pm
par Aurelienazerty
I'm the author of Glance Mod for phpbb3, but I have not enouth time to work on it, it's enouth for our forum use case, that's all I want. As Olivier said, the modifications are realy simples : Do a
substr here : 'TOPIC_LINK' => $topic_link
In order to see it for not logged user, juste put the
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
<!-- ENDIF -->
In an other place in the template
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 4:06 pm
par TheCrewStyle
If is so simple like you say, please write me that 2 lines of code. please.
I know that is what you want for your board, but i ask for you help.\
Otherway,
I tried to do something. Please tell me if i'm wrong.
I will add this parameter in glance_config.php:
And, in glance.php i will add this subtr after 'TOPIC_LINK' => $topic_link :
$glance_max_topic_title_length = substr("topic_title", 0, 7);
7 will be the number of characters which will apear on index at recent discussions.
It's ok?
And this code :
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
<!-- ENDIF -->
I added in other place on forum (you can see this in picture), in index_body. But same problem, is not showing.
Pas trop le temps
Publié : novembre 21, 2009, 7:46 pm
par Aurelienazerty
TheCrewStyle a écrit :If is so simple like you say, please write me that 2 lines of code. please.
Écoute garçon, je ne sais pas si c'est le meilleur moyen de parler pour qu'on fasse le boulot à ta place. Si ce n'est pas compliqué intellectuellement parlant, cela demande du temps, de l'envie, et ça là tout de suite, je n'en ai pas. On t'as expliqué comment faire dans les grandes lignes, à toi d'être curieux et débrouillard pour arriver à tes fins.
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 10:00 pm
par Arken
That should make it. I accept cheque and Paypal
Code : Tout sélectionner
<?php
/***************************************************************************
* glance.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
* version : 2.2.1
*
***************************************************************************/
/* Edit your PREFERENCES in glance_config.php, NOT HERE. */
/************************* DO NOT EDIT BELOW THIS LINE *********************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
define('IN_GLANCE', true);
include($phpbb_root_path . 'glance_config.'.$phpEx);
//
// GET USER LAST VISIT
//
$glance_last_visit = $userdata['user_lastvisit'];
//
// MESSAGE TRACKING
//
//if ( !isset($tracking_topics) && $glance_track ) $tracking_topics = ( isset($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) : '';
$tracking_topics = array();
// CHECK FOR BAD WORDS
//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
//
// GET THE LATEST NEWS TOPIC
//
if ( $glance_num_news )
{
$news_data = $db->sql_fetchrow($result);
if ( 1 )
{
$sql_select = ", p.post_time";
$sql_from = ", " . POSTS_TABLE . " p";
$sql_where = " AND p.post_id = t.topic_last_post_id";
}
$sql = "SELECT t.topic_id, t.topic_title, t.topic_time, t.forum_id" . $sql_select . "
FROM " . TOPICS_TABLE . " t" . $sql_from . "
WHERE t.forum_id = " . $glance_news_forum_id . $sql_where . "
AND t.topic_moved_id = 0
ORDER BY t.topic_first_post_id DESC
LIMIT " . $glance_num_news;
$latest_news = array();
$result = $db->sql_query($sql);
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_news[] = $topic_row;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
//
// GET THE LAST 5 TOPICS
//
if ( $glance_num_recent )
{
$unauthed_forums = array();
$sql = "SELECT forum_id, auth_view FROM " . FORUMS_TABLE . " WHERE forum_id <> " . $glance_news_forum_id;
$glance_auth_level = ( $glance_auth_read ) ? AUTH_VIEW : AUTH_ALL;
//$is_auth_ary = auth($glance_auth_level, AUTH_LIST_ALL, $userdata);
$forumsignore = '';
$notAllowedForums = array();
$notAllowedForums = array_keys($auth->acl_getf('!f_read', true));
if (sizeof($notAllowedForums)> 0) {
$forumsignore = implode(', ', $notAllowedForums);
} else {
$forumsignore= "-1";
}
if ( $num_forums = count($is_auth_ary) )
{
while ( list($forum_id, $auth_mod) = each($is_auth_ary) )
{
$unauthed = false;
if ( !$auth_mod['auth_view'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( !$glance_auth_read && !$auth_mod['auth_read'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( $unauthed )
{
$forumsignore .= $forum_id . ', ';
}
}
}
$sql = "SELECT t.topic_title, t.topic_id, p2.post_time, t.forum_id
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2
WHERE t.forum_id NOT IN (" . $forumsignore . "," . $glance_news_forum_id . ")
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY t.topic_last_post_id DESC
LIMIT " . $glance_num_recent;
$latest_topics = array();
$result = $db->sql_query($sql);
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;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
if ( $glance_num_news )
{
if ( !empty($latest_news) )
{
$bullet_pre = 'glance_news_bullet';
for ( $i = 0; $i < count($latest_news); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_news[$i]['topic_id'];
if ( $latest_news[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_news[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
$topic_link = $glance_forum_dir . 'viewtopic.php?t=' . $latest_news[$i]['topic_id'] . $newest_code;
$template->assign_block_vars('news', array(
'BULLET' => $$bullet_full,
'TOPIC_TITLE' => substr($latest_news[$i]['topic_title'], 0, $glance_max_topic_title_length),
'TOPIC_LINK' => $topic_link,
'TOPIC_TIME' => $user->format_date($latest_news[$i]['topic_time']))
);
}
}
else
{
$template->assign_block_vars('news', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
if ( $glance_num_recent )
{
$glance_info = 'counted recent';
$bullet_pre = 'glance_recent_bullet';
if ( !empty($latest_topics) )
{
for ( $i = 0; $i < count($latest_topics); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_topics[$i]['topic_id'];
if ( $latest_topics[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
//avant nico:
//$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
//Modif nico:
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '&view=latest';
//Post à pointer
$post = 0;
if ( $unread_topics && $glance_show_new_bullets ) {
//Récupérer le premier post non lu
$sql = "Select post_id
FROM `" . POSTS_TABLE . "`
where post_time >= ".$tracking_topics[$topic_id]."
AND topic_id = ".$topic_id."
ORDER by post_time ASC
limit 1";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["post_id"];
}
} else {
$sql = "Select max(post_id)
FROM `" . POSTS_TABLE . "`
where topic_id = ".$topic_id;
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["max(post_id)"];
}
}
$topic_link = $glance_forum_dir . 'viewtopic.php?p=' . $post . "#p".$post;
$template->assign_block_vars('recent', array(
'BULLET' => $$bullet_full,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => substr($latest_topics[$i]['topic_title'], 0, $glance_max_topic_title_length))
);
}
}
else
{
$template->assign_block_vars('recent', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
if ( $glance_num_news )
{
$template->assign_block_vars('switch_glance_news', array());
}
if ( $glance_num_recent )
{
$template->assign_block_vars('switch_glance_recent', array());
}
$template->assign_vars(array(
'RECENT_HEADING' => $glance_recent_heading,
'NEWS_HEADING' => $glance_news_heading)
);
$template->assign_var('GLANCE_OUTPUT_YES', 'YES');
// THE END
?>
Ficher de configuration
glance_config.php à mettre également à la racine du forum
Code : Tout sélectionner
<?php
/***************************************************************************
* glance_config.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
*
***************************************************************************/
if ( !defined('IN_GLANCE') )
{
die("Hacking attempt");
}
/***************************************************************************
*
* *************** SET UP VARIABLES HERE ***********************/
// FORUM DIRECTORY
$glance_forum_dir = '';
// NEWS FORUM ID
$glance_news_forum_id = 0; // SET TO ZERO IF YOU DO NOT HAVE A NEWS FORUM
// NUMBER OF NEWS ARTICLES YOU WISH TO DISPLAY
$glance_num_news = 0; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED or DO NOT HAVE A NEWS FORUM
// NUMBER OF RECENT ARTICLES YOU WISH TO DISPLAY
$glance_num_recent = 10; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED
// NEWS HEADING
$glance_news_heading = 'Dernières brèves';
// RECENT TOPIC HEADING
$glance_recent_heading = 'Dernières discussions';
// NEWS BULLET OLD
$glance_news_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET OLD
$glance_recent_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// NEWS BULLET NEW
$glance_news_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET NEW
$glance_recent_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// TABLE WIDTH
$glance_table_width = 250;
// CHANGE THE BULLET IF A TOPIC IS NEW? (true / false)
$glance_show_new_bullets = true;
// MESSAGE TRACKING WILL TRACK TO SEE IF A USER HAS READ THE TOPIC DURING THEIR SESSION (true / false)
$glance_track = true;
// SHOW TOPICS THE USER CAN VIEW, BUT NOT READ? (true / false)
$glance_auth_read = true;
// MAX TOPIC TITLE LENGTH
$glance_max_topic_title_length = 80;
/************************* DO NOT EDIT BELOW THIS LINE *********************/
?>
Editer le fichier
index.php situé à la racine du forum
AvantCode : Tout sélectionner
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
Rajouter:
Code : Tout sélectionner
if ($user->data['is_registered']) include($phpbb_root_path . 'glance.'.$phpEx);
situé à la racine du forum.Comme il existe 2 thèmes par défaut et qu'ils n'ont rien à voir, voici
pour la template prosilver :
Modifier le fichier
/styles/prosilver/template/overall_header.html
Avant Code : Tout sélectionner
<!-- IF S_DISPLAY_SEARCH and not S_IN_SEARCH -->
<div id="search-box">
<form action="{U_SEARCH}" method="post" id="search">
<fieldset>
<input name="keywords" id="keywords" type="text" maxlength="128" title="{L_SEARCH_KEYWORDS}" class="inputbox search" value="<!-- IF SEARCH_WORDS-->{SEARCH_WORDS}<!-- ELSE -->{L_SEARCH_MINI}<!-- ENDIF -->" onclick="if(this.value=='{LA_SEARCH_MINI}')this.value='';" onblur="if(this.value=='')this.value='{LA_SEARCH_MINI}';" />
<input class="button2" value="{L_SEARCH}" type="submit" /><br />
<a href="{U_SEARCH}" title="{L_SEARCH_ADV_EXPLAIN}">{L_SEARCH_ADV}</a> {S_SEARCH_HIDDEN_FIELDS}
</fieldset>
</form>
</div>
<!-- ENDIF -->
Rajouter :
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
<!-- ENDIF -->
Ajouter le fichier
glance_body.html dans
/styles/prosilver/template/Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td >
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">{news.BULLET}<a href="{news.TOPIC_LINK}">{news.TOPIC_TITLE}</a><br>{news.TOPIC_TIME}</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >{recent.BULLET}<a href="{recent.TOPIC_LINK}">{recent.TOPIC_TITLE}</a></td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>
Modifier le fichier
/styles/prosilver/theme/common.css, à la fin ajouter :
Code : Tout sélectionner
#atGlanceBox {
color: #FFFFFF;
margin-top: 0px;
margin-right: 250px;
display: block;
float: right;
position: absolute;
right: 0px;
white-space: nowrap; /* For Opera */
}
#atGlanceBox a {
color: #ffffff;
}
#atGlanceBox a:hover {
color: #b8cdef;
}
Pour le thème
subsilver 2
Modifier le fichier
/styles/subsilver2/template/overall_header.html
Après Code : Tout sélectionner
<td width="100%" align="center"><h1>{SITENAME}</h1><span class="gen">{SITE_DESCRIPTION}</span></td>
Ajouter
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<td>
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
</td>
<!-- ENDIF -->
Ajouter le fichier glance_body.html dans
/styles/subsilver2/template/Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">
{news.BULLET}
<a href="{news.TOPIC_LINK}" class="forumlink">
{news.TOPIC_TITLE}
</a>
<br>
{news.TOPIC_TIME}
</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >
{recent.BULLET}
<a href="{recent.TOPIC_LINK}" class="genmed">
{recent.TOPIC_TITLE}
</a>
</td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>
cheers.
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 11:30 pm
par TheCrewStyle
Hi Olivier,
Thanks for your help but is nothing changed.
I followed your changes, but nothing happened. It's all the same.
Later edit:
My bad, i didn't look in glance_config.php to change the character limit. Thanks for your effor and work.
But could you help me with the other problem? Is not showing to guests, just registered.
Thanks a lot.
Re: Mod At a Glance pour phpbb3
Publié : novembre 21, 2009, 11:42 pm
par Arken
i guess it's because of the "if" below :
Code : Tout sélectionner
if ($user->data['is_registered']) include($phpbb_root_path . 'glance.'.$phpEx);
just remove the "if" statement :
Re: Mod At a Glance pour phpbb3
Publié : novembre 22, 2009, 12:24 am
par TheCrewStyle
I tried that before, but i get an error on index when i'm logging out
Code : Tout sélectionner
Eroare generală
SQL ERROR [ mysqli ]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 [1064]
O eroare SQL a apărut în timp ce pagina era în lucru. Vă rugăm să contactaţi Administratorul forumului dacă problema persistă.
Va rugăm să anunţati administratorul forumului sau webmaster-ul: thecrewstyle
ça me reviens
Publié : novembre 22, 2009, 9:38 am
par Aurelienazerty
Ha oui, maintenant ça me reviens, c'est pour ça que j'avais limité ça aux utilisateurs enregistrés.
Je n'ai pas cherché pourquoi ça faisait ça, car j'utilise les même requêtes sur la page d'accueil du site et ça fonctionne.
Re: Mod At a Glance pour phpbb3
Publié : novembre 22, 2009, 11:10 am
par Arken
TheCrewStyle a écrit :I tried that before, but i get an error on index when i'm logging out
Ok, then, i don't know. It requires more investigation (and thus more time) than just adding few lines of code (like I did). My advise : try to find some help on official phpBB forums.
Re: Mod At a Glance pour phpbb3
Publié : novembre 22, 2009, 11:24 am
par TheCrewStyle
Olivier a écrit :TheCrewStyle a écrit :I tried that before, but i get an error on index when i'm logging out
Ok, then, i don't know. It requires more investigation (and thus more time) than just adding few lines of code (like I did). My advise : try to find some help on official phpBB forums.
I tried to get help from there, but they sent me here, to the author's page.
http://www.phpbb.com/community/viewtopi ... &t=1865715
Aurelienazerty, i sawed that on the main page of the site it works even if you are not logged in.
I clear there is something changed in glance.php or somewhere else.
If you can show us the file that you used there i will be more than glade.
Here, in my country, are more who like's your mod. And some of them want if you can to make it visible for guest's. When you have time and you want.
Take a look here
http://phpbb.ro/viewtopic.php?f=47&t=15862
A message from a phpbb.com moderator:
We do not provide support for MODs downloaded at other sites and we do not provide MOD support in this forum at all. You have to ask the MOD author for support in his support topic or the place where you downloaded the MOD.
Locking.
Re: Mod At a Glance pour phpbb3
Publié : novembre 28, 2009, 10:20 pm
par TheCrewStyle
some help?
Pas de modifs
Publié : décembre 1, 2009, 9:56 pm
par Aurelienazerty
Comme je l'ai dis plus haut, je n'ai pas fais de modifications particulière pour que ça fonctionne sur la page d'index du site. C'est la même requête, mais le site n'est pas intégré à 100% avec phpbb3, l'explication doit venir d'ici.
Cela dit, voilà la fonction en question, je ne sais pas si ça vous aidera beaucoup :
Code : Tout sélectionner
/** Affiche les derniers messages */
function dernierMessages($userdata, $nbMsg) {
global $user,$auth;
$myUser = new user_site($userdata['user_id']);
$tracking_topics = array();
$affichage_php = "";
$notAllowedForums = array();
$notAllowedForums = array_keys($auth->acl_getf('!f_read', true));
if (sizeof($notAllowedForums)> 0) {
$forumsignore = implode(', ', $notAllowedForums);
} else {
$forumsignore= "-1";
}
$affichage_php .= "
<table style='width: 745px;'>
";
//Récupérer les dernier messages du forum
$requete = "SELECT t.*, p2.post_time, p2.poster_id, p2.post_time
FROM " . POSTS_TABLE . " p
inner join " . TOPICS_TABLE . " t on p.post_id = t.topic_first_post_id
inner join " . POSTS_TABLE . " p2 on p2.post_id = t.topic_last_post_id
WHERE t.forum_id NOT IN (" . $forumsignore . ")
AND t.topic_moved_id = 0
ORDER BY t.topic_last_post_id DESC LIMIT 0, $nbMsg";
//echo $requete;
$tab = $GLOBALS['bdd']->requete($requete);
$nbNewMsg = 0;
foreach ($tab as $key => $resultat) {
$tracking_topics += get_complete_topic_tracking($resultat["forum_id"], $resultat["topic_id"], $global_announce_list = false);
$post_id = $resultat["topic_last_post_id"];
$topic_id = $resultat["topic_id"];
$nomTopic = $resultat["topic_title"];
$poster_id = $resultat["poster_id"];
$post_time = $resultat["post_time"];
$posteur = new user_site($poster_id);
$login = $posteur->username();
//Transformation de la date
$dateComplete = strftime("%d/%m/%Y %Hh%M",(int)$post_time);
$unread_topics = "";
$puce = "puce.jpg";
if ($resultat["post_time"] > $userdata['user_lastvisit'] ) {
$unread_topics = "sujetNonLu";
$puce = "puce_new.jpg";
if( !empty($tracking_topics[$topic_id]) ) {
if( $tracking_topics[$topic_id] >= $resultat["post_time"] ) {
$unread_topics = "";
$puce = "puce.jpg";
} else {
//Récupérer le premier post non lu
$query2 = "Select post_id
FROM `" . POSTS_TABLE . "`
where post_time >= ".$tracking_topics[$topic_id]."
AND topic_id = ".$topic_id."
ORDER by post_time ASC
limit 1";
$tab2 = $GLOBALS['bdd']->requete($query2);
$post_id = $tab2[0]["post_id"];
//Compter le nombre de messages nons lus
$query2 = "Select count(post_id)
FROM `" . POSTS_TABLE . "`
where post_time > ".$tracking_topics[$topic_id]."
AND topic_id = ".$topic_id;
$tab2 = $GLOBALS['bdd']->requete($query2);
$nbNewMsg += $tab2[0]["count(post_id)"];
}
}
}
$affichage_php .= "
<tr>
<td style='border: 1px solid #E0E0E0; padding-left: 3px;'>
<img src='/images/interface/common/".$puce."' alt='' class='".$unread_topics."'>
<a href='/forum/viewtopic.php?p=".$post_id."#p$post_id' title='Voir ce sujet' class='".$unread_topics."'>
$nomTopic
</a>
</td>
<td style='width: 150px; text-align: center; background-color: #F4F4F4; border: 1px solid #E0E0E0;'>
".$login."
</td>
<td style='width: 170px; text-align: center; border: 1px solid #E0E0E0;'>
".$dateComplete."
</td>
</tr>";
}
$affichage_php .= "</table> ";
$affichage_php .= afficherCompteurs($userdata, $nbNewMsg);
return $affichage_php;
}
Bug trouvé
Publié : février 6, 2012, 9:16 pm
par Aurelienazerty
J'ai trouvé le bug, en fait à la ligne 224 de glance.php, il suffisait de rajouter
J'ai modifié le fichier en question dans le premier post.
Bon ok, ce message ne sert à rien et la réponse vient 2 ans après, mais le tout c'est de trouver !
autre bug
Publié : février 9, 2015, 3:12 pm
par Aurelienazerty
Suite
à ça, j'ai modifié le code