Darathor
Citation :
But : Ajoute un bouton d'édition rapide au messages que vous avez le droit d'éditer. Ce bouton permet d'afficher un formulaire d'édition directement dans le topic sans recharger la page.
Prérequis :
- [Sous-MOD] Définitions CSS complémentaires (1.1)
- [MOD] Cross-edit prevention (1.0)
Remarques :
- côté utilisateur, ce MOD necessite l'activation des javascripts.
Auteur : Darathor (darathor@free.fr)
Version : 1.0 (14/01/2007)
Compatibilité phpBB : 2.0.22
Dans "viewtopic.php" :
Code :
#
# Trouver
#
'L_GOTO_PAGE' => $lang['Goto_page'],
#
# Ajouter après
#
// DEBUT MOD Quick edit
'L_SUBMIT' => $lang['Submit'],
// FIN MOD Quick edit
#
# Trouver
#
$edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
#
# Ajouter après
#
// DEBUT MOD Quick edit
// Formulaire d'édition.
$editable_message = $postrow[$i]['post_text'];
if ( $postrow[$i]['bbcode_uid'] != '' )
{
$editable_message = preg_replace('/\:(([a-z0-9]:)?)' . $postrow[$i]['bbcode_uid'] . '/s', '', $editable_message);
}
$editable_message = str_replace('<', '<', $editable_message);
$editable_message = str_replace('>', '>', $editable_message);
$editable_message = str_replace('<br />', "\n", $editable_message);
$area_id = 'area_' . $postrow[$i]['post_id'] . '_' . time();
// Champs cachés.
$edit_hidden_form_fields = '<input type="hidden" name="mode" value="editpost" />';
$edit_hidden_form_fields .= '<input type="hidden" name="quick_edit" value="1" />';
$edit_hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $postrow[$i]['post_id'] . '" />';
$edit_hidden_form_fields .= '<input type="hidden" name="get_text_time" value="' . time() . '" />';
$edit_hidden_form_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
// Boutons.
$quick_edit_img = '<img id="quick_edit_' . $postrow[$i]['post_id'] . '" src="' . $images['QuEd_icon_quick_edit'] . '" alt="' . $lang['QuEd_quick_edit'] . '" title="' . $lang['QuEd_quick_edit'] . '" onclick="displayQuickEdit(' . $postrow[$i]['post_id'] . ');" style="cursor: pointer;" class="display_inline" />';
$cancel_quick_edit_img = '<img id="cancel_quick_edit_' . $postrow[$i]['post_id'] . '" src="' . $images['QuEd_icon_cancel_quick_edit'] . '" alt="' . $lang['QuEd_cancel_quick_edit'] . '" title="' . $lang['QuEd_cancel_quick_edit'] . '" onclick="hideQuickEdit(' . $postrow[$i]['post_id'] . ');" style="cursor: pointer;" class="display_none" />';
// FIN MOD Quick edit
#
# Trouver
#
$edit = '';
#
# Ajouter après
#
// DEBUT MOD Quick edit
$editable_message = '';
$edit_hidden_form_fields = '';
$quick_edit_img = '';
$cancel_quick_edit_img = '';
// FIN MOD Quick edit
#
# Trouver
#
'QUOTE_IMG' => $quote_img,
#
# Ajouter après
#
// DEBUT MOD Quick edit
'EDITABLE_MESSAGE' => $editable_message,
'QUICK_EDIT_IMG' => $quick_edit_img,
'CANCEL_QUICK_EDIT_IMG' => $cancel_quick_edit_img,
'AREA_ID' => $area_id,
'S_EDIT_ACTION' => append_sid("posting.$phpEx"),
'S_HIDDEN_FIELDS' => $edit_hidden_form_fields,
// FIN MOD Quick edit
#
# Trouver
#
}
$template->pparse('body');
#
# Ajouter avant
#
// DEBUT MOD Quick edit
if(($userdata['user_id'] == $poster_id && $is_auth['auth_edit']) || $is_auth['auth_mod'])
{
$template->assign_block_vars('postrow.switch_editable', array());
}
// FIN MOD Quick edit
Dans "posting.php" :
Code :
#
# En début de ligne, trouver
#
$sql = "SELECT f.*, t.topic_id
#
# Remplacer ce début de ligne par
#
// COMMENTAIRE MOD Quick edit : La requête qui suit a été modifiée.
// -- DEBUT Ajouté
// , t.topic_title
// -- FIN Ajouté
$sql = "SELECT f.*, t.topic_id, t.topic_title
#
# Trouver
#
//
// The user is not authed, if they're not logged in then redirect
#
# Ajouter avant
#
// DEBUT MOD Quick edit
if($HTTP_POST_VARS['quick_edit'])
{
// Récupération des données des cases à cocher.
$HTTP_POST_VARS['disable_html'] = !$post_info['enable_html'];
$HTTP_POST_VARS['disable_bbcode'] = !$post_info['enable_bbcode'];
$HTTP_POST_VARS['disable_smilies'] = !$post_info['enable_smilies'];
$HTTP_POST_VARS['attach_sig'] = $post_info['enable_sig'];
$HTTP_POST_VARS['subject'] = addslashes(($post_info['topic_first_post_id'] == $post_id) ? $post_info['topic_title'] : $post_info['post_subject']);
$topic_type = $post_info['topic_type'];
// Gestion du MOD Extended topic watch
$sql_ext = (defined('EXTW_MAIL')) ? ('AND type = ' . EXTW_MAIL) : ' ';
$sql = "SELECT topic_id
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
$sql_ext
AND user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
}
$HTTP_POST_VARS['notify'] = ( $db->sql_fetchrow($result) ) ? TRUE : $userdata['user_notify'];
}
// FIN MOD Quick edit
#
# Trouver
#
$username = ( !empty($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : '';
#
# Ajouter avant
#
// DEBUT MOD Quick edit
if(isset($HTTP_POST_VARS['quick_edit']))
{
$username = $post_info['p.post_username'];
$subject = addslashes(html_entity_decode(($post_info['topic_first_post_id'] == $post_id) ? $post_info['topic_title'] : $post_info['post_subject']));
$message = (!empty($HTTP_POST_VARS['message'])) ? $HTTP_POST_VARS['message'] : '';
$poll_title = addslashes(html_entity_decode($poll_title));
if (is_array($poll_options))
{
foreach($poll_options as $key => $value)
{
$poll_options[$key] = addslashes(html_entity_decode($value));
}
}
$bbcode_uid = '';
}
else
{
// FIN MOD Quick edit
#
# Trouver
#
$bbcode_uid = '';
#
# Ajouter après
#
// DEBUT MOD Quick edit
}
// FIN MOD Quick edit
Dans "templates/subSilver/subSilver.cfg" :
Code :
#
# Trouver
#
?>
#
# Ajouter avant
#
// DEBUT MOD Quick edit
$images['QuEd_icon_quick_edit'] = "$current_template_images/{LANG}/icon_quick_edit.gif";
$images['QuEd_icon_cancel_quick_edit'] = "$current_template_images/{LANG}/icon_cancel_quick_edit.gif";
// FIN MOD Quick edit
Dans "language/lang_french/lang_main.php" :
Code :
#
# Trouver
#
?>
#
# Ajouter avant
#
// DEBUT MOD Quick edit
$lang['QuEd_quick_edit'] = 'Édition rapide de ce message';
$lang['QuEd_cancel_quick_edit'] = 'Annuler l\'édition rapide de ce message';
// FIN MOD Quick edit
Dans "templates/subSilver/viewtopic_body.tpl" :
Code :
#
# Ajouter tout en haut
#
<script language="Javascript" type="text/javascript" src="templates/quick_edit.js"></script>
#
# Dans une ligne, trouver
#
{postrow.EDIT_IMG}
#
# Dans cette ligne, ajouter après
#
{postrow.QUICK_EDIT_IMG}{postrow.CANCEL_QUICK_EDIT_IMG}
#
# Trouver
#
<td colspan="2"><span class="postbody">{postrow.MESSAGE}{postrow.SIGNATURE}</span><span class="gensmall">{postrow.EDITED_MESSAGE}</span></td>
#
# remplacer par
#
<td colspan="2">
<div id="{postrow.U_POST_ID}_text">
<span class="postbody">{postrow.MESSAGE}{postrow.SIGNATURE}</span><span class="gensmall">{postrow.EDITED_MESSAGE}</span>
</div>
<!-- BEGIN switch_editable -->
<div id="{postrow.U_POST_ID}_edit" class="display_none">
<form class="cm" action="{postrow.S_EDIT_ACTION}" method="post">
<textarea class="post gensmall complet" style="height:250px; overflow:auto;" name="message" tabindex="3" rows="15" cols="35">{postrow.EDITABLE_MESSAGE}</textarea>
{postrow.S_HIDDEN_FIELDS}<input type="submit" accesskey="s" tabindex="6" name="post" class="mainoption" value="{L_SUBMIT}" />
</form>
</div>
<!-- END switch_editable -->
</td>
Uploader aux emplacement suivants les fichiers contenus dans ce zip :
- templates/subSilver/images/lang_french/icon_cancel_quick_edit.gif
- templates/subSilver/images/lang_french/icon_quick_edit.gif
- templates/quick_edit.js