Changeset 136 for trunk/bin


Ignore:
Timestamp:
Jun 3, 2006 7:47:48 PM (18 years ago)
Author:
scdev
Message:

Q - Merged branches/2.0singleton into trunk. Completed updating classes to use singleton methods. Implemented tests. Fixed some bugs. Changed some interfaces.

Location:
trunk/bin
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/file_importer.php

    r111 r136  
    77
    88require realpath(dirname(__FILE__) . '/..') . '/config/cli_config.inc.php';
     9
     10$app =& App::getInstance();
     11$db =& DB::getInstance();
     12   
    913
    1014// Test arguments.
     
    3135            preg_match('/BALANCE:\s*\$([\.\d]+)/', $file_text, $amt);
    3236            $file_date = date('Y-m-d', strtotime(preg_replace('|[^_]*_|', '', basename($file))));
    33 //             DB::query("
     37//             $db->query("
    3438//                 INSERT INTO invoice_tbl (
    3539//                     client_id,
     
    4347//                     added_datetime
    4448//                 ) VALUES (
    45 //                     '" . DB::escapeString(0) . "',
    46 //                     '" . DB::escapeString('hosting') . "',
    47 //                     '" . DB::escapeString($file_date) . "',
    48 //                     '" . DB::escapeString($amt[1]) . "',
    49 //                     '" . DB::escapeString('Paid') . "',
    50 //                     '" . DB::escapeString('') . "',
    51 //                     '" . DB::escapeString($file_text) . "',
    52 //                     '" . DB::escapeString($file_date) . "',
     49//                     '" . $db->escapeString(0) . "',
     50//                     '" . $db->escapeString('hosting') . "',
     51//                     '" . $db->escapeString($file_date) . "',
     52//                     '" . $db->escapeString($amt[1]) . "',
     53//                     '" . $db->escapeString('Paid') . "',
     54//                     '" . $db->escapeString('') . "',
     55//                     '" . $db->escapeString($file_text) . "',
     56//                     '" . $db->escapeString($file_date) . "',
    5357//                     NOW()
    5458//                 )
     
    5660
    5761        } else {
    58             App::logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
     62            $app->logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
    5963        }
    6064    }
    61     App::logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
     65    $app->logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
    6266} else {
    63     App::logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
     67    $app->logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
    6468}
    6569
  • trunk/bin/module_maker/_config.inc.php

    r19 r136  
    3030
    3131$app =& App::getInstance('module_maker');
    32 
    3332$app->setParam(array(
    3433    'site_name' => 'Module Maker',
     
    4342    'log_screen_priority' => LOG_DEBUG,
    4443));
    45 
    4644require_once 'global/db_auth.inc.php';
    4745
     46// Start application-based functionality: database, session, environment, ini setup, etc.
     47// Most configuration parameters must be set before starting the App.
    4848$app->start();
    4949
     50// Global DB object. Automatically preconfigured by $app->start().
     51$db =& DB::getInstance();
     52
     53
    5054?>
  • trunk/bin/module_maker/form_template.cli.php

    r121 r136  
    1717
    1818// Get DB tables.
    19 $qid = DB::query("SHOW TABLES");
     19$qid = $db->query("SHOW TABLES");
    2020while (list($row) = mysql_fetch_row($qid)) {
    2121    $tables[] = $row;
     
    2424// Make sure requested table is in database.
    2525if (!in_array($db_tbl, $tables)) {
    26     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     26    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    2727}
    2828
    2929// Get DB table column info.
    30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     30$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    3131while ($row = mysql_fetch_row($qid)) {
    3232    $cols[] = $row;
     
    6565<label for="$field"<\x3fphp \$fv->err('$field') \x3f>><\x3fphp echo _("$title"); \x3f></label>
    6666<select name="$field" id="$field" class="sc-small"><\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f></select>
    67     <span class="commanditem commandtext"><a href="<\x3fphp echo App::oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span>
     67    <span class="commanditem commandtext"><a href="<\x3fphp echo \$app->oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span>
    6868    <\x3fphp if ('' != \$frm['<##>_id']) { \x3f>
    69     <span class="commanditem commandtext"><a href="<\x3fphp echo App::oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span>
     69    <span class="commanditem commandtext"><a href="<\x3fphp echo \$app->oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span>
    7070    <\x3fphp } \x3f>
    7171E_O_F;
  • trunk/bin/module_maker/list_template.cli.php

    r121 r136  
    3030
    3131// Get DB tables.
    32 $qid = DB::query("SHOW TABLES");
     32$qid = $db->query("SHOW TABLES");
    3333while (list($row) = mysql_fetch_row($qid)) {
    3434    $tables[] = $row;
     
    3737// Make sure requested table is in database.
    3838if (!in_array($db_tbl, $tables)) {
    39     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     39    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    4040}
    4141
    4242// Get DB table column info.
    43 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     43$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    4444while ($row = mysql_fetch_row($qid)) {
    4545    $cols[] = $row;
     
    8080            $listrows[] = "<\x3fphp echo strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>";
    8181        } else if (preg_match('/.*(begin|start).*date.*/i', $field)) {
    82             $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     82            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8383        } else if (preg_match('/.*(end|expire).*date.*/i', $field)) {
    84             $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     84            $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8585        } else if (preg_match('/datetime/i', $type)) {
    86             $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     86            $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8787        } else if (preg_match('/date/i', $type)) {
    88             $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     88            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8989        } else if (preg_match('/(amount|_rate)/i', $field)) {
    9090            $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>";
     
    110110<div id="commandbox">
    111111<form action="<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>" method="get">
    112 <\x3fphp App::printHiddenSession(false); \x3f>
    113     <span class="sc-nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
     112<\x3fphp \$app->printHiddenSession(false); \x3f>
     113    <span class="sc-nowrap commandtext"><a href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
    114114    <br />
    115115
     
    149149    <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f>
    150150    <tr>
    151         <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
    152         <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
     151        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
     152        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
    153153
    154154E_O_F;
     
    164164
    165165echo isset($op) ? '' : <<<E_O_F
    166         <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     166        <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
    167167    </tr>
    168168    <\x3fphp } \x3f>
  • trunk/bin/module_maker/module.cli.php

    r119 r136  
    129129
    130130// Get DB tables.
    131 $qid = DB::query("SHOW TABLES");
     131$qid = $db->query("SHOW TABLES");
    132132while (list($row) = mysql_fetch_row($qid)) {
    133133    $tables[] = $row;
     
    136136// Make sure requested table is in database.
    137137if (!in_array($db_tbl, $tables)) {
    138     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     138    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    139139}
    140140
    141141// Ensure requested table contains columns.
    142142// Get DB table column info.
    143 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     143$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    144144while ($row = mysql_fetch_row($qid)) {
    145145    $cols[] = $row;
     
    266266        // If file upload errors, redirect to edit operation for the inserted record.
    267267        if (\$upload->anyErrors() || false === \$new_file) {
    268             App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
     268            \$app->dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
    269269        }
    270270E_O_F;
     
    300300
    301301$search['date'] = '/%DATE%/';
    302 $replace['date'] = date(App::getParam('date_format'));
     302$replace['date'] = date($app->getParam('date_format'));
    303303
    304304$search['name_plural'] = '/%NAME_PLURAL%/';
  • trunk/bin/module_maker/skel/adm_form.ihtml

    r51 r136  
    22
    33%ADMIN_FORM_TAG_INIT%
    4 <?php App::printHiddenSession(); ?>
     4<?php $app->printHiddenSession(); ?>
    55<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
    66<input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>" />
  • trunk/bin/module_maker/skel/adm_list.ihtml

    r124 r136  
    44<div id="commandbox">
    55<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
    6 <?php App::printHiddenSession(false); ?>
    7     <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span>
     6<?php $app->printHiddenSession(false); ?>
     7    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span>
    88    <br />
    99
     
    1717
    1818<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    19 <?php App::printHiddenSession(); ?>
     19<?php $app->printHiddenSession(); ?>
    2020<?php include 'list_info.ihtml'; ?>
    2121<table class="list">
     
    2828    <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
    2929    <tr>
    30         <td class="sc-padleft sc-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="sc-padleft sc-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>
     30        <td class="sc-padleft sc-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="sc-padleft sc-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>
    3232%ADM_LIST_ROWS%
    33         <td class="sc-padleft sc-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>
     33        <td class="sc-padleft sc-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>
    3434    </tr>
    3535    <?php } ?>
  • trunk/bin/module_maker/skel/admin.php

    r111 r136  
    1111$auth->requireLogin();
    1212// $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%);
    13 App::sslOn();
     13$app->sslOn();
    1414
    1515require_once 'codebase/lib/PageNumbers.inc.php';
     
    3333$fv = new FormValidator();
    3434
     35$cache =& SessionCache::getInstance();
     36
    3537%SORT_ORDER%
    3638
     
    4143
    4244// Search limiters retain their values between page requests.
    43 App::carryQuery('search_query');
    44 App::carryQuery('filter_<##>');
     45$app->carryQuery('search_query');
     46$app->carryQuery('filter_<##>');
    4547%ADMIN_UPLOAD_CONFIG%
    4648/******************************************************************************
     
    5153// allows us to remember which page we came from so we can go back there.
    5254if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    53     App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
     55    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
    5456}
    5557
    5658if (getFormData('break_list_cache', false)) {
    5759    // Break the cache because we are changing the list data.
    58     SessionCache::breakCache($_SERVER['PHP_SELF']);
     60    $cache->delete($_SERVER['PHP_SELF']);
    5961}
    6062
     
    8183//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
    8284    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
    83     if (App::validBoomerangURL('%NAME_PLURAL%')) {
     85    if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    8486        // Display boomerang page.
    85         App::dieBoomerangURL('%NAME_PLURAL%');
     87        $app->dieBoomerangURL('%NAME_PLURAL%');
    8688    }
    8789    // Display default page.
    88     App::dieURL($_SERVER['PHP_SELF']);
     90    $app->dieURL($_SERVER['PHP_SELF']);
    8991    break;
    9092
     
    9294//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD);
    9395    if (getFormdata('cancel', false)) {
    94         if (App::validBoomerangURL('%NAME_PLURAL%')) {
     96        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    9597            // Display boomerang page.
    96             App::dieBoomerangURL('%NAME_PLURAL%');
     98            $app->dieBoomerangURL('%NAME_PLURAL%');
    9799        }
    98100        // Display default page.
    99         App::dieURL($_SERVER['PHP_SELF']);
     101        $app->dieURL($_SERVER['PHP_SELF']);
    100102    }
    101103    validateInput();
     
    109111        if (getFormdata('repeat', false)) {
    110112            // Display function again.
    111             App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
    112         } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
     113            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
     114        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    113115            // Display boomerang page.
    114             App::dieBoomerangURL('%NAME_PLURAL%');
     116            $app->dieBoomerangURL('%NAME_PLURAL%');
    115117        }
    116118        // Display default page.
    117         App::dieURL($_SERVER['PHP_SELF']);
     119        $app->dieURL($_SERVER['PHP_SELF']);
    118120    }
    119121    break;
     
    122124//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_EDIT);
    123125    if (getFormdata('reset', false)) {
    124         App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
    125         App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
     126        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
     127        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
    126128    }
    127129    if (getFormdata('cancel', false)) {
     
    129131        $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%'));
    130132        $lock->remove();
    131         if (App::validBoomerangURL('%NAME_PLURAL%')) {
     133        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    132134            // Display boomerang page.
    133             App::dieBoomerangURL('%NAME_PLURAL%');
     135            $app->dieBoomerangURL('%NAME_PLURAL%');
    134136        }
    135137        // Display default page.
    136         App::dieURL($_SERVER['PHP_SELF']);
     138        $app->dieURL($_SERVER['PHP_SELF']);
    137139    }
    138140    validateInput();
     
    146148        if (getFormdata('repeat', false)) {
    147149            // Display edit function with next available ID.
    148             $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
     150            $qid = $db->query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
    149151            if (list($next_id) = mysql_fetch_row($qid)) {
    150                 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
     152                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
    151153            } else {
    152                 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
     154                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
    153155            }
    154         } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
     156        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    155157            // Display boomerang page.
    156             App::dieBoomerangURL('%NAME_PLURAL%');
     158            $app->dieBoomerangURL('%NAME_PLURAL%');
    157159        }
    158160        // Display default page.
    159         App::dieURL($_SERVER['PHP_SELF']);
     161        $app->dieURL($_SERVER['PHP_SELF']);
    160162    }
    161163    break;
     
    164166//     $auth->requireAccessClearance(ZONE_ADMIN_PROGRAMS_FUNC_REORDER);
    165167    updateRank(getFormData('rank'));
    166     App::dieURL($_SERVER['PHP_SELF']);
     168    $app->dieURL($_SERVER['PHP_SELF']);
    167169    break;
    168170
     
    207209{
    208210    global $lock;
    209 
     211    $db =& DB::getInstance();
     212   
    210213    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    211214    if ($lock->isLocked() && !$lock->isMine()) {
     
    214217
    215218    // Get the information for the form.
    216     $qid = DB::query("
     219    $qid = $db->query("
    217220        SELECT *
    218221        FROM %DB_TBL%
    219         WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     222        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    220223    ");
    221224    if (!$frm = mysql_fetch_assoc($qid)) {
    222         App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    223         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    224         App::dieBoomerangURL();
     225        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     226        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     227        $app->dieBoomerangURL();
    225228    }
    226229
     
    246249{
    247250    global $lock;
    248 
     251    $db =& DB::getInstance();
     252    $cache =& SessionCache::getInstance();
     253   
    249254    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    250255    if ($lock->isLocked() && !$lock->isMine()) {
     
    253258
    254259    // Break the cache because we are changing the list data.
    255     SessionCache::breakCache($_SERVER['PHP_SELF']);
     260    $cache->delete($_SERVER['PHP_SELF']);
    256261
    257262    // Get the information for this object.
    258     $qid = DB::query("
     263    $qid = $db->query("
    259264        SELECT <##>
    260265        FROM %DB_TBL%
    261         WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     266        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    262267    ");
    263268    if (! list($name) = mysql_fetch_row($qid)) {
    264         App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    265         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    266         App::dieBoomerangURL();
     269        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     270        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     271        $app->dieBoomerangURL();
    267272    }
    268273
    269274    // Delete the record.
    270     DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'");
    271 
    272     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
     275    $db->query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'");
     276
     277    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
    273278
    274279    // Unlock record.
     
    279284{
    280285    global $auth;
    281 
     286    $db =& DB::getInstance();
     287    $cache =& SessionCache::getInstance();
     288   
    282289    // Break the cache because we are changing the list data.
    283     SessionCache::breakCache($_SERVER['PHP_SELF']);
     290    $cache->delete($_SERVER['PHP_SELF']);
    284291
    285292%INSERT%
    286     $last_insert_id = mysql_insert_id(DB::getDBH());
     293    $last_insert_id = mysql_insert_id($db->getDBH());
    287294
    288295    // Create version.
     
    290297    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
    291298
    292     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
     299    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
    293300
    294301    return $last_insert_id;
     
    297304function updateRecord($frm)
    298305{
    299     global $auth, $lock;
    300 
     306    global $auth, $lock;
     307    $app =& App::getInstance();
     308    $cache =& SessionCache::getInstance();
     309   
    301310    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
    302311    if ($lock->isLocked() && !$lock->isMine()) {
     
    305314
    306315    // Break the cache because we are changing the list data.
    307     SessionCache::breakCache($_SERVER['PHP_SELF']);
     316    $cache->delete($_SERVER['PHP_SELF']);
    308317
    309318%UPDATE%
     
    313322    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
    314323
    315     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
     324    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
    316325
    317326    // Unlock record.
     
    323332    global $page;
    324333    global $so;
    325 
     334    $db =& DB::getInstance();
     335    $prefs =& Prefs::getInstance();
     336    $cache =& SessionCache::getInstance();
     337   
    326338    $where_clause = '';
    327339
     
    336348    if (getFormData('filter_<##>', false)) {
    337349        // Limit by filter.
    338         $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . DB::escapeString(getFormData('filter_<##>')) . "'";
     350        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . $db->escapeString(getFormData('filter_<##>')) . "'";
    339351    }
    340352
    341353    // Count the total number of records so we can do something about the page numbers.
    342     $qid = DB::query("
     354    $qid = $db->query("
    343355        SELECT COUNT(*)
    344356        FROM %DB_TBL%
     
    371383    // without knowing the hash.
    372384    $cache_hash = md5($sql . '|' . $page->total_items);
    373     if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
    374         SessionCache::breakCache($_SERVER['PHP_SELF']);
    375         Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    376     }
    377 
    378     if (SessionCache::isCached($_SERVER['PHP_SELF'])) {
     385    if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
     386        $cache->delete($_SERVER['PHP_SELF']);
     387        $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
     388    }
     389
     390    if ($cache->exists($_SERVER['PHP_SELF'])) {
    379391        // Get the cached results.
    380         $list = SessionCache::getCache($_SERVER['PHP_SELF']);
     392        $list = $cache->get($_SERVER['PHP_SELF']);
    381393    } else {
    382394        // If the list is not already cached, query now.
    383         $qid = DB::query($sql);
     395        $qid = $db->query($sql);
    384396        // Fill an array with the items for this page.
    385397        while ($row = mysql_fetch_assoc($qid)) {
     
    389401        if (isset($list) && !empty($list)) {
    390402            // Cache the results.
    391             SessionCache::putCache($list, $_SERVER['PHP_SELF']);
     403            $cache->set($list, $_SERVER['PHP_SELF']);
    392404        }
    393405    }
     
    398410function updateRank($ranks)
    399411{
     412    $db =& DB::getInstance();
     413    $cache =& SessionCache::getInstance();
     414   
    400415    if (!is_array($ranks)) {
    401         App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
     416        $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
    402417        return false;
    403418    }
    404419
    405420    // Break the cache because we are changing the list data.
    406     SessionCache::breakCache($_SERVER['PHP_SELF']);
     421    $cache->delete($_SERVER['PHP_SELF']);
    407422
    408423    // Count the ranks with invalid numbers
     
    416431            $unspecified_counter++;
    417432        }
    418         DB::query("
     433        $db->query("
    419434            UPDATE %DB_TBL% SET
    420                 rank = '" . DB::escapeString($new_rank) . "'
    421             WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     435                rank = '" . $db->escapeString($new_rank) . "'
     436            WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    422437        ");
    423438    }
    424439
    425     App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
     440    $app->raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
    426441    if ($unspecified_counter > 0) {
    427         App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     442        $app->raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
    428443    }
    429444}
  • trunk/bin/module_maker/skel/public.ihtml

    r1 r136  
    11<p><?php echo nl2br(fancyTxt(oTxt($item['content'], true))); ?></p>
    2 <p><em><?php echo sprintf(_("Published %s"), date(App::getParam('date_format'), strtotime($item['<##>']))); ?></em></p>
     2<p><em><?php echo sprintf(_("Published %s"), date($app->getParam('date_format'), strtotime($item['<##>']))); ?></em></p>
    33
    44<!--
  • trunk/bin/module_maker/skel/public.php

    r111 r136  
    3434
    3535    // Get requested record.
    36     $qid = DB::query("
     36    $qid = $db->query("
    3737        SELECT * FROM %DB_TBL%
    38         WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
     38        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
    3939        AND publish = 'true'
    4040        <##>AND (publish_date <= CURDATE() OR publish_date = '0000-00-00')
     
    4242    ");
    4343    if (!$item = mysql_fetch_assoc($qid)) {
    44         App::raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
    45         App::dieBoomerangURL();
     44        $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
     45        $app->dieBoomerangURL();
    4646    }
    4747
    4848    // Update the hit counter for this record.
    49     DB::query("
     49    $db->query("
    5050        UPDATE %DB_TBL%
    5151        SET hit_count = hit_count + 1
    52         WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
     52        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
    5353    ");
    5454
     
    6161    // Get the DEFAULT list.
    6262    $%NAME_SINGULAR%_list = array();
    63     $qid = DB::query("
     63    $qid = $db->query("
    6464        SELECT *
    6565        FROM %DB_TBL%
     
    7979    // Get the FEATURED list.
    8080    $featured_list = array();
    81     $qid = DB::query("
     81    $qid = $db->query("
    8282        SELECT *
    8383        FROM %DB_TBL%
     
    9292    // Get the POPULAR list.
    9393    $popular_list = array();
    94     $qid = DB::query("
     94    $qid = $db->query("
    9595        SELECT *
    9696        FROM %DB_TBL%
     
    104104    // Get the RECENT list.
    105105    $recent_list = array();
    106     $qid = DB::query("
     106    $qid = $db->query("
    107107        SELECT *
    108108        FROM %DB_TBL%
  • trunk/bin/module_maker/skel/public_list.ihtml

    r42 r136  
    55        ?>
    66        <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?>
    7             <h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></a></h4>
     7            <h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></a></h4>
    88        <?php } else { ?>
    99            <h4><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></h4>
    1010        <?php } ?>
    1111        <p>
    12         <em><?php echo date(App::getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> &mdash; <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?>
     12        <em><?php echo date($app->getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> &mdash; <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?>
    1313
    1414        <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?>
    15             <br /><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a>
     15            <br /><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a>
    1616        <?php } ?>
    1717        </p>
     
    3232    <?php
    3333    foreach ($featured_list as $item) {
    34         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php
     34        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php
    3535    }
    3636}
     
    4444    <?php
    4545    foreach ($popular_list as $item) {
    46         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
     46        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
    4747    }
    4848}
     
    5656    <?php
    5757    foreach ($recent_list as $item) {
    58         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
     58        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
    5959    }
    6060}
  • trunk/bin/module_maker/sql.cli.php

    r111 r136  
    3030
    3131// Get DB tables.
    32 $qid = DB::query("SHOW TABLES");
     32$qid = $db->query("SHOW TABLES");
    3333while (list($row) = mysql_fetch_row($qid)) {
    3434    $tables[] = $row;
     
    3737// Make sure requested table is in database.
    3838if (!in_array($db_tbl, $tables)) {
    39     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     39    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    4040}
    4141
     
    4646
    4747// Get DB table column info.
    48 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     48$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    4949while ($row = mysql_fetch_row($qid)) {
    5050    $cols[] = $row;
     
    7676        } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) {
    7777            // Toggle types.
    78             $c[$field] = "'\" . DB::escapeString(\$auth->getVal('user_id')) . \"'";
     78            $c[$field] = "'\" . \$db->escapeString(\$auth->getVal('user_id')) . \"'";
    7979        } else if ('added_datetime' == $field || 'modified_datetime' == $field) {
    8080            // DB record insertion datetime.
     
    8282        } else {
    8383            // Default. Just insert data.
    84             $c[$field] = "'\" . DB::escapeString(\$frm['$field']) . \"'";
     84            $c[$field] = "'\" . \$db->escapeString(\$frm['$field']) . \"'";
    8585        }
    8686    }
     
    107107echo <<<E_O_F
    108108    // Insert record data.
    109     DB::query("
     109    \$db->query("
    110110        INSERT INTO $db_tbl (
    111111            $db_keys
     
    133133echo <<<E_O_F
    134134    // Update record data.
    135     DB::query("
     135    \$db->query("
    136136        UPDATE $db_tbl SET$key_eq_val
    137         WHERE $primary_key = '" . DB::escapeString(\$frm['$primary_key']) . "'
     137        WHERE $primary_key = '" . \$db->escapeString(\$frm['$primary_key']) . "'
    138138    ");
    139139E_O_F;
     
    148148$delim = 'WHERE';
    149149if (!empty($primary_key)) {
    150     $where_clause = "            $delim $primary_key = '\" . DB::escapeString(\$frm['$primary_key']) . \"'\n";
     150    $where_clause = "            $delim $primary_key = '\" . \$db->escapeString(\$frm['$primary_key']) . \"'\n";
    151151    $delim = 'AND';
    152152}
     
    155155        continue;
    156156    }
    157     $where_clause .= "            $delim $k = '\" . DB::escapeString(\$frm['$k']) . \"'\n";
     157    $where_clause .= "            $delim $k = '\" . \$db->escapeString(\$frm['$k']) . \"'\n";
    158158    $delim = 'AND';
    159159}
    160160echo <<<E_O_F
    161161        // Delete record data.
    162         DB::query("
     162        \$db->query("
    163163            DELETE FROM $db_tbl
    164164$where_clause        ");
     
    183183if (!isset($op) || 'search' == $op) {
    184184$search_skip_columns = array('added_datetime', 'added_by_user_id', 'modified_datetime', 'modified_by_user_id', 'publish', 'featured');
    185 $search_columns = $db_tbl . '.' . join(" LIKE '%\" . DB::escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
     185$search_columns = $db_tbl . '.' . join(" LIKE '%\" . \$db->escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
    186186echo <<<E_O_F
    187187            \$where_clause .= (empty(\$where_clause) ? 'WHERE' : 'AND') . "
    188188                (
    189                     $search_columns LIKE '%" . DB::escapeString(\$qry_words[\$i]) . "%'
     189                    $search_columns LIKE '%" . \$db->escapeString(\$qry_words[\$i]) . "%'
    190190                )
    191191            ";
  • trunk/bin/module_maker/validation.cli.php

    r111 r136  
    1717
    1818// Get DB tables.
    19 $qid = DB::query("SHOW TABLES");
     19$qid = $db->query("SHOW TABLES");
    2020while (list($row) = mysql_fetch_row($qid)) {
    2121    $tables[] = $row;
     
    2424// Make sure requested table is in database.
    2525if (!in_array($db_tbl, $tables)) {
    26     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     26    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    2727}
    2828
    2929// Get DB table column info.
    30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     30$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    3131while ($row = mysql_fetch_row($qid)) {
    3232    $cols[] = $row;
     
    277277// natsort($o);
    278278
     279// Remove last empty element.
     280if ('' == end($o)) {
     281    array_pop($o);
     282}
     283
    279284echo "function validateInput()
    280285{
    281286    global \$fv;
    282287
    283     ";
    284 echo join("\n    ", $o);
    285 echo "
     288    " . join("\n    ", $o) . "
    286289}";
    287290?>
Note: See TracChangeset for help on using the changeset viewer.