--- /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: show.php,v 1.1 2004-10-16 18:17:50 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_skinned_page('newsletter/show.tpl', AUTH_COOKIE, false, 'newsletter/head.tpl');
+require("newsletter.inc.php");
+
+$nid = empty($_GET['nid']) ? 'last' : $_GET['nid'];
+$nl = new NewsLetter($nid);
+$page->assign_by_ref('nl',$nl);
+
+$page->run();
+?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: submit.php,v 1.2 2004-10-16 17:53:40 x2000habouzit Exp $
+ $Id: submit.php,v 1.3 2004-10-16 18:17:50 x2000habouzit Exp $
***************************************************************************/
require("auto.prepend.inc.php");
-new_skinned_page('newsletter/submit.tpl', AUTH_COOKIE);
+new_skinned_page('newsletter/submit.tpl', AUTH_COOKIE, false, 'newsletter/head.tpl');
require("newsletter.inc.php");
if(isset($_POST['see'])) {
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: newsletter.inc.php,v 1.6 2004-10-16 17:49:38 x2000habouzit Exp $
+ $Id: newsletter.inc.php,v 1.7 2004-10-16 18:17:51 x2000habouzit Exp $
***************************************************************************/
class NewsLetter {
var $_id;
- var $_cats;
+ var $_date;
+ var $_cats = Array();
+ var $_arts = Array();
function NewsLetter($id=null) {
global $globals;
if(isset($id)) {
+ if($id == 'last') {
+ $res = $globals->db->query("SELECT MAX(id) FROM newsletter WHERE bits!='new'");
+ list($id) = mysql_fetch_row($res);
+ }
$res = $globals->db->query("SELECT * FROM newsletter WHERE id='$id'");
} else {
$res = $globals->db->query("SELECT * FROM newsletter WHERE bits='new'");
}
$nl = mysql_fetch_assoc($res);
$this->_id = $nl['id'];
+ $this->_date = $nl['date'];
mysql_free_result($res);
$res = $globals->db->query("SELECT cid,titre FROM newsletter_cat ORDER BY pos");
- $this->_cats = Array();
while(list($cid,$title) = mysql_fetch_row($res)) {
$this->_cats[$cid] = $title;
}
mysql_free_result($res);
-
+
+ $res = $globals->db->query("SELECT title,body,append,aid,cid,pos
+ FROM newsletter_art AS a
+ INNER JOIN newsletter AS n USING(id)
+ ORDER BY 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);
+ }
+ mysql_free_result($res);
}
-
function saveArticle(&$a) {
global $globals;
if($a->_aid) {
$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,100,'{$a->_title}','{$a->_body}','{$a->_append}'
+ SELECT {$this->_id},MAX(aid)+1,0,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 toHtml() {
+ return "foo";
+ }
}
class NLArticle {
function get_nl_list() {
global $globals;
- $res = $globals->db->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC");
+ $res = $globals->db->query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC");
$ans = Array();
while($tmp = mysql_fetch_assoc($res)) $ans[] = $tmp;
mysql_free_result($res);
--- /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: head.tpl,v 1.1 2004-10-16 18:17:51 x2000habouzit Exp $
+ ***************************************************************************}
+
+{literal}
+<style type="text/css">
+ div.nl {
+ margin: auto;
+ font-familly: georgia,"times new roman",serif;
+ width:56ex;
+ text-align: justify;
+ }
+</style>
+{/literal}
+
+{* 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: show.tpl,v 1.1 2004-10-16 18:17:51 x2000habouzit Exp $
+ ***************************************************************************}
+
+{dynamic}
+<div class="rubrique">
+ Lettre de Polytechnique.org de {$nl->_date|date_format:"%B %Y"}
+</div>
+
+<p>[<a href='index.php'>liste des lettres</a>]</p>
+
+<form method="post" action="{$smarty.server.PHP_SELF}">
+ <div class='center'>
+ <input type='submit' value="me l'envoyer" name='send' />
+ </div>
+</form>
+
+<table class="bicol" cellpadding="3" cellspacing="0">
+ <tr>
+ <td>
+ <div class='nl'>
+ {$nl->toHtml()}
+ </div>
+ </td>
+ </tr>
+</table>
+
+{/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.2 2004-10-16 17:52:27 x2000habouzit Exp $
+ $Id: submit.tpl,v 1.3 2004-10-16 18:17:51 x2000habouzit Exp $
***************************************************************************}
<tr><th>Version html</th></tr>
<tr id='html'>
<td>
- <div style="margin: auto; font-familly:georgia; width:56ex; text-align: justify">
+ <div class='nl'>
{$art->toHtml()|smarty:nodefaults}
</div>
</td>