Ignore:
Timestamp:
Jul 27, 2015 7:56:08 AM (9 years ago)
Author:
anonymous
Message:

Improved module maker validation output. Allow disabling cache at run time for ACL. Added ACL getList() method. Improved ACL CLI listing. Fixed app boomerang array initialization. Now retaining identical boomerang URLs if the key is different. Added a maximum boomerang time. Added a way to disable cache per request through a query string. Added validator isDecimal() method. Added disableSelectOptions() HTML method. Added getGravatarURL() method. Change how navigation page array is managed. Updated navigation currentPage() method to test an array of URLs.

File:
1 edited

Legend:

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

    r533 r534  
    7373        $field = $col[0];
    7474        $title = ucfirst(str_replace('_', ' ', $field));
    75         $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
     75        $type = preg_replace('/^(\w+).*$/', '$1', $col[1]);
     76        $max_dig = preg_replace('/^\w+\((\d+)(?:,\d+)?\).*$/', '$1', $col[1]);
     77        $max_dec = preg_replace('/^\w+\((?:\d+)(?:,(\d+))?\).*$/', '$1', $col[1]);
    7678        $is_primary_key = ('PRI' == $col[3]);
    7779        $unsigned = preg_match('/\s+unsigned\s*$/i', $col[1]);
     
    110112        case 'varchar' :
    111113            $len_type = 'string';
    112             $max_length = 255;
     114            $max_length = '' != $max_dig ? $max_dig : 255;
    113115            break;
    114116
     
    131133            break;
    132134
     135        case 'bit' :
     136            $len_type = 'num';
     137            $min = 0;
     138            $max = '' != $max_dig ? $max_dig : 64;
     139            break;
     140
    133141        case 'tinyint' :
    134         case 'bit' :
    135142        case 'bool' :
    136143            $len_type = 'num';
     
    191198        case 'float' :
    192199            $len_type = 'num';
    193             $min = -3.40282E+38;
    194             $max = 3.40282E+38;
     200            if ($unsigned) {
     201                $min = 0;
     202                $max = 3.40282E+38;
     203            } else {
     204                $min = -3.40282E+38;
     205                $max = 3.40282E+38;
     206            }
    195207            break;
    196208
    197209        case 'double' :
    198210        case 'double precision' :
     211            $len_type = 'num';
     212            if ($unsigned) {
     213                $min = 0;
     214                $max = 1.7976931348623157E+308;
     215            } else {
     216                $min = -1.7976931348623157E+308;
     217                $max = 1.7976931348623157E+308;
     218            }
     219            break;
     220
    199221        case 'real' :
    200222        case 'decimal' :
    201223        case 'dec' :
    202224        case 'numeric' :
    203             $len_type = 'num';
    204             $min = -1.79769E+308;
    205             $max = 1.79769E+308;
     225        case 'fixed' :
     226            $len_type = 'decimal'; // This doesn't match anything, on purpose.
    206227            break;
    207228
     
    255276
    256277        case 'float' :
    257         case 'float' :
    258278        case 'double' :
    259         case 'double' :
     279            $negative_ok = $unsigned ? '' : ', true';
     280            $o[] = "\$fv->isFloat('$field', sprintf(_(\"%s must be a valid number.\"), _(\"$title\"))$negative_ok);";
     281            break;
     282
    260283        case 'real' :
    261284        case 'decimal' :
    262285        case 'dec' :
    263286        case 'numeric' :
    264             $negative_ok = $unsigned ? '' : ', true';
    265             $o[] = "\$fv->isFloat('$field', sprintf(_(\"%s must be a valid number.\"), _(\"$title\"))$negative_ok);";
     287        case 'float' :
     288            $max = str_repeat('9', $max_dig - $max_dec);
     289            if ($max_dec > 0) {
     290                $max .= '.' . str_repeat('9', $max_dec);
     291            }
     292            if ($unsigned) {
     293                $negative_ok = 'false';
     294                $min = 0;
     295            } else {
     296                $negative_ok = 'true';
     297                $min = -$max;
     298            }
     299            $negative_ok = $unsigned ? 'false' : 'true';
     300            $o[] = "\$fv->isDecimal('$field', sprintf(_(\"%s must be a number between %d and %d.\"), _(\"$title\"), $min, $max), $negative_ok, $max_dig, $max_dec);";
    266301            break;
    267302
Note: See TracChangeset for help on using the changeset viewer.