]> git.mjollnir.org Git - s9y.git/commitdiff
small changes & avoiding notices to breakfast stuff
authorPenny Leach <mjollnir@titania.local>
Sun, 18 Jun 2006 09:25:54 +0000 (21:25 +1200)
committerPenny Leach <mjollnir@titania.local>
Sun, 18 Jun 2006 09:25:54 +0000 (21:25 +1200)
include/breakfast.inc.php
plugins/serendipity_plugin_breakfast/lang_en.inc.php
plugins/serendipity_plugin_breakfast/lib.php
plugins/serendipity_plugin_breakfast/serendipity_plugin_breakfast.php

index bdcab4549fe77003249a7224b0983ddb972662dd..cbbb47238bdd4b0be0a328f0ef0ecb35b34ea4e9 100644 (file)
@@ -21,7 +21,7 @@ if (!empty($_REQUEST['date'])) {
 $output = '<h3 class="serendipity_date">breakfast</h3>
 <p>For some time, I have been going out for weekly Sunday breakfast with a group of people that ranges somewhere between 5 and 10 in number.  After awhile, we decided we needed some sort of rating system.  Since I already sometimes <a href="http://she.geek.nz/archives/198-breakfast-with-mischief-bad-group.html">write</a> <a href="http://she.geek.nz/archives/228-aro-cafe.html">about</a> <a href="http://she.geek.nz/archives/240-highlights-of-the-weekend.html">breakfast</a> here already, I thought I would make it more official and write a s9y plugin for it.</p>
 <p>So here it is:</p>
-<p>So far, you can check out the most recent breakfast only</p>';
+<p>(So far, you can check out the most recent breakfast only)</p>';
 /*
 <p><form action="?" method="post">Filter by: '.breakfast_cafe_dropdown($cafe).', '.breakfast_people_dropdown($person).', '.breakfast_meal_dropdown($meal).', '.breakfast_date_dropdown($date).'<input type="submit" value="Go!" /></form></p>
 <p><a href="?">Or, just the most recent breakfast</a></p>';
@@ -62,5 +62,7 @@ foreach ($categories as $cat => $weight) {
 }
 $output .= '<td>Total</td></tr></tr>'.$tabledata.'</table>';
 
+$output .= '<p>Minimum: '.$latest['totals']['min'].'%, Maximum: '.$latest['totals']['max'].'%, Average: '
+.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</p>';
 $serendipity['smarty']->assign('content_message',$output);
 ?>
index 1f4e885f3d8d69d2c7b8b681476eda35ca5794f9..d081b9b6fc0940224f895671d8ab8e32fa5a3fd9 100644 (file)
@@ -1,4 +1,4 @@
 <?php
-define('PLUGIN_BREAKFAST_TITLE','mbg');
+define('PLUGIN_BREAKFAST_TITLE','mischief bad group!');
 define('PLUGIN_BREAKFAST_DESC','mbg breakfast');
 ?>
\ No newline at end of file
index 98caaeecf8b0b4325cf4e1cdfef2210573eb45c6..e2cc0c4e4c673a897c4d04648b7b1a0429772c47 100644 (file)
@@ -9,13 +9,15 @@ function breaKfast_cafe_dropdown($selected=0) {
     <select name="cafe">
         <option value="0">-- Cafe --</option>';
     $results = serendipity_db_query('SELECT * FROM mbg_cafe');
-    foreach ($results as $r) {
-        $s = '';
-        if ($r['id'] == $selected) {
-            $s = 'selected="selected"';
-        }
-        $output .='<option value="'.$r['id'].'" '.$s.'>'.$r['name'].'</option>';
-    }                              
+    if (is_array($results)) {
+        foreach ($results as $r) {
+            $s = '';
+            if ($r['id'] == $selected) {
+                $s = 'selected="selected"';
+            }
+            $output .='<option value="'.$r['id'].'" '.$s.'>'.$r['name'].'</option>';
+        }            
+    }                  
     $output .= '</select>';
     return $output;
 }
@@ -27,9 +29,11 @@ function breakfast_person_dropdown($count) {
     $output = '
     <select name="person'.$count.'">
         <option value="0">-- Person --</option>';
-    foreach ($people as $person) {
-        $output .= '<option value="'.$person['id'].'">'.$person['name'].((!empty($person['alias'])) ? '('.$person['alias'].')' : '').'</option>';
-    }                              
+    if (is_array($people)) {
+        foreach ($people as $person) {
+            $output .= '<option value="'.$person['id'].'">'.$person['name'].((!empty($person['alias'])) ? '('.$person['alias'].')' : '').'</option>';
+        }                             
+    } 
     $output .= '</select>';
     return $output;
 }
@@ -42,13 +46,15 @@ function breakfast_people_dropdown($selected=0) {
     $output = '
     <select name="person">
         <option value="0">-- Person --</option>';
-    foreach ($people as $person) {
-        $s = '';
-        if ($person['id'] == $selected) {
-            $s = 'selected="selected"';
-        }
-        $output .= '<option value="'.$person['id'].'" '.$s.'>'.((!empty($person['alias'])) ? $person['alias'] : $person['name']).'</option>';
-    }                              
+    if (is_array($people)) {
+        foreach ($people as $person) {
+            $s = '';
+            if ($person['id'] == $selected) {
+                $s = 'selected="selected"';
+            }
+            $output .= '<option value="'.$person['id'].'" '.$s.'>'.((!empty($person['alias'])) ? $person['alias'] : $person['name']).'</option>';
+        }            
+    }                  
     $output .= '</select>';
     return $output;
 }
@@ -61,9 +67,11 @@ function breakfast_menu_dropdown($count) {
     $output = '
     <select name="meal'.$count.'">
         <option value="0">-- Meal --</option>';
-    foreach ($menu as $item) {
-        $output .= '<option value="'.$item['id'].'">'.$item['name'].'</option>';
-    }                              
+    if (is_array($menu)) {
+        foreach ($menu as $item) {
+            $output .= '<option value="'.$item['id'].'">'.$item['name'].'</option>';
+        }                           
+    }   
     $output .= '</select>';
     return $output;
 }
@@ -75,12 +83,14 @@ function breakfast_meal_dropdown($selected=0) {
     $output = '
     <select name="meal'.$count.'">
         <option value="0">-- Meal --</option>';
-    foreach ($menu as $item) {
-        $s = '';
-        if ($item['id'] == $selected) {
-            $s = 'selected="selected"';
+    if (is_array($menu)) {
+        foreach ($menu as $item) {
+            $s = '';
+            if ($item['id'] == $selected) {
+                $s = 'selected="selected"';
+            }
+            $output .= '<option value="'.$item['id'].'" '.$s.'>'.$item['name'].'</option>';
         }
-        $output .= '<option value="'.$item['id'].'" '.$s.'>'.$item['name'].'</option>';
     }                              
     $output .= '</select>';
     return $output;
@@ -91,10 +101,12 @@ function breakfast_scoring_dropdowns($count) {
         $categories = serendipity_db_query('SELECT * FROM mbg_category');
     }
     $output = '';
-    foreach ($categories as $i => $c) {
-        $output .= $c['category'].' ('.$c['weight'].') : <input size="2" maxlength="2" type="text" name="score-'.$c['id'].'-'.$count.'" /> ';
-        if ($i == 3) {
-            $output .= '<br />';
+    if (is_array($categories)) {
+        foreach ($categories as $i => $c) {
+            $output .= $c['category'].' ('.$c['weight'].') : <input size="2" maxlength="2" type="text" name="score-'.$c['id'].'-'.$count.'" /> ';
+            if ($i == 3) {
+                $output .= '<br />';
+            }
         }
     }
     return $output;
@@ -104,12 +116,14 @@ function breakfast_date_dropdown($selected=0) {
     $output = '
     <select name="date">
         <option value="0">-- Date --</option>';
-    foreach ($dates as $date) {
-        $s = '';
-        if ($date['date'] == $selected) {
-            $s = 'selected="selected"';
+    if (is_array($dates)) {
+        foreach ($dates as $date) {
+            $s = '';
+            if ($date['date'] == $selected) {
+                $s = 'selected="selected"';
+            }
+            $output .= '<option value="'.$date['date'].'">'.date('j F Y',$date['date']).' ('.$date['name'].')</option>';
         }
-        $output .= '<option value="'.$date['date'].'">'.date('j F Y',$date['date']).' ('.$date['name'].')</option>';
     }
     $output .= '</select>';
     return $output;
index c9f7b645ec322f1ca16869d6b4f4af4bf67f8154..e3d245d8e29971e9a6f4325051b5ff21927490c2 100644 (file)
@@ -51,27 +51,30 @@ class serendipity_plugin_breakfast extends serendipity_plugin
             .' had \''.$attendee['meal'].'\':</b></td>
   </tr>';
         foreach ($attendee['scores'] as $category => $score) {
+            if (empty($score)) {
+                continue;
+            }
             echo '  <tr>
-    <td>'.$category.':</td><td>'.$score['score'].'/'.$score['weight'].'</td>
+    <td>'.$category.':</td><td align="right">'.$score['score'].'/'.$score['weight'].'</td>
   </tr>';
         }
         echo '  <tr>
-    <td>Total</td><td>'.$attendee['totals']['scores'].'%</td>
+    <td>Total</td><td align="right">'.$attendee['totals']['scores'].'%</td>
   </tr>
   <tr>
     <td colspan="2"><b>The group gave:</td>
   </tr>
   <tr>
-    <td>Min:</td><td>'.$latest['totals']['min'].'%</td>
+    <td>Min:</td><td align="right">'.$latest['totals']['min'].'%</td>
   </tr>
   <tr>
-    <td>Max:</td><td>'.$latest['totals']['max'].'%</td>
+    <td>Max:</td><td align="right">'.$latest['totals']['max'].'%</td>
   </tr>
   <tr>
-    <td>Avergage:</td><td>'.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</td>
+    <td>Avergage:</td><td align="right">'.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</td>
   </tr>
   <tr>
-      <td nowrap="nowrap" colspan="2"><a href="/breakfast/">What the hell is this?</a></td>
+      <td nowrap="nowrap" colspan="2"><br /><br /><a href="/breakfast/">What the hell is this?</a></td>
   </tr>
 </table>';
         return;
@@ -162,3 +165,8 @@ class serendipity_plugin_breakfast extends serendipity_plugin
 }
 
 /* vim: set sts=4 ts=4 expandtab : */
+/** 
+TODO! 
+finish query builder page
+make sure there is no collision of saving same name of new breakfasts in admin page
+**/