more work on the path
authorx2000habouzit <x2000habouzit>
Sat, 16 Oct 2004 18:17:50 +0000 (18:17 +0000)
committerx2000habouzit <x2000habouzit>
Sat, 16 Oct 2004 18:17:50 +0000 (18:17 +0000)
htdocs/newsletter/show.php [new file with mode: 0644]
htdocs/newsletter/submit.php
include/newsletter.inc.php
templates/newsletter/head.tpl [new file with mode: 0644]
templates/newsletter/show.tpl [new file with mode: 0644]
templates/newsletter/submit.tpl

diff --git a/htdocs/newsletter/show.php b/htdocs/newsletter/show.php
new file mode 100644 (file)
index 0000000..4aec834
--- /dev/null
@@ -0,0 +1,33 @@
+<?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();
+?>
index fcfb24b..8b3a6c7 100644 (file)
  *  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'])) {
index 8788081..4275623 100644 (file)
@@ -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 (file)
index 0000000..abd83f8
--- /dev/null
@@ -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}
+<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: *}
diff --git a/templates/newsletter/show.tpl b/templates/newsletter/show.tpl
new file mode 100644 (file)
index 0000000..f0e6c7a
--- /dev/null
@@ -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}
+<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: *}
index d68fef3..5ebe8e7 100644 (file)
@@ -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 
   <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>