Revision: 2287
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2287&view=rev
Author:   jberanek
Date:     2012-04-10 09:58:31 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
* Added a UTF-8 to UTF-16 (little-endian) conversion routine into
 language.inc, so you don't need iconv just to get UTF-16 CSV output.
 Made outputting a BOM the default, as it should never hurt, and
 some applications (Excel 2007 on Windows at least) don't understand
 UTF-16LE without a BOM.

* Made trailer.inc more modular, you now call the function
 output_trailer() if you want to finish an MRBS page, instead of
 including trailer.inc. If you want the trailer somewhere else, the
 function generate_trailer() returns the trailer as a string.

Modified Paths:
--------------
    mrbs/trunk/web/admin.php
    mrbs/trunk/web/day.php
    mrbs/trunk/web/defaultincludes.inc
    mrbs/trunk/web/del.php
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/edit_entry_handler.php
    mrbs/trunk/web/edit_users.php
    mrbs/trunk/web/functions.inc
    mrbs/trunk/web/help.php
    mrbs/trunk/web/import.php
    mrbs/trunk/web/language.inc
    mrbs/trunk/web/month.php
    mrbs/trunk/web/pending.php
    mrbs/trunk/web/report.php
    mrbs/trunk/web/search.php
    mrbs/trunk/web/systemdefaults.inc.php
    mrbs/trunk/web/trailer.inc
    mrbs/trunk/web/view_entry.php
    mrbs/trunk/web/week.php

Modified: mrbs/trunk/web/admin.php
===================================================================
--- mrbs/trunk/web/admin.php    2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/admin.php    2012-04-10 09:58:31 UTC (rev 2287)
@@ -427,6 +427,5 @@
   echo "</div>\n";
 }
 
-
-require_once "trailer.inc"
+output_trailer();
 ?>
\ No newline at end of file

Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php      2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/day.php      2012-04-10 09:58:31 UTC (rev 2287)
@@ -127,5 +127,6 @@
   }
 }
 
-require_once "trailer.inc";
+output_trailer();
+
 ?>

Modified: mrbs/trunk/web/defaultincludes.inc
===================================================================
--- mrbs/trunk/web/defaultincludes.inc  2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/defaultincludes.inc  2012-04-10 09:58:31 UTC (rev 2287)
@@ -13,5 +13,6 @@
 require_once "dbsys.inc";
 require_once "mrbs_auth.inc";
 require_once "standard_vars.inc.php";
+require_once "trailer.inc";
 
 ?>
\ No newline at end of file

Modified: mrbs/trunk/web/del.php
===================================================================
--- mrbs/trunk/web/del.php      2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/del.php      2012-04-10 09:58:31 UTC (rev 2287)
@@ -71,7 +71,7 @@
     echo "<a href=\"admin.php\"><span id=\"del_no\">" . get_vocab("NO") . 
"!</span></a>\n";
     echo "</div>\n";
     echo "</div>\n";
-    require_once "trailer.inc";
+    output_trailer();
   }
 }
 
@@ -96,7 +96,7 @@
     echo get_vocab("delarea");
     echo "<a href=\"admin.php\">" . get_vocab("backadmin") . "</a>";
     echo "</p>\n";
-    require_once "trailer.inc";
+    output_trailer();
   }
 }
 

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/edit_area_room.php   2012-04-10 09:58:31 UTC (rev 2287)
@@ -1246,4 +1246,5 @@
   <?php
 }
 
-require_once "trailer.inc" ?>
+output_trailer();
+?>

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/edit_entry.php       2012-04-10 09:58:31 UTC (rev 2287)
@@ -1558,6 +1558,4 @@
   </fieldset>
 </form>
 
-
-
-<?php require_once "trailer.inc" ?>
+<?php output_trailer() ?>

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2012-04-09 14:52:58 UTC (rev 
2286)
+++ mrbs/trunk/web/edit_entry_handler.php       2012-04-10 09:58:31 UTC (rev 
2287)
@@ -685,5 +685,5 @@
 
 echo "</div>\n";
 
