Introduces a new tab structure for browsing into banana
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 15 Jul 2006 15:46:47 +0000 (15:46 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:01 +0000 (00:35 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@110 9869982d-c50d-0410-be91-f2a2ec7c7c7b

Changelog
banana/banana.inc.php.in
banana/misc.inc.php
css/banana.css
css/style.css

index 70c5395..1b2c924 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
 Sat, 15 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
+       * New tabbed structure
        * Support of Content-ID references (multipart/related)
 
 Fri, 14 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
index 2940852..61cc777 100644 (file)
@@ -132,19 +132,19 @@ class Banana
 
         if (is_null($group)) {
             if (isset($banana->get['subscribe'])) {
-                return $banana->action_listSubs();
+                return makeTable($banana->action_listSubs());
             } elseif (isset($_POST['validsubs'])) {
                 $banana->action_saveSubs();
             }
-            return $banana->action_listGroups();
+            return makeTable($banana->action_listGroups());
 
         } elseif (is_null($artid)) {
             if (isset($_POST['action']) && $_POST['action'] == 'new') {
-                return $banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1);
+                return makeTable($banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1));
             } elseif ($action == 'new') {
-                return $banana->action_newFup($group);
+                return makeTable($banana->action_newFup($group));
             } else {
-                return $banana->action_showThread($group, isset($banana->get['first']) ? intval($banana->get['first']) : 1);
+                return makeTable($banana->action_showThread($group, isset($banana->get['first']) ? intval($banana->get['first']) : 1));
             }
 
         } else {
@@ -167,12 +167,12 @@ class Banana
                                   . '<input type="hidden" name="action" value="cancel" />'
                                   . '<input type="submit" value="Annuler !" />'
                                   . '</p></form>';
-                            return $form.$res;
+                            return makeTable($form . $res);
                         }
-                        return $res;
+                        return makeTable("" . $res);
 
                     case 'new':
-                        return $banana->action_newFup($group, $artid);
+                        return makeTable($banana->action_newFup($group, $artid));
                 }
             }
 
@@ -182,13 +182,10 @@ class Banana
                     $view = true;
                 }
                 $att = $banana->action_getAttachment($group, $artid, $banana->get['pj'], $view);
-                if ($att != "") {
-                    return $res.$att;
-                }
-                return "";
+                return makeTable($res . $att);
             }
             
-            return $res . $banana->action_showArticle($group, $artid, $partid);
+            return makeTable($banana->action_showArticle($group, $artid, $partid));
         }
     }
 
@@ -205,15 +202,14 @@ class Banana
     {
         $this->_newGroup();
         
-        $cuts = displayshortcuts();
-        $res  = '<h1>'._b_('Les forums de Banana').'</h1>'.$cuts.$this->groups->to_html();
+        $res  = $this->groups->to_html();
         if (count($this->newgroups->overview)) {
             $res .= '<p>'._b_('Les forums suivants ont été créés depuis ton dernier passage :').'</p>';
             $res .= $this->newgroups->to_html();
         }
 
         $this->nntp->quit();
-        return $res.$cuts;
+        return $res;
     }
 
     function action_listSubs()
@@ -221,8 +217,7 @@ class Banana
         $this->_require('groups');
         $this->groups = new BananaGroups(BANANA_GROUP_ALL);
         
-        $cuts = displayshortcuts();
-        $res  = '<h1>'._b_('Abonnements').'</h1>'.$cuts.$this->groups->to_html(true).$cuts;
+        $res  = $this->groups->to_html(true);
 
         $this->nntp->quit();
         return $res;
@@ -239,15 +234,13 @@ class Banana
         }
 
         $first = $first - ($first % $this->tmax) + 1;
-
-        $cuts = displayshortcuts($first);
         
-        $res  = '<h1>'.$group.'</h1>'.$cuts;
-        $res  .= $this->spool->to_html($first, $first+$this->tmax);
+        $pages = displayPages($first);
+        $res  = $pages . $this->spool->to_html($first, $first+$this->tmax) . $pages;
 
         $this->nntp->quit();
         
-        return $res.$cuts;
+        return $res;
     }
 
     function action_showArticle($group, $id, $part)
@@ -261,16 +254,14 @@ class Banana
                 $this->spool->delid($id);
             }
             $this->nntp->quit();
-            return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message.   Le message a peut-être été annulé').'</p>';
+            return '<p class="error">'._b_('Impossible d\'accéder au message.   Le message a peut-être été annulé').'</p>';
         }
 
