Changeset 316


Ignore:
Timestamp:
Mar 12, 2008 1:47:19 AM (16 years ago)
Author:
quinn
Message:

Minor improvements to module maker scripts. Minor AuthorizeNet? change.

Location:
trunk
Files:
1 added
8 edited

Legend:

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

    r295 r316  
    5454        // Human readable.
    5555        $field = $col[0];
     56        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    5657        $title = ucfirst(str_replace('_', ' ', $field));
    57         $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
     58
     59        switch ($field) {
     60        case 'added_by_user_id' :
     61        case 'modified_by_user_id' :
     62            $title = "by";
     63            break;
     64
     65        case 'added_datetime' :
     66        case 'modified_datetime' :
     67            $title = str_replace(' datetime', '', $title);
     68            break;
     69        }
    5870
    5971        // Get primary key.
     
    136148if (!isset($op) || 'headerrows' == $op) {
    137149    foreach ($headers as $field=>$title) {
     150        if (preg_match('/(_date|_datetime|_time|price|value|quantity)/', $field)) {
     151            $ordering = 'DESC';
     152        } else {
     153            $ordering = 'ASC';
     154        }
     155
    138156        if ($field == $primary_key) {
    139             echo "        <th><\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"ID\"), 'ASC'); \x3f></th>\n";
     157            echo "        <th><\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"ID\"), 'DESC'); \x3f></th>\n";
    140158        } else {
    141             echo "        <th><\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"$title\"), 'ASC'); \x3f></th>\n";
     159            echo "        <th><\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"$title\"), '$ordering'); \x3f></th>\n";
    142160        }
    143161    }
     
    149167    <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f>
    150168    <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>
     169        <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/i/pen.gif" alt="Edit" width="12" height="12" border="0" /></a> &nbsp;</td>
     170        <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/i/multiple.png" alt="" width="12" height="12" border="0" /></a> &nbsp;</td>
    153171
    154172E_O_F;
     
    164182
    165183echo 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>
     184        <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/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    167185    </tr>
    168186    <\x3fphp } \x3f>
  • trunk/bin/module_maker/module.cli.php

    r295 r316  
    118118// Ensure essential directories exist.
    119119if (!is_dir("$admin_dir")) {
    120     die(basename($_SERVER['argv'][0]) . " Error: $admin_dir directory not found.\n");
     120    die(basename($_SERVER['argv'][0]) . " Error: admin_dir '$admin_dir' directory not found.\n");
    121121}
    122122if (!is_dir("$admin_tpl_dir")) {
    123     die(basename($_SERVER['argv'][0]) . " Error: $admin_tpl_dir directory not found.\n");
     123    die(basename($_SERVER['argv'][0]) . " Error: admin_tpl_dir '$admin_tpl_dir' directory not found.\n");
    124124}
    125125if (!is_dir("$public_dir")) {
    126     die(basename($_SERVER['argv'][0]) . " Error: $public_dir directory not found.\n");
     126    die(basename($_SERVER['argv'][0]) . " Error: public_dir '$public_dir' directory not found.\n");
    127127}
    128128if (!is_dir("$public_tpl_dir")) {
    129     die(basename($_SERVER['argv'][0]) . " Error: $public_tpl_dir directory not found.\n");
     129    die(basename($_SERVER['argv'][0]) . " Error: public_tpl_dir '$public_tpl_dir' directory not found.\n");
    130130}
    131131
     
    174174        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    175175        $default = $col[4];
     176       
     177        if (mb_strpos($default, '0000') !== false || '0' == $default) {
     178            $default = '';
     179        }
    176180
    177181        // Get primary key.
  • trunk/bin/module_maker/skel/adm_list.ihtml

    r295 r316  
    2626    <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
    2727    <tr>
    28         <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>
    29         <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>
     28        <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/i/pen.gif" alt="Edit" width="12" height="12" border="0" /></a> &nbsp;</td>
     29        <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/i/multiple.png" alt="" width="12" height="12" border="0" /></a> &nbsp;</td>
    3030%ADM_LIST_ROWS%
    31         <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>
     31        <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/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    3232    </tr>
    3333    <?php } ?>
  • trunk/docs/examples/_config.inc.php

    r295 r316  
    3939    'site_email' => 'hello@example.com',
    4040    'redirect_home_url' => '/',
     41    'images_path' => '/i',
    4142
    4243    'date_format' => 'd M Y',
  • trunk/lib/AuthorizeNet.inc.php

    r250 r316  
    4242
    4343    var $post_url = ''; // The URL to post data to.
    44     var $md5_hash_value = ','; // A custom value for the response delimination character.
    4544    var $_results = array();
    4645    var $_params = array();
     
    5756        'x_delim_char'      => ',',
    5857        'x_encap_char'      => '',
     58        'md5_hash_salt'    => '',
    5959    );
    6060
     
    111111    function AuthorizeNet($params = array())
    112112    {
     113        $app =& App::getInstance();
     114
    113115        if (!function_exists('curl_init')) {
    114116            trigger_error('AuthorizeNet error: curl not installed.', E_USER_ERROR);
     
    118120        $this->post_url = isset($params['post_url']) ? $params['post_url'] : 'https://secure.authorize.net/gateway/transact.dll';
    119121
    120         // A custom value for the response delimination character.
    121         $this->md5_hash_value = isset($params['md5_hash_value']) ? $params['md5_hash_value'] : '';
    122 
    123122        // Set default parameters.
    124123        $this->_params = $this->_default_params;
     124       
     125        $this->setParam(array('md5_hash_salt' => $app->getParam('signing_key')));
    125126    }
    126127
     
    239240        return (
    240241            mb_strtolower($this->getResult('x_md5_hash')) == mb_strtolower(md5(
    241                 $this->md5_hash_value .
     242                $this->getParam('md5_hash_salt') .
    242243                $this->getParam('x_login') .
    243244                $this->getResult('x_trans_id') .
  • trunk/lib/Cache.inc.php

    r247 r316  
    133133
    134134        if (true !== $this->getParam('enabled')) {
    135             $app->logMsg(sprintf('Cache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
     135            $app->logMsg(sprintf('Cache disabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
    136136            return false;
    137137        }
     
    182182
    183183        if (true !== $this->getParam('enabled')) {
    184             $app->logMsg(sprintf('Cache not enabled, not getting data.', null), LOG_DEBUG, __FILE__, __LINE__);
     184            $app->logMsg(sprintf('Cache disabled, not getting data.', null), LOG_DEBUG, __FILE__, __LINE__);
    185185            return false;
    186186        }
  • trunk/lib/SortOrder.inc.php

    r281 r316  
    2020    var $sort_by;
    2121    var $order;
    22     var $asc_widget = '<img src="/admin/_widgets/sort_ascending.gif" alt="[ASC]" width="11" height="7" border="0" />';
    23     var $desc_widget = '<img src="/admin/_widgets/sort_descending.gif" alt="[DESC]" width="11" height="7" border="0" />';
     22    var $asc_widget;
     23    var $desc_widget;
    2424    var $default_sort;
    2525    var $default_order;
     
    3535    function SortOrder($default_sort = '', $default_order = '')
    3636    {
     37        $app =& App::getInstance();
     38       
     39        // Setup the HTML for printing ASC/DESC paths.
     40        // This should be converted to CSS someday.
     41        $images_path = $app->getParam('images_path') ? $app->getParam('images_path') : '/admin/_widgets';
     42        $this->asc_widget = sprintf('<img src="%s/sort_ascending.gif" alt="%s" width="11" height="7" border="0" />', $images_path, _("Ascending"));
     43        $this->desc_widget = sprintf('<img src="%s/sort_descending.gif" alt="%s" width="11" height="7" border="0" />', $images_path, _("Ascending"));
     44       
     45        // Setup prefs object.
    3746        $this->prefs = new Prefs($_SERVER['PHP_SELF']);
    3847        $this->prefs->setParam(array('persistent' => false));
    3948
     49        // Setup defaults.
    4050        $this->setDefault($default_sort, $default_order);
    41 
    4251        $this->default_sort = $default_sort;
    43         $this->default_order = $default_order;       
     52        $this->default_order = $default_order;
    4453    }
    4554
  • trunk/services/templates/admin_list.ihtml

    r295 r316  
    3232    <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
    3333    <tr>
    34         <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0" /></a> &nbsp;</td>
    35         <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF(sprintf('/admin/versions.php?record_table=%s&record_key=%s&record_val=%s&boomerang=true', $auth->getParam('db_table'), $auth->getParam('db_primary_key'), $list[$i]['admin_id'])); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
     34        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/i/pen.gif" alt="Edit" width="12" height="12" border="0" /></a> &nbsp;</td>
     35        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF(sprintf('/admin/versions.php?record_table=%s&record_key=%s&record_val=%s&boomerang=true', $auth->getParam('db_table'), $auth->getParam('db_primary_key'), $list[$i]['admin_id'])); ?>"><img src="/admin/i/multiple.png" alt="" width="12" height="12" border="0" /></a> &nbsp;</td>
    3636        <td class="sc-nowrap"><?php echo oTxt($list[$i]['admin_id'], true); ?> &nbsp;</td>
    3737        <td class="sc-nowrap"><?php echo oTxt($list[$i]['username'], true); ?> &nbsp;</td>
     
    5050        <td class="sc-nowrap"><?php echo oTxt($list[$i]['added_admin_username'], true); ?> &nbsp;</td>
    5151        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
    52         <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" 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]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0" /></a> &nbsp;</td>
     52        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" 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]['username'])) ?>')"><img src="/admin/i/trash.gif" alt="Delete" width="10" height="10" border="0" /></a> &nbsp;</td>
    5353    </tr>
    5454    <?php } ?>
Note: See TracChangeset for help on using the changeset viewer.