Index: /trunk/bin/module_maker/form_template.cli.php
===================================================================
--- /trunk/bin/module_maker/form_template.cli.php	(revision 19)
+++ /trunk/bin/module_maker/form_template.cli.php	(revision 20)
@@ -65,5 +65,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <select name="$field" class="formselect">
+            <select name="$field" class="small">
             <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field DESC'); \x3f>
             </select>
@@ -75,14 +75,14 @@
         
         // File upload.
-        if (preg_match('/file/i', $field)) {
-            $output[$field] = <<<E_O_F
-    <tr>
-        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
-        <td valign="top">
-            <input type="file" name="$field" value="<\x3fphp echo \$_FILES['$field']['name']; \x3f>" />
-            <\x3fphp if (getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
-            <div class="help"><\x3fphp printf(_("The current file <strong>%s</strong> will be overwritten if a new file is selected for upload."), \$frm['$field']) \x3f></div>
+        if (preg_match('/file|image/i', $field)) {
+            $output[$field] = <<<E_O_F
+    <tr>
+        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
+        <td valign="top">
+            <input type="file" name="$field" />
+            <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
+            <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\$s\"><strong>%2\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>
             <\x3fphp } \x3f>
-            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->valid_file_extensions)) \x3f></div>
+            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->getParam('valid_file_extensions'))) \x3f></div>
         </td>
     </tr>
@@ -97,5 +97,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <input type="password" class="forminputtext" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
+            <input type="password" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
         </td>
     </tr>
@@ -138,5 +138,5 @@
         <td>&nbsp;</td>
         <td>
-            <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f>><label><\x3fphp echo _("$title"); \x3f></label>
+            <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f> /><label><\x3fphp echo _("$title"); \x3f></label>
         </td>
     </tr>
@@ -157,5 +157,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <textarea class="text" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
+            <textarea class="large" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
         </td>
     </tr>
@@ -196,5 +196,5 @@
         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
         <td valign="top">
-            <input type="text" class="text" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
+            <input type="text" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
         </td>
     </tr>
Index: /trunk/bin/module_maker/list_template.cli.php
===================================================================
--- /trunk/bin/module_maker/list_template.cli.php	(revision 19)
+++ /trunk/bin/module_maker/list_template.cli.php	(revision 20)
@@ -112,5 +112,5 @@
     <br />
     
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
+    <input type="text" class="small" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
     <select name="filter_<##>">
         <\x3fphp // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); \x3f>
Index: /trunk/bin/module_maker/module.cli.php
===================================================================
--- /trunk/bin/module_maker/module.cli.php	(revision 19)
+++ /trunk/bin/module_maker/module.cli.php	(revision 20)
@@ -56,7 +56,7 @@
 
 // Names
-$module_title = ucwords($module_name_plural);
-$item_title = ucwords($module_name_singular);
-$module_name_upper = strtoupper($module_name_plural);
+$module_title = ucwords(str_replace('_', ' ', $module_name_plural));
+$item_title = ucwords(str_replace('_', ' ', $module_name_singular));
+$module_name_upper = strtoupper(str_replace('_', ' ', $module_name_plural));
 
 // Admin files
@@ -76,5 +76,12 @@
 // Only after we've defined essential files can we clean.
 if ('clean' == $op) {
-    cleanFiles();
+    echo "Beginning file cleanup\n";
+    trashFile("$admin_dir/$admin_script");
+    trashFile("$admin_tpl_dir/$admin_list_template");
+    trashFile("$admin_tpl_dir/$admin_form_template");
+    trashFile("$public_dir/$public_script");
+    trashFile("$public_tpl_dir/$public_list_template");
+    trashFile("$public_tpl_dir/$public_detail_template");    
+    echo "End file cleanup\n";
     die;
 }
@@ -140,5 +147,5 @@
 
 // Loop through columns
-$multipart_form_required = false;
+$upload_file_capability = false;
 $headers = array();
 $public_list_page_vars = array();
@@ -160,6 +167,6 @@
         
         // Our form will require type="multipart/form-data".
-        if (preg_match('/file/i', $field)) {
-            $multipart_form_required = true;
+        if (preg_match('/file|image/i', $field)) {
+            $upload_file_capability = true;
         }
         
@@ -184,5 +191,99 @@
 
 
-// -------------VARS-------------
+// Search-replace variables ----------------------------------
+
+// Admin script file upload replacement routines...
+
+$search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
+$replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
+$search['admin_upload_include'] = '/%ADMIN_UPLOAD_INCLUDE%/';
+$replace['admin_upload_include'] = '';
+$search['admin_upload_config'] = '/%ADMIN_UPLOAD_CONFIG%/';
+$replace['admin_upload_config'] = '';
+$search['admin_upload_init'] = '/%ADMIN_UPLOAD_INIT%/';
+$replace['admin_upload_init'] = '';
+$search['admin_upload_del'] = '/%ADMIN_UPLOAD_DEL%/';
+$replace['admin_upload_del'] = '';
+$search['admin_upload_insert'] = '/%ADMIN_UPLOAD_INSERT%/';
+$replace['admin_upload_insert'] = '';
+$search['admin_upload_insert2'] = '/%ADMIN_UPLOAD_INSERT2%/';
+$replace['admin_upload_insert2'] = '';
+$search['admin_upload_update'] = '/%ADMIN_UPLOAD_UPDATE%/';
+$replace['admin_upload_update'] = '';
+
+if ($upload_file_capability) {
+    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />";
+
+    $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n";
+
+    $replace['admin_upload_config'] = <<<E_O_F
+
+// This module has file upload capability.
+\$upload = new Upload();
+\$upload->setParam(array(
+    'upload_path' => COMMON_BASE . '/html/_db_files/<##>',
+    'dest_file_perms' => 0666,
+    'allow_overwriting' => false,
+    'valid_file_extensions' => array('jpg', 'gif', 'png', 'jpeg'),
+));
+
+E_O_F;
+
+    $replace['admin_upload_init'] = <<<E_O_F
+
+// Copy uploaded image name into form data.
+\$_POST['<##>'] = isset(\$_FILES['<##>']) ? \$_FILES['<##>']['name'] : '';
+ 
+
+E_O_F;
+
+    $replace['admin_upload_del'] = <<<E_O_F
+
+    // Delete file.
+    if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
+        \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
+    }
+E_O_F;
+
+    $replace['admin_upload_insert'] = <<<E_O_F
+
+	    // Upload file.
+        if (!\$new_files = \$upload->process('<##>')) {
+            // Upload failed. Reload form, displaying errors.
+            \$frm =& addRecordForm();
+            \$frm = array_merge(\$frm, getFormData());
+            \$nav->addPage(_("Add %ITEM_TITLE%"));
+            \$main_template = '%ADMIN_FORM_TEMPLATE%';
+            break;
+        }
+E_O_F;
+
+    $replace['admin_upload_insert2'] = <<<E_O_F
+
+        // Record inserted successfuly. Now we know the primary key, prepend to filename.
+        \$upload->moveFile(\$new_files[0]['name'], \$%PRIMARY_KEY% . '_' . \$new_files[0]['name']);
+E_O_F;
+
+    $replace['admin_upload_update'] = <<<E_O_F
+
+        // Upload new file.
+        if (getFormData('<##>')) {
+            if (\$upload->process('<##>',  getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'))) {
+                // Upload success. Delete old file.
+                if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
+                    \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
+                }
+            } else {
+                // Upload failed. Reload form, displaying errors.
+                \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
+                \$frm = array_merge(\$frm, getFormData());
+                \$nav->addPage(_("Edit %ITEM_TITLE%"));
+                \$main_template = '%ADMIN_FORM_TEMPLATE%';
+                break;
+            }            
+        }
+E_O_F;
+} // End if.
+
 
 // Simple...
