Revision: 1399
http://mrbs.svn.sourceforge.net/mrbs/?rev=1399&view=rev
Author: cimorrison
Date: 2010-07-27 21:07:46 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
Simplified code dealing with custom fields
Modified Paths:
--------------
mrbs/trunk/web/edit_entry.php
mrbs/trunk/web/view_entry.php
Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php 2010-07-27 11:57:05 UTC (rev 1398)
+++ mrbs/trunk/web/edit_entry.php 2010-07-27 21:07:46 UTC (rev 1399)
@@ -837,23 +837,19 @@
<?php
// CUSTOM FIELDS
- if (count($custom_fields))
+
+ foreach ($fields as $field)
{
- $field_natures = array();
- $field_lengths = array();
- foreach ($fields as $field)
+ $key = $field['name'];
+ if (!in_array($key, $standard_fields['entry']))
{
- $field_natures[$field['name']] = $field['nature'];
- $field_lengths[$field['name']] = $field['length'];
- }
- foreach ($custom_fields as $key => $value)
- {
+ $value = $custom_fields[$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_natures[$key] == 'boolean') ||
- (($field_natures[$key] == 'integer') &&
isset($field_lengths[$key]) && ($field_lengths[$key] <= 2)) )
+ if (($field['nature'] == 'boolean') ||
+ (($field['nature'] == 'integer') && isset($field['length']) &&
($field['length'] <= 2)) )
{
echo "<input type=\"checkbox\" class=\"checkbox\" " .
"id=\"f_$key\" name=\"f_$key\" value=\"1\" " .
@@ -862,7 +858,7 @@
}
// Output a textarea if it's a character string longer than the limit
for a
// text input
- elseif (($field_natures[$key] == 'character') &&
isset($field_lengths[$key]) && ($field_lengths[$key] > $text_input_max))
+ elseif (($field['nature'] == 'character') && isset($field['length'])
&& ($field['length'] > $text_input_max))
{
echo "<textarea rows=\"8\" cols=\"40\" " .
"id=\"f_$key\" name=\"f_$key\" " .
Modified: mrbs/trunk/web/view_entry.php
===================================================================
--- mrbs/trunk/web/view_entry.php 2010-07-27 11:57:05 UTC (rev 1398)
+++ mrbs/trunk/web/view_entry.php 2010-07-27 21:07:46 UTC (rev 1399)
@@ -473,38 +473,33 @@
<td><?php echo get_vocab("lastupdate") ?>:</td>
<td><?php echo $updated ?></td>
</tr>
-<?php
- if (count($custom_fields))
+ <?php
+ // The custom fields
+ $fields = sql_field_info($tbl_entry);
+ foreach ($fields as $field)
{
- $fields = sql_field_info($tbl_entry);
- $field_natures = array();
- $field_lengths = array();
- foreach ($fields as $field)
+ $key = $field['name'];
+ if (!in_array($key, $standard_fields['entry']))
{
- $field_natures[$field['name']] = $field['nature'];
- $field_lengths[$field['name']] = $field['length'];
- }
- foreach ($custom_fields as $key => $value)
- {
echo "<tr>\n";
echo "<td>" . get_loc_field_name($tbl_entry, $key) . ":</td>\n";
// Output a yes/no if it's a boolean or integer <= 2 bytes (which we will
// assume are intended to be booleans)
- if (($field_natures[$key] == 'boolean') ||
- (($field_natures[$key] == 'integer') && isset($field_lengths[$key])
&& ($field_lengths[$key] <= 2)) )
+ if (($field['nature'] == 'boolean') ||
+ (($field['nature'] == 'integer') && isset($field['length']) &&
($field['length'] <= 2)) )
{
- $shown_value = empty($value) ? get_vocab("no") : get_vocab("yes");
+ $shown_value = empty($custom_fields[$key]) ? get_vocab("no") :
get_vocab("yes");
}
// Otherwise output a string
else
{
- $shown_value = (isset($value)) ? mrbs_nl2br(htmlspecialchars($value)):
" ";
+ $shown_value = (isset($custom_fields[$key])) ?
mrbs_nl2br(htmlspecialchars($custom_fields[$key])): " ";
}
echo "<td>$shown_value</td>\n";
echo "</tr>\n";
}
}
-?>
+ ?>
<tr>
<td><?php echo get_vocab("rep_type") ?>:</td>
<td><?php echo get_vocab($repeat_key) ?></td>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits