예제 #1
1
파일: Array.php 프로젝트: Artea/freebeer
 function search($needle, $haystack, $sort_flag = null, $compare_function = null)
 {
     $len = strlen($needle);
     if (!$len) {
         return false;
     }
     if (!is_array($haystack)) {
         return false;
     }
     if (is_null($compare_function)) {
         $compare_function = 'strncmp';
     }
     if ($sort_flag) {
         sort($haystack);
     }
     fbDebug::dump($haystack, '$haystack');
     $high = count($haystack) - 1;
     if ($high < 0) {
         return false;
     }
     $mid = 0;
     $low = 0;
     fbDebug::log(sprintf("%3d: low=%5s high=%5s mid=%5s arr[mid]=%5s\n", __LINE__, $low, $high, $mid, $haystack[$mid]));
     while ($high >= $low) {
         $mid = $high + $low >> 1;
         $t = @$compare_function($needle, $haystack[$mid], $len);
         if ($t < 0) {
             $high = $mid - 1;
         } elseif ($t > 0) {
             $low = $mid + 1;
         } else {
             fbDebug::log(sprintf("%3d: low=%5s high=%5s mid=%5s arr[mid]=%5s\n", __LINE__, $low, $high, $mid, $haystack[$mid]));
             return $mid;
         }
         fbDebug::log(sprintf("%3d: low=%5s high=%5s mid=%5s arr[mid]=%5s\n", __LINE__, $low, $high, $mid, $haystack[$mid]));
     }
     fbDebug::log(sprintf("%3d: low=%5s high=%5s mid=%5s arr[mid]=%5s\n", __LINE__, $low, $high, $mid, $haystack[$mid]));
     return $mid;
 }
예제 #2
0
파일: Gettext.php 프로젝트: Artea/freebeer
 function gettext($message)
 {
     fbDebug::enter();
     static $current_locale = null;
     $locale = fbLocale::getLocale();
     if ($locale != $current_locale) {
         fbGettext::_loadData();
         $current_locale = $locale;
     }
     $translation_map =& fbGettext::_translation_map();
     fbDebug::dump($translation_map, 'translation_map');
     if (isset($translation_map[$message])) {
         return $translation_map[$message];
     }
     return $message;
 }
예제 #3
0
파일: Locale.php 프로젝트: Artea/freebeer
 function numberFormat($number, $digits = null, $locale = null)
 {
     fbDebug::enter();
     static $localeconv_cache = array();
     $get_locale = is_null($locale);
     fbDebug::dump($get_locale, '$get_locale');
     if ($get_locale) {
         $locale = fbLocale::getLocale(LC_MONETARY);
         fbDebug::dump($locale, '$locale');
     }
     fbDebug::dump($localeconv_cache, '$localeconv_cache');
     if (!isset($localeconv_cache[$locale])) {
         fbDebug::dump($locale, '$locale');
         if (!$get_locale) {
             $rv = fbLocale::pushLocale(LC_MONETARY, $locale);
             fbDebug::dump($rv, '$rv');
         }
         $_locale = fbLocale::getLocale(LC_MONETARY);
         fbDebug::dump($_locale, '$_locale');
         $localeconv_cache[$locale] = localeconv();
         fbDebug::dump($localeconv_cache[$locale], '$localeconv_cache[$locale]');
         if (!$get_locale) {
             fbLocale::popLocale(LC_MONETARY);
         }
     }
     $lc = $localeconv_cache[$locale];
     fbDebug::dump($lc, '$lc');
     if (is_null($digits)) {
         $digits = $lc['int_frac_digits'];
     }
     $rv = number_format($number, $digits, $lc['mon_decimal_point'], $lc['mon_thousands_sep']);
     $n = strpos($rv, '-');
     if ($n !== false) {
         $rv = str_replace('-', $lc['negative_sign'], $rv);
     }
     fbDebug::leave($rv);
     return $rv;
 }
예제 #4
0
 function &Execute($sql, $inputarr = false, $arg3 = false)
 {
     $this->_start();
     $rs =& parent::Execute($sql, $inputarr, $arg3);
     if (!$rs) {
         // \todo use adodb-error.inc.php values instead
         // key violations should not be fatal errors
         if ($this->ErrorNo() == 1062) {
             return $rs;
         }
         $this->_error("Execute", $sql, $inputarr);
     }
     $affected_rows = $this->Affected_Rows();
     $this->_end();
     $this->_dumpSql("Execute", $sql, $inputarr);
     $this->_explain($sql, $inputarr, $arg3);
     $this->_elapsed();
     ADODB_debug::rsdumpNoSql($rs);
     if ($rs && fbDebug::_level() & FB_DEBUG_SQL) {
         if (preg_match('/^\\s*insert\\s+|^\\s*delete\\s+|^\\s*update\\s+/i', $sql)) {
             fbDebug::dump($affected_rows, 'Affected_Rows');
         }
     }
     //		fbDebug::log(fbDebug::hr());
     return $rs;
 }