/[cvs]/nfo/php/libs/org.netfrag.glib/utils/extensions.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/utils/extensions.php

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

revision 1.1 by joko, Sat Apr 5 19:53:45 2003 UTC revision 1.8 by joko, Wed Jul 21 12:56:19 2004 UTC
# Line 13  Line 13 
13   * $Id$   * $Id$
14   *   *
15   * $Log$   * $Log$
16     * Revision 1.8  2004/07/21 12:56:19  joko
17     * php5 compatibility
18     *
19     * Revision 1.7  2003/06/25 23:41:14  joko
20     * now using "global $Dumper_mode"
21     *
22     * Revision 1.6  2003/04/16 16:24:23  joko
23     * + odd and even from php.net
24     *
25     * Revision 1.5  2003/04/11 01:31:50  joko
26     * + function log (from flib-shortcuts)
27     *
28     * Revision 1.4  2003/04/09 07:55:47  joko
29     * + function untwingle_reference
30     *
31     * Revision 1.3  2003/04/08 22:35:16  joko
32     * + 'function yesno' from utils/links.php
33     *
34     * Revision 1.2  2003/04/06 01:37:31  jonen
35     * + added functions to generate and handle unique ID's
36     *
37   * Revision 1.1  2003/04/05 19:53:45  joko   * Revision 1.1  2003/04/05 19:53:45  joko
38   * moved here from ../   * moved here from ../
39   *   *
# Line 163  class php { Line 184  class php {
184    }    }
185    
186    function Dumper() {    function Dumper() {
187        global $Dumper_mode;
188      $arg_list = func_get_args();      $arg_list = func_get_args();
189      $count = 1;      $count = 1;
190    
# Line 180  class php { Line 202  class php {
202        ob_end_clean();        ob_end_clean();
203    
204      //print "mode: " . $this->Dumper_mode . "<br/>";      //print "mode: " . $this->Dumper_mode . "<br/>";
205      //if ($this->Dumper_mode == HTML) {      if ($Dumper_mode == 'single_line') {
206          $var_dump = str_replace("\n", ' ', $var_dump);
207        } else {
208        $var_dump = str_replace("\n", '<br/>', $var_dump);        $var_dump = str_replace("\n", '<br/>', $var_dump);
209        $var_dump = str_replace(" ", '&nbsp;', $var_dump);        $var_dump = str_replace(" ", '&nbsp;', $var_dump);
210      //}      }
211            
212      //if (sizeof($args) == 1) { $var_dump .= '<br/>'; }      //if (sizeof($args) == 1) { $var_dump .= '<br/>'; }
213            
# Line 408  class php { Line 432  class php {
432    
433    // from: http://www.php.net/manual/en/function.method-exists.php    // from: http://www.php.net/manual/en/function.method-exists.php
434    function class_has_method($className, $methodName) {    function class_has_method($className, $methodName) {
435      $bool_exists = (in_array(strtolower($methodName), get_class_methods($className)));  
436        // new as of 2004-07-21: php5 compatibility
437        // taken from http://php.net/manual/en/function.version-compare.php
438        if (version_compare(phpversion(), "5.0.0", "<")) {
439          $methodName = strtolower($methodName);
440        }
441        
442        $bool_exists = (in_array($methodName, get_class_methods($className)));
443      return $bool_exists;      return $bool_exists;
444    }    }
445    
# Line 507  class php { Line 538  class php {
538  */  */
539    
540      if (!class_exists($classname)) {      if (!class_exists($classname)) {
541        user_error("Class '$classname' doesn't exist.");        php::log( "Class '$classname' doesn't exist.", PEAR_LOG_ERR );
542        return;        return;
543      }      }
544    
# Line 637  Bitte versuchen Sie es später nocheinmal Line 668  Bitte versuchen Sie es später nocheinmal
668    
669    }    }
670    
671      //examples on howto create unique id's
672      // from: http://www.php.net/manual/en/function.uniqid.php
673      function CreateGUID(){
674        srand((double)microtime()*1000000);
675        $r = rand ;
676        $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
677        $m = md5 ($u);
678        return($m);
679      }
680    
681      function CompressID( $ID ){
682        return(Base64_encode(pack("H*",$ID)));
683      }
684    
685      function ExpandID ($ID){
686        return ( implode(unpack("H*",Base64_decode($ID)), '') );
687      }
688    
689      // from: utils/links.php
690      function yesno($bool) {
691        return $bool ? 'yes' : 'no';
692      }
693    
694      function untwingle_reference($item, $options = array()) {
695        
696        // default
697        if (!$options['seperator']) { $options['seperator'] = '_'; }
698        
699        if ( is_string($item) && (substr($item, 0, 2) == "o_") ) {
700          //print "YAI!<br/>";
701          $parts = split($options['seperator'], $item);
702          $result = array(
703            ident => $parts[1],
704            type => $parts[2],
705          );
706          return $result;
707        }
708      }
709    
710      // wrapper-function for getting the logger instance
711      // TODO: review! what about php::append_log?
712      function log($string, $level = PEAR_LOG_DEBUG) {
713        global $app;
714        $app->log($string, $level);
715      }
716    
717      // from: http://www.php.net/manual/en/function.array-filter.php#AEN7432
718      function odd($var) {
719          return ($var % 2 == 1);
720      }
721      function even($var) {
722          return ($var % 2 == 0);
723      }
724    
725  }  }
726    

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

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