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
1=== modified file 'README'
2--- README 2010-10-13 00:20:33 +0000
3+++ README 2011-04-13 17:24:38 +0000
4@@ -44,8 +44,10 @@
5 viewforum.php L92 à L113
6
7
8-Affichage de l'accueil + gagnant du mois
9-index.php L58 à L74
10+Mod affichage de l'accueil + gagnant du mois :
11+Voir plugins/AP_Reception.php + lang/Francais/reception.php + index.php (L58 à L79)
12+Les chaines correspondantes sont stockées dans deux nouvelles clefs de la table config: c_welcome_message et c_winner_message.
13+Pas de modification de la structure de la base. Les clefs se créent automatiquement, rien de spécial à faire.
14
15
16 Affichage de usertitle uniquement pour admins et modos.
17@@ -88,4 +90,4 @@
18 search.php (augmentation de la limite des 200)
19 parser.php (balise apt)
20 divers dans style/
21-viewtopic.php (lien vers haut de page)
22\ No newline at end of file
23+viewtopic.php (lien vers haut de page)
24
25=== modified file 'index.php'
26--- index.php 2011-02-18 15:28:26 +0000
27+++ index.php 2011-04-13 17:24:38 +0000
28@@ -57,33 +57,22 @@
29
30 <!-- Begin Forum accueil + gagnant du mois-->
31
32-<?
33-//$sql = 'SELECT winner, welcome FROM '.$db->prefix.'accueil';
34-//$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
35-//$welc = $db->fetch_assoc($result);
36-?>
37 <div id="announce-welcome" class="box">
38- <table ><tbody class="inbox">
39- <tr>
40- <td class="welcome"><p>
41-<?php
42-//echo $welc['welcome'];
43-?>
44-Bienvenue&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 />
45-Avant 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 />
46-Si 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>
47-</p></td>
48+ <table>
49+ <tbody class="inbox">
50+ <tr>
51+ <td class="welcome">
52+ <p><?php echo $pun_config['c_welcome_message']; ?></p>
53+ </td>
54
55- <td class="winner"><div id="winner_inbox">
56-<p>
57-<?php
58-//echo $welc['winner'];
59-?>
60-Gagnant 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/>
61-<span class="winner_name">maxjules</span>
62-</p></div>
63-</td>
64-</tr></tbody></table>
65+ <td class="winner">
66+ <div id="winner_inbox">
67+ <p><?php echo $pun_config['c_winner_message']; ?></p>
68+ </div>
69+ </td>
70+ </tr>
71+ </tbody>
72+ </table>
73 </div>
74
75
76
77=== added file 'lang/Francais/reception.php'
78--- lang/Francais/reception.php 1970-01-01 00:00:00 +0000
79+++ lang/Francais/reception.php 2011-04-13 17:24:38 +0000
80@@ -0,0 +1,17 @@
81+<?php
82+
83+$lang_reception = array(
84+'mod name' => "Accueil et gagnant",
85+'description' => "Gérer le bandeau d'accueil ainsi que le gagnant du mois.",
86+'insert update impossible' => "Impossible de mettre le bandeau d'accueil à jour.",
87+'reception title' => "Texte de bienvenue :",
88+'winner title' => "Cadre « gagnant du mois » :",
89+'empty' => "vide",
90+'edit' => "Modifier",
91+'cancel' => "Annuler",
92+'preview' => "Aperçu",
93+'save' => "Enregistrer",
94+'edit multiple annonces' => "Vous ne pouvez modifier qu'un seul champ à la fois. Veuillez terminer l'édition en cours."
95+);
96+
97+?>
98
99=== added file 'plugins/AP_Reception.php'
100--- plugins/AP_Reception.php 1970-01-01 00:00:00 +0000
101+++ plugins/AP_Reception.php 2011-04-13 17:24:38 +0000
102@@ -0,0 +1,175 @@
103+<?php
104+/***********************************************************************
105+
106+ Copyright (C) 2011 Nicolas Delvaux <nicolas.delvaux@gmx.com>
107+
108+ This file is a plugin for FluxBB, created for ubuntu-fr.
109+
110+ This plugin is free software; you can redistribute it and/or modify it
111+ under the terms of the GNU General Public License as published
112+ by the Free Software Foundation; either version 2 of the License,
113+ or (at your option) any later version.
114+
115+ This plugin is distributed in the hope that it will be useful, but
116+ WITHOUT ANY WARRANTY; without even the implied warranty of
117+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118+ GNU General Public License for more details.
119+
120+ You should have received a copy of the GNU General Public License
121+ along with this program; if not, write to the Free Software
122+ Foundation, Inc., 59 Temple Place, Suite 330, Boston,
123+ MA 02111-1307 USA
124+
125+************************************************************************/
126+
127+/*
128+
129+This plugin create and use 2 new rows in the 'config' table (key -> value structure):
130+ - c_welcome_message -> "The welcome-box message"
131+ - c_winner_message -> "The winner-box message"
132+Both messages should be plain HTML.
133+
134+*/
135+
136+// Make sure no one attempts to run this script "directly"
137+if (!defined('PUN'))
138+ exit;
139+
140+// Tell admin_loader.php that this is indeed a plugin and that it is loaded
141+define('PUN_PLUGIN_LOADED', 1);
142+
143+// Plugin version
144+define('PLUGIN_VERSION', '1.0');
145+// Load the language file
146+require PUN_ROOT.'lang/'.$pun_user['language'].'/reception.php';
147+
148+//
149+// The rest is up to you!
150+//
151+//define('DEBUG',1);
152+
153+// Let's test if we update something
154+if (isset($_POST['update_field'])) {
155+ if (isset($pun_config[$_POST['update_field']]))
156+ {
157+ $query = 'UPDATE '.$db->prefix.'config SET conf_value=\''.$db->escape($_POST['new_text']).'\' WHERE conf_name=\''.$_POST['update_field'].'\'';
158+ } else {
159+ $query = 'INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\''.$_POST['update_field'].'\', \''.$db->escape($_POST['new_text']).'\')';
160+ }
161+
162+ $result = $db->query($query, true) or error($lang_reception['insert update impossible'], __FILE__, __LINE__, $db->error());
163+ if (defined('DEBUG'))
164+ error_log("[Reception] Query: ".$query);
165+
166+ // Update config locally (for immediate display in this page) and globally
167+ $pun_config[$_POST['update_field']] = $_POST['new_text'];
168+ require PUN_ROOT.'include/cache.php';
169+ generate_config_cache();
170+}
171+
172+// Display the admin navigation menu
173+generate_admin_menu($plugin);
174+?>
175+
176+<div id="reception_plugin" class="blockform">
177+ <h2><span><?php echo $lang_reception['mod name']; ?> version <?php echo PLUGIN_VERSION; ?></span></h2>
178+ <p><?php echo $lang_reception['description']; ?></p>
179+ <table cellspacing="0">
180+ <tbody>
181+ <tr>
182+ <td class="tcl">
183+ <div class="inform">
184+ <fieldset>
185+ <legend><?php echo $lang_reception['reception title']; ?></legend>
186+ <div class="infldset">
187+ <div id="welcome_field">
188+ <div id="welcome_text">
189+<?php
190+ if ($pun_config['c_welcome_message'] != '')
191+ {
192+ echo $pun_config['c_welcome_message'].'</div><div>';
193+ }
194+ else
195+ {
196+ echo '</div><div><em>'.$lang_reception['empty'].'</em>';
197+ }
198+?>
199+ </div>
200+ <br/>
201+ <input type="button" value="<?php echo $lang_reception['edit']; ?>" onclick="edit('welcome_')" />
202+ </div>
203+ </div>
204+ </fieldset>
205+ </div>
206+ </td>
207+ </tr>
208+ <tr>
209+ <td >
210+ <div class="inform">
211+ <fieldset>
212+ <legend><?php echo $lang_reception['winner title']; ?></legend>
213+ <div class="infldset">
214+ <div id="winner_field">
215+ <div id="winner_text">
216+<?php
217+ if ($pun_config['c_winner_message'] != '')
218+ {
219+ echo $pun_config['c_winner_message'].'</div><div>';
220+ }
221+ else
222+ {
223+ echo '</div><div><em>'.$lang_reception['empty'].'</em>';
224+ }
225+?>
226+ </div>
227+ <br/>
228+ <input type="button" value="<?php echo $lang_reception['edit']; ?>" onclick="edit('winner_')" />
229+ </div>
230+ </div>
231+ </fieldset>
232+ </div>
233+ </td>
234+ </tr>
235+ </tbody>
236+ </table>
237+</div>
238+
239+<script type="text/javascript">
240+//<![CDATA[
241+
242+var oldField = "";
243+
244+function edit(pid) {
245+
246+ // Just one edition at a time
247+ if (document.getElementById('new_text')) {
248+ alert("<?php echo $lang_reception['edit multiple annonces']; ?>");
249+ return (1);
250+ }
251+
252+ oldField = document.getElementById(pid+'field').innerHTML.replace(/<br>/g, '<br/>');
253+ var editText = document.getElementById(pid+'text').innerHTML.replace(/<br>/g, '<br/>');
254+
255+ 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+"\")' />";
256+
257+ document.getElementById(pid+'field').innerHTML = newField;
258+}
259+
260+function preview(pid) {
261+ var preview = document.getElementById('new_text').value;
262+
263+ 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+"\")' />";
264+
265+ document.getElementById(pid+'field').innerHTML = preview_field;
266+}
267+
268+function cancel(pid) {
269+ document.getElementById(pid+'field').innerHTML = oldField;
270+ oldField = "";
271+}
272+
273+//]]>
274+</script>
275+
276+<?php
277+// Note that the script just ends here. The footer will be included by admin_loader.php.

Subscribers

People subscribed via source and target branches