@@ -242,10 +343,4 @@
 $replace['search_fields'] = join(", ", $headers);
 
-$search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
-if ($multipart_form_required) {
-    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"12000000\">";
-} else {
-    $replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
-}
 
 
@@ -419,23 +514,16 @@
  *****************************************************************************/
 
-/**
- * Removes existing modules files. Danger!
- */
-function cleanFiles()
+function trashFile($file_path_name)
 {
     global $user_trash_folder;
-    global $admin_dir;
-    global $admin_script;
-    global $admin_tpl_dir;
-    global $admin_list_template;
-    global $admin_form_template;
-    global $public_dir;
-    global $public_script;
-    global $public_tpl_dir;
-    global $public_detail_template;
-    global $public_list_template;
+    static $file_prefix;
     
-    echo "Beginning file cleanup\n";
-
+    if (!isset($file_prefix)) {
+        $file_prefix = time();
+    } else {
+        $file_prefix++;
+    }
+    
+    // Make user trash folder.
     if (!dir($user_trash_folder)) {
         mkdir($user_trash_folder);
@@ -447,47 +535,11 @@
     }
 
-    if (file_exists("$admin_dir/$admin_script")) {
-        rename("$admin_dir/$admin_script", "$user_trash_folder/$admin_script" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_dir/$admin_script");
+    // Move file to trash.
+    if (file_exists($file_path_name)) {
+        rename($file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
+        printf("Moved to trash: %s -> %s\n", $file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
     } else {
-        printf("File not found: %s\n", "$admin_dir/$admin_script");
-    }
-
-    if (file_exists("$admin_tpl_dir/$admin_list_template")) {
-        rename("$admin_tpl_dir/$admin_list_template", "$user_trash_folder/$admin_list_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_list_template");
-    } else {
-        printf("File not found: %s\n", "$admin_tpl_dir/$admin_list_template");
-    }
-
-    if (file_exists("$admin_tpl_dir/$admin_form_template")) {
-        rename("$admin_tpl_dir/$admin_form_template", "$user_trash_folder/$admin_form_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_form_template");
-    } else {
-        printf("File not found: %s\n", "$admin_tpl_dir/$admin_form_template");
-    }
-
-    if (file_exists("$public_dir/$public_script")) {
-        rename("$public_dir/$public_script", "$user_trash_folder/$public_script" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_dir/$public_script");
-    } else {
-        printf("File not found: %s\n", "$public_dir/$public_script");
-    }
-
-    if (file_exists("$public_tpl_dir/$public_list_template")) {
-        rename("$public_tpl_dir/$public_list_template", "$user_trash_folder/$public_list_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_tpl_dir/$public_list_template");
-    } else {
-        printf("File not found: %s\n", "$public_tpl_dir/$public_list_template");
-    }
-
-    if (file_exists("$public_tpl_dir/$public_detail_template")) {
-        rename("$public_tpl_dir/$public_detail_template", "$user_trash_folder/$public_detail_template" . '_' . md5(microtime()));
-        printf("Moved to trash: %s\n", "$public_tpl_dir/$public_detail_template");
-    } else {
-        printf("File not found: %s\n", "$public_tpl_dir/$public_detail_template");
-    }
-    
-    echo "End file cleanup\n";
+        printf("File not found: %s\n", $file_path_name);
+    }
 }
 
Index: /trunk/bin/module_maker/skel/adm_form.ihtml
===================================================================
--- /trunk/bin/module_maker/skel/adm_form.ihtml	(revision 19)
+++ /trunk/bin/module_maker/skel/adm_form.ihtml	(revision 20)
@@ -3,6 +3,6 @@
 %ADMIN_FORM_TAG_INIT%
 <?php App::printHiddenSession(); ?>
-<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>">
-<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>">
+<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
+<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>" />
 
 <table>
Index: /trunk/bin/module_maker/skel/adm_list.ihtml
===================================================================
--- /trunk/bin/module_maker/skel/adm_list.ihtml	(revision 19)
+++ /trunk/bin/module_maker/skel/adm_list.ihtml	(revision 20)
@@ -1,5 +1,5 @@
 
 <?php $fv->printErrorMessages(); ?>
-<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
 <?php App::printHiddenSession(false); ?>
 
@@ -8,5 +8,5 @@
     <br />
     
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: %SEARCH_FIELDS%.")); ?>" />
+    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: <##> %SEARCH_FIELDS%.")); ?>" />
     <select name="filter_<##>">
         <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?>
@@ -14,7 +14,9 @@
     <input type="submit" name="list" value="<?php echo _("Search"); ?>" />
 </div>
+</form>
 
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
+<?php App::printHiddenSession(); ?>
 <?php include 'list_info.ihtml'; ?>
-
 <table class="list">
     <tr>
@@ -26,8 +28,8 @@
     <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
     <tr>
-        <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
-        <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
+        <td class="padleft nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
+        <td class="padleft nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
 %ADM_LIST_ROWS%
-        <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['______RECORD_NAME______'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['______RECORD_NAME______'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
+        <td class="padleft nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['<##>'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     </tr>
     <?php } ?>
Index: /trunk/bin/module_maker/skel/admin.php
===================================================================
--- /trunk/bin/module_maker/skel/admin.php	(revision 19)
+++ /trunk/bin/module_maker/skel/admin.php	(revision 20)
@@ -21,5 +21,5 @@
 require_once 'codebase/lib/RecordLock.inc.php';
 require_once 'codebase/lib/RecordVersion.inc.php';
-
+%ADMIN_UPLOAD_INCLUDE%
 
 /******************************************************************************
@@ -40,11 +40,15 @@
 $page->setPageNumber(getFormData('page_number'));
 
+// Search limiters retain their values between page requests.
+App::carryQuery('search_query');
+App::carryQuery('filter_<##>');
+%ADMIN_UPLOAD_CONFIG%
 /******************************************************************************
  * MAIN
  *****************************************************************************/
- 
+ %ADMIN_UPLOAD_INIT%
 // We may want to use the add/edit interface from another script, so this
 // allows us to remember which page we came from so we can go back there.
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
 }
@@ -76,5 +80,5 @@
 case 'del' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
-    deleteRecord(getFormData('%PRIMARY_KEY%'));
+    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
     if (App::validBoomerangURL('%NAME_PLURAL%')) {
         // Display boomerang page.
@@ -96,6 +100,6 @@
         $nav->addPage(_("Add %ITEM_TITLE%"));
         $main_template = '%ADMIN_FORM_TEMPLATE%';
-    } else {
-        $%PRIMARY_KEY% = insertRecord(getFormData());
+    } else {%ADMIN_UPLOAD_INSERT%
+        $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT2%
         if (getFormdata('repeat', false)) {
             // Display function again.
@@ -134,5 +138,5 @@
         $nav->addPage(_("Edit %ITEM_TITLE%"));
         $main_template = '%ADMIN_FORM_TEMPLATE%';
-    } else {
+    } else {%ADMIN_UPLOAD_UPDATE%
         updateRecord(getFormData());
         if (getFormdata('repeat', false)) {
@@ -277,5 +281,5 @@
 
     // Create version.
-    $version = new RecordVersion($GLOBALS['auth']);
+    $version = RecordVersion::getInstance($GLOBALS['auth']);
     $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
     
@@ -300,5 +304,5 @@
         
         // Create version.
-        $version = new RecordVersion($GLOBALS['auth']);
+        $version = RecordVersion::getInstance($GLOBALS['auth']);
         $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
     
@@ -403,6 +407,6 @@
     foreach ($ranks as $id => $new_rank) {
         if ('' == trim($new_rank) || !is_numeric($new_rank) || $new_rank > 2147483646) {
-            // Unspecified entries recieve a sort order of 1000.
-            $new_rank = 1000;
+            // Unspecified entries receive a sort order of 10000.
+            $new_rank = 10000;
             $unspecified_counter++; 
         }
@@ -416,5 +420,5 @@
     App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
     if ($unspecified_counter > 0) {
-        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 1000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
+        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     }
 }
Index: /trunk/css/admin.inc.css
===================================================================
--- /trunk/css/admin.inc.css	(revision 19)
+++ /trunk/css/admin.inc.css	(revision 20)
@@ -44,8 +44,14 @@
 /* The following are here in addition to in utilities.inc.css only because I want the font size 70%. Is there a more general way to do this? There currently are NO font-size specifications in utilities.inc.css or codebase.inc.css. That seems safest, but requires that they are redefined anyways (like here for eg). Have you figured out how to do font sizes correctly? */
 
+/* Why does having a form change the presentation of the page? Don't do that. */
+form
+{
+    margin: 0;
+}
+
 form label
 {
     font-size: 70%;
-    max-width: 20em;
+    max-width: 25em;
     /* BEAU: I added class="right" to the <TD> to make them align right as they were before. Do you know a better way? */
     /*float: right;*/
@@ -216,5 +222,5 @@
 {
 	vertical-align: top;
-	padding-right: 6px;
+	padding: 8px 6px 0 0 ;
 }
 
Index: /trunk/css/utilities.inc.css
===================================================================
--- /trunk/css/utilities.inc.css	(revision 19)
+++ /trunk/css/utilities.inc.css	(revision 20)
@@ -15,5 +15,5 @@
 {
     color: #000;
-    margin: 0 4px 0 0;
+    margin: 0 0.5em 0 0;
     padding: 0;
 }
@@ -23,17 +23,10 @@
 {
     font-weight: bold;
-    margin: 1px;
-}
-
-/* BEAU: Should be in EMs? Also, sometimes it is nice to have the select menu be only the width as its contents. How to override this? */
-select
-{
-    width: 250px;
-    margin: 4px 4px 0 0;
+    margin: 0.5em;
 }
 
 input
 {
-    margin: 4px 4px 0 0;
+    margin: 0.5em 0.5em 0 0;
 }
 
@@ -46,18 +39,22 @@
 BEAU: I want more text box widths! I find need for boxes that fit 5em, 10em, 20em, and 40em widths. These should be in EMs so text can resize and still fit. Since it is useful to apply a width to other form elements to have them similar sizes (not always a text box, such as <select multiple>) I propose renaming them to "input.tiny", "input.small", "input.medium", "input.large", and "input.half" (not sure how you would do "half" in EMs however.
 */
-input.text, textarea.text
+input.tiny, textarea.tiny
 {
-    width: 250px;
+	width: 5em;
 }
 
-input.textsmall, textarea.textsmall
+input.small, textarea.small
 {
-    width: 150px;
+	width: 10em;
 }
 
-input.texthalf, textarea.texthalf
+input.medium, textarea.medium
 {
-    width: 121px;
-    /*  125 minus 4 to account for the 4px padding on the right  */
+	width: 20.5em;
+}
+
+input.large, textarea.large
+{
+	width: 41.5em;
 }
 
@@ -67,13 +64,33 @@
 }
 
-/* BEAU: Again, here, "small", "medium", "large" denominations make sense. But how to diferentiate width from height? */
-textarea.twoliner
+textarea.twolines
 {
     height: 3em;
 }
 
-textarea.paragraphs
+textarea.short
 {
-    height: 20em;
+    height: 8em;
+}
+
+textarea.tall
+{
+    height: 25em;
+}
+
+textarea.fullscreen
+{
+    height: 40em;
+}
+
+/* BEAU: Should be in EMs? Also, sometimes it is nice to have the select menu be only the width as its contents. How to override this? */
+select.small
+{
+	width: 10em;
+}
+
+select.medium
+{
+	width: 20.5em;
 }
 
Index: /trunk/docs/coding_standards.txt
===================================================================
--- /trunk/docs/coding_standards.txt	(revision 19)
+++ /trunk/docs/coding_standards.txt	(revision 20)
@@ -296,5 +296,5 @@
 value in HTML, the parameter name is the value.  For example:
 
-    <input type="checkbox" checked="checked">
+    <input type="checkbox" checked="checked" />
     <select name="example">
         <option selected="selected" value="1">Example</option>
Index: /trunk/lib/App.inc.php
===================================================================
--- /trunk/lib/App.inc.php	(revision 19)
+++ /trunk/lib/App.inc.php	(revision 20)
@@ -29,4 +29,7 @@
     // Instance of database object.
     var $db;
+    
+    // Array of query arguments will be carried persistently between requests.
+    var $_carry_queries = array();
 
     // Hash of global application parameters.
@@ -47,5 +50,5 @@
         'ssl_enabled' => false,
     
-        // Character set for page output. Set in the Content-Type header and an HTML <meta content-type> tag.
+        // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag.
         'character_set' => 'utf-8',
 
@@ -534,12 +537,31 @@
     
     /**
+     * Sets which query arguments will be carried persistently between requests.
+     * Values in the _carry_queries array will be copied to URLs (via oHREF()) and 
+     * to hidden input values (via printHiddenSession()).
+     *
+     * @access  public
+     * @param   string  $query_key  The key of the query argument to save.  
+     * @author  Quinn Comendant <quinn@strangecode.com>
+     * @since   14 Nov 2005 19:24:52
+     */
+    function carryQuery($query_key)
+    {
+        if (!isset($this) || !is_a($this, 'App')) {
+            $this =& App::getInstance();
+        }
+        
+        // If not already set, and there is a non-empty value provided in the request...
+        if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
+            // Copy the value of the specified query argument into the _carry_queries array.
+        	$this->_carry_queries[$query_key] = getFormData($query_key);
+        }
+    }
+    
+    /**
      * Outputs a fully qualified URL with a query of all the used (ie: not empty)
      * keys and values, including optional queries. This allows simple printing of
      * links without needing to know which queries to add to it. If cookies are not
      * used, the session id will be propogated in the URL.
-     *
-     * @global string $carry_queries       An array of keys to define which values to
-     *                                     carry through from the POST or GET.
-     *                                     $carry_queries = array('qry'); for example.
      *
      * @param  string $url                 The initial url
@@ -565,30 +587,7 @@
             return false;
         }
-        
-        static $_using_trans_sid;
-        global $carry_queries;
-    
-        // Save the trans_sid setting.
-        if (!isset($_using_trans_sid)) {
-            $_using_trans_sid = ini_get('session.use_trans_sid');
-        }
-    
-        // Initialize the carried queries.
-        if (!isset($carry_queries['_carry_queries_init'])) {
-            if (!is_array($carry_queries)) {
-                $carry_queries = array($carry_queries);
-            }
-            $tmp = $carry_queries;
-            $carry_queries = array();
-            foreach ($tmp as $key) {
-                if (!empty($key) && getFormData($key, false)) {
-                    $carry_queries[$key] = getFormData($key);
-                }
-            }
-            $carry_queries['_carry_queries_init'] = true;
-        }
-    
-        // Get any additional query arguments to add to the $carry_queries array.
-        // If FALSE is a function argument, DO NOT carry the queries.
+    
+        // Get any provided query arguments to include in the final URL.
+        // If FALSE is a provided here, DO NOT carry the queries.
         $do_carry_queries = true;
         $one_time_carry_queries = array();
@@ -611,5 +610,5 @@
             }
         }
-    
+        
         // Get the first delimiter that is needed in the url.
         $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?';
@@ -617,6 +616,6 @@
         $q = '';
         if ($do_carry_queries) {
-            // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
-            $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
+            // Join the global _carry_queries and local one_time_carry_queries.
+            $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
             foreach ($query_args as $key=>$val) {
                 // Check value is set and value does not already exist in the url.
@@ -648,5 +647,5 @@
                     && 
                     (
-                        !$_using_trans_sid
+                        !ini_get('session.use_trans_sid')
                         || preg_match('!^(http|https)://!i', $url)
                     )
@@ -668,8 +667,4 @@
      * as hidden form elements for GET_VARS that might be in use. 
      *
-     * @global string $carry_queries     An array of keys to define which values to
-     *                                   carry through from the POST or GET.
-     *                                   $carry_queries = array('qry'); for example
-     *
      * @param  mixed  $carry_args        Additional url arguments to carry in the query,
      *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
@@ -679,5 +674,5 @@
      */
     function printHiddenSession($carry_args=null)
-    {
+    {    
         if (!isset($this) || !is_a($this, 'App')) {
             $this =& App::getInstance();
@@ -687,31 +682,7 @@
             return false;
         }
-        
-        static $_using_trans_sid;
-        global $carry_queries;
-    
-        // Save the trans_sid setting.
-        if (!isset($_using_trans_sid)) {
-            $_using_trans_sid = ini_get('session.use_trans_sid');
-        }
-        
-        // Initialize the carried queries.
-        if (!isset($carry_queries['_carry_queries_init'])) {
-            if (!is_array($carry_queries)) {
-                $carry_queries = array($carry_queries);
-            }
-            $tmp = $carry_queries;
-            $carry_queries = array();
-            foreach ($tmp as $key) {
-                if (!empty($key) && getFormData($key, false)) {
-                    $carry_queries[$key] = getFormData($key);
-                }
-            }
-            $carry_queries['_carry_queries_init'] = true;
-        }
-    
-        // Get any additional query names to add to the $carry_queries array 
-        // that are found as function arguments.
-        // If FALSE is a function argument, DO NOT carry the queries.
+    
+        // Get any provided query arguments to include in the final hidden form data.
+        // If FALSE is a provided here, DO NOT carry the queries.
         $do_carry_queries = true;
         $one_time_carry_queries = array();
@@ -737,6 +708,7 @@
         // For each existing POST value, we create a hidden input to carry it through a form.
         if ($do_carry_queries) {
-            // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
-            $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
+            // Join the global _carry_queries and local one_time_carry_queries.
+            // urlencode is not used here, not for form data!
+            $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
             foreach ($query_args as $key=>$val) {
                 echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
@@ -745,5 +717,5 @@
         
         // Include the SID if cookies are disabled.
-        if (!isset($_COOKIE[session_name()]) && !$_using_trans_sid) {
+        if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
             echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
         }
Index: /trunk/lib/PayPal.inc.php
===================================================================
--- /trunk/lib/PayPal.inc.php	(revision 19)
+++ /trunk/lib/PayPal.inc.php	(revision 20)
@@ -188,5 +188,5 @@
                 if (!in_array($key, array('button_url', 'link_url', 'submit_img', 'submit_text'))) {
                     ?>
-                    <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>">
+                    <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>" />
                     <?php
                 }
@@ -194,5 +194,5 @@
         } 
         ?>
-        <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>">
+        <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" />
         </form>
         <?php
Index: /trunk/lib/RecordLock.inc.php
===================================================================
--- /trunk/lib/RecordLock.inc.php	(revision 19)
+++ /trunk/lib/RecordLock.inc.php	(revision 20)
@@ -345,8 +345,8 @@
         <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?>
         <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p>
-        <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>">
+        <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" />
         <?php } ?>
         
-        <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>">
+        <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" />
         </form>
         <?php
Index: /trunk/lib/RecordVersion.inc.php
===================================================================
--- /trunk/lib/RecordVersion.inc.php	(revision 19)
+++ /trunk/lib/RecordVersion.inc.php	(revision 20)
@@ -40,8 +40,4 @@
     {
         static $instances = array();
-
-        if (!is_a($auth_object, 'Auth_SQL')) {
-            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
-        }
                 
         if (!isset($instances[$auth_object->getVal('auth_name')])) {
@@ -60,5 +56,5 @@
     {
         if (!is_a($auth_object, 'Auth_SQL')) {
-        	trigger_error('Passed argument is not a valid Auth_SQL object.', E_USER_ERROR);
+            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
         }
         
Index: /trunk/lib/SortOrder.inc.php
===================================================================
--- /trunk/lib/SortOrder.inc.php	(revision 19)
+++ /trunk/lib/SortOrder.inc.php	(revision 20)
@@ -15,5 +15,5 @@
  * 
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.6
+ * @version 1.6.1
  */
 require_once dirname(__FILE__) . '/App.inc.php';
@@ -26,6 +26,6 @@
     var $sort_by;
     var $order;
-    var $asc_widget;
-    var $desc_widget;
+    var $asc_widget = '<img src="/admin/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">';
+    var $desc_widget = '<img src="/admin/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">';
     var $default_sort;
     var $default_order;
@@ -41,7 +41,4 @@
     function SortOrder($default_sort = '', $default_order = '')
     {        
-        $this->asc_widget = '<img src="/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">';
-        $this->desc_widget = '<img src="/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">';
-        
         $this->setDefault($default_sort, $default_order);
     
@@ -146,6 +143,6 @@
         }
 
-        if (!empty($this->_columns[strtolower($this->sort_by)][strtolower(strtolower($this->order))])) {
-            return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower(strtolower($this->order))]);
+        if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) {
+            return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]);
         } else {
             App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);
Index: /trunk/lib/SpellCheck.inc.php
===================================================================
--- /trunk/lib/SpellCheck.inc.php	(revision 19)
+++ /trunk/lib/SpellCheck.inc.php	(revision 20)
@@ -346,5 +346,5 @@
                 ?>
                 </select>
-                <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20">
+                <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20" />
                 <?php if ($this->_use_personal_wordlist) { ?>
                 <input name="save_to_personal_wordlist[]" type="checkbox" value="<?php echo $i ?>" /><?php echo _("Learn spelling") ?>
Index: /trunk/lib/Upload.inc.php
===================================================================
--- /trunk/lib/Upload.inc.php	(revision 19)
+++ /trunk/lib/Upload.inc.php	(revision 20)
@@ -3,12 +3,10 @@
  * Upload.inc.php 
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
- */
-
-/**
+ *
  * The Upload class provides an interface to deal with http uploaded files.
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
  * @requires App.inc.php
- * @version 1.0
+ * @version 1.2
  */
 
@@ -19,21 +17,24 @@
     // General object parameters.
     var $_params = array(
+    
+        // Display message with raiseMsg?
         'display_messages' => true,
+        
+        // Existing files will be overwritten when there is a name conflict?
         'allow_overwriting' => false,
+
+        // The filesystem path to the final upload directory.
+        'upload_path' => null,
+
+        // The file permissions of the uploaded files. Remember, files will be owned by the web server user.
+        'dest_file_perms' => 0600,
+
+        // Require file to have one of the following file extentions.
+        'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm'),
     );
-
-    // Disk path where new image(s) will be uploaded.
-    var $upload_directory_path = null;
 
     // Array of files with errors.
     var $errors = array();
-    
-    // Array of acceptable file extensions (lowercase).
-    var $valid_file_extensions = array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm');
-    
-    // The uploaded files will normally be owned by user 'apache'. Set world-read/write 
-    // if the website admin needs to read/delete these files.
-    var $dest_file_perms = 0600;
-    
+
     // Array of file extensions and corresponding mime-types.
     var $mime_extension_map = array(
@@ -223,4 +224,22 @@
     {
         if (isset($params) && is_array($params)) {
+        
+            // Enforce valid upload_path parameter.
+            if (isset($params['upload_path'])) {
+                $params['upload_path'] = realpath($params['upload_path']);
+                // Must be directory.
+                if (!is_dir($params['upload_path'])) {
+                    App::logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
+                    trigger_error(sprintf('Upload directory invalid: %s', $params['upload_path']), E_USER_ERROR);
+                }
+                // Must be writable.
+                if (!is_writable($params['upload_path'])) {
+                    App::logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
+                    trigger_error(sprintf('Upload directory not writable: %s', $params['upload_path']), E_USER_ERROR);
+                }
+                // Set the default upload path, stripping any extra slashes if needed.
+                $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']);
+            }
+        
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
@@ -250,26 +269,8 @@
      *
      */
-    function setUploadPath($path)
-    {
-        $path = realpath($path);
-        
-        if (!is_dir($path)) {
-            App::logMsg(sprintf('Upload directory invalid: %s', $path), LOG_ERR, __FILE__, __LINE__);
-        }
-        if (!is_writable($path)) {
-            App::logMsg(sprintf('Upload directory not writable: %s', $path), LOG_ERR, __FILE__, __LINE__);
-        }
-        
-        // Set the default upload path, stripping any extra slashes if needed.
-        $this->upload_directory_path = preg_replace('!/+$!', '', $path);
-    }
-
-    /**
-     *
-     */
     function process($form_name, $custom_file_name=null)
     {
         // Ensure we have a upload directory.
-        if (!isset($this->upload_directory_path)) {
+        if (!$this->getParam('upload_path')) {
             App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             $this->raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
@@ -364,6 +365,6 @@
             
             // Check to be sure the file has a valid file extension.
-            if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->valid_file_extensions)) {
-                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this->valid_file_extensions)), MSG_ERR, __FILE__, __LINE__);
+            if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->getParam('valid_file_extensions'))) {
+                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
                 App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file extension."), $files['name'][$i]), LOG_WARNING, __FILE__, __LINE__);
                 $this->errors[] = $files['name'][$i];
@@ -417,9 +418,9 @@
             
             // Set the path and file name.
-            $file_path_name = $this->upload_directory_path . '/' . $file_name;
+            $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
             
             // Move the file to the final place.
             if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
-                chmod($file_path_name, $this->dest_file_perms);
+                chmod($file_path_name, $this->getParam('dest_file_perms'));
                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $files['name'][$i]), MSG_SUCCESS, __FILE__, __LINE__);
                 if (!isset($custom_file_name) && $files['name'][$i] != $file_name) {
@@ -449,10 +450,10 @@
     {
         // Ensure we have a upload directory.
-        if (!isset($this->upload_directory_path)) {
+        if (!$this->getParam('upload_path')) {
             App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
         
-        $file_path_name = $this->upload_directory_path . '/' . $file_name;
+        $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
 
         if (!is_file($file_path_name)) {
@@ -474,13 +475,16 @@
     {
         // Ensure we have an upload directory.
-        if (!isset($this->upload_directory_path)) {
+        if (!$this->getParam('upload_path')) {
             App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
         
-        $old_file_path_name = $this->upload_directory_path . '/' . $old_name;
-        $new_file_path_name = $this->upload_directory_path . '/' . $new_name;
+        $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name;
+        $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name;
         if (file_exists($old_file_path_name)) {
-            if (!rename($old_file_path_name, $new_file_path_name)) {
+            if (rename($old_file_path_name, $new_file_path_name)) {
+                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> has been renamed to <strong>%s</strong>."), basename($old_file_path_name), basename($new_file_path_name)), MSG_NOTICE, __FILE__, __LINE__);
+                App::logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__);
+            } else {
                 $this->raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_ERR, __FILE__, __LINE__);
                 App::logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_ERR, __FILE__, __LINE__);
@@ -500,10 +504,30 @@
     {
         // Ensure we have a upload directory.
-        if (!isset($this->upload_directory_path)) {
+        if (!$this->getParam('upload_path')) {
             App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
         
-        return file_exists($this->upload_directory_path . '/' . $file_name);
+        return file_exists($this->getParam('upload_path') . '/' . $file_name);
+    }
+
+    /**
+     * Get filename by glob pattern. Searches a directory for an image that matches the 
+     * specified glob pattern and returns the filename of the first file found.
+     *
+     * @access  public
+     * @param   string  $pattern   Pattern to match filename.
+     * @return  string filename on success, empty string on failure.
+     * @author  Quinn Comendant <quinn@strangecode.com>
+     * @since   15 Nov 2005 20:55:22
+     */
+    function getFilenameGlob($pattern)
+    {
+        $file_list = glob(sprintf('%s/%s', $this->getParam('upload_path'), $pattern));
+        if (isset($file_list[0])) {
+            return basename($file_list[0]);
+        } else {
+            return '';
+        }
     }
 
Index: /trunk/lib/Utilities.inc.php
===================================================================
--- /trunk/lib/Utilities.inc.php	(revision 19)
+++ /trunk/lib/Utilities.inc.php	(revision 20)
@@ -298,5 +298,5 @@
         }
     } else {
-        // We've come to the last dimention of the array, save the "array" and it's value.
+        // We've come to the last dimention of the array, save the "array" and its value.
         $args[$prefix] = urlencode($data);
     }
Index: /trunk/services/admins.php
===================================================================
--- /trunk/services/admins.php	(revision 19)
+++ /trunk/services/admins.php	(revision 20)
@@ -53,4 +53,7 @@
 $page->setPageNumber(getFormData('page_number'));
 
+// Search limiters retain their values between page requests.
+App::carryQuery('search_query');
+
 
 /******************************************************************************
@@ -60,5 +63,5 @@
 // We may want to use the add/edit interface from another script, so this
 // allows us to remember which page we came from so we can go back there.
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
 }
@@ -380,5 +383,5 @@
     
     // Create version.
-    $version = new RecordVersion($GLOBALS['auth']);
+    $version = RecordVersion::getInstance($GLOBALS['auth']);
     $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
     
@@ -420,5 +423,5 @@
 
         // Create version.
-        $version = new RecordVersion($GLOBALS['auth']);
+        $version = RecordVersion::getInstance($GLOBALS['auth']);
         $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
     
@@ -450,13 +453,4 @@
             ";
         }
-    }
-
-    if (getFormData('search_query', false)) {
-        // Search query.
-        $where_clause = $search_where_clause;
-    }
-    if (getFormData('filter_admin_user_type', false)) {
-        // Limit by filter.
-        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " user_type = '" . addslashes(getFormData('filter_admin_user_type')) . "'";
     }
 
Index: /trunk/services/lock.php
===================================================================
--- /trunk/services/lock.php	(revision 19)
+++ /trunk/services/lock.php	(revision 20)
@@ -11,5 +11,5 @@
 App::sslOn();
 
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
     $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
Index: /trunk/services/login.php
===================================================================
--- /trunk/services/login.php	(revision 19)
+++ /trunk/services/login.php	(revision 20)
@@ -5,5 +5,5 @@
  */
 
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
     App::setBoomerangURL($_SERVER['HTTP_REFERER']);
Index: /trunk/services/password.php
===================================================================
--- /trunk/services/password.php	(revision 19)
+++ /trunk/services/password.php	(revision 20)
@@ -1,5 +1,5 @@
 <?php
 /**
- * passwd.php 
+ * password.php 
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
  */
@@ -25,7 +25,7 @@
  *****************************************************************************/
 
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_passwd');
+    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
 }
 App::sslOn();
@@ -57,5 +57,5 @@
         App::logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
         App::raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
-        App::dieBoomerangURL('admin_passwd');
+        App::dieBoomerangURL('admin_password');
     }
     break;
@@ -64,5 +64,5 @@
 // Templates.
 include 'header.ihtml';
-include 'codebase/services/templates/passwd.ihtml';
+include 'codebase/services/templates/password.ihtml';
 include 'footer.ihtml';
 
Index: /trunk/services/templates/admin_form.ihtml
===================================================================
--- /trunk/services/templates/admin_form.ihtml	(revision 19)
+++ /trunk/services/templates/admin_form.ihtml	(revision 20)
@@ -3,7 +3,7 @@
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <?php App::printHiddenSession(); ?>
-<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>">
-<input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>">
-<input type="hidden" name="old_username" value="<?php echo $frm['old_username']; ?>">
+<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
+<input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>" />
+<input type="hidden" name="old_username" value="<?php echo $frm['old_username']; ?>" />
 
 <table>
@@ -13,37 +13,37 @@
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></td>
+        <td class="right"><label for="username"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></label></td>
         <td valign="top">
-            <input type="text" class="forminputtext" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>">
+            <input type="text" class="small" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>" />
         </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></td>
+        <td class="right"><label for="userpass"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></label></td>
         <td valign="top">
-            <input type="password" class="forminputtext" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>">
+            <input type="password" class="small" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>" />
         </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></td>
+        <td class="right"><label for="first_name"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></label></td>
         <td valign="top">
-            <input type="text" class="forminputtext" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>">
+            <input type="text" class="small" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>" />
         </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></td>
+        <td class="right"><label for="last_name"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></label></td>
         <td valign="top">
-            <input type="text" class="forminputtext" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>">
+            <input type="text" class="small" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>" />
         </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></td>
+        <td class="right"><label for="email"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></label></td>
         <td valign="top">
-            <input type="text" class="forminputtext" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>">
+            <input type="text" class="medium" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>" />
         </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></td>
+        <td class="right"><label for="user_type"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></label></td>
         <td valign="top">
-            <select name="user_type">
+            <select name="user_type" class="small">
             <?php printSetSelectForm('admin_tbl', 'user_type', $frm['user_type'], true); ?>
             </select>
Index: /trunk/services/templates/admin_list.ihtml
===================================================================
--- /trunk/services/templates/admin_list.ihtml	(revision 19)
+++ /trunk/services/templates/admin_list.ihtml	(revision 20)
@@ -2,5 +2,4 @@
 <?php $fv->printErrorMessages(); ?>
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<?php $carry_queries = array('search_query', 'filter_admin_user_type'); ?>
 <?php App::printHiddenSession(false); ?>
 <div id="commandbox">
@@ -8,10 +7,5 @@
     <br />
     
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" />
-<!-- 
-    <select name="filter_<##>">
-        <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?>
-    </select>
- -->
+    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" />
     <input type="submit" name="list" value="<?php echo _("Search"); ?>" />
 </div>
Index: /trunk/services/templates/lock.ihtml
===================================================================
--- /trunk/services/templates/lock.ihtml	(revision 19)
+++ /trunk/services/templates/lock.ihtml	(revision 20)
@@ -18,7 +18,7 @@
     <?php if ($lock->getSecondsElapsed() > $lock->timeout) { ?>
     <p><?php printf(_("You can force unlock the record if you believe the editing session has expired. You might want to confirm with before doing this."), $lock->getEditor()) ?></p>
-    <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>">
+    <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" />
     <?php } ?>
 
-    <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>">
+    <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" />
 </form>
Index: /trunk/services/templates/log_list.ihtml
===================================================================
--- /trunk/services/templates/log_list.ihtml	(revision 19)
+++ /trunk/services/templates/log_list.ihtml	(revision 20)
@@ -30,5 +30,5 @@
     </table>
 <?php } ?>
-    <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo oTxt(getFormData('search_query')); ?>" title="<?php echo _("All lines in currently viewed log file are searched."); ?>" />
+    <input type="text" class="small" size="20" name="search_query" value="<?php echo oTxt(getFormData('search_query')); ?>" title="<?php echo _("All lines in currently viewed log file are searched."); ?>" />
     <input type="checkbox" name="search_grep"<?php frmChecked(getFormData('search_grep')) ?> /><span class="commandtext"><?php echo _("Use Grep"); ?></span>
     <input type="submit" name="list" value="<?php echo _("Search"); ?>" class="formsubmitbutton" />
Index: /trunk/services/templates/login_form.ihtml
===================================================================
--- /trunk/services/templates/login_form.ihtml	(revision 19)
+++ /trunk/services/templates/login_form.ihtml	(revision 20)
@@ -1,16 +1,20 @@
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <?php App::printHiddenSession() ?>
-<table border="0" cellspacing="0" cellpadding="4">
+<table>
     <tr>
-        <td class="formlabel" align="right" valign="top"><?php echo _("Username"); ?></td>
-        <td valign="top"><input type="text" class="forminputtext" size="25" name="username" value="<?php echo oTxt($frm['username']); ?>"></td>
+        <td class="right"><label for="username"><?php echo _("Username"); ?></label></td>
+        <td valign="top">
+            <input type="text" class="medium" size="20" name="username" value="<?php echo oTxt($frm['username']); ?>" />
+        </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top"><?php echo _("Password"); ?></td>
-        <td valign="top"><input type="password" class="forminputtext" size="25" name="password" value="<?php echo oTxt($frm['password']); ?>"></td>
+        <td class="right"><label for="password"><?php echo _("Password"); ?></label></td>
+        <td valign="top">
+            <input type="password" class="medium" size="20" name="password" value="<?php echo oTxt($frm['password']); ?>" />
+        </td>
     </tr>
     <tr>
-        <td class="formlabel" align="right" valign="top">&nbsp;</td>
-        <td valign="top"><br /><input type="submit" class="formsubmitbutton" value="<?php echo _("Login"); ?>"></td>
+        <td>&nbsp;</td>
+        <td valign="top"><input type="submit" value="<?php echo _("Login"); ?>" /></td>
     </tr>
 </table>
Index: unk/services/templates/passwd.ihtml
===================================================================
--- /trunk/services/templates/passwd.ihtml	(revision 19)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?php $fv->printErrorMessages(); ?>
-
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<?php App::printHiddenSession() ?>
-<input type="hidden" name="op" value="update_password">
-<table border="0" cellspacing="0" cellpadding="4">
-    <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></td>
-        <td valign="top"><input type="password" class="forminputtext" size="25" name="oldpassword" /></td>
-    </tr>
-    <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></td>
-        <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword" /></td>
-    </tr>
-    <tr>
-        <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></td>
-        <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword2" /></td>
-    </tr>
-    <tr>
-        <td class="formlabel" align="right" valign="top">&nbsp;</td>
-        <td valign="top"><br /><input type="submit" class="formsubmitbutton" value="<?php echo _("Change password"); ?>" /></td>
-    </tr>
-</table>
-</form>
Index: /trunk/services/templates/password.ihtml
===================================================================
--- /trunk/services/templates/password.ihtml	(revision 20)
+++ /trunk/services/templates/password.ihtml	(revision 20)
@@ -0,0 +1,30 @@
+<?php $fv->printErrorMessages(); ?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+<?php App::printHiddenSession() ?>
+<input type="hidden" name="op" value="update_password" />
+<table>
+    <tr>
+        <td class="right"><label for="oldpassword"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></label></td>
+        <td valign="top">
+            <input type="text" class="medium" size="50" name="oldpassword" />
+        </td>
+    </tr>
+    <tr>
+        <td class="right"><label for="newpassword"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></label></td>
+        <td valign="top">
+            <input type="password" class="medium" size="50" name="newpassword" />
+        </td>
+    </tr>
+    <tr>
+        <td class="right"><label for="newpassword2"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></label></td>
+        <td valign="top">
+            <input type="password" class="medium" size="50" name="newpassword2" />
+        </td>
+    </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <td valign="top"><input type="submit" value="<?php echo _("Change password"); ?>" /></td>
+    </tr>
+</table>
+</form>
Index: /trunk/services/templates/versions_list.ihtml
===================================================================
--- /trunk/services/templates/versions_list.ihtml	(revision 19)
+++ /trunk/services/templates/versions_list.ihtml	(revision 20)
@@ -1,5 +1,5 @@
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <?php App::printHiddenSession() ?>
-<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>">
+<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>" />
 <table class="list" border="0" cellspacing="0" cellpadding="4">
 <tr>
@@ -31,4 +31,4 @@
 </table>
 <div class="help"><?php printf(_("When there are more than %s versions, those over %s days old are deleted."), $version->record_version_min_qty, $version->record_version_min_days); ?></div>
-<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>">
+<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>" />
 </form>
Index: /trunk/services/versions.php
===================================================================
--- /trunk/services/versions.php	(revision 19)
+++ /trunk/services/versions.php	(revision 20)
@@ -17,8 +17,11 @@
  *****************************************************************************/
 
-$version = new RecordVersion($GLOBALS['auth']);
+$version = RecordVersion::getInstance($GLOBALS['auth']);
 
-// These values must be kept across requests.
-$carry_queries = array('record_table', 'record_key', 'record_val', 'version_title');
+// Query arguments to retain their values between page requests.
+App::carryQuery('record_table');
+App::carryQuery('record_key');
+App::carryQuery('record_val');
+App::carryQuery('version_title');
 
 // Titles and navigation header.
@@ -41,5 +44,5 @@
 }
 
-if (getFormData('boomerang', false)) {
+if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
