/[cvs]/nfo/php/libs/org.netfrag.flib/utils/helper.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/utils/helper.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Tue Nov 12 05:42:31 2002 UTC revision 1.4 by jonen, Sun Dec 22 13:29:54 2002 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -----------------------------------------------------------------------------  //    -----------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.4  2002/12/22 13:29:54  jonen
7    //    + added number format helper functions:
8    //      + number_format_locale()
9    //      + is_amount()
10    //
11    //    Revision 1.3  2002/12/11 01:00:22  joko
12    //    + renamed function 'sai' to 'array_init'
13    //
14    //    Revision 1.2  2002/12/01 04:49:54  joko
15    //    + function Dumper (from function dumpVar)
16    //
17  //    Revision 1.1  2002/11/12 05:42:31  joko  //    Revision 1.1  2002/11/12 05:42:31  joko
18  //    + initial checkin  //    + initial checkin
19  //  //
# Line 51  function get_date_forStorage($arg_date) Line 62  function get_date_forStorage($arg_date)
62  }  }
63    
64  // -------------------------------------------------  // -------------------------------------------------
65  // sophisticated array init  // array initializer
66  // initializes passed variable (taken by reference) with an empty array  // initializes passed variable (taken by reference) with an empty array
67  // does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1)  // does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1)
68  function sai(&$var, $clear = 0) {  function array_init(&$var, $clear = 0) {
69    if (!is_array($var) || $clear) { $var = array(); }    if (!is_array($var) || $clear) { $var = array(); }
70  }  }
71        
72    
73  // format functions  // format functions
74  function isvalidemailaddress($mail) {  function isvalidemailaddress($mail) {
75      // TODO: review for regex process load
76    //return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2));    //return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2));
77    if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) {    if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) {
78          return "format";          return "format";
# Line 72  function isvalidemailaddress($mail) { Line 84  function isvalidemailaddress($mail) {
84  }  }
85    
86  function dumpVar($var) {  function dumpVar($var) {
87      return Dumper($var);
88    }
89    
90    function Dumper($var) {
91    ob_start();    ob_start();
92    print_r($var);    print_r($var);
93    $var_dump = ob_get_contents();    $var_dump = ob_get_contents();
# Line 142  function dprint($message) { Line 158  function dprint($message) {
158  }  }
159  */  */
160    
161    function number_format_storage($string) {
162        $locale_info = localeconv();
163        $string =  str_replace($locale_info["decimal_point"], ".",  $string);
164        return $string;
165    }
166    
167    function number_format_locale1($string) {
168        $locale_info = localeconv();
169        $string =  str_replace(".", $locale_info["decimal_point"],  $string);
170        return $string;
171    }
172    
173    
174    function number_format_locale ($num, $decimals = null) {
175       $locale = localeconv();
176       if(!isset($decimals)) $decimals = $locale['frac_digits'];
177       return number_format($num, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
178    }
179    
180    
181    function is_amount($amount) {
182      //if( (number_format_locale((string)doubleval($amount)) === number_format_locale((string)$amount)) && number_format_locale((doubleval($amount)) >number_format_locale(0)) ) {
183      if( ((string)doubleval($amount) === (string)$amount) && (doubleval($amount) > 0) ) {
184        return 1;
185      }
186    }
187    
188  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed