Revision: 1459
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1459&view=rev
Author:   cimorrison
Date:     2010-09-20 09:43:45 +0000 (Mon, 20 Sep 2010)

Log Message:
-----------
Merged in latest changes from the trunk

Modified Paths:
--------------
    mrbs/branches/provisional_bookings_new_style/INSTALL
    mrbs/branches/provisional_bookings_new_style/web/config.inc.php
    mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
    mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php

Property Changed:
----------------
    mrbs/branches/provisional_bookings_new_style/
    mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql


Property changes on: mrbs/branches/provisional_bookings_new_style
___________________________________________________________________
Modified: svn:mergeinfo
   - /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/trunk:1407-1448
   + /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/trunk:1407-1458

Modified: mrbs/branches/provisional_bookings_new_style/INSTALL
===================================================================
--- mrbs/branches/provisional_bookings_new_style/INSTALL        2010-09-20 
09:07:04 UTC (rev 1458)
+++ mrbs/branches/provisional_bookings_new_style/INSTALL        2010-09-20 
09:43:45 UTC (rev 1459)
@@ -211,7 +211,7 @@
 1.  Timezone
 
 You must set the timezone to a valid value, a list of which can be found at
-http://php.net/manual/en/timezones.php.   Don't forget to uncomment the line
+http://php.net/manual/timezones.php.   Don't forget to uncomment the line
 by removing the '//' at the beginning.   Note that the timezone to use is the
 timezone in which your meeting rooms are located, not the timezone of your
 server in case they are different.

Modified: mrbs/branches/provisional_bookings_new_style/web/config.inc.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/config.inc.php     
2010-09-20 09:07:04 UTC (rev 1458)
+++ mrbs/branches/provisional_bookings_new_style/web/config.inc.php     
2010-09-20 09:43:45 UTC (rev 1459)
@@ -19,7 +19,7 @@
 // When upgrading an existing installation, this should be set to the
 // timezone the web server runs in.
 //
-// A list of valid timezones can be found at 
http://php.net/manual/en/timezones.php
+// A list of valid timezones can be found at 
http://php.net/manual/timezones.php
 // The following line must be uncommented by removing the '//' at the beginning
 //$timezone = "Europe/London";
 

Modified: mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_entry.php     
2010-09-20 09:07:04 UTC (rev 1458)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_entry.php     
2010-09-20 09:43:45 UTC (rev 1459)
@@ -51,6 +51,49 @@
 require_once "defaultincludes.inc";
 require_once "mrbs_sql.inc";
 
+// Generate an input field with an associated label
+// Optional fourth parameter: $maxlength - the maximum length of input allowed
+function generate_input($label_text, $name, $value)
+{
+  // get any optional fourth parameter
+  if (func_num_args() > 3)
+  {
+    $maxlength = func_get_arg(3);
+  }
+  // generate the HTML
+  $html  = "<label for=\"$name\">$label_text</label>\n";
+  $html .= "<input id=\"$name\" name=\"$name\"";
+  $html .= (isset($maxlength)) ? " maxlength=\"$maxlength\"" : '';
+  $html .= " value=\"" . htmlspecialchars($value) . "\">\n";
+  echo $html;
+}
+
+// Generates a select box from $options, an array of options
+function generate_select($label_text, $name, $value, $options)
+{
+  // generate the HTML
+  $html  = "<label for=\"$name\">$label_text</label>\n";
+  $html .= "<select id=\"$name\" name=\"$name\">\n";
+  foreach ($options as $option)
+  {
+    $html .= "<option";
+    $html .= (isset($value) && ($value == $option)) ? " selected=\"selected\"" 
: '';
+    $html .= ">$option</option>\n";
+  }
+  $html .= "</select>\n";
+  echo $html;
+}
+
+// Generate a textarea with an associated label
+function generate_textarea($label_text, $name, $value)
+{
+  $html  = "<label for=\"$name\">$label_text</label>\n";
+  // textarea rows and cols are overridden by CSS height and width
+  $html .= "<textarea id=\"$name\" name=\"$name\" rows=\"8\" cols=\"40\">" . 
htmlspecialchars ($value) . "</textarea>\n";
+  echo $html;
+}
+    
+
 global $twentyfourhour_format;
 
 // Get non-standard form variables