-        $cuts = displayshortcuts();
-        $res  = '<h1>'._b_('Message').'</h1>'.$cuts;
-        $res .= $this->post->to_html($part);
+        $res = $this->post->to_html($part);
 
         $this->nntp->quit();
         
-        return $res.$cuts;
+        return $res;
     }
 
     function action_getAttachment($group, $id, $pjid, $action)
@@ -284,14 +275,14 @@ class Banana
                 $this->spool->delid($id);
             }
             $this->nntp->quit();
-            return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message.   Le message a peut-être été annulé').'</p>';
+            return '<p class="error">'._b_('Impossible d\'accéder au message.   Le message a peut-être été annulé').'</p>';
         }
 
         $this->nntp->quit();
         if ($this->post->get_attachment($pjid, $action)) {
             return "";
         } else {
-            return displayshortcuts().'<p calss="error">'._b_('Impossible d\'accéder à la pièce jointe.').'</p>';
+            return '<p calss="error">'._b_('Impossible d\'accéder à la pièce jointe.').'</p>';
         }
     }
 
@@ -342,9 +333,7 @@ class Banana
 
         $this->nntp->quit();
 
-        $cuts  = displayshortcuts();
-        $html  = '<h1>'._b_('Nouveau message').'</h1>'.$cuts;
-        $html .= '<form enctype="multipart/form-data" action="'
+        $html  = '<form enctype="multipart/form-data" action="'
                . htmlentities(makeLink(Array('group' => $group)))
                .'" method="post" accept-charset="utf-8">';
         $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
@@ -370,7 +359,7 @@ class Banana
         $html .= '<input type="submit" value="Envoyer le message" /></th></tr>';
         $html .= '</table></form>';
 
-        return $html.$cuts;
+        return $html;
     }
 
     function action_doFup($group, $artid = -1)
index 0786659..09cd285 100644 (file)
@@ -380,67 +380,97 @@ function formatFrom($text) {
     return preg_replace("/\\\(\(|\))/","\\1",$result);
 }
 
