Pour ma part, je complète ce tuto avec le tuto "comment installer les MODs".
Aors, qu'est-ce que les mods? Vous savez, des fois, les possibilités du forum phpBB ne suffisent pas... alors voilà, une expansion du forum s'impose. Et c'est grâce aux MODs que vous pouvez améliorer les capacités de votre forum.
Alors, les MODs se trouvent à cette adresse:
http://www.phpbb.com/mods/Pour commencer, les MODs selon moi indispensables.
Le MOD qui ajoute une description au topic (comme ici:"Parce qu'il y en marre de forumactif!!!!"):
http://www.phpbb.com/phpBB/viewtopic.php?t=278064Le MOD qui affiche, dans une section du forum, en plus du pseudo du dernier posteur, le sujet dans lequel celui-ci a posté (comme ici, quoi)
http://www.phpbb.com/phpBB/viewtopic.php?t=200004Le MOD qui affiche "aujourd'hui" et "hier" au lieu des dates du jour-même ou de la veille
http://www.phpbb.com/phpBB/viewtopic.php?t=158812Pour vous montrer comment installer un MOD, je vais "décortiquer" le MOD qui ajoute une description au topic.
Voici le contenu du MOD avec mes commentaires.
##############################################################
En principe, toute ligne començant par deux dièses ne sert à rien. Les lignes dans le code qui commencent par "//" ne servent à rien non plus, ce sont des commentaires.
##
## MOD Title: topic description
## MOD Author: Swizec < iareswizec@hotmail.com > (swizec) N/A
## MOD Description: This mod adds a description to the topics on the forum, Like on vBullettin systems and some others.
## MOD Version: 1.2.6
##
## Installation Level: Intermediate
## Installation Time: ~35 Minutes
## Files To Edit: viewforum.php, posting.php, functions_post.php, posting_body.tpl, posting_preview.tpl,
## viewforum_body.tpl, admin_board.php, lang_admin.php, lang_main.php, board_config_body.tpl
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
Bon, on zappe un peu tout ça ^^
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
Là, on vous dit de faire une copie de sauvegarde de tout fichier relatif au MOD (et il FAUT le faire)!
##############################################################
#
#-----[ SQL ]------------------------------------------
#
On commence par faire un tour dans phpMyAdmin, et y coller le code ci-dessous. Il permettra de créer une place pour les descriptions dans la base de données. En fait, le titre [SQL] correspond au code à coller dans phpMyAdmin, tout bêtement.
ALTER TABLE `phpbb_topics` ADD `topic_description` VARCHAR( 255 ) NOT NULL AFTER `topic_title`;
INSERT INTO phpbb_config
SET config_name = 'allow_descriptions',
config_value = '1';
INSERT INTO phpbb_config SET
config_name='only_mods_desc',
config_value='0';
ALTER TABLE `phpbb_topics` ADD `topic_descmod` TINYINT NOT NULL AFTER `topic_description`;
#
#-----[ OPEN ]------------------------------------------
#
Voici que commence la partie la plus intéressante: édition des fichiers du forum [OPEN] est ouvrir un fichier, c'est assez logique.
viewforum.php
Donc là, c'est le fichier viewforum.php qui doit être ouvert (je ne sais pas, moi, avec le bloc-notes même, ça ira. Mais optez pour un prog spécialisé, comme le génial PHP Designer 2005 (gratuit), qui surligne la syntaxe).
#
#-----[ FIND ]------------------------------------------
#
[FIND] correspond à trouver un bloc de texte. Bien sûr, vous n'allez pas chercher à la vue, mais plutôt avec les moyens du bloc-notes (ou du porg que vous utilisez).
$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
Il éxiste deux titres correspondant à "ajouter un code à la nouvelle ligne". [ AFTER, ADD ] correspond à "ajouter après", ce qui veut dire que le code suivant doit être inséré à la ligne après le code que vous avez trouvé. [ BEFORE, ADD ] correspondrait à "ajouter avant", ce qui veut dire que le code suivant devrait être inséré à la ligne avant le code que vous avez trouvé. Mais bon, ici, on insère après.
// mod topic description: add
$topic_desc = ( count ( $orig_word ) ) ? preg_replace ( $orig_word, $replacement_word, $topic_rowset[$i]['topic_description']) : $topic_rowset[$i]['topic_description'];
#
#-----[ FIND ]------------------------------------------
#
$template->assign_block_vars('topicrow', array(
Donc, on cherche cette ligne das tout le fichier PHP, comme la première fois.
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description: add
$desc4mod = $topic_rowset[ $i ][ 'topic_descmod' ];
if ( $topic_desc != '' && $board_config[ 'allow_descriptions' ] ) {
if ( !$desc4mod )
$s = TRUE;
elseif ( ( $topic_rowset[$i]['user_id'] == $userdata[ 'user_id' ] ) || $is_auth[ 'auth_mod' ] )
$s = TRUE;
else $s = FALSE;
}else $s = FALSE;
$topic_desc = ( $s ) ? '<br />' . $topic_desc : '';
SaniOKh: si vous avez bien retenu ce que j'avais dit avant, le code suivant était à coleer à la ligne AVANT le code que vous avez trouvé. Après, je vous laisse, parce que ce n'est que de ça.
#
#-----[ FIND ]------------------------------------------
#
'TOPIC_TITLE' => $topic_title,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
'TOPIC_DESC' => $topic_desc,
#
#-----[ OPEN ]------------------------------------------
#
Quand vous voyez le titre [OPEN], ne vous précipitez pas à ouvrir le fichier, pensez à sauvegarder celui que vous êtes en train d'éditer (je vous jure, ça m'arrive^^).
posting.php
#
#-----[ FIND ]------------------------------------------
#
$select_sql = ( !$submit ) ? ", t.topic_title,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description: add
#
#-----[ IN-LINE FIND ]------------------------------------------
#
t.topic_title,
Ah! c'est nouveau, ça! Alors, vous avez trouvé la ligne de code "$select_sql = ( !$submit ) ? ", t.topic_title,", et vous devez en fait trouver la PARTIE DE CETTE LIGNE qui est "t.topic_title,". Bon, c'est fait.
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
t.topic_description, t.topic_descmod,
Le IN-LINE dans le titre veut dire que le code est à ajouter DANS LA LIGNE MÊME. La ligne de code d'avant était:
$select_sql = ( !$submit ) ? ", t.topic_title,
Donc, après ajout, elle est devenue comme ça:
$select_sql = ( !$submit ) ? ", t.topic_title, t.topic_description, t.topic_descmod,
#
#-----[ FIND ]------------------------------------------
#
$post_data['poster_id'] = $post_info['poster_id'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
$desc4mod = $post_info[ 'topic_descmod' ];
#
#-----[ FIND ]------------------------------------------
#
//
// Set toggles for various options
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
$desc4mod = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['desc4mod']) ) ? TRUE : FALSE ) : FALSE;
#
#-----[ FIND ]------------------------------------------
#
$subject = ( !empty($HTTP_POST_VARS['subject']) ) ? trim($HTTP_POST_VARS['subject']) : '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
$description = ( !empty($HTTP_POST_VARS['description']) ) ? trim($HTTP_POST_VARS['description']) : '';
#
#-----[ FIND ]------------------------------------------
#
submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description add argument
#
#-----[ IN-LINE FIND ]------------------------------------------
#
str_replace("\'", "''", $subject),
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
str_replace("\'", "''", $description), $desc4mod,
#
#-----[ FIND ]------------------------------------------
#
$subject = ( !empty($HTTP_POST_VARS['subject']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['subject']))) : '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
$description = ( !empty($HTTP_POST_VARS['description']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['description']))) : '';
#
#-----[ FIND ]------------------------------------------
#
$preview_subject = $subject;
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
$preview_description = $description;
if ( $board_config [ 'allow_descriptions' ] && ( !$board_config [ 'only_mods_desc' ] || ( $board_config [ 'only_mods_desc' ] && $is_auth['auth_mod'] ) ) )
$template -> assign_block_vars ( 'switch_description', array ( ) );
#
#-----[ FIND ]------------------------------------------
#
'TOPIC_TITLE' => $preview_subject,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
'TOPIC_DESC' => $preview_description,
#
#-----[ FIND ]------------------------------------------
#
'L_POST_SUBJECT' => $lang['Post_subject'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
'L_DESCRIPTION' => $lang [ 'Description' ],
'L_DESC4MOD' => $lang [ 'desc4mod' ],
#
#-----[ FIND ]------------------------------------------
#
$subject = '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
$description = '';
if ( $board_config [ 'allow_descriptions' ] && ( !$board_config [ 'only_mods_desc' ] || ( $board_config [ 'only_mods_desc' ] && $is_auth['auth_mod'] ) ) )
$template -> assign_block_vars ( 'switch_description', array ( ) );
#
#-----[ FIND ]------------------------------------------
#
$subject = '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
$description = '';
#
#-----[ FIND ]------------------------------------------
#
$subject = ( $post_data['first_post'] ) ? $post_info['topic_title'] : $post_info['post_subject'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
$description = ( $post_data['first_post'] && ( !$board_config [ 'only_mods_desc' ] || ( $board_config [ 'only_mods_desc' ] && $is_auth['auth_mod'] ) ) ) ? $post_info['topic_description'] : '';
#
#-----[ FIND ]------------------------------------------
#
$smilies_on = ( $post_info['enable_smilies'] ) ? true : false;
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description add
if ( $post_data['first_post'] && $board_config [ 'allow_descriptions' ] && ( !$board_config [ 'only_mods_desc' ] || ( $board_config [ 'only_mods_desc' ] && $is_auth['auth_mod'] ) ) )
$template -> assign_block_vars ( 'switch_description', array ( ) );
#
#-----[ FIND ]------------------------------------------
#
'SUBJECT' => $subject,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
'DESCRIPTION' => $description,
#
#-----[ FIND ]------------------------------------------
#
'L_SUBJECT' => $lang['Subject'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
'L_DESCRIPTION' => $lang[ 'Description' ],
'L_DESC4MOD' => $lang[ 'desc4mod' ],
#
#-----[ FIND ]------------------------------------------
#
'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '',
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description add
'S_DESC4MOD_CHECKED' => ( $desc4mod ) ? 'checked="checked"' : '',
#
#-----[ OPEN ]------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------
#
function submit_post(
#
#-----[ IN-LINE FIND ]------------------------------------------
#
&$post_subject,
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
&$post_description, &$desc4mod,
#
#-----[ FIND ]------------------------------------------
#
$sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description: add to sql query
#
#-----[ IN-LINE FIND ]------------------------------------------
#
topic_title,
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
topic_description, topic_descmod,
#
#-----[ IN-LINE FIND ]------------------------------------------
#
VALUES ('$post_subject',
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
'$post_description', '$desc4mod',
#
#-----[ IN-LINE FIND ]------------------------------------------
#
"UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject',
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
topic_description='$post_description', topic_descmod='$desc4mod',
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_body.tpl
Là , il faudra faire attention, parce que ce fichier fait partie du skin de votre forum, si vous utilisez un skin autre que SubSilver, allez chercher le fichier posting_body.tpl de celui-ci.
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1" width="22%"><span class="gen"><b>{L_SUBJECT}</b></span></td>
<td class="row2" width="78%"> <span class="gen">
<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />
</span> </td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN switch_description -->
<tr>
<td class="row1" width="22%"><span class="gen"><b>{L_DESCRIPTION}</b></span></td>
<td class="row2" width="78%"> <span class="gen">
<input type="text" name="description" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{DESCRIPTION}" /> <input type="checkbox" name="desc4mod" {S_DESC4MOD_CHECKED} /> {L_DESC4MOD}
</span> </td>
</tr>
<!-- END switch_description -->
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_preview.tpl
Attention, encore un fichier du skin!
#
#-----[ FIND ]------------------------------------------
#
{POST_SUBJECT}
#
#-----[ IN-LINE FIND ]------------------------------------------
#
_SUBJECT}
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
{TOPIC_DESC}
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewforum_body.tpl
Attention, encore un fichier du skin!
#
#-----[ FIND ]------------------------------------------
#
<td class="row1" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />
{topicrow.GOTO_PAGE}</span></td>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{topicrow.TOPIC_TITLE}</a></span>
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<span class="genmed">{topicrow.TOPIC_DESC}</span>
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
$avatars_local_yes = ( $new['allow_avatar_local'] ) ? "checked=\"checked\"" : "";
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description add
$description_yes = ( $new['allow_descriptions'] ) ? "checked=\"checked\"" : "";
$description_no = ( !$new['allow_descriptions'] ) ? "checked=\"checked\"" : "";
$descmods_yes = ( $new['only_mods_desc'] ) ? "checked=\"checked\"" : "";
$descmods_no = ( !$new['only_mods_desc'] ) ? "checked=\"checked\"" : "";
#
#-----[ FIND ]------------------------------------------
#
"L_RESET" => $lang['Reset'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
// mod topic description: add
"L_ALLOW_DESC" => $lang[ 'allow_desc' ],
"L_MODS_DESC" => $lang[ 'mods_desc' ],
"L_DESCRIPTION_SETTINGS" => $lang [ 'desc_settings' ],
#
#-----[ FIND ]------------------------------------------
#
"AVATARS_LOCAL_YES" => $avatars_local_yes,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description: add
"DESCRIPTION_YES" => $description_yes,
"DESCRIPTION_NO" => $description_no,
"DESCMODS_YES" => $descmods_yes,
"DESCMODS_NO" => $descmods_no,
// mod topic description end
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
Il y a comme une injustice dans ces MODs: ils sont tous désignés pour les forums en anglais... alors, ouvrez plutôt ce fichier:
language/lang_french/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description add
$lang[ 'allow_desc' ] = 'Allow descriptions';
$lang[ 'mods_desc' ] = 'Only mods add descriptions';
$lang[ 'desc_settings' ] = 'Description settings';
C'est space quand une chose est en moitié anglais-moitié français. Alors, avant le "?>" ajoutez plutôt ceci:
// mod topic description add
$lang[ 'allow_desc' ] = 'Autoriser les descriptions';
$lang[ 'mods_desc' ] = 'Seuls les modérateurs décrivent les sujets';
$lang[ 'desc_settings' ] = 'Paramètres des descriptions';
Et là, attention quand vous traduisez! Parce que les apostrophes MARQUENT LES FINS DES CHAÎNES! Alors, si vous voulez mettre un apostrophe à l'intérieur de votre phrase, mettez un trait devant, comme ceci: \'
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
(râle)Avec un seul fichier langue, ce serait tellement plus simple... bon, ouvrez celui-là:
language/lang_french/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// mod topic description: add
$lang['Description'] = 'Description: ';
$lang['desc4mod'] = 'Description only for moderators';
Ca aussi, il faudra le traduire. Ajoutez ceci au lieu du code donné:
// mod topic description: add
$lang['Description'] = 'Description: ';
$lang['desc4mod'] = 'Description seulement accessible aux modérateurs';
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
Encore un fichier du skin, faites gaffe...
#
#-----[ FIND ]------------------------------------------
#
<tr>
<th class="thHead" colspan="2">{L_AVATAR_SETTINGS}</th>
</tr>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
<tr>
<th class="thHead" colspan="2">{L_DESCRIPTION_SETTINGS}</th>
</tr>
<tr>
<td class="row1">{L_ALLOW_DESC}</td>
<td class="row2"><input type="radio" name="allow_descriptions" value="1" {DESCRIPTION_YES} /> {L_YES} <input type="radio" name="allow_descriptions" value="0" {DESCRIPTION_NO} /> {L_NO}</td>
</tr>
<tr>
<td class="row1">{L_MODS_DESC}</td>
<td class="row2"><input type="radio" name="only_mods_desc" value="1" {DESCMODS_YES} /> {L_YES} <input type="radio" name="only_mods_desc" value="0" {DESCMODS_NO} /> {L_NO}</td>
</tr>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Fini! Maintenant, vous avez un champ de description de sujet!
Il existe aussi les titres comportant "REPLACE" au lieu de "AFTER, ADD" ou "BEFORE, ADD". Dans ce cas, il faudra remplacer le code trouvé avec FIND par le code présenté juste en dessous.
Et voilà, je crois que c'est bon.
Vous pouvez aussi télécharger le petit script sur le site officiel de phpBB qui vous installera le MOD tout seul, mais le problème est qu'il ne tient bien sûr pas compte ni de la langue, ni du skin utilisé.