if (obj != null) {
document.getElementById(obj).innerHTML = Ajax.xml_client.responseText;
}
- if (func != null) {
+ if (func != null) {
func(Ajax.xml_client.responseText);
}
} else if (Ajax.xml_client.status == 403) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function quoted_printable_encode($input, $line_max = 76) {
+function quoted_printable_encode($input, $line_max = 76)
+{
$lines = preg_split("/(?:\r\n|\r|\n)/", $input);
$eol = "\n";
$linebreak = "=0D=0A=\n ";
!preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
}
+/** Check if the string is utf8
+ */
+function is_utf8($s)
+{
+ return @iconv('utf-8', 'utf-8', $s) == $s;
+}
+
+
/** Remove accent from a string and replace them by the nearest letter
*/
global $lc_convert, $uc_convert;
return array(
'events' => $this->make_hook('ev', AUTH_COOKIE),
'rss' => $this->make_hook('rss', AUTH_PUBLIC),
+ 'events/preview' => $this->make_hook('preview', AUTH_PUBLIC, '', NO_AUTH),
'events/submit' => $this->make_hook('ev_submit', AUTH_MDP),
'admin/events' => $this->make_hook('admin_events', AUTH_MDP, 'admin'),
WHERE u.user_id = {?} AND FIND_IN_SET(e.flags, "valide")
AND peremption >= NOW()', $uid);
$page->assign('rss', $rss);
- }
+ }
+
+ function handler_preview(&$page)
+ {
+ require_once('url_catcher.inc.php');
+ $page->changeTpl('events/preview.tpl', NO_SKIN);
+ $texte = Get::v('texte');
+ if (!is_utf8($texte)) {
+ $texte = utf8_encode($texte);
+ }
+ if (strpos($_SERVER['HTTP_REFERER'], 'admin') === false) {
+ $texte = url_catcher(pl_entities($texte));
+ }
+ $titre = Get::v('titre');
+ if (!is_utf8($titre)) {
+ $titre = utf8_encode($titre);
+ }
+ $page->assign('texte_html', $texte);
+ $page->assign('titre', $titre);
+ header('Content-Type: text/html; charset=utf-8');
+ }
function handler_ev_submit(&$page)
{
$page->changeTpl('events/submit.tpl');
+ $page->addJsLink('ajax.js');
+
+ require_once('wiki.inc.php');
+ wiki_require_page('Xorg.Annonce');
$titre = Post::v('titre');
$texte = Post::v('texte');
if ($action && (!trim($texte) || !trim($titre))) {
$page->trig("L'article doit avoir un titre et un contenu");
- } elseif ($action == 'Confirmer') {
+ } elseif ($action) {
$texte = $texte_catch_url;
require_once 'validations.inc.php';
$evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max,
function handler_admin_events(&$page, $action = 'list', $eid = null)
{
$page->changeTpl('events/admin.tpl');
+ $page->addJsLink('ajax.js');
$page->assign('xorg_title','Polytechnique.org - Administration - Evenements');
$page->register_modifier('hde', 'html_entity_decode');
list($titre, $texte, $peremption, $promo_min, $promo_max) = $res->fetchOneRow();
$page->assign('titre',$titre);
$page->assign('texte',$texte);
+ $page->assign('texte_html', pl_entity_decode($texte));
$page->assign('promo_min',$promo_min);
$page->assign('promo_max',$promo_max);
$page->assign('peremption',$peremption);
{if $action eq 'edit'}
-{include file="include/form.evenement.tpl"}
+{include file="events/form.tpl"}
{else}
{* *}
{**************************************************************************}
+<script type="text/javascript">
+ {literal}
+ function updatePreview()
+ {
+ var titre = document.getElementById('titre').value;
+ var texte = document.getElementById('texte').value;
+
+ if (titre == '' || texte == '') {
+ document.getElementById('valid').style.display = 'none';
+ document.getElementById('info').style.display = '';
+ } else {
+ document.getElementById('valid').style.display = '';
+ document.getElementById('info').style.display = 'none';
+ }
+ var page = 'events/preview?titre=' + titre + '&texte=' + texte;
+ if (is_IE) {
+ {/literal}
+ page = "{$globals->baseurl}/" + page;
+ {literal}
+ }
+ Ajax.update_html('preview', page, null);
+ return false;
+ }
+ {/literal}
+</script>
+
+<div id="preview">
+{include file="events/preview.tpl"}
+</div>
+<br />
+
<form action="{$platal->path}" method="post">
<table class="bicol">
<tr>
- <th colspan="2">Contenu du message</th>
- </tr>
- {if strlen(trim($texte))}
- <tr class="pair">
- <td colspan="2" style="border-bottom: 1px dotted #777">
- {$texte|smarty:nodefaults|nl2br}
- </td>
+ <th colspan="2">Contenu de l'annonce</th>
</tr>
- {/if}
<tr>
<td class="titre">Titre</td>
<td>
- <input type="text" name="titre" size="50" maxlength="200" value="{$titre}" />
+ <input type="text" name="titre" id="titre" size="50" maxlength="200" value="{$titre}" />
</td>
</tr>
<tr>
<td class="titre">Texte</td>
- <td><textarea name="texte" rows="10" cols="60" onfocus="update_texte_count(this.form)">{$texte}</textarea></td>
+ <td><textarea name="texte" id="texte" rows="10" cols="60" onfocus="update_texte_count(this.form)">{$texte}</textarea></td>
</tr>
<tr>
<td colspan="2" class="smaller">
}
{/literal}
</script>
- Essaie de faire un <strong>texte court</strong>, une annonce ne doit pas excéder 800 caractères soit une douzaine de ligne. Tu en es déjà à <input type='text' name='texte_count' size="4"/> caractères.
+ Essaie de faire un <strong>texte court</strong>, une annonce ne doit pas excéder 800 caractères soit une douzaine de ligne. Tu en es déjà à <input type='text' name='texte_count' size="4" /> caractères.
</td>
</tr>
- <tr>
- <th colspan="2">Informations complémentaires</th>
- </tr>
</table>
+ <div class="center">
+ <input type="submit" name="preview" value="Aperçu" onclick="updatePreview(); return false;" />
+ </div>
+ <p id="info" {if trim($texte) && trim($titre)}style="display: none"{/if}>
+ Le bouton de confirmation n'apparaît que si l'aperçu est concluant.
+ </p>
+ <p class="erreur">
+ N'oublie pas de remplir suivantes :
+ </p>
+
<table class="bicol">
+ <tr>
+ <th colspan="2">Informations complémentaires</th>
+ </tr>
<tr class="pair">
<td colspan="2">
Tu peux limiter la visibilité de ton annonce aux camarades de certaines promotions :
</tr>
</table>
- <div class="center">
+ <div class="center" {if !trim($texte) || !trim($titre)}style="display: none"{/if} id="valid">
<input type="hidden" name="evt_id" value="{$smarty.post.evt_id}" />
<input type="submit" name="action" value="Proposer" />
</div>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2007 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+{if trim($titre) || trim($texte_html)}
+<table class="bicol">
+ <tr><th><em>Aperçu de : </em>{$titre|nl2br}</th></tr>
+ <tr class="pair"><td>{$texte_html|nl2br|smarty:nodefaults}</td></tr>
+</table>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<h1>Proposition d'information événementielle</h1>
-{if $action eq "proposer" && trim($titre) && trim($texte)}
-
-<p>
-Voici ton annonce :
-</p>
-
-<table class="bicol">
- <tr><th>{$titre|nl2br}</th></tr>
- <tr><td>{$texte_html|nl2br|smarty:nodefaults}</td></tr>
-</table>
-
-<p>
-Ce message est à destination
-{if $promo_min || $promo_max}
-des promotions {if $promo_min}X{$promo_min}{/if} {if $promo_max}jusqu'à X{$promo_max}{else} et plus{/if}
-{else}
-de toutes les promotions
-{/if}
-et sera affiché sur la page d'accueil jusqu'au {$peremption|date_format}.
-</p>
-
-{if $valid_mesg}
-<p>
-Tu as ajouté le message suivant à l'intention du validateur : {$valid_mesg|nl2br}
-</p>
-{/if}
-
-<form action="events/submit" method="post">
- <div>
- <input type="hidden" name="titre" value="{$titre}" />
- <input type="hidden" name="texte" value="{$texte}" />
- <input type="hidden" name="promo_min" value="{$promo_min}" />
- <input type="hidden" name="promo_max" value="{$promo_max}" />
- <input type="hidden" name="peremption" value="{$peremption}" />
- <input type="hidden" name="valid_mesg" value="{$valid_mesg}" />
- <input type="submit" name="action" value="Confirmer" />
- <input type="submit" name="action" value="Modifier" />
- </div>
-</form>
-
-
-{elseif $action eq "confirmer"}
-
{if $ok}
<p>
Ta proposition a bien été enregistrée, un administrateur va se charger de la valider aussi rapidement que possible.
<a href="events">Retour à la page d'accueil</a>
</p>
{else}
-<p class="erreur">
-Une erreur s'est produite pendant l'enregistrement de ta proposition.
-Merci de nous <a href="Xorg/NousContacter">contacter</a>!
-</p>
-{/if}
-{else}
+{include file="events/form.tpl"}
-{include file="include/form.evenement.tpl"}
+{include file="../spool/wiki.d/cache_Xorg.Annonce.tpl included=1}
{/if}