-require_once "trailer.inc";
+output_trailer();
 ?>

Modified: mrbs/trunk/web/edit_users.php
===================================================================
--- mrbs/trunk/web/edit_users.php       2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/edit_users.php       2012-04-10 09:58:31 UTC (rev 2287)
@@ -879,6 +879,6 @@
   
 }   // ($initial_user_creation != 1)
 
-require_once "trailer.inc";
+output_trailer();
 
 ?>

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/functions.inc        2012-04-10 09:58:31 UTC (rev 2287)
@@ -638,7 +638,7 @@
     error_log("MRBS SESSION: ".print_r($_SESSION, true));
   }
   echo "<p>$message</p>";
-  require_once "trailer.inc";
+  output_trailer();
   exit;
 }
 

Modified: mrbs/trunk/web/help.php
===================================================================
--- mrbs/trunk/web/help.php     2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/help.php     2012-04-10 09:58:31 UTC (rev 2287)
@@ -36,5 +36,5 @@
  
 require_once "site_faq" . $faqfilelang . ".html";
 
-require_once "trailer.inc";
+output_trailer();
 ?>

Modified: mrbs/trunk/web/import.php
===================================================================
--- mrbs/trunk/web/import.php   2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/import.php   2012-04-10 09:58:31 UTC (rev 2287)
@@ -543,5 +543,5 @@
 
 echo "</form>\n";
   
-require_once "trailer.inc";
+output_trailer();
 ?>
\ No newline at end of file

Modified: mrbs/trunk/web/language.inc
===================================================================
--- mrbs/trunk/web/language.inc 2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/language.inc 2012-04-10 09:58:31 UTC (rev 2287)
@@ -752,7 +752,8 @@
       return "\xEF\xBB\xBF";
       break;
     case 'utf-16':
-      return "\xFE\xFF";
+      // Little-endian
+      return "\xFF\xFE";
       break;
     default:
       return '';
@@ -1146,7 +1147,71 @@
   return $ret;
 }
 
-  
+
+// Takes a UTF-8 string and converts it to UTF-16 without using iconv
+function utf8_to_utf16($string)
+{
+  $ucs2 = array();
+  $byte_index = 0;
+      
+  while (!is_null($byte_index))
+  {
+    $next = utf8_seq($string, $byte_index);
+
+    $c0 = ord($next[0]);
+
+    // Easy case, code is 0xxxxxxx - just use it as is
+    if ($c0 < 0x80)
+    {
+      array_push($ucs2, $c0);
+      continue;
+    }
+    $cn = ord($next[1]) ^ 0x80;
+    $ucs = ($c0 << 6) | $cn;
+
+    // Two byte codes: 110xxxxx 10xxxxxx
+    if ($c0 < 0xE0)
+    {
+      $ucs &= ~0x3000;
+      array_push($ucs2, $ucs);
+      continue;
+    }
+
+    $cn = ord($next[2]) ^ 0x80;
+    $ucs = ($ucs << 6) | $cn;
+
+    // Three byte codes: 1110xxxx 10xxxxxx 10xxxxxx
+    if ($c0 < 0xF0)
+    {
+      $ucs &= ~0xE0000;
+      array_push($ucs2, $ucs);
+      continue;
+    }
+        
+    $cn = ord($next[3]) ^ 0x80;
+    $ucs = ($ucs << 6) | $cn;
+    
+    // Four byte codes: 11110xxx 10xxxxxxx 10xxxxxx 10xxxxxx
+    if ($c0 < 0xF8)
+    {
+      $ucs &= ~0x3C00000;
+      array_push($ucs2, $ucs);
+      continue;
+    }
+    die("Shouldn't get here!");
+  }
+
+  $out = "";
+  foreach ($ucs2 as $char)
+  {
+    $ucs_string = pack("v", $char);
+    //error_log(sprintf("UCS %04x -> 
%02x,%02x",$char,ord($ucs_string[0]),ord($ucs_string[1])));
+    $out .= $ucs_string;
+  }
+  return $out;
+}
+
+
 // Takes a UTF-8 string, and returns the number of _characters_ in the
 // string
 function utf8_strlen($str)

Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php    2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/month.php    2012-04-10 09:58:31 UTC (rev 2287)
@@ -108,7 +108,7 @@
 if ($room_invalid)
 {
   echo "<h1>".get_vocab("no_rooms_for_area")."</h1>";
-  require_once "trailer.inc";
+  output_trailer();
   exit;
 }
 
