Changeset 20


Ignore:
Timestamp:
Nov 17, 2005 3:00:00 AM (19 years ago)
Author:
scdev
Message:

Tons of little updates and bugfixes. CSS updates to templates and core css files. File upload ability to module_maker. Remade Upload interface to use setParam/getParam.

Location:
trunk
Files:
28 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/form_template.cli.php

    r19 r20  
    6565        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    6666        <td valign="top">
    67             <select name="$field" class="formselect">
     67            <select name="$field" class="small">
    6868            <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field DESC'); \x3f>
    6969            </select>
     
    7575       
    7676        // File upload.
    77         if (preg_match('/file/i', $field)) {
    78             $output[$field] = <<<E_O_F
    79     <tr>
    80         <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    81         <td valign="top">
    82             <input type="file" name="$field" value="<\x3fphp echo \$_FILES['$field']['name']; \x3f>" />
    83             <\x3fphp if (getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
    84             <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>
     77        if (preg_match('/file|image/i', $field)) {
     78            $output[$field] = <<<E_O_F
     79    <tr>
     80        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
     81        <td valign="top">
     82            <input type="file" name="$field" />
     83            <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
     84            <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>
    8585            <\x3fphp } \x3f>
    86             <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>
     86            <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>
    8787        </td>
    8888    </tr>
     
    9797        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    9898        <td valign="top">
    99             <input type="password" class="forminputtext" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
     99            <input type="password" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
    100100        </td>
    101101    </tr>
     
    138138        <td>&nbsp;</td>
    139139        <td>
    140             <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f>><label><\x3fphp echo _("$title"); \x3f></label>
     140            <input type="checkbox" name="$field" <\x3fphp frmChecked(!empty(\$frm['$field'])) \x3f> /><label><\x3fphp echo _("$title"); \x3f></label>
    141141        </td>
    142142    </tr>
     
    157157        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    158158        <td valign="top">
    159             <textarea class="text" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
     159            <textarea class="large" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
    160160        </td>
    161161    </tr>
     
    196196        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    197197        <td valign="top">
    198             <input type="text" class="text" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>">
     198            <input type="text" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
    199199        </td>
    200200    </tr>
  • trunk/bin/module_maker/list_template.cli.php

    r19 r20  
    112112    <br />
    113113   
    114     <input type="text" class="forminputtext" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
     114    <input type="text" class="small" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
    115115    <select name="filter_<##>">
    116116        <\x3fphp // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); \x3f>
  • trunk/bin/module_maker/module.cli.php

    r19 r20  
    5656
    5757// Names
    58 $module_title = ucwords($module_name_plural);
    59 $item_title = ucwords($module_name_singular);
    60 $module_name_upper = strtoupper($module_name_plural);
     58$module_title = ucwords(str_replace('_', ' ', $module_name_plural));
     59$item_title = ucwords(str_replace('_', ' ', $module_name_singular));
     60$module_name_upper = strtoupper(str_replace('_', ' ', $module_name_plural));
    6161
    6262// Admin files
     
    7676// Only after we've defined essential files can we clean.
    7777if ('clean' == $op) {
    78     cleanFiles();
     78    echo "Beginning file cleanup\n";
     79    trashFile("$admin_dir/$admin_script");
     80    trashFile("$admin_tpl_dir/$admin_list_template");
     81    trashFile("$admin_tpl_dir/$admin_form_template");
     82    trashFile("$public_dir/$public_script");
     83    trashFile("$public_tpl_dir/$public_list_template");
     84    trashFile("$public_tpl_dir/$public_detail_template");   
     85    echo "End file cleanup\n";
    7986    die;
    8087}
     
    140147
    141148// Loop through columns
    142 $multipart_form_required = false;
     149$upload_file_capability = false;
    143150$headers = array();
    144151$public_list_page_vars = array();
     
    160167       
    161168        // Our form will require type="multipart/form-data".
    162         if (preg_match('/file/i', $field)) {
    163             $multipart_form_required = true;
     169        if (preg_match('/file|image/i', $field)) {
     170            $upload_file_capability = true;
    164171        }
    165172       
     
    184191
    185192
    186 // -------------VARS-------------
     193// Search-replace variables ----------------------------------
     194
     195// Admin script file upload replacement routines...
     196
     197$search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
     198$replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
     199$search['admin_upload_include'] = '/%ADMIN_UPLOAD_INCLUDE%/';
     200$replace['admin_upload_include'] = '';
     201$search['admin_upload_config'] = '/%ADMIN_UPLOAD_CONFIG%/';
     202$replace['admin_upload_config'] = '';
     203$search['admin_upload_init'] = '/%ADMIN_UPLOAD_INIT%/';
     204$replace['admin_upload_init'] = '';
     205$search['admin_upload_del'] = '/%ADMIN_UPLOAD_DEL%/';
     206$replace['admin_upload_del'] = '';
     207$search['admin_upload_insert'] = '/%ADMIN_UPLOAD_INSERT%/';
     208$replace['admin_upload_insert'] = '';
     209$search['admin_upload_insert2'] = '/%ADMIN_UPLOAD_INSERT2%/';
     210$replace['admin_upload_insert2'] = '';
     211$search['admin_upload_update'] = '/%ADMIN_UPLOAD_UPDATE%/';
     212$replace['admin_upload_update'] = '';
     213
     214if ($upload_file_capability) {
     215    $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=\"<##>\" />";
     216
     217    $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n";
     218
     219    $replace['admin_upload_config'] = <<<E_O_F
     220
     221// This module has file upload capability.
     222\$upload = new Upload();
     223\$upload->setParam(array(
     224    'upload_path' => COMMON_BASE . '/html/_db_files/<##>',
     225    'dest_file_perms' => 0666,
     226    'allow_overwriting' => false,
     227    'valid_file_extensions' => array('jpg', 'gif', 'png', 'jpeg'),
     228));
     229
     230E_O_F;
     231
     232    $replace['admin_upload_init'] = <<<E_O_F
     233
     234// Copy uploaded image name into form data.
     235\$_POST['<##>'] = isset(\$_FILES['<##>']) ? \$_FILES['<##>']['name'] : '';
     236 
     237
     238E_O_F;
     239
     240    $replace['admin_upload_del'] = <<<E_O_F
     241
     242    // Delete file.
     243    if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
     244        \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
     245    }
     246E_O_F;
     247
     248    $replace['admin_upload_insert'] = <<<E_O_F
     249
     250        // Upload file.
     251        if (!\$new_files = \$upload->process('<##>')) {
     252            // Upload failed. Reload form, displaying errors.
     253            \$frm =& addRecordForm();
     254            \$frm = array_merge(\$frm, getFormData());
     255            \$nav->addPage(_("Add %ITEM_TITLE%"));
     256            \$main_template = '%ADMIN_FORM_TEMPLATE%';
     257            break;
     258        }
     259E_O_F;
     260
     261    $replace['admin_upload_insert2'] = <<<E_O_F
     262
     263        // Record inserted successfuly. Now we know the primary key, prepend to filename.
     264        \$upload->moveFile(\$new_files[0]['name'], \$%PRIMARY_KEY% . '_' . \$new_files[0]['name']);
     265E_O_F;
     266
     267    $replace['admin_upload_update'] = <<<E_O_F
     268
     269        // Upload new file.
     270        if (getFormData('<##>')) {
     271            if (\$upload->process('<##>',  getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'))) {
     272                // Upload success. Delete old file.
     273                if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
     274                    \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
     275                }
     276            } else {
     277                // Upload failed. Reload form, displaying errors.
     278                \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
     279                \$frm = array_merge(\$frm, getFormData());
     280                \$nav->addPage(_("Edit %ITEM_TITLE%"));
     281                \$main_template = '%ADMIN_FORM_TEMPLATE%';
     282                break;
     283            }           
     284        }
     285E_O_F;
     286} // End if.
     287
    187288
    188289// Simple...
     
    242343$replace['search_fields'] = join(", ", $headers);
    243344
    244 $search['admin_form_tag_init'] = '/%ADMIN_FORM_TAG_INIT%/';
    245 if ($multipart_form_required) {
    246     $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\">";
    247 } else {
    248     $replace['admin_form_tag_init'] = "<form method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">";
    249 }
    250345
    251346
     
    419514 *****************************************************************************/
    420515
    421 /**
    422  * Removes existing modules files. Danger!
    423  */
    424 function cleanFiles()
     516function trashFile($file_path_name)
    425517{
    426518    global $user_trash_folder;
    427     global $admin_dir;
    428     global $admin_script;
    429     global $admin_tpl_dir;
    430     global $admin_list_template;
    431     global $admin_form_template;
    432     global $public_dir;
    433     global $public_script;
    434     global $public_tpl_dir;
    435     global $public_detail_template;
    436     global $public_list_template;
     519    static $file_prefix;
    437520   
    438     echo "Beginning file cleanup\n";
    439 
     521    if (!isset($file_prefix)) {
     522        $file_prefix = time();
     523    } else {
     524        $file_prefix++;
     525    }
     526   
     527    // Make user trash folder.
    440528    if (!dir($user_trash_folder)) {
    441529        mkdir($user_trash_folder);
     
    447535    }
    448536
    449     if (file_exists("$admin_dir/$admin_script")) {
    450         rename("$admin_dir/$admin_script", "$user_trash_folder/$admin_script" . '_' . md5(microtime()));
    451         printf("Moved to trash: %s\n", "$admin_dir/$admin_script");
     537    // Move file to trash.
     538    if (file_exists($file_path_name)) {
     539        rename($file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
     540        printf("Moved to trash: %s -> %s\n", $file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name)));
    452541    } else {
    453         printf("File not found: %s\n", "$admin_dir/$admin_script");
    454     }
    455 
    456     if (file_exists("$admin_tpl_dir/$admin_list_template")) {
    457         rename("$admin_tpl_dir/$admin_list_template", "$user_trash_folder/$admin_list_template" . '_' . md5(microtime()));
    458         printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_list_template");
    459     } else {
    460         printf("File not found: %s\n", "$admin_tpl_dir/$admin_list_template");
    461     }
    462 
    463     if (file_exists("$admin_tpl_dir/$admin_form_template")) {
    464         rename("$admin_tpl_dir/$admin_form_template", "$user_trash_folder/$admin_form_template" . '_' . md5(microtime()));
    465         printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_form_template");
    466     } else {
    467         printf("File not found: %s\n", "$admin_tpl_dir/$admin_form_template");
    468     }
    469 
    470     if (file_exists("$public_dir/$public_script")) {
    471         rename("$public_dir/$public_script", "$user_trash_folder/$public_script" . '_' . md5(microtime()));
    472         printf("Moved to trash: %s\n", "$public_dir/$public_script");
    473     } else {
    474         printf("File not found: %s\n", "$public_dir/$public_script");
    475     }
    476 
    477     if (file_exists("$public_tpl_dir/$public_list_template")) {
    478         rename("$public_tpl_dir/$public_list_template", "$user_trash_folder/$public_list_template" . '_' . md5(microtime()));
    479         printf("Moved to trash: %s\n", "$public_tpl_dir/$public_list_template");
    480     } else {
    481         printf("File not found: %s\n", "$public_tpl_dir/$public_list_template");
    482     }
    483 
    484     if (file_exists("$public_tpl_dir/$public_detail_template")) {
    485         rename("$public_tpl_dir/$public_detail_template", "$user_trash_folder/$public_detail_template" . '_' . md5(microtime()));
    486         printf("Moved to trash: %s\n", "$public_tpl_dir/$public_detail_template");
    487     } else {
    488         printf("File not found: %s\n", "$public_tpl_dir/$public_detail_template");
    489     }
    490    
    491     echo "End file cleanup\n";
     542        printf("File not found: %s\n", $file_path_name);
     543    }
    492544}
    493545
  • trunk/bin/module_maker/skel/adm_form.ihtml

    r19 r20  
    33%ADMIN_FORM_TAG_INIT%
    44<?php App::printHiddenSession(); ?>
    5 <input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>">
    6 <input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>">
     5<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
     6<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>" />
    77
    88<table>
  • trunk/bin/module_maker/skel/adm_list.ihtml

    r19 r20  
    11
    22<?php $fv->printErrorMessages(); ?>
    3 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
     3<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
    44<?php App::printHiddenSession(false); ?>
    55
     
    88    <br />
    99   
    10     <input type="text" class="forminputtext" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: %SEARCH_FIELDS%.")); ?>" />
     10    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: <##> %SEARCH_FIELDS%.")); ?>" />
    1111    <select name="filter_<##>">
    1212        <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?>
     
    1414    <input type="submit" name="list" value="<?php echo _("Search"); ?>" />
    1515</div>
     16</form>
    1617
     18<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
     19<?php App::printHiddenSession(); ?>
    1720<?php include 'list_info.ihtml'; ?>
    18 
    1921<table class="list">
    2022    <tr>
     
    2628    <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
    2729    <tr>
    28         <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>
    29         <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>
     30        <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>
     31        <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>
    3032%ADM_LIST_ROWS%
    31         <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>
     33        <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>
    3234    </tr>
    3335    <?php } ?>
  • trunk/bin/module_maker/skel/admin.php

    r19 r20  
    2121require_once 'codebase/lib/RecordLock.inc.php';
    2222require_once 'codebase/lib/RecordVersion.inc.php';
    23 
     23%ADMIN_UPLOAD_INCLUDE%
    2424
    2525/******************************************************************************
     
    4040$page->setPageNumber(getFormData('page_number'));
    4141
     42// Search limiters retain their values between page requests.
     43App::carryQuery('search_query');
     44App::carryQuery('filter_<##>');
     45%ADMIN_UPLOAD_CONFIG%
    4246/******************************************************************************
    4347 * MAIN
    4448 *****************************************************************************/
    45  
     49 %ADMIN_UPLOAD_INIT%
    4650// We may want to use the add/edit interface from another script, so this
    4751// allows us to remember which page we came from so we can go back there.
    48 if (getFormData('boomerang', false)) {
     52if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    4953    App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
    5054}
     
    7680case 'del' :
    7781//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
    78     deleteRecord(getFormData('%PRIMARY_KEY%'));
     82    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
    7983    if (App::validBoomerangURL('%NAME_PLURAL%')) {
    8084        // Display boomerang page.
     
    96100        $nav->addPage(_("Add %ITEM_TITLE%"));
    97101        $main_template = '%ADMIN_FORM_TEMPLATE%';
    98     } else {
    99         $%PRIMARY_KEY% = insertRecord(getFormData());
     102    } else {%ADMIN_UPLOAD_INSERT%
     103        $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT2%
    100104        if (getFormdata('repeat', false)) {
    101105            // Display function again.
     
    134138        $nav->addPage(_("Edit %ITEM_TITLE%"));
    135139        $main_template = '%ADMIN_FORM_TEMPLATE%';
    136     } else {
     140    } else {%ADMIN_UPLOAD_UPDATE%
    137141        updateRecord(getFormData());
    138142        if (getFormdata('repeat', false)) {
     
    277281
    278282    // Create version.
    279     $version = new RecordVersion($GLOBALS['auth']);
     283    $version = RecordVersion::getInstance($GLOBALS['auth']);
    280284    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
    281285   
     
    300304       
    301305        // Create version.
    302         $version = new RecordVersion($GLOBALS['auth']);
     306        $version = RecordVersion::getInstance($GLOBALS['auth']);
    303307        $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
    304308   
     
    403407    foreach ($ranks as $id => $new_rank) {
    404408        if ('' == trim($new_rank) || !is_numeric($new_rank) || $new_rank > 2147483646) {
    405             // Unspecified entries recieve a sort order of 1000.
    406             $new_rank = 1000;
     409            // Unspecified entries receive a sort order of 10000.
     410            $new_rank = 10000;
    407411            $unspecified_counter++;
    408412        }
     
    416420    App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
    417421    if ($unspecified_counter > 0) {
    418         App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 1000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     422        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
    419423    }
    420424}
  • trunk/css/admin.inc.css

    r19 r20  
    4444/* 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? */
    4545
     46/* Why does having a form change the presentation of the page? Don't do that. */
     47form
     48{
     49    margin: 0;
     50}
     51
    4652form label
    4753{
    4854    font-size: 70%;
    49     max-width: 20em;
     55    max-width: 25em;
    5056    /* BEAU: I added class="right" to the <TD> to make them align right as they were before. Do you know a better way? */
    5157    /*float: right;*/
     
    216222{
    217223    vertical-align: top;
    218     padding-right: 6px;
     224    padding: 8px 6px 0 0 ;
    219225}
    220226
  • trunk/css/utilities.inc.css

    r19 r20  
    1515{
    1616    color: #000;
    17     margin: 0 4px 0 0;
     17    margin: 0 0.5em 0 0;
    1818    padding: 0;
    1919}
     
    2323{
    2424    font-weight: bold;
    25     margin: 1px;
    26 }
    27 
    28 /* 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? */
    29 select
    30 {
    31     width: 250px;
    32     margin: 4px 4px 0 0;
     25    margin: 0.5em;
    3326}
    3427
    3528input
    3629{
    37     margin: 4px 4px 0 0;
     30    margin: 0.5em 0.5em 0 0;
    3831}
    3932
     
    4639BEAU: 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.
    4740*/
    48 input.text, textarea.text
     41input.tiny, textarea.tiny
    4942{
    50     width: 250px;
     43    width: 5em;
    5144}
    5245
    53 input.textsmall, textarea.textsmall
     46input.small, textarea.small
    5447{
    55     width: 150px;
     48    width: 10em;
    5649}
    5750
    58 input.texthalf, textarea.texthalf
     51input.medium, textarea.medium
    5952{
    60     width: 121px;
    61     /*  125 minus 4 to account for the 4px padding on the right  */
     53    width: 20.5em;
     54}
     55
     56input.large, textarea.large
     57{
     58    width: 41.5em;
    6259}
    6360
     
    6764}
    6865
    69 /* BEAU: Again, here, "small", "medium", "large" denominations make sense. But how to diferentiate width from height? */
    70 textarea.twoliner
     66textarea.twolines
    7167{
    7268    height: 3em;
    7369}
    7470
    75 textarea.paragraphs
     71textarea.short
    7672{
    77     height: 20em;
     73    height: 8em;
     74}
     75
     76textarea.tall
     77{
     78    height: 25em;
     79}
     80
     81textarea.fullscreen
     82{
     83    height: 40em;
     84}
     85
     86/* 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? */
     87select.small
     88{
     89    width: 10em;
     90}
     91
     92select.medium
     93{
     94    width: 20.5em;
    7895}
    7996
  • trunk/docs/coding_standards.txt

    r19 r20  
    296296value in HTML, the parameter name is the value.  For example:
    297297
    298     <input type="checkbox" checked="checked">
     298    <input type="checkbox" checked="checked" />
    299299    <select name="example">
    300300        <option selected="selected" value="1">Example</option>
  • trunk/lib/App.inc.php

    r19 r20  
    2929    // Instance of database object.
    3030    var $db;
     31   
     32    // Array of query arguments will be carried persistently between requests.
     33    var $_carry_queries = array();
    3134
    3235    // Hash of global application parameters.
     
    4750        'ssl_enabled' => false,
    4851   
    49         // Character set for page output. Set in the Content-Type header and an HTML <meta content-type> tag.
     52        // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag.
    5053        'character_set' => 'utf-8',
    5154
     
    534537   
    535538    /**
     539     * Sets which query arguments will be carried persistently between requests.
     540     * Values in the _carry_queries array will be copied to URLs (via oHREF()) and
     541     * to hidden input values (via printHiddenSession()).
     542     *
     543     * @access  public
     544     * @param   string  $query_key  The key of the query argument to save. 
     545     * @author  Quinn Comendant <quinn@strangecode.com>
     546     * @since   14 Nov 2005 19:24:52
     547     */
     548    function carryQuery($query_key)
     549    {
     550        if (!isset($this) || !is_a($this, 'App')) {
     551            $this =& App::getInstance();
     552        }
     553       
     554        // If not already set, and there is a non-empty value provided in the request...
     555        if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
     556            // Copy the value of the specified query argument into the _carry_queries array.
     557            $this->_carry_queries[$query_key] = getFormData($query_key);
     558        }
     559    }
     560   
     561    /**
    536562     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
    537563     * keys and values, including optional queries. This allows simple printing of
    538564     * links without needing to know which queries to add to it. If cookies are not
    539565     * used, the session id will be propogated in the URL.
    540      *
    541      * @global string $carry_queries       An array of keys to define which values to
    542      *                                     carry through from the POST or GET.
    543      *                                     $carry_queries = array('qry'); for example.
    544566     *
    545567     * @param  string $url                 The initial url
     
    565587            return false;
    566588        }
    567        
    568         static $_using_trans_sid;
    569         global $carry_queries;
    570    
    571         // Save the trans_sid setting.
    572         if (!isset($_using_trans_sid)) {
    573             $_using_trans_sid = ini_get('session.use_trans_sid');
    574         }
    575    
    576         // Initialize the carried queries.
    577         if (!isset($carry_queries['_carry_queries_init'])) {
    578             if (!is_array($carry_queries)) {
    579                 $carry_queries = array($carry_queries);
    580             }
    581             $tmp = $carry_queries;
    582             $carry_queries = array();
    583             foreach ($tmp as $key) {
    584                 if (!empty($key) && getFormData($key, false)) {
    585                     $carry_queries[$key] = getFormData($key);
    586                 }
    587             }
    588             $carry_queries['_carry_queries_init'] = true;
    589         }
    590    
    591         // Get any additional query arguments to add to the $carry_queries array.
    592         // If FALSE is a function argument, DO NOT carry the queries.
     589   
     590        // Get any provided query arguments to include in the final URL.
     591        // If FALSE is a provided here, DO NOT carry the queries.
    593592        $do_carry_queries = true;
    594593        $one_time_carry_queries = array();
     
    611610            }
    612611        }
    613    
     612       
    614613        // Get the first delimiter that is needed in the url.
    615614        $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?';
     
    617616        $q = '';
    618617        if ($do_carry_queries) {
    619             // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
    620             $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
     618            // Join the global _carry_queries and local one_time_carry_queries.
     619            $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
    621620            foreach ($query_args as $key=>$val) {
    622621                // Check value is set and value does not already exist in the url.
     
    648647                    &&
    649648                    (
    650                         !$_using_trans_sid
     649                        !ini_get('session.use_trans_sid')
    651650                        || preg_match('!^(http|https)://!i', $url)
    652651                    )
     
    668667     * as hidden form elements for GET_VARS that might be in use.
    669668     *
    670      * @global string $carry_queries     An array of keys to define which values to
    671      *                                   carry through from the POST or GET.
    672      *                                   $carry_queries = array('qry'); for example
    673      *
    674669     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
    675670     *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
     
    679674     */
    680675    function printHiddenSession($carry_args=null)
    681     {
     676    {   
    682677        if (!isset($this) || !is_a($this, 'App')) {
    683678            $this =& App::getInstance();
     
    687682            return false;
    688683        }
    689        
    690         static $_using_trans_sid;
    691         global $carry_queries;
    692    
    693         // Save the trans_sid setting.
    694         if (!isset($_using_trans_sid)) {
    695             $_using_trans_sid = ini_get('session.use_trans_sid');
    696         }
    697        
    698         // Initialize the carried queries.
    699         if (!isset($carry_queries['_carry_queries_init'])) {
    700             if (!is_array($carry_queries)) {
    701                 $carry_queries = array($carry_queries);
    702             }
    703             $tmp = $carry_queries;
    704             $carry_queries = array();
    705             foreach ($tmp as $key) {
    706                 if (!empty($key) && getFormData($key, false)) {
    707                     $carry_queries[$key] = getFormData($key);
    708                 }
    709             }
    710             $carry_queries['_carry_queries_init'] = true;
    711         }
    712    
    713         // Get any additional query names to add to the $carry_queries array
    714         // that are found as function arguments.
    715         // If FALSE is a function argument, DO NOT carry the queries.
     684   
     685        // Get any provided query arguments to include in the final hidden form data.
     686        // If FALSE is a provided here, DO NOT carry the queries.
    716687        $do_carry_queries = true;
    717688        $one_time_carry_queries = array();
     
    737708        // For each existing POST value, we create a hidden input to carry it through a form.
    738709        if ($do_carry_queries) {
    739             // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
    740             $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
     710            // Join the global _carry_queries and local one_time_carry_queries.
     711            // urlencode is not used here, not for form data!
     712            $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
    741713            foreach ($query_args as $key=>$val) {
    742714                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
     
    745717       
    746718        // Include the SID if cookies are disabled.
    747         if (!isset($_COOKIE[session_name()]) && !$_using_trans_sid) {
     719        if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
    748720            echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
    749721        }
  • trunk/lib/PayPal.inc.php

    r19 r20  
    188188                if (!in_array($key, array('button_url', 'link_url', 'submit_img', 'submit_text'))) {
    189189                    ?>
    190                     <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>">
     190                    <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $val; ?>" />
    191191                    <?php
    192192                }
     
    194194        }
    195195        ?>
    196         <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']; ?>">
     196        <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']; ?>" />
    197197        </form>
    198198        <?php
  • trunk/lib/RecordLock.inc.php

    r19 r20  
    345345        <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?>
    346346        <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>
    347         <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>">
     347        <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" />
    348348        <?php } ?>
    349349       
    350         <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>">
     350        <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" />
    351351        </form>
    352352        <?php
  • trunk/lib/RecordVersion.inc.php

    r19 r20  
    4040    {
    4141        static $instances = array();
    42 
    43         if (!is_a($auth_object, 'Auth_SQL')) {
    44             trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
    45         }
    4642               
    4743        if (!isset($instances[$auth_object->getVal('auth_name')])) {
     
    6056    {
    6157        if (!is_a($auth_object, 'Auth_SQL')) {
    62             trigger_error('Passed argument is not a valid Auth_SQL object.', E_USER_ERROR);
     58            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
    6359        }
    6460       
  • trunk/lib/SortOrder.inc.php

    r19 r20  
    1515 *
    1616 * @author  Quinn Comendant <quinn@strangecode.com>
    17  * @version 1.6
     17 * @version 1.6.1
    1818 */
    1919require_once dirname(__FILE__) . '/App.inc.php';
     
    2626    var $sort_by;
    2727    var $order;
    28     var $asc_widget;
    29     var $desc_widget;
     28    var $asc_widget = '<img src="/admin/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">';
     29    var $desc_widget = '<img src="/admin/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">';
    3030    var $default_sort;
    3131    var $default_order;
     
    4141    function SortOrder($default_sort = '', $default_order = '')
    4242    {       
    43         $this->asc_widget = '<img src="/_widgets/sort_ascending.gif" alt="" width="11" height="7" border="0">';
    44         $this->desc_widget = '<img src="/_widgets/sort_descending.gif" alt="" width="11" height="7" border="0">';
    45        
    4643        $this->setDefault($default_sort, $default_order);
    4744   
     
    146143        }
    147144
    148         if (!empty($this->_columns[strtolower($this->sort_by)][strtolower(strtolower($this->order))])) {
    149             return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower(strtolower($this->order))]);
     145        if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) {
     146            return ' ORDER BY ' . addslashes($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]);
    150147        } else {
    151148            App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);
  • trunk/lib/SpellCheck.inc.php

    r19 r20  
    346346                ?>
    347347                </select>
    348                 <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20">
     348                <input type="text" name="spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]" value="<?php echo $original_word ?>" size="20" />
    349349                <?php if ($this->_use_personal_wordlist) { ?>
    350350                <input name="save_to_personal_wordlist[]" type="checkbox" value="<?php echo $i ?>" /><?php echo _("Learn spelling") ?>
  • trunk/lib/Upload.inc.php

    r19 r20  
    33 * Upload.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    5  */
    6 
    7 /**
     5 *
    86 * The Upload class provides an interface to deal with http uploaded files.
    97 *
    108 * @author  Quinn Comendant <quinn@strangecode.com>
    119 * @requires App.inc.php
    12  * @version 1.0
     10 * @version 1.2
    1311 */
    1412
     
    1917    // General object parameters.
    2018    var $_params = array(
     19   
     20        // Display message with raiseMsg?
    2121        'display_messages' => true,
     22       
     23        // Existing files will be overwritten when there is a name conflict?
    2224        'allow_overwriting' => false,
     25
     26        // The filesystem path to the final upload directory.
     27        'upload_path' => null,
     28
     29        // The file permissions of the uploaded files. Remember, files will be owned by the web server user.
     30        'dest_file_perms' => 0600,
     31
     32        // Require file to have one of the following file extentions.
     33        'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm'),
    2334    );
    24 
    25     // Disk path where new image(s) will be uploaded.
    26     var $upload_directory_path = null;
    2735
    2836    // Array of files with errors.
    2937    var $errors = array();
    30    
    31     // Array of acceptable file extensions (lowercase).
    32     var $valid_file_extensions = array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm');
    33    
    34     // The uploaded files will normally be owned by user 'apache'. Set world-read/write
    35     // if the website admin needs to read/delete these files.
    36     var $dest_file_perms = 0600;
    37    
     38
    3839    // Array of file extensions and corresponding mime-types.
    3940    var $mime_extension_map = array(
     
    223224    {
    224225        if (isset($params) && is_array($params)) {
     226       
     227            // Enforce valid upload_path parameter.
     228            if (isset($params['upload_path'])) {
     229                $params['upload_path'] = realpath($params['upload_path']);
     230                // Must be directory.
     231                if (!is_dir($params['upload_path'])) {
     232                    App::logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
     233                    trigger_error(sprintf('Upload directory invalid: %s', $params['upload_path']), E_USER_ERROR);
     234                }
     235                // Must be writable.
     236                if (!is_writable($params['upload_path'])) {
     237                    App::logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
     238                    trigger_error(sprintf('Upload directory not writable: %s', $params['upload_path']), E_USER_ERROR);
     239                }
     240                // Set the default upload path, stripping any extra slashes if needed.
     241                $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']);
     242            }
     243       
    225244            // Merge new parameters with old overriding only those passed.
    226245            $this->_params = array_merge($this->_params, $params);
     
    250269     *
    251270     */
    252     function setUploadPath($path)
    253     {
    254         $path = realpath($path);
    255        
    256         if (!is_dir($path)) {
    257             App::logMsg(sprintf('Upload directory invalid: %s', $path), LOG_ERR, __FILE__, __LINE__);
    258         }
    259         if (!is_writable($path)) {
    260             App::logMsg(sprintf('Upload directory not writable: %s', $path), LOG_ERR, __FILE__, __LINE__);
    261         }
    262        
    263         // Set the default upload path, stripping any extra slashes if needed.
    264         $this->upload_directory_path = preg_replace('!/+$!', '', $path);
    265     }
    266 
    267     /**
    268      *
    269      */
    270271    function process($form_name, $custom_file_name=null)
    271272    {
    272273        // Ensure we have a upload directory.
    273         if (!isset($this->upload_directory_path)) {
     274        if (!$this->getParam('upload_path')) {
    274275            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
    275276            $this->raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
     
    364365           
    365366            // Check to be sure the file has a valid file extension.
    366             if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->valid_file_extensions)) {
    367                 $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__);
     367            if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->getParam('valid_file_extensions'))) {
     368                $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__);
    368369                App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file extension."), $files['name'][$i]), LOG_WARNING, __FILE__, __LINE__);
    369370                $this->errors[] = $files['name'][$i];
     
    417418           
    418419            // Set the path and file name.
    419             $file_path_name = $this->upload_directory_path . '/' . $file_name;
     420            $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    420421           
    421422            // Move the file to the final place.
    422423            if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
    423                 chmod($file_path_name, $this->dest_file_perms);
     424                chmod($file_path_name, $this->getParam('dest_file_perms'));
    424425                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $files['name'][$i]), MSG_SUCCESS, __FILE__, __LINE__);
    425426                if (!isset($custom_file_name) && $files['name'][$i] != $file_name) {
     
    449450    {
    450451        // Ensure we have a upload directory.
    451         if (!isset($this->upload_directory_path)) {
     452        if (!$this->getParam('upload_path')) {
    452453            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
    453454            return false;
    454455        }
    455456       
    456         $file_path_name = $this->upload_directory_path . '/' . $file_name;
     457        $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    457458
    458459        if (!is_file($file_path_name)) {
     
    474475    {
    475476        // Ensure we have an upload directory.
    476         if (!isset($this->upload_directory_path)) {
     477        if (!$this->getParam('upload_path')) {
    477478            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
    478479            return false;
    479480        }
    480481       
    481         $old_file_path_name = $this->upload_directory_path . '/' . $old_name;
    482         $new_file_path_name = $this->upload_directory_path . '/' . $new_name;
     482        $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name;
     483        $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name;
    483484        if (file_exists($old_file_path_name)) {
    484             if (!rename($old_file_path_name, $new_file_path_name)) {
     485            if (rename($old_file_path_name, $new_file_path_name)) {
     486                $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__);
     487                App::logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__);
     488            } else {
    485489                $this->raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_ERR, __FILE__, __LINE__);
    486490                App::logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_ERR, __FILE__, __LINE__);
     
    500504    {
    501505        // Ensure we have a upload directory.
    502         if (!isset($this->upload_directory_path)) {
     506        if (!$this->getParam('upload_path')) {
    503507            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
    504508            return false;
    505509        }
    506510       
    507         return file_exists($this->upload_directory_path . '/' . $file_name);
     511        return file_exists($this->getParam('upload_path') . '/' . $file_name);
     512    }
     513
     514    /**
     515     * Get filename by glob pattern. Searches a directory for an image that matches the
     516     * specified glob pattern and returns the filename of the first file found.
     517     *
     518     * @access  public
     519     * @param   string  $pattern   Pattern to match filename.
     520     * @return  string filename on success, empty string on failure.
     521     * @author  Quinn Comendant <quinn@strangecode.com>
     522     * @since   15 Nov 2005 20:55:22
     523     */
     524    function getFilenameGlob($pattern)
     525    {
     526        $file_list = glob(sprintf('%s/%s', $this->getParam('upload_path'), $pattern));
     527        if (isset($file_list[0])) {
     528            return basename($file_list[0]);
     529        } else {
     530            return '';
     531        }
    508532    }
    509533
  • trunk/lib/Utilities.inc.php

    r19 r20  
    298298        }
    299299    } else {
    300         // We've come to the last dimention of the array, save the "array" and it's value.
     300        // We've come to the last dimention of the array, save the "array" and its value.
    301301        $args[$prefix] = urlencode($data);
    302302    }
  • trunk/services/admins.php

    r19 r20  
    5353$page->setPageNumber(getFormData('page_number'));
    5454
     55// Search limiters retain their values between page requests.
     56App::carryQuery('search_query');
     57
    5558
    5659/******************************************************************************
     
    6063// We may want to use the add/edit interface from another script, so this
    6164// allows us to remember which page we came from so we can go back there.
    62 if (getFormData('boomerang', false)) {
     65if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    6366    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
    6467}
     
    380383   
    381384    // Create version.
    382     $version = new RecordVersion($GLOBALS['auth']);
     385    $version = RecordVersion::getInstance($GLOBALS['auth']);
    383386    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    384387   
     
    420423
    421424        // Create version.
    422         $version = new RecordVersion($GLOBALS['auth']);
     425        $version = RecordVersion::getInstance($GLOBALS['auth']);
    423426        $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
    424427   
     
    450453            ";
    451454        }
    452     }
    453 
    454     if (getFormData('search_query', false)) {
    455         // Search query.
    456         $where_clause = $search_where_clause;
    457     }
    458     if (getFormData('filter_admin_user_type', false)) {
    459         // Limit by filter.
    460         $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " user_type = '" . addslashes(getFormData('filter_admin_user_type')) . "'";
    461455    }
    462456
  • trunk/services/lock.php

    r19 r20  
    1111App::sslOn();
    1212
    13 if (getFormData('boomerang', false)) {
     13if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    1414    // We remember which page we came from so we can go back there.
    1515    $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
  • trunk/services/login.php

    r19 r20  
    55 */
    66
    7 if (getFormData('boomerang', false)) {
     7if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    88    // We remember which page we came from so we can go back there.
    99    App::setBoomerangURL($_SERVER['HTTP_REFERER']);
  • trunk/services/password.php

    r19 r20  
    11<?php
    22/**
    3  * passwd.php
     3 * password.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2525 *****************************************************************************/
    2626
    27 if (getFormData('boomerang', false)) {
     27if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    2828    // We remember which page we came from so we can go back there.
    29     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_passwd');
     29    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
    3030}
    3131App::sslOn();
     
    5757        App::logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
    5858        App::raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
    59         App::dieBoomerangURL('admin_passwd');
     59        App::dieBoomerangURL('admin_password');
    6060    }
    6161    break;
     
    6464// Templates.
    6565include 'header.ihtml';
    66 include 'codebase/services/templates/passwd.ihtml';
     66include 'codebase/services/templates/password.ihtml';
    6767include 'footer.ihtml';
    6868
  • trunk/services/templates/admin_form.ihtml

    r19 r20  
    33<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    44<?php App::printHiddenSession(); ?>
    5 <input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>">
    6 <input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>">
    7 <input type="hidden" name="old_username" value="<?php echo $frm['old_username']; ?>">
     5<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
     6<input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>" />
     7<input type="hidden" name="old_username" value="<?php echo $frm['old_username']; ?>" />
    88
    99<table>
     
    1313    </tr>
    1414    <tr>
    15         <td class="formlabel" align="right" valign="top"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></td>
     15        <td class="right"><label for="username"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></label></td>
    1616        <td valign="top">
    17             <input type="text" class="forminputtext" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>">
     17            <input type="text" class="small" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>" />
    1818        </td>
    1919    </tr>
    2020    <tr>
    21         <td class="formlabel" align="right" valign="top"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></td>
     21        <td class="right"><label for="userpass"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></label></td>
    2222        <td valign="top">
    23             <input type="password" class="forminputtext" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>">
     23            <input type="password" class="small" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>" />
    2424        </td>
    2525    </tr>
    2626    <tr>
    27         <td class="formlabel" align="right" valign="top"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></td>
     27        <td class="right"><label for="first_name"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></label></td>
    2828        <td valign="top">
    29             <input type="text" class="forminputtext" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>">
     29            <input type="text" class="small" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>" />
    3030        </td>
    3131    </tr>
    3232    <tr>
    33         <td class="formlabel" align="right" valign="top"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></td>
     33        <td class="right"><label for="last_name"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></label></td>
    3434        <td valign="top">
    35             <input type="text" class="forminputtext" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>">
     35            <input type="text" class="small" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>" />
    3636        </td>
    3737    </tr>
    3838    <tr>
    39         <td class="formlabel" align="right" valign="top"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></td>
     39        <td class="right"><label for="email"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></label></td>
    4040        <td valign="top">
    41             <input type="text" class="forminputtext" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>">
     41            <input type="text" class="medium" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>" />
    4242        </td>
    4343    </tr>
    4444    <tr>
    45         <td class="formlabel" align="right" valign="top"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></td>
     45        <td class="right"><label for="user_type"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></label></td>
    4646        <td valign="top">
    47             <select name="user_type">
     47            <select name="user_type" class="small">
    4848            <?php printSetSelectForm('admin_tbl', 'user_type', $frm['user_type'], true); ?>
    4949            </select>
  • trunk/services/templates/admin_list.ihtml

    r19 r20  
    22<?php $fv->printErrorMessages(); ?>
    33<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    4 <?php $carry_queries = array('search_query', 'filter_admin_user_type'); ?>
    54<?php App::printHiddenSession(false); ?>
    65<div id="commandbox">
     
    87    <br />
    98   
    10     <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.")); ?>" />
    11 <!--
    12     <select name="filter_<##>">
    13         <?php // printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', city, '&mdash;', title)", '<##>_id', getFormData('filter_<##>'), array('Any <##>'), 'ORDER BY <##> ASC'); ?>
    14     </select>
    15  -->
     9    <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.")); ?>" />
    1610    <input type="submit" name="list" value="<?php echo _("Search"); ?>" />
    1711</div>
  • trunk/services/templates/lock.ihtml

    r19 r20  
    1818    <?php if ($lock->getSecondsElapsed() > $lock->timeout) { ?>
    1919    <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>
    20     <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>">
     20    <input type="submit" class="formsubmitbutton" name="unlock" value="<?php echo _("Unlock"); ?>" />
    2121    <?php } ?>
    2222
    23     <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>">
     23    <input type="submit" class="formsubmitbutton" name="cancel" value="<?php echo _("Cancel"); ?>" />
    2424</form>
  • trunk/services/templates/log_list.ihtml

    r19 r20  
    3030    </table>
    3131<?php } ?>
    32     <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."); ?>" />
     32    <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."); ?>" />
    3333    <input type="checkbox" name="search_grep"<?php frmChecked(getFormData('search_grep')) ?> /><span class="commandtext"><?php echo _("Use Grep"); ?></span>
    3434    <input type="submit" name="list" value="<?php echo _("Search"); ?>" class="formsubmitbutton" />
  • trunk/services/templates/login_form.ihtml

    r19 r20  
    11<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    22<?php App::printHiddenSession() ?>
    3 <table border="0" cellspacing="0" cellpadding="4">
     3<table>
    44    <tr>
    5         <td class="formlabel" align="right" valign="top"><?php echo _("Username"); ?></td>
    6         <td valign="top"><input type="text" class="forminputtext" size="25" name="username" value="<?php echo oTxt($frm['username']); ?>"></td>
     5        <td class="right"><label for="username"><?php echo _("Username"); ?></label></td>
     6        <td valign="top">
     7            <input type="text" class="medium" size="20" name="username" value="<?php echo oTxt($frm['username']); ?>" />
     8        </td>
    79    </tr>
    810    <tr>
    9         <td class="formlabel" align="right" valign="top"><?php echo _("Password"); ?></td>
    10         <td valign="top"><input type="password" class="forminputtext" size="25" name="password" value="<?php echo oTxt($frm['password']); ?>"></td>
     11        <td class="right"><label for="password"><?php echo _("Password"); ?></label></td>
     12        <td valign="top">
     13            <input type="password" class="medium" size="20" name="password" value="<?php echo oTxt($frm['password']); ?>" />
     14        </td>
    1115    </tr>
    1216    <tr>
    13         <td class="formlabel" align="right" valign="top">&nbsp;</td>
    14         <td valign="top"><br /><input type="submit" class="formsubmitbutton" value="<?php echo _("Login"); ?>"></td>
     17        <td>&nbsp;</td>
     18        <td valign="top"><input type="submit" value="<?php echo _("Login"); ?>" /></td>
    1519    </tr>
    1620</table>
  • trunk/services/templates/password.ihtml

    r19 r20  
    33<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    44<?php App::printHiddenSession() ?>
    5 <input type="hidden" name="op" value="update_password">
    6 <table border="0" cellspacing="0" cellpadding="4">
     5<input type="hidden" name="op" value="update_password" />
     6<table>
    77    <tr>
    8         <td class="formlabel" align="right" valign="top"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></td>
    9         <td valign="top"><input type="password" class="forminputtext" size="25" name="oldpassword" /></td>
     8        <td class="right"><label for="oldpassword"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></label></td>
     9        <td valign="top">
     10            <input type="text" class="medium" size="50" name="oldpassword" />
     11        </td>
    1012    </tr>
    1113    <tr>
    12         <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></td>
    13         <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword" /></td>
     14        <td class="right"><label for="newpassword"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></label></td>
     15        <td valign="top">
     16            <input type="password" class="medium" size="50" name="newpassword" />
     17        </td>
    1418    </tr>
    1519    <tr>
    16         <td class="formlabel" align="right" valign="top"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></td>
    17         <td valign="top"><input type="password" class="forminputtext" size="25" name="newpassword2" /></td>
     20        <td class="right"><label for="newpassword2"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></label></td>
     21        <td valign="top">
     22            <input type="password" class="medium" size="50" name="newpassword2" />
     23        </td>
    1824    </tr>
    1925    <tr>
    20         <td class="formlabel" align="right" valign="top">&nbsp;</td>
    21         <td valign="top"><br /><input type="submit" class="formsubmitbutton" value="<?php echo _("Change password"); ?>" /></td>
     26        <td>&nbsp;</td>
     27        <td valign="top"><input type="submit" value="<?php echo _("Change password"); ?>" /></td>
    2228    </tr>
    2329</table>
  • trunk/services/templates/versions_list.ihtml

    r19 r20  
    11<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    22<?php App::printHiddenSession() ?>
    3 <input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>">
     3<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>" />
    44<table class="list" border="0" cellspacing="0" cellpadding="4">
    55<tr>
     
    3131</table>
    3232<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>
    33 <input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>">
     33<input type="submit" class="formsubmitbutton" name="op" value="<?php echo _("Cancel"); ?>" />
    3434</form>
  • trunk/services/versions.php

    r19 r20  
    1717 *****************************************************************************/
    1818
    19 $version = new RecordVersion($GLOBALS['auth']);
     19$version = RecordVersion::getInstance($GLOBALS['auth']);
    2020
    21 // These values must be kept across requests.
    22 $carry_queries = array('record_table', 'record_key', 'record_val', 'version_title');
     21// Query arguments to retain their values between page requests.
     22App::carryQuery('record_table');
     23App::carryQuery('record_key');
     24App::carryQuery('record_val');
     25App::carryQuery('version_title');
    2326
    2427// Titles and navigation header.
     
    4144}
    4245
    43 if (getFormData('boomerang', false)) {
     46if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    4447    // We remember which page we came from so we can go back there.
    4548    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
Note: See TracChangeset for help on using the changeset viewer.