@@ -366,11 +409,20 @@
 // do a little form verifying
 function validate(form)
 {
-  // null strings and spaces only strings not allowed
-  if(/(^$)|(^\s+$)/.test(form.name.value))
+  <?php
+  // First of all check that a name (brief description) has been entered.
+  // Only do this if the name is being entered via an INPUT box.   If it's
+  // being entered via a SELECT box there's no need to do this because there's
+  // bound to be a value and the test below will fail on some browsers (eg IE)
+  ?>
+  if (form.name.tagName.toLowerCase() == 'input')
   {
-    alert ( "<?php echo get_vocab("you_have_not_entered") . '\n' . 
get_vocab("brief_description") ?>");
-    return false;
+    // null strings and spaces only strings not allowed
+    if(/(^$)|(^\s+$)/.test(form.name.value))
+    {
+      alert ( "<?php echo get_vocab("you_have_not_entered") . '\n' . 
get_vocab("brief_description") ?>");
+      return false;
+    }
   }
   <?php if( ! $enable_periods ) { ?>
 
@@ -542,19 +594,32 @@
   <fieldset>
   <legend><?php echo get_vocab($token); ?></legend>
 
-    <div id="div_name">
-      <label for="name"><?php echo get_vocab("namebooker")?>:</label>
-      <?php
-      echo "<input id=\"name\" name=\"name\" maxlength=\"" . 
$maxlength['entry.name'] . "\" value=\"" . htmlspecialchars($name) . "\">\n";
-      ?>
-    </div>
+    <?php  
+    echo "<div id=\"div_name\">\n";
+    $label_text = get_vocab("namebooker") . ":";
+    if (count($select_options['entry.name']) > 0)
+    {
+      generate_select($label_text, 'name', $name, 
$select_options['entry.name']);  
+    }
+    else
+    {
+      generate_input($label_text, 'name', $name, $maxlength['entry.name']);
+    }
+    echo "</div>\n";
+    
+    echo "<div id=\"div_description\">\n";
+    $label_text = get_vocab("fulldescription");
+    if (count($select_options['entry.description']) > 0)
+    {
+      generate_select($label_text, 'description', $description, 
$select_options['entry.description']);
+    }
+    else
+    {
+      generate_textarea($label_text, 'description', $description);
+    }
+    echo "</div>\n";
+    ?>
 
-    <div id="div_description">
-      <label for="description"><?php echo 
get_vocab("fulldescription")?></label>
-      <!-- textarea rows and cols are overridden by CSS height and width -->
-      <textarea id="description" name="description" rows="8" cols="40"><?php 
echo htmlspecialchars ( $description ); ?></textarea>
-    </div>
-
     <div id="div_date">
       <?php
       echo "<label for=\"start_datepicker\">" . get_vocab("date") . 
":</label>\n";
@@ -870,35 +935,34 @@
       if (!in_array($key, $standard_fields['entry']))
       {
         $value = $custom_fields[$key];
+        $label_text = get_loc_field_name($tbl_entry, $key) . ":";
         echo "<div>\n";
-        echo "<label for=\"f_$key\">" . get_loc_field_name($tbl_entry, $key) . 
":</label>\n";
         // Output a checkbox if it's a boolean or integer <= 2 bytes (which we 
will
         // assume are intended to be booleans)
         if (($field['nature'] == 'boolean') || 
             (($field['nature'] == 'integer') && isset($field['length']) && 
($field['length'] <= 2)) )
         {
+          echo "<label for=\"f_$key\">$label_text</label>\n";
           echo "<input type=\"checkbox\" class=\"checkbox\" " .
                 "id=\"f_$key\" name=\"f_$key\" value=\"1\" " .
                 ((!empty($value)) ? " checked=\"checked\"" : "") .
                 ">\n";
         }
+        // Output a select box if they want one
+        elseif (count($select_options["entry.$key"]) > 0)
+        {
+          generate_select($label_text, "f_$key", $value, 
$select_options["entry.$key"]);
+        }
         // Output a textarea if it's a character string longer than the limit 
for a
         // text input
         elseif (($field['nature'] == 'character') && isset($field['length']) 
&& ($field['length'] > $text_input_max))
         {
-          echo "<textarea rows=\"8\" cols=\"40\" " .
-                "id=\"f_$key\" name=\"f_$key\" " .
-                ">\n";
-          echo htmlspecialchars($value);
-          echo "</textarea>\n";
+          generate_textarea($label_text, "f_$key", $value);   
         }
         // Otherwise output a text input
         else
         {
-          echo "<input type=\"text\" " .
-                "id=\"f_$key\" name=\"f_$key\" " .
-                "value=\"" . htmlspecialchars($value) . "\"" .
-                ">\n";
+          generate_input($label_text, "f_$key", $value);
         }
         echo "</div>\n";
       }
@@ -956,11 +1020,13 @@
           ?>
         </div>
       </div>
-      <div>
-        <label for="rep_num_weeks"><?php echo 
get_vocab("rep_num_weeks")?>:<br><?php echo 
get_vocab("rep_for_nweekly")?></label>
-        <input type="text" id="rep_num_weeks" name="rep_num_weeks" 
value="<?php echo $rep_num_weeks?>">
-      </div>
+     
       <?php
+      echo "<div>\n";
+      $label_text = get_vocab("rep_num_weeks") . ":<br>" . 
get_vocab("rep_for_nweekly");
+      generate_input($label_text, 'rep_num_weeks', $rep_num_weeks);
+      echo "</div>\n";
+
       echo "</fieldset>\n";
     }
     elseif (isset($id))

Modified: 
mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php     
2010-09-20 09:07:04 UTC (rev 1458)
+++ mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php     
2010-09-20 09:43:45 UTC (rev 1459)
@@ -476,6 +476,26 @@
 $confirmed_default = TRUE;
 
 /***********************************************
+ * Form values
+ ***********************************************/
+
+// It is possible to constrain some form values to be selected from a drop-
+// down select box, rather than allowing free form input.   This is done by
+// putting the permitted options in an array as part of the $select_options
+// two dimensional array.   The first index specifies the form field in the
+// format tablename.columnname.    For example to restrict the name of a 
booking
+// to 'Physics', 'Chemistry' or 'Biology' uncomment the line below.
+
+//$select_options['entry.name'] = array('Physics', 'Chemistry', 'Biology');
+
+// At the moment this feature is only supported for the name, description and
+// any custom fields in the entry table.   However the indexing format of
+// tablename.columnname has been chosen to allow it to be extended to other
+// tables in the future.
+
+
+ 
+/***********************************************
  * Authentication settings - read AUTHENTICATION
  ***********************************************/
 


Property changes on: 
mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql
___________________________________________________________________
Modified: svn:mergeinfo
   - /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/trunk/web/upgrade/5/pgsql.sql:1407-1448
   + /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/trunk/web/upgrade/5/pgsql.sql:1407-1458


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

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to