@@ -539,5 +539,5 @@
   minicals($year, $month, $day, $area, $room, 'month');
 }
 
-require_once "trailer.inc";
+output_trailer();
 ?>

Modified: mrbs/trunk/web/pending.php
===================================================================
--- mrbs/trunk/web/pending.php  2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/pending.php  2012-04-10 09:58:31 UTC (rev 2287)
@@ -289,5 +289,5 @@
   echo "</div>\n";
 }
 
-require_once "trailer.inc";
+output_trailer();
 ?>

Modified: mrbs/trunk/web/report.php
===================================================================
--- mrbs/trunk/web/report.php   2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/report.php   2012-04-10 09:58:31 UTC (rev 2287)
@@ -50,7 +50,15 @@
   }
   else
   {
-    return iconv($in_charset, $out_charset, $string);
+    if (($in_charset == 'UTF-8') &&
+        ($out_charset == 'UTF-16'))
+    {
+      return utf8_to_utf16($string);
+    }
+    else
+    {
+      return iconv($in_charset, $out_charset, $string);
+    }
   }
 }
 
@@ -1441,6 +1449,6 @@
 
 if (($output_as_html || empty($nmatch)) & !$ajax)
 {
-  require_once "trailer.inc";
+  output_trailer();
 }
 ?>

Modified: mrbs/trunk/web/search.php
===================================================================
--- mrbs/trunk/web/search.php   2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/search.php   2012-04-10 09:58:31 UTC (rev 2287)
@@ -170,14 +170,14 @@
       </fieldset>
     </form>
     <?php
-    require_once "trailer.inc";
+    output_trailer();
     exit;
   }
 
   if (!isset($search_str) || ($search_str == ''))
   {
     echo "<p class=\"error\">" . get_vocab("invalid_search") . "</p>";
-    require_once "trailer.inc";
+    output_trailer();
     exit;
   }
 
@@ -274,7 +274,7 @@
 if (($total <= 0) && !$ajax)
 {
   echo "<p id=\"nothing_found\">" . get_vocab("nothing_found") . "</p>\n";
-  require_once "trailer.inc";
+  output_trailer();
   exit;
 }
 
@@ -356,6 +356,6 @@
   echo "</tbody>\n";
   echo "</table>\n";
   echo "</div>\n";
-  require_once "trailer.inc";
+  output_trailer();
 }
 ?>

Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php       2012-04-09 14:52:58 UTC (rev 
2286)
+++ mrbs/trunk/web/systemdefaults.inc.php       2012-04-10 09:58:31 UTC (rev 
2287)
@@ -321,7 +321,7 @@
 // of 12.
 $monthly_view_entries_details = "both";
 
-// To view weeks in the bottom (trailer.inc) as week numbers (42) instead of
+// To view weeks in the bottom trailer as week numbers (42) instead of
 // 'first day of the week' (13 Oct), set this to TRUE.  Will also give week
 // numbers in the month view
 $view_week_number = FALSE;
@@ -963,13 +963,12 @@
 // then CSV files are written using the MRBS default charset (utf-8).  However
 // Microsoft Excel (at least up to Excel 2010 on Windows and 2011 on Mac) is 
not
 // guaranteed to recognise utf-8, but does recognise utf-16, so the default 
