From 97a975d3eb3ea68d55f8ee982bc152ee6d23a8a2 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 16 Oct 2004 18:17:50 +0000 Subject: [PATCH] more work on the path --- htdocs/newsletter/show.php | 33 ++++++++++++++++++++++++++++ htdocs/newsletter/submit.php | 4 ++-- include/newsletter.inc.php | 33 ++++++++++++++++++++++------ templates/newsletter/head.tpl | 34 +++++++++++++++++++++++++++++ templates/newsletter/show.tpl | 48 +++++++++++++++++++++++++++++++++++++++++ templates/newsletter/submit.tpl | 4 ++-- 6 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 htdocs/newsletter/show.php create mode 100644 templates/newsletter/head.tpl create mode 100644 templates/newsletter/show.tpl diff --git a/htdocs/newsletter/show.php b/htdocs/newsletter/show.php new file mode 100644 index 0000000..4aec834 --- /dev/null +++ b/htdocs/newsletter/show.php @@ -0,0 +1,33 @@ +assign_by_ref('nl',$nl); + +$page->run(); +?> diff --git a/htdocs/newsletter/submit.php b/htdocs/newsletter/submit.php index fcfb24b..8b3a6c7 100644 --- a/htdocs/newsletter/submit.php +++ b/htdocs/newsletter/submit.php @@ -18,11 +18,11 @@ * 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'])) { diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 8788081..4275623 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -18,7 +18,7 @@ * 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 $ ***************************************************************************/ @@ -51,44 +51,63 @@ function enriched_to_text($input,$html=false) { 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 { @@ -172,7 +191,7 @@ class NLSexeConstraint { 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); diff --git a/templates/newsletter/head.tpl b/templates/newsletter/head.tpl new file mode 100644 index 0000000..abd83f8 --- /dev/null +++ b/templates/newsletter/head.tpl @@ -0,0 +1,34 @@ +{*************************************************************************** + * 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} + +{/literal} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/newsletter/show.tpl b/templates/newsletter/show.tpl new file mode 100644 index 0000000..f0e6c7a --- /dev/null +++ b/templates/newsletter/show.tpl @@ -0,0 +1,48 @@ +{*************************************************************************** + * 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} +
+ Lettre de Polytechnique.org de {$nl->_date|date_format:"%B %Y"} +
+ +

[liste des lettres]

+ +
+
+ +
+
+ + + + + +
+
+ {$nl->toHtml()} +
+
+ +{/dynamic} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/newsletter/submit.tpl b/templates/newsletter/submit.tpl index d68fef3..5ebe8e7 100644 --- a/templates/newsletter/submit.tpl +++ b/templates/newsletter/submit.tpl @@ -17,7 +17,7 @@ * 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 $ ***************************************************************************} @@ -60,7 +60,7 @@ il faut te limiter Version html -
+
{$art->toHtml()|smarty:nodefaults}
-- 2.1.4