--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 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 *
+ ***************************************************************************
+ $Id: newsletter.php,v 1.1 2004-10-16 19:54:34 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_admin_page('admin/newsletter.tpl');
+require("newsletter.inc.php");
+
+$page->assign_by_ref('nl_list',get_nl_slist());
+$page->run();
+?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 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 *
+ ***************************************************************************
+ $Id: newsletter_edit.php,v 1.1 2004-10-16 19:54:34 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_admin_page('admin/newsletter_edit.tpl', false, 'newsletter/head.tpl');
+require("newsletter.inc.php");
+
+$nid = empty($_GET['nid']) ? 'last' : $_GET['nid'];
+$nl = new NewsLetter($nid);
+if(isset($_GET['del_aid'])) {
+ $nl->delArticle($_GET['del_aid']);
+ header("Location: ?nid=$nid");
+}
+
+if(isset($_POST['save'])) {
+ $eaid = $_GET['edit_aid'];
+ $art = new NLArticle($_POST['title'], $_POST['body'], $_POST['append'], $eaid, $_POST['cid'], $_POST['pos']);
+ $nl->saveArticle($art);
+ header("Location: ?nid=$nid");
+}
+
+if(isset($_GET['edit_aid'])) {
+ $eaid = $_GET['edit_aid'];
+ if($eaid<0) {
+ if(!empty($_POST)) {
+ $art = new NLArticle($_POST['title'], $_POST['body'], $_POST['append'],
+ $eaid, $_POST['cid'], $_POST['pos']);
+ } else {
+ $art = new NLArticle();
+ }
+ } else {
+ $art = $nl->getArt($_GET['edit_aid']);
+ }
+ $page->assign('art', $art);
+}
+
+$page->assign_by_ref('nl',$nl);
+
+$page->run();
+?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: newsletter.inc.php,v 1.7 2004-10-16 18:17:51 x2000habouzit Exp $
+ $Id: newsletter.inc.php,v 1.8 2004-10-16 19:54:35 x2000habouzit Exp $
***************************************************************************/
class NewsLetter {
var $_id;
var $_date;
+ var $_title;
var $_cats = Array();
var $_arts = Array();
$nl = mysql_fetch_assoc($res);
$this->_id = $nl['id'];
$this->_date = $nl['date'];
+ $this->_title = $nl['titre'];
mysql_free_result($res);
$res = $globals->db->query("SELECT cid,titre FROM newsletter_cat ORDER BY pos");
}
mysql_free_result($res);
- $res = $globals->db->query("SELECT title,body,append,aid,cid,pos
+ $res = $globals->db->query("SELECT a.title,a.body,a.append,a.aid,a.cid,a.pos
FROM newsletter_art AS a
INNER JOIN newsletter AS n USING(id)
- ORDER BY a.pos");
+ LEFT JOIN newsletter_cat AS c ON(a.cid=c.cid)
+ ORDER BY c.pos,a.pos");
while(list($title,$body,$append,$aid,$cid,$pos) = mysql_fetch_row($res)) {
- $_arts["a$aid"] = new NLArticle($title,$body,$append,$aid,$cid,$pos);
+ $this->_arts[$cid]["a$aid"] = new NLArticle($title,$body,$append,$aid,$cid,$pos);
}
mysql_free_result($res);
}
+ function getArt($aid) {
+ foreach($this->_arts as $key=>$artlist) {
+ if(isset($artlist["a$aid"])) return $artlist["a$aid"];
+ }
+ return null;
+ }
+
function saveArticle(&$a) {
global $globals;
- if($a->_aid) {
- $globals->db->query("REPLACE INTO newsletter_art (id,aid,cid,pos,title,body.append)
+ if($a->_aid>=0) {
+ $globals->db->query("REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append)
VALUES({$this->_id},{$a->_aid},{$a->_cid},{$a->_pos},
'{$a->_title}','{$a->_body}','{$a->_append}')");
$this->_arts['a'.$a->_aid] = $a;
} else {
$globals->db->query(
"INSERT INTO newsletter_art
- SELECT {$this->_id},MAX(aid)+1,0,IF(MAX(pos)<100,100,MAX(pos)+1),'{$a->_title}','{$a->_body}','{$a->_append}'
+ SELECT {$this->_id},MAX(aid)+1,{$a->_cid},
+ ". ($a->_pos ? $a->_pos : "IF(MAX(pos)<100,100,MAX(pos)+1),").",
+ '{$a->_title}','{$a->_body}','{$a->_append}'
FROM newsletter_art AS a
WHERE a.id={$this->_id}");
$this->_arts['a'.$a->_aid] = $a;
}
}
+ function delArticle($aid) {
+ global $globals;
+ $globals->db->query("DELETE FROM newsletter_art WHERE id='{$this->_id}' AND aid='$aid'");
+ foreach($this->_arts as $key=>$art) {
+ unset($this->_arts[$key]["a$aid"]);
+ }
+ }
+
function toHtml() {
return "foo";
}
var $_body;
var $_append;
- function NLArticle($title,$body,$append,$aid=null,$cid=0,$pos=100) {
+ function NLArticle($title='',$body='',$append='',$aid=-1,$cid=0,$pos=0) {
$this->_body = $body;
$this->_title = $title;
$this->_append = $append;
$this->_aid = $aid;
- $this->_cid = $aid;
- $this->_pos = $aid;
+ $this->_cid = $cid;
+ $this->_pos = $pos;
}
function body() { return stripslashes(trim($this->_body)); }
}
function toHtml() {
- $title = '<strong>'.stripslashes($this->_title).'</strong>';
+ $title = '<span style="font-weight:bold; font-style: italic; font-size: 125%">'
+ .stripslashes($this->_title).'</span>';
$body = enriched_to_text($this->_body,true);
$app = enriched_to_text($this->_append,true);
}
+function get_nl_slist() {
+ global $globals;
+ $res = $globals->db->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC");
+ $ans = Array();
+ while($tmp = mysql_fetch_assoc($res)) $ans[] = $tmp;
+ mysql_free_result($res);
+ return $ans;
+}
+
function get_nl_list() {
global $globals;
$res = $globals->db->query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC");
function subscribe_nl() {
global $globals;
- $globals->db->query("REPLACE INTO newsletter_ins (user_id,last) SELECT {$_SESSION['uid']}, MAX(id) FROM newsletter WHERE bits!='new'");
+ $globals->db->query("REPLACE INTO newsletter_ins (user_id,last)
+ SELECT {$_SESSION['uid']}, MAX(id)
+ FROM newsletter WHERE bits!='new'");
}
?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: index.tpl,v 1.9 2004-10-15 14:30:55 x2000habouzit Exp $
+ $Id: index.tpl,v 1.10 2004-10-16 19:54:35 x2000habouzit Exp $
***************************************************************************}
</td></tr>
<tr class="pair"><td>
<strong>Newsletter : </strong>
+ <a href="newsletter.php">Liste</a> |
<a href="newsletter_cats.php">Catégories</a> |
<a href="newsletter_prep.php">Préparation</a> |
<a href="newsletter_archi.php">Archives</a> |
--- /dev/null
+{***************************************************************************
+ * Copyright (C) 2003-2004 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 *
+ ***************************************************************************
+ $Id: newsletter.tpl,v 1.1 2004-10-16 19:54:35 x2000habouzit Exp $
+ ***************************************************************************}
+
+
+<div class="rubrique">
+ Lettre de Polytechnique.org
+</div>
+
+{dynamic}
+<table class="bicol" cellpadding="3" cellspacing="0" summary="liste des NL">
+ <tr>
+ <th>date</th>
+ <th>titre</th>
+ </tr>
+ {foreach item=nl from=$nl_list}
+ <tr class="{cycle values="impair,pair"}">
+ <td>{$nl.date|date_format:"%Y-%m-%d"}</td>
+ <td>
+ <a href="{"admin/newsletter_edit.php"|url}?nid={$nl.id}">{$nl.titre|default:"[no title]"}</a>
+ </td>
+ </tr>
+ {/foreach}
+</table>
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
--- /dev/null
+{***************************************************************************
+ * Copyright (C) 2003-2004 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 *
+ ***************************************************************************
+ $Id: newsletter_edit.tpl,v 1.1 2004-10-16 19:54:35 x2000habouzit Exp $
+ ***************************************************************************}
+
+{dynamic}
+<div class="rubrique">
+ Lettre de Polytechnique.org de {$nl->_date|date_format:"%B %Y"}
+</div>
+
+{if !$art}
+
+<table class="bicol" cellpadding="3" cellspacing="0">
+ <tr>
+ <th>
+ {$nl->_title|default:"[no title]"}
+ </th>
+ <th></th>
+ </tr>
+ <tr>
+ <td>
+ Créer un nouvel article ...
+ </td>
+ <td style='vertical-align:middle; border-left: 1px gray solid'>
+ [<a href="{$smarty.server.PHP_SELF}?nid={$nl->_id}&edit_aid=-1#edit">créer</a>]
+ </td>
+ </tr>
+ {foreach from=$nl->_arts item=arts key=cat}
+ <tr>
+ <th>
+ {$nl->_cats[$cat]|default:"[no cat]"}
+ </th>
+ <th></th>
+ </tr>
+ {foreach from=$arts item=art}
+ <tr class="{cycle values="impair,pair"}">
+ <td>
+ <div class='nl'>
+ {$art->toHtml()|smarty:nodefaults}
+ </div>
+ </td>
+ <td style='vertical-align:middle; border-left: 1px gray solid'>
+ <strong>Pos: {$art->_pos}</strong><br />
+ [<a href="{$smarty.server.PHP_SELF}?nid={$nl->_id}&edit_aid={$art->_aid}#edit">edit</a>]<br />
+ [<a href="{$smarty.server.PHP_SELF}?nid={$nl->_id}&del_aid={$art->_aid}">delete</a>]
+ </td>
+ </tr>
+ {/foreach}
+ {/foreach}
+</table>
+
+{else}
+
+<p>
+[<a href="?nid={$nl->_id}">retour</a>]
+</p>
+
+{if !$art->check()}<p class='erreur'>article trop long !</p>{/if}
+<table class='bicol'>
+ <tr><th>Version texte</th></tr>
+ <tr id='text'>
+ <td><pre>{$art->toText()}</pre></td>
+ </tr>
+ <tr><th>Version html</th></tr>
+ <tr id='html'>
+ <td>
+ <div class='nl'>
+ {$art->toHtml()|smarty:nodefaults}
+ </div>
+ </td>
+ </tr>
+</table>
+
+<br />
+
+<form action="{$smarty.server.REQUEST_URI}" method="post">
+ <table class='bicol'>
+ <tr>
+ <th colspan='2'>
+ <a id='edit'></a>Editer un article
+ <input type='hidden' name='aid' value='{$smarty.get.edit_aid}' />
+ </th>
+ </tr>
+ <tr class="impair">
+ <td class='titre'>Sujet</td>
+ <td>
+ <input size='60' type='text' value='{$art->_title}' name='title' />
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class='titre'>Catégorie</td>
+ <td>
+ <select name='cid'>
+ <option value='0'>-- none --</option>
+ {foreach from=$nl->_cats item=text key=cid}
+ <option value='{$cid}' {if $art->_cid eq $cid}selected="selected"{/if}>{$text}</option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class='titre'>Position</td>
+ <td>
+ <input type='text' value='{$art->_pos}' name='pos' />
+ </td>
+ </tr>
+ <tr class="pair">
+ <td class='titre'>Contenu</td>
+ <td>
+ <textarea cols="68" rows="10" name='body'>{$art->body()}</textarea>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class='titre'>Ajouts (emails, contacts, tarifs, site web, ...)</td>
+ <td>
+ <textarea cols="68" rows="6" name='append'>{$art->append()}</textarea>
+ </td>
+ </tr>
+ <tr class='pair'>
+ <td colspan='2' class='center'>
+ <input type='submit' value='visualiser' />
+ <input type='submit' name='save' value='Sauver' />
+ </td>
+ </tr>
+ </table>
+</form>
+
+{/if}
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: submit.tpl,v 1.3 2004-10-16 18:17:51 x2000habouzit Exp $
+ $Id: submit.tpl,v 1.4 2004-10-16 19:54:35 x2000habouzit Exp $
***************************************************************************}
{/if}
<form action="{$smarty.server.PHP_SELF}" method='post'>
-<table class='tinybicol'>
- <tr><th>Version texte</th></tr>
- <tr id='text'>
+ <table class='tinybicol'>
+ <tr><th>Version texte</th></tr>
+ <tr id='text'>
<td><pre>{$art->toText()}</pre></td>
- </tr>
- {if $art->check()}
- <tr><th>Version html</th></tr>
- <tr id='html'>
- <td>
- <div class='nl'>
- {$art->toHtml()|smarty:nodefaults}
- </div>
- </td>
- </tr>
- <tr>
- <th>Soumettre</th>
- </tr>
- <tr>
- <td>
- Si tu es content de ton article, tu peux le soummetre.
- Sinon, tu peux continuer à l'éditer en dessous
- </td>
- </tr>
- <tr>
- <td class='center'>
- <input type='hidden' value="{$smarty.request.title}" name='title' />
- <input type='hidden' value="{$art->body()}" name="body" />
- <input type='hidden' value="{$art->append()}" name='append' />
- <input type='submit' name='valid' value='soumettre' />
- </td>
- </tr>
- {/if}
-</table>
+ </tr>
+ {if $art->check()}
+ <tr><th>Version html</th></tr>
+ <tr id='html'>
+ <td>
+ <div class='nl'>
+ {$art->toHtml()|smarty:nodefaults}
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <th>Soumettre</th>
+ </tr>
+ <tr>
+ <td>
+ Si tu es content de ton article, tu peux le soummetre.
+ Sinon, tu peux continuer à l'éditer en dessous
+ </td>
+ </tr>
+ <tr>
+ <td class='center'>
+ <input type='hidden' value="{$smarty.request.title}" name='title' />
+ <input type='hidden' value="{$art->body()}" name="body" />
+ <input type='hidden' value="{$art->append()}" name='append' />
+ <input type='submit' name='valid' value='soumettre' />
+ </td>
+ </tr>
+ {/if}
+ </table>
</form>
<br />
<tr class="impair">
<td class='titre'>Sujet</td>
<td>
- <input type='text' value='{$smarty.request.title}' name='title' />
+ <input size='60' type='text' value='{$smarty.request.title}' name='title' />
</td>
</tr>
<tr class="pair">