Revision: 1481
http://mrbs.svn.sourceforge.net/mrbs/?rev=1481&view=rev
Author: cimorrison
Date: 2010-09-30 12:11:55 +0000 (Thu, 30 Sep 2010)
Log Message:
-----------
Simplified code by getting rid of magic prefix for custom fields and replacing
it with a constant.
Modified Paths:
--------------
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/internalconfig.inc.php
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2010-09-30 11:44:50 UTC (rev 1480)
+++ mrbs/trunk/web/edit_area_room.php 2010-09-30 12:11:55 UTC (rev 1481)
@@ -102,7 +102,7 @@
$type = 'string';
break;
}
- $var = "f_" . $field['name'];
+ $var = VAR_PREFIX . $field['name'];
$$var = get_form_var($var, $type);
if (($type == 'int') && ($$var === ''))
{
@@ -222,7 +222,7 @@
break;
// then look at any user defined fields
default:
- $var = "f_" . $field['name'];
+ $var = VAR_PREFIX . $field['name'];
switch ($field['nature'])
{
case 'integer':
@@ -516,15 +516,16 @@
// then look at any user defined fields
default:
$label_text = get_loc_field_name($tbl_room, $field['name']);
- echo "<label for=\"f_" . $field['name'] .
"\">$label_text:</label>\n";
+ $var_name = VAR_PREFIX . $field['name'];
+ echo "<label for=\"$var_name\">$label_text:</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 "<input type=\"checkbox\" class=\"checkbox\" " .
- "id=\"f_" . $field['name'] . "\" " .
- "name=\"f_" . $field['name'] . "\" " .
+ "id=\"$var_name\" " .
+ "name=\"$var_name\" " .
"value=\"1\" " .
((!empty($row[$field['name']])) ? " checked=\"checked\""
: "") .
"$disabled>\n";
@@ -534,8 +535,8 @@
elseif (($field['nature'] == 'character') &&
isset($field['length']) && ($field['length'] > $text_input_max))
{
echo "<textarea rows=\"8\" cols=\"40\" " .
- "id=\"f_" . $field['name'] . "\" " .
- "name=\"f_" . $field['name'] . "\" " .
+ "id=\"$var_name\" " .
+ "name=\"$var_name\" " .
"$disabled>\n";
echo htmlspecialchars($row[$field['name']]);
echo "</textarea>\n";
@@ -544,8 +545,8 @@
else
{
echo "<input type=\"text\" " .
- "id=\"f_" . $field['name'] . "\" " .
- "name=\"f_" . $field['name'] . "\" " .
+ "id=\"$var_name\" " .
+ "name=\"$var_name\" " .
"value=\"" . htmlspecialchars($row[$field['name']]) .
"\"" .
"$disabled>\n";
}
Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php 2010-09-30 11:44:50 UTC (rev 1480)
+++ mrbs/trunk/web/edit_entry.php 2010-09-30 12:11:55 UTC (rev 1481)
@@ -868,6 +868,7 @@
$key = $field['name'];
if (!in_array($key, $standard_fields['entry']))
{
+ $var_name = VAR_PREFIX . $key;
$value = $custom_fields[$key];
$label_text = get_loc_field_name($tbl_entry, $key) . ":";
echo "<div>\n";
@@ -876,27 +877,27 @@
if (($field['nature'] == 'boolean') ||
(($field['nature'] == 'integer') && isset($field['length']) &&
($field['length'] <= 2)) )
{
- echo "<label for=\"f_$key\">$label_text</label>\n";
+ echo "<label for=\"$var_name\">$label_text</label>\n";
echo "<input type=\"checkbox\" class=\"checkbox\" " .
- "id=\"f_$key\" name=\"f_$key\" value=\"1\" " .
+ "id=\"$var_name\" name=\"$var_name\" 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"]);
+ generate_select($label_text, $var_name, $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))
{
- generate_textarea($label_text, "f_$key", $value);
+ generate_textarea($label_text, $var_name, $value);
}
// Otherwise output a text input
else
{
- generate_input($label_text, "f_$key", $value);
+ generate_input($label_text, $var_name, $value);
}
echo "</div>\n";
}
Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php 2010-09-30 11:44:50 UTC (rev
1480)
+++ mrbs/trunk/web/edit_entry_handler.php 2010-09-30 12:11:55 UTC (rev
1481)
@@ -57,7 +57,7 @@
$f_type = 'string';
break;
}
- $var = "f_" . $field['name'];
+ $var = VAR_PREFIX . $field['name'];
$custom_fields[$field['name']] = get_form_var($var, $f_type);
if (($f_type == 'int') && ($custom_fields[$field['name']] === ''))
{
Modified: mrbs/trunk/web/edit_users.php
===================================================================
--- mrbs/trunk/web/edit_users.php 2010-09-30 11:44:50 UTC (rev 1480)
+++ mrbs/trunk/web/edit_users.php 2010-09-30 12:11:55 UTC (rev 1481)
@@ -40,8 +40,6 @@
require_once "defaultincludes.inc";
-define('VAR_PREFIX', 'f_'); // Prefix for custom field variable names
-
// Get non-standard form variables
$Action = get_form_var('Action', 'string');
$Id = get_form_var('Id', 'int');
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2010-09-30 11:44:50 UTC (rev
1480)
+++ mrbs/trunk/web/internalconfig.inc.php 2010-09-30 12:11:55 UTC (rev
1481)
@@ -17,9 +17,9 @@
// in calls to nl2br. TRUE means XHTML, FALSE means HTML.
define('IS_XHTML', FALSE);
- /*************************************************
+/*************************************************
* ENTRY STATUS CODES - internal use, do not change
- **************************************************/
+ *************************************************/
// The booking status codes that are used in the status column in the
// entry table. Although there are only two codes at the moment, the
@@ -29,9 +29,9 @@
define('STATUS_PROVISIONAL', 0);
define('STATUS_CONFIRMED', 1);
- /*************************************************
+/*************************************************
* REPEAT TYPE CODES - internal use, do not change
- **************************************************/
+ *************************************************/
define('REP_NONE', 0);
define('REP_DAILY', 1);
@@ -41,10 +41,15 @@
define('REP_MONTHLY_SAMEDAY', 5);
define('REP_N_WEEKLY', 6);
- /****************************************************************
- * DATABASE TABLES - STANDARD FIELDS - internal use, do not change
- *****************************************************************/
+/****************************************************************
+ * DATABASE TABLES - internal use, do not change
+ ****************************************************************/
+// CUSTOM FIELDS
+// Prefix for custom field variable names
+define('VAR_PREFIX', 'f_'); // must begin with a letter;
+
+// STANDARD FIELDS
// These are the standard fields in the database tables. If you add more
// standard (not user defined, custom) fields, then you need to change these
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