-function displayShortcuts($first = -1)
+function displayTabs()
 {
     global $banana;
     extract($banana->state);
     
-    $res  = '<div class="banana_scuts">';
-    $res .= '<span class="title"> Profil :</span> ' . makeHREF(Array('subscribe' => 1), _b_('Abonnements'));
+    $res  = Array();
     if (function_exists('hook_shortcuts') && $cstm = hook_shortcuts()) {
-        $res .= ' . ' . $cstm;
+        $res = $cstm;
     }
-    $res .= '<br />';
-    
-    $res .=  '<span class="title">Navigation :</span> '
-         . (is_null($group) ? 'Les forums' : makeHREF(Array(), _b_('Les forums')));
+    array_push($res,
+               makeHREF(Array('subscribe' => 1), _b_('Abonnements')),
+               is_null($group) ? Array(_b_('Les forums'), true) : makeHREF(Array(), _b_('Les forums')));
 
     if (!is_null($group)) {
-        $res .= ' > ' . makeHREF(Array('group' => $group), $group);
+        $grplink = makeHREF(Array('group' => $group), $group);
+        $grpcur  = Array($group, true);
         if (is_null($artid)) {
-            if (sizeof($banana->spool->overview)>$banana->tmax) {
-                $res .= ' > Pages';
-                $res .= '<div class="pages">';
-                $n = intval(log(count($banana->spool->overview), 10))+1;
-                $i = 1;
-                for ($ndx = 1 ; $ndx <= sizeof($banana->spool->overview) ; $ndx += $banana->tmax) {
-                    if ($first==$ndx) {
-                        $res .= '<strong>' . $i . '</strong> ';
-                    } else {
-                        $res .= makeHREF(Array('group' => $group,
-                                              'first' => $ndx),
-                                        $i, 
-                                        $ndx . '-' . min($ndx+$banana->tmax-1,sizeof($banana->spool->overview)))
-                             . ' ';
-                    }
-                    $i++;
-                }
-                $res .= '</div>';
-            }
-            if (!is_null($action)) {
-                if ($action == 'new') {
-                    $res .= ' > Nouveau Message';
-                }
+            if (@$action == 'new') {
+                array_push($res, $grplink, Array(_b_('Nouveau Message'), true));
+            } else {
+                array_push($res, $grpcur);
             }
         } else {
             if (!is_null($action)) {
-                $res .= ' > ' . makeHREF(Array('group' => $group,
-                                               'artid' => $artid),
-                                         _b_('Message'))
-                     . ' > ';
+                array_push($res,
+                           $grplink,
+                           makeHREF(Array('group' => $group,
+                                          'artid' => $artid),
+                                    _b_('Message')));
                 if ($action == 'new') {
-                    $res .= 'Répondre';
+                    array_push($res, Array(_b_('Répondre'), true));
                 } elseif ($action == 'cancel') {
-                    $res .= 'Annuler';
+                    array_push($res, Array(_b_('Annuler'), true));
                 }
             } else {
-                $res .= ' > Message';
+                array_push($res, $grplink, Array(_b_('Message'), true));
+            }
+        }
+    }
+    $ret = '<ul id="onglet">';
+    foreach ($res as $onglet) {
+        if (is_string($onglet)) {
+            $ret .= '<li>' . $onglet . '</li>';
+        } else {
+            $ret .= '<li class="actif">' . $onglet[0] . '</li>';
+        }
+    }
+    $ret .= '</ul>';
+    return $ret;
+}
+
+function displayPages($first = -1)
+{
+    global $banana;
+    extract($banana->state);
+    $res = null; 
+    if (!is_null($group) && is_null($artid)
+            && sizeof($banana->spool->overview)>$banana->tmax) {
+        $res .= '<div class="pages">';
+        $n = intval(log(count($banana->spool->overview), 10))+1;
+        $i = 1;
+        for ($ndx = 1 ; $ndx <= sizeof($banana->spool->overview) ; $ndx += $banana->tmax) {
+            if ($first==$ndx) {
+                $res .= '<strong>' . $i . '</strong> ';
+            } else {
+                $res .= makeHREF(Array('group' => $group,
+                                       'first' => $ndx),
+                                 $i, 
+                                 $ndx . '-' . min($ndx+$banana->tmax-1,sizeof($banana->spool->overview)))
+                     . ' ';
             }
+            $i++;
         }
+        $res .= '</div>';
     }
-    return $res.'</div>';
+    return $res;
 }
 
+function makeTable($text)
+{
+    return '<table class="cadre_a_onglet" cellpadding="0" cellspacing="0">'
+         . '<tr><td>'
+         . displayTabs()
+         . '</td></tr>'
+         . '<tr><td class="conteneur_tab">'
+         . $text
+         . '</td></tr>'
+         . '</table>';
+}        
+
 /********************************************************************************
  *  FORMATTING STUFF : BODY
  */
index b88a278..bd24dfb 100644 (file)
@@ -66,3 +66,53 @@ table.bicol th {
 
 table.bicol td { padding: 0px 4px; }
 
+table.cadre_a_onglet{
+    width: 100%;
+    border-width: 0;
+    padding : 0;
+    margin: 0;
+}
+
+td.conteneur_tab {
+    border-width : 1px 2px 2px 1px;
+    border-style : solid;
+    border-color : #a2c2e1;
+    padding : 4px 4px 4px 4px;
+}
+
+#onglet {
+    display : block;
+    margin : 0;
+    padding : 0;
+}
+
+#onglet li {
+    display : block;
+    float : left;
+    padding : 0.4ex;
+    margin : 0 0.3ex -1px 0;
+    background : #eee;
+    border-width : 1px 1px 0px 1px;
+    border-style : solid;
+    border-color : #a2c2e1;
+    border-bottom-color : #a2c2e1;
+    width: auto;
+    height: 5ex;
+    text-align: center;
+}
+
+#onglet li:hover { background : #fc3; }
+
+#onglet li.actif {
+    background-color: #fff;
+    border-bottom-color : #eceade;
+}
+
+#onglet li a {
+    font-size: 80%;
+    font-weight : normal;
+    text-decoration : none;
+}
+
+#onglet li a:hover { text-decoration: underline; }
+#onglet li img { margin-right : 2px; }
index 004b3c4..9b48a5c 100644 (file)
@@ -6,17 +6,11 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
-div.banana_scuts {
-    text-align: left;
-    padding: 0.5em 0em;
-}
-div.banana_scuts .title {
-    font-weight: bold;
-}
-div.banana_scuts .pages {
+div.pages {
     font-size: 80%;
     text-align: center;
     padding-top: 0.1em;
+    padding-bottom: 0.1em;
 }
 div.banana_action { float: right; }
 div.banana_menu { float: left; }