setting
-// for $csv_charset is 'utf-16'.   This does however require that you have the 
iconv
-// module installed and enabled on your PHP system.   If this is not possible, 
setting
-// $csv_charset to 'utf-8' and $csv_bom to TRUE (ie requiring MRBS to output a 
Byte
-// Order Mark) will make Excel 2010 on Windows, and maybe earlier versions, 
work. 
+// for $csv_charset is 'utf-16'. Setting $csv_charset to 'utf-8' and $csv_bom
+// to TRUE (ie requiring MRBS to output a Byte Order Mark) will make Excel
+// 2010 on Windows, and maybe earlier versions, work. 
 // But utf-8 with, or without, a BOM will not work on Excel 2011 for Mac.
 $csv_charset = 'utf-16';
-$csv_bom = FALSE;
+$csv_bom = TRUE;
 
 
 /*************

Modified: mrbs/trunk/web/trailer.inc
===================================================================
--- mrbs/trunk/web/trailer.inc  2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/trailer.inc  2012-04-10 09:58:31 UTC (rev 2287)
@@ -2,205 +2,220 @@
 
 // $Id$
 
-
-if(!isset($year))
+function generate_trailer()
 {
-  $year = strftime("%Y");
-}
+  global $year, $month, $day, $area, $room, $simple_trailer;
+  global $strftime_format;
 
-if (!isset($month))
-{
-  $month = strftime("%m");
-}
+  $output = "";
 
-if (!isset($day))
-{
-  $day = strftime("%d");
-}
+  if(!isset($year))
+  {
+    $year = strftime("%Y");
+  }
 
-if (empty($area))
-{
-  $params = "";
-}
-else
-{
-  $params = "&amp;area=$area";
-}
+  if (!isset($month))
+  {
+    $month = strftime("%m");
+  }
+
+  if (!isset($day))
+  {
+    $day = strftime("%d");
+  }
+
+  if (empty($area))
+  {
+    $params = "";
+  }
+  else
+  {
+    $params = "&amp;area=$area";
+  }
   if (!empty($room))
-{
-  $params .= "&amp;room=$room";
-}
+  {
+    $params .= "&amp;room=$room";
+  }
 
-echo "</div>";  // Close of the contents div
+  $output .= "</div>";  // Close of the contents div
 
-if ($simple_trailer) {
-  echo "<div class=\"screenonly trailer\" id=\"simple_trailer\">\n";
-  echo "<div id=\"simple\">\n";
-  echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day$params\">";
-  echo get_vocab("viewday")."</a>|";
-  echo "<a href=\"week.php?year=$year&amp;month=$month&amp;day=$day$params\">";
-  echo get_vocab("viewweek")."</a>|";
-  echo "<a 
href=\"month.php?year=$year&amp;month=$month&amp;day=$day$params\">";
-  echo get_vocab("viewmonth")."</a>\n";
-  echo "</div>\n";
-  echo "</div>\n";
-}
-
-else
-{
-  echo "<div class=\"screenonly trailer\" id=\"trailer\">\n";
+  if ($simple_trailer)
+  {
+    $output .= "<div class=\"screenonly trailer\" id=\"simple_trailer\">\n";
+    $output .= "<div id=\"simple\">\n";
+    $output .= "<a 
href=\"day.php?year=$year&amp;month=$month&amp;day=$day$params\">";
+    $output .= get_vocab("viewday")."</a>|";
+    $output .= "<a 
href=\"week.php?year=$year&amp;month=$month&amp;day=$day$params\">";
+    $output .= get_vocab("viewweek")."</a>|";
+    $output .= "<a 
href=\"month.php?year=$year&amp;month=$month&amp;day=$day$params\">";
+    $output .= get_vocab("viewmonth")."</a>\n";
+    $output .= "</div>\n";
+    $output .= "</div>\n";
+  }
+  else
+  {
+    $output .= "<div class=\"screenonly trailer\" id=\"trailer\">\n";
   
-  // DAYS
-  echo "<div id=\"viewday\">\n";
-  echo "<div class=\"trailer_label\">\n";
-  echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day$params\">" 
. get_vocab("viewday") .":</a>\n";
-  echo "</div>\n";
+    // DAYS
+    $output .= "<div id=\"viewday\">\n";
+    $output .= "<div class=\"trailer_label\">\n";
+    $output .= "<a 
href=\"day.php?year=$year&amp;month=$month&amp;day=$day$params\">" . 
get_vocab("viewday") .":</a>\n";
+    $output .= "</div>\n";
   
-  echo "<div class=\"trailer_links\">\n";
-  for ($i = -6; $i <= 7; $i++)
-  {
-    $ctime = mktime(0, 0, 0, $month, $day + $i, $year);
+    $output .= "<div class=\"trailer_links\">\n";
+    for ($i = -6; $i <= 7; $i++)
+    {
+      $ctime = mktime(0, 0, 0, $month, $day + $i, $year);
   
-    $str = utf8_strftime($strftime_format['daymonth'], $ctime);
-    $class = "";
+      $str = utf8_strftime($strftime_format['daymonth'], $ctime);
+      $class = "";
   
-    $cyear  = date("Y", $ctime);
-    $cmonth = date("m", $ctime);
-    $cday   = date("d", $ctime);
+      $cyear  = date("Y", $ctime);
+      $cmonth = date("m", $ctime);
+      $cday   = date("d", $ctime);
     
-    // put in a separator, unless we are at the beginning
-    if ($i != -6)
-    {
-      echo " | ";
-    }
-    
-    // if it's a hidden day set the class; otherwise construct the anchor
-    // (don't offer a link if the day is a hidden day)
-    if (is_hidden_day(date("w", $ctime)))
-    { 
-      $class .= "hidden";      
-    }
-    else
-    {
-      $str = "<a 
href=\"day.php?year=$cyear&amp;month=$cmonth&amp;day=$cday$params\">" . $str . 
"</a>";
-    }
-    
-    // and if it's the current day, add square brackets and set the class
-    if ($i == 0)
-    {
-      $str = "[ " . $str . " ]";
-      if (empty($class))
+      // put in a separator, unless we are at the beginning
+      if ($i != -6)
       {
-        $class = "current";
+        $output .= " | ";
       }
+    
+      // if it's a hidden day set the class; otherwise construct the anchor
+      // (don't offer a link if the day is a hidden day)
+      if (is_hidden_day(date("w", $ctime)))
+      { 
+        $class .= "hidden";      
+      }
       else
       {
-        $class .= " current";
+        $str = "<a 
href=\"day.php?year=$cyear&amp;month=$cmonth&amp;day=$cday$params\">" . $str . 
"</a>";
       }
-    } 
-    echo "<span" . ((empty($class)) ? '' : " class=\"$class\"") . 
">$str</span>\n";
-  }
-  echo "</div>\n";
+    
+      // and if it's the current day, add square brackets and set the class
+      if ($i == 0)
+      {
+        $str = "[ " . $str . " ]";
+        if (empty($class))
+        {
+          $class = "current";
+        }
+        else
+        {
+          $class .= " current";
+        }
+      } 
+      $output .= "<span" . ((empty($class)) ? '' : " class=\"$class\"") . 
">$str</span>\n";
+    }
+    $output .= "</div>\n";
   
-  echo "</div>\n";
+    $output .= "</div>\n";
   
   
-  // WEEKS
-  echo "<div id=\"viewweek\">\n";
-  echo "<div class=\"trailer_label\">\n";
-  echo "<a 
href=\"week.php?year=$year&amp;month=$month&amp;day=$day$params\">".get_vocab("viewweek").":</a>\n";
-  echo "</div>\n";
+    // WEEKS
+    $output .= "<div id=\"viewweek\">\n";
+    $output .= "<div class=\"trailer_label\">\n";
+    $output .= "<a 
href=\"week.php?year=$year&amp;month=$month&amp;day=$day$params\">".get_vocab("viewweek").":</a>\n";
+    $output .= "</div>\n";
  
-  $ctime = mktime(0, 0, 0, $month, $day, $year);
-  // How many days to skip back to first day of week:
-  $skipback = (date("w", $ctime) - $weekstarts + 7) % 7;
+    $ctime = mktime(0, 0, 0, $month, $day, $year);
+    // How many days to skip back to first day of week:
+    $skipback = (date("w", $ctime) - $weekstarts + 7) % 7;
   
-  echo "<div class=\"trailer_links\">\n";
-  for ($i = -4; $i <= 4; $i++)
-  {
-    $ctime = mktime(0, 0, 0, $month, $day + 7 * $i - $skipback, $year);
+    $output .= "<div class=\"trailer_links\">\n";
+    for ($i = -4; $i <= 4; $i++)
+    {
+      $ctime = mktime(0, 0, 0, $month, $day + 7 * $i - $skipback, $year);
   
-    $cweek  = date("W", $ctime);
-    $cday   = date("d", $ctime);
-    $cmonth = date("m", $ctime);
-    $cyear  = date("Y", $ctime);
+      $cweek  = date("W", $ctime);
+      $cday   = date("d", $ctime);
+      $cmonth = date("m", $ctime);
+      $cyear  = date("Y", $ctime);
     
-    // $htime gives you the d/m/y to use in the href link.    This is the
-    // real day that we want to look at, whereas $ctime is the start of that 
week
-    $htime = mktime(0, 0, 0, $month, $day + 7 * $i, $year);
-    $hday   = date("d", $htime);
-    $hmonth = date("m", $htime);
-    $hyear  = date("Y", $htime);
+      // $htime gives you the d/m/y to use in the href link.    This is the
+      // real day that we want to look at, whereas $ctime is the start of that 
week
+      $htime = mktime(0, 0, 0, $month, $day + 7 * $i, $year);
+      $hday   = date("d", $htime);
+      $hmonth = date("m", $htime);
+      $hyear  = date("Y", $htime);
     
-    if ($i != -4)
-    {
-      echo " | ";
-    }
+      if ($i != -4)
+      {
+        $output .= " | ";
+      }
   
-    if ($view_week_number)
-    {
-      $str = $cweek;
+      if ($view_week_number)
+      {
+        $str = $cweek;
+      }
+      else
+      {
+        $str = utf8_strftime($strftime_format['daymonth'], $ctime);
+      }
+      if ($i == 0)
+      {
+        $output .= "<span class=\"current\">\n[ ";
+      }
+      $output .= "  <a 
href=\"week.php?year=$hyear&amp;month=$hmonth&amp;day=$hday$params\">$str</a>\n";
+      if ($i == 0)
+      {
+        $output .= "]</span>\n";
+      }
     }
-    else
-    {
-      $str = utf8_strftime($strftime_format['daymonth'], $ctime);
-    }
-    if ($i == 0)
-    {
-      echo "<span class=\"current\">\n[ ";
-    }
-    echo "  <a 
href=\"week.php?year=$hyear&amp;month=$hmonth&amp;day=$hday$params\">$str</a>\n";
-    if ($i == 0)
-    {
-      echo "]</span>\n";
-    }
-  }
-  echo "</div>\n";
+    $output .= "</div>\n";
   
-  echo "</div>\n";
+    $output .= "</div>\n";
   
   
-  // MONTHS
-  echo "<div id=\"viewmonth\">\n";
-  echo "<div class=\"trailer_label\">\n";
-  echo "<a 
href=\"month.php?year=$year&amp;month=$month&amp;day=$day$params\">".get_vocab("viewmonth").":</a>\n";
-  echo "</div>\n";
+    // MONTHS
+    $output .= "<div id=\"viewmonth\">\n";
+    $output .= "<div class=\"trailer_label\">\n";
+    $output .= "<a 
href=\"month.php?year=$year&amp;month=$month&amp;day=$day$params\">".get_vocab("viewmonth").":</a>\n";
+    $output .= "</div>\n";
   
-  echo "<div class=\"trailer_links\">\n";
-  for ($i = -2; $i <= 6; $i++)
-  {
-    $ctime = mktime(0, 0, 0, $month + $i, 1, $year);
-    $str = utf8_strftime($strftime_format['monyear'], $ctime);
+    $output .= "<div class=\"trailer_links\">\n";
+    for ($i = -2; $i <= 6; $i++)
+    {
+      $ctime = mktime(0, 0, 0, $month + $i, 1, $year);
+      $str = utf8_strftime($strftime_format['monyear'], $ctime);
      
-    $cmonth = date("m", $ctime);
-    $cyear  = date("Y", $ctime);
-    $cday   = $day;
-    // decrement day until it's a valid one for the month, in case you're 
moving to a month with fewer
-    // days than the current one
-    while (!checkdate($cmonth, $cday, $cyear) && ($cday > 1))
-    {
-      $cday--;
+      $cmonth = date("m", $ctime);
+      $cyear  = date("Y", $ctime);
+      $cday   = $day;
+      // decrement day until it's a valid one for the month, in case you're 
moving to a month with fewer
+      // days than the current one
+      while (!checkdate($cmonth, $cday, $cyear) && ($cday > 1))
+      {
+        $cday--;
+      }
+      if ($i != -2)
+      {
+        $output .= " | ";
+      }
+      if ($i == 0)
+      {
+        $output .= "<span class=\"current\">\n[ ";
+      }
+      $output .= "  <a 
href=\"month.php?year=$cyear&amp;month=$cmonth&amp;day=$cday$params\">$str</a>\n";
+      if ($i == 0)
+      {
+        $output .= "]</span>\n";
+      }
     }
-    if ($i != -2)
-    {
-      echo " | ";
-    }
-    if ($i == 0)
-    {
-      echo "<span class=\"current\">\n[ ";
-    }
-    echo "  <a 
href=\"month.php?year=$cyear&amp;month=$cmonth&amp;day=$cday$params\">$str</a>\n";
-    if ($i == 0)
-    {
-      echo "]</span>\n";
-    }
+    $output .= "</div>\n";  // end of links div
+    $output .= "</div>\n";  // end of viewmonth
+    $output .= "</div>\n";  // end of "classic" trailer
   }
-  echo "</div>\n";  // end of links div
-  echo "</div>\n";  // end of viewmonth
-  echo "</div>\n";  // end of "classic" trailer
+  return $output;
 }
 
-// Print footer
-print_footer(FALSE);
 
+// Output the trailer for the bottom of the page, including the footer
+function output_trailer()
+{
+  echo generate_trailer();
+
+  // Print footer
+  print_footer(FALSE);
+}
+
 ?>

Modified: mrbs/trunk/web/view_entry.php
===================================================================
--- mrbs/trunk/web/view_entry.php       2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/view_entry.php       2012-04-10 09:58:31 UTC (rev 2287)
@@ -479,5 +479,5 @@
 </div>
 
 <?php
-require_once "trailer.inc";
+output_trailer();
 ?>

Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php     2012-04-09 14:52:58 UTC (rev 2286)
+++ mrbs/trunk/web/week.php     2012-04-10 09:58:31 UTC (rev 2287)
@@ -47,7 +47,7 @@
 if ($room_invalid)
 {
   echo "<h1>".get_vocab("no_rooms_for_area")."</h1>";
-  require_once "trailer.inc";
+  output_trailer();
   exit;
 }
 
@@ -107,5 +107,5 @@
   minicals($year, $month, $day, $area, $room, 'week');
 }
 
-require_once "trailer.inc"; 
+output_trailer(); 
 ?>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to