Merge lp:~malizor/ubuntu-fr-forum/plugin-accueil into lp:ubuntu-fr-forum

Proposed by Nicolas Delvaux
Status: Merged
Merged at revision: 124
Proposed branch: lp:~malizor/ubuntu-fr-forum/plugin-accueil
Merge into: lp:ubuntu-fr-forum
Diff against target: 277 lines (+211/-28)
4 files modified
README (+5/-3)
index.php (+14/-25)
lang/Francais/reception.php (+17/-0)
plugins/AP_Reception.php (+175/-0)
To merge this branch: bzr merge lp:~malizor/ubuntu-fr-forum/plugin-accueil
Reviewer Review Type Date Requested Status
Ubuntu-fr-webteam Pending
Review via email: mp+57351@code.launchpad.net
To post a comment you must log in.
122. By Nicolas Delvaux

Indentation !!!!!

123. By Nicolas Delvaux

Correction du message d'erreur en cas de problème SQL.

124. By Nicolas Delvaux

Documentation de l'ensemble.

125. By Nicolas Delvaux

indentation²

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2010-10-13 00:20:33 +0000
+++ README 2011-04-13 17:24:38 +0000
@@ -44,8 +44,10 @@
44viewforum.php L92 à L11344viewforum.php L92 à L113
4545
4646
47Affichage de l'accueil + gagnant du mois47Mod affichage de l'accueil + gagnant du mois :
48index.php L58 à L7448Voir plugins/AP_Reception.php + lang/Francais/reception.php + index.php (L58 à L79)
49Les chaines correspondantes sont stockées dans deux nouvelles clefs de la table config: c_welcome_message et c_winner_message.
50Pas de modification de la structure de la base. Les clefs se créent automatiquement, rien de spécial à faire.
4951
5052
51Affichage de usertitle uniquement pour admins et modos.53Affichage de usertitle uniquement pour admins et modos.
@@ -88,4 +90,4 @@
88search.php (augmentation de la limite des 200)90search.php (augmentation de la limite des 200)
89parser.php (balise apt)91parser.php (balise apt)
90divers dans style/92divers dans style/
91viewtopic.php (lien vers haut de page)
92\ No newline at end of file93\ No newline at end of file
94viewtopic.php (lien vers haut de page)
9395
=== modified file 'index.php'
--- index.php 2011-02-18 15:28:26 +0000
+++ index.php 2011-04-13 17:24:38 +0000
@@ -57,33 +57,22 @@
5757
58<!-- Begin Forum accueil + gagnant du mois-->58<!-- Begin Forum accueil + gagnant du mois-->
5959
60<?
61//$sql = 'SELECT winner, welcome FROM '.$db->prefix.'accueil';
62//$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
63//$welc = $db->fetch_assoc($result);
64?>
65<div id="announce-welcome" class="box">60<div id="announce-welcome" class="box">
66 <table ><tbody class="inbox">61 <table>
67 <tr>62 <tbody class="inbox">
68 <td class="welcome"><p>63 <tr>
69<?php64 <td class="welcome">
70//echo $welc['welcome'];65 <p><?php echo $pun_config['c_welcome_message']; ?></p>
71?>66 </td>
72Bienvenue&nbsp;! pour utiliser au mieux ce forum, consultez les <a href="./misc.php?action=rules">règles du forum</a> ainsi que <a href="http://doc.ubuntu-fr.org/tutoriel/howto_forum">l'aide à l'utilisation du forum.</a><br />
73Avant de poser une question, vérifiez que la solution ne se trouve pas déjà dans la documentation ou le forum grâce à la &laquo;&nbsp;Recherche rapide&nbsp;&raquo; en haut de cette page. Sinon, postez dans la bonne section afin d'obtenir de meilleures réponses.<br />
74Si vous avez résolu votre problème, <a href="http://doc.ubuntu-fr.org/tutoriel/howto_forum#passer_son_sujet_en_resolu">ajoutez [Résolu]</a> au titre de la discussion, et n'oubliez pas de <a href="http://doc.ubuntu-fr.org/wiki/participer_wiki">documenter notre wiki.</a>
75</p></td>
7667
77 <td class="winner"><div id="winner_inbox">68 <td class="winner">
78<p>69 <div id="winner_inbox">
79<?php70 <p><?php echo $pun_config['c_winner_message']; ?></p>
80//echo $welc['winner'];71 </div>
81?>72 </td>
82Gagnant de l'abonnement<br/><a name="Linux Pratique" href="http://www.linux-pratique.com/"><span class="linux_pratique">Linux Pratique</span></a><br/>du mois de novembre<br/>73 </tr>
83<span class="winner_name">maxjules</span>74 </tbody>
84</p></div>75 </table>
85</td>
86</tr></tbody></table>
87</div>76</div>
8877
8978
9079
=== added file 'lang/Francais/reception.php'
--- lang/Francais/reception.php 1970-01-01 00:00:00 +0000
+++ lang/Francais/reception.php 2011-04-13 17:24:38 +0000
@@ -0,0 +1,17 @@
1<?php
2
3$lang_reception = array(
4'mod name' => "Accueil et gagnant",
5'description' => "Gérer le bandeau d'accueil ainsi que le gagnant du mois.",
6'insert update impossible' => "Impossible de mettre le bandeau d'accueil à jour.",
7'reception title' => "Texte de bienvenue :",
8'winner title' => "Cadre « gagnant du mois » :",
9'empty' => "vide",
10'edit' => "Modifier",
11'cancel' => "Annuler",
12'preview' => "Aperçu",
13'save' => "Enregistrer",
14'edit multiple annonces' => "Vous ne pouvez modifier qu'un seul champ à la fois. Veuillez terminer l'édition en cours."
15);
16
17?>
018
=== added file 'plugins/AP_Reception.php'
--- plugins/AP_Reception.php 1970-01-01 00:00:00 +0000
+++ plugins/AP_Reception.php 2011-04-13 17:24:38 +0000
@@ -0,0 +1,175 @@
1<?php
2/***********************************************************************
3
4 Copyright (C) 2011 Nicolas Delvaux <nicolas.delvaux@gmx.com>
5
6 This file is a plugin for FluxBB, created for ubuntu-fr.
7
8 This plugin is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
12
13 This plugin is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 MA 02111-1307 USA
22
23************************************************************************/
24
25/*
26
27This plugin create and use 2 new rows in the 'config' table (key -> value structure):
28 - c_welcome_message -> "The welcome-box message"
29 - c_winner_message -> "The winner-box message"
30Both messages should be plain HTML.
31
32*/
33
34// Make sure no one attempts to run this script "directly"
35if (!defined('PUN'))
36 exit;
37
38// Tell admin_loader.php that this is indeed a plugin and that it is loaded
39define('PUN_PLUGIN_LOADED', 1);
40
41// Plugin version
42define('PLUGIN_VERSION', '1.0');
43// Load the language file
44require PUN_ROOT.'lang/'.$pun_user['language'].'/reception.php';
45
46//
47// The rest is up to you!
48//
49//define('DEBUG',1);
50
51// Let's test if we update something
52if (isset($_POST['update_field'])) {
53 if (isset($pun_config[$_POST['update_field']]))
54 {
55 $query = 'UPDATE '.$db->prefix.'config SET conf_value=\''.$db->escape($_POST['new_text']).'\' WHERE conf_name=\''.$_POST['update_field'].'\'';
56 } else {
57 $query = 'INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\''.$_POST['update_field'].'\', \''.$db->escape($_POST['new_text']).'\')';
58 }
59
60 $result = $db->query($query, true) or error($lang_reception['insert update impossible'], __FILE__, __LINE__, $db->error());
61 if (defined('DEBUG'))
62 error_log("[Reception] Query: ".$query);
63
64 // Update config locally (for immediate display in this page) and globally
65 $pun_config[$_POST['update_field']] = $_POST['new_text'];
66 require PUN_ROOT.'include/cache.php';
67 generate_config_cache();
68}
69
70// Display the admin navigation menu
71generate_admin_menu($plugin);
72?>
73
74<div id="reception_plugin" class="blockform">
75 <h2><span><?php echo $lang_reception['mod name']; ?> version <?php echo PLUGIN_VERSION; ?></span></h2>
76 <p><?php echo $lang_reception['description']; ?></p>
77 <table cellspacing="0">
78 <tbody>
79 <tr>
80 <td class="tcl">
81 <div class="inform">
82 <fieldset>
83 <legend><?php echo $lang_reception['reception title']; ?></legend>
84 <div class="infldset">
85 <div id="welcome_field">
86 <div id="welcome_text">
87<?php
88 if ($pun_config['c_welcome_message'] != '')
89 {
90 echo $pun_config['c_welcome_message'].'</div><div>';
91 }
92 else
93 {
94 echo '</div><div><em>'.$lang_reception['empty'].'</em>';
95 }
96?>
97 </div>
98 <br/>
99 <input type="button" value="<?php echo $lang_reception['edit']; ?>" onclick="edit('welcome_')" />
100 </div>
101 </div>
102 </fieldset>
103 </div>
104 </td>
105 </tr>
106 <tr>
107 <td >
108 <div class="inform">
109 <fieldset>
110 <legend><?php echo $lang_reception['winner title']; ?></legend>
111 <div class="infldset">
112 <div id="winner_field">
113 <div id="winner_text">
114<?php
115 if ($pun_config['c_winner_message'] != '')
116 {
117 echo $pun_config['c_winner_message'].'</div><div>';
118 }
119 else
120 {
121 echo '</div><div><em>'.$lang_reception['empty'].'</em>';
122 }
123?>
124 </div>
125 <br/>
126 <input type="button" value="<?php echo $lang_reception['edit']; ?>" onclick="edit('winner_')" />
127 </div>
128 </div>
129 </fieldset>
130 </div>
131 </td>
132 </tr>
133 </tbody>
134 </table>
135</div>
136
137<script type="text/javascript">
138//<![CDATA[
139
140var oldField = "";
141
142function edit(pid) {
143
144 // Just one edition at a time
145 if (document.getElementById('new_text')) {
146 alert("<?php echo $lang_reception['edit multiple annonces']; ?>");
147 return (1);
148 }
149
150 oldField = document.getElementById(pid+'field').innerHTML.replace(/<br>/g, '<br/>');
151 var editText = document.getElementById(pid+'text').innerHTML.replace(/<br>/g, '<br/>');
152
153 var newField = "<form id='form' action='<?php echo $_SERVER['REQUEST_URI'] ?>' method='post'><div id='new_"+pid+"text'><textarea cols='90' rows='7' name='new_text' id='new_text'>"+editText+"</textarea></div><input type='button' value='<?php echo $lang_reception['preview']; ?>' onclick='preview(\""+pid+"\")' /><input type='button' value='<?php echo $lang_reception['cancel']; ?>' onclick='cancel(\""+pid+"\")' />";
154
155 document.getElementById(pid+'field').innerHTML = newField;
156}
157
158function preview(pid) {
159 var preview = document.getElementById('new_text').value;
160
161 var preview_field = "<form id='form' action='<?php echo $_SERVER['REQUEST_URI'] ?>' method='post'><div id='preview_text'>"+preview+"</div><br/><input type='submit' value='<?php echo $lang_reception['save']; ?>' /><textarea style='display:none;' name='new_text' id='new_text'>"+preview+"</textarea><input type='hidden' name='update_field' value='c_"+pid+"message' /><input type='button' value='<?php echo $lang_reception['cancel']; ?>' onclick='cancel(\""+pid+"\")' />";
162
163 document.getElementById(pid+'field').innerHTML = preview_field;
164}
165
166function cancel(pid) {
167 document.getElementById(pid+'field').innerHTML = oldField;
168 oldField = "";
169}
170
171//]]>
172</script>
173
174<?php
175// Note that the script just ends here. The footer will be included by admin_loader.php.

Subscribers

People subscribed via source and target branches