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

Diff of /nfo/php/libs/org.netfrag.glib/php_extensions.php

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

revision 1.3 by joko, Wed Mar 5 18:54:41 2003 UTC revision 1.7 by joko, Fri Apr 4 17:35:40 2003 UTC
# Line 13  Line 13 
13   * $Id$   * $Id$
14   *   *
15   * $Log$   * $Log$
16     * Revision 1.7  2003/04/04 17:35:40  joko
17     * fixed php croaking
18     * moved error handling function to 'php_errors.php'
19     * + function php::maintenance
20     *
21     * Revision 1.6  2003/03/11 02:14:18  joko
22     * + fixed metadata for phpDocumentor
23     *
24     * Revision 1.5  2003/03/10 22:58:46  joko
25     * + fixed metadata for phpDocumentor
26     *
27     * Revision 1.4  2003/03/05 23:16:46  joko
28     * updated docu - phpDocumentor is very strict about its 'blocks'...
29     *
30   * Revision 1.3  2003/03/05 18:54:41  joko   * Revision 1.3  2003/03/05 18:54:41  joko
31   * updated docu - phpDocumentor is very strict about its 'blocks'...   * updated docu - phpDocumentor is very strict about its 'blocks'...
32   *   *
# Line 68  php::export_symbols(); Line 82  php::export_symbols();
82    
83    
84  /**  /**
85   * --- php extension functions lying in the php:: namespace   * --- php extension functions living in the php:: namespace
86   *   *
87   * <pre>   * <pre>
88   *  x php::Dumper   *  x php::Dumper
# Line 92  php::export_symbols(); Line 106  php::export_symbols();
106   * @package org.netfrag.glib   * @package org.netfrag.glib
107   * @name php   * @name php
108   *   *
  * @todo  
109   * <pre>   * <pre>
110   * Todo:   * Todo:
111   *   * @todo (o) establish mkInstance here (move from DesignPattern::Object::mkObject)
112   *  o establish mkInstance here (move from DesignPattern::Object::mkObject)   * @todo (o) establish loadModule here (move from DesignPattern::Object::loadModule)
  *  o establish loadModule here (move from DesignPattern::Object::loadModule)  
113   *   *
114   * Ideas:   * Ideas:
115   *  o php::create_redirector_function('func', array( type => 'lamba|function|method', name => 'Abc::do_xyz') )   * @todo (o) php::create_redirector_function('func', array( type => 'lamba|function|method', name => 'Abc::do_xyz') )
116   *  o php::create_redirector_method('class|obj_ref', 'method', $target)   * @todo (o) php::create_redirector_method('class|obj_ref', 'method', $target)
117   *  o php::export_symbol(from, to) (maybe solves above two)   * @todo (o) php::export_symbol(from, to) (maybe solves above two)
118   * </pre>   * </pre>
119   *   *
120   */   */
# Line 293  class php { Line 305  class php {
305          //set_error_handler('php_error_handler');          //set_error_handler('php_error_handler');
306          // TODO: do stack-backtracing here to determine function called two or three levels before!!!          // TODO: do stack-backtracing here to determine function called two or three levels before!!!
307          //print "file: $filename<br/>";          //print "file: $filename<br/>";
308          if (!include_once($filename)) {          if (!@include_once($filename)) {
309            $msg = "php::loadModule error: Could not load module '$namespacedClassname', file '$filename' does not exist.";            $msg = "php::loadModule error: Could not load module '$namespacedClassname', file '$filename' does not exist.";
310            user_error($msg);            user_error($msg);
311            php::append_log($msg, PEAR_LOG_ERR);            php::append_log($msg, PEAR_LOG_ERR);
# Line 355  class php { Line 367  class php {
367        
368            
369      // trace      // trace
370        //print "mkObject: $classname<br>";        //print "mkObject: $classname<br/>";
371        //print "file: $filename<br>";        //print "file: $filename<br/>";
372            
373      // build native class name from namespaced one      // build native class name from namespaced one
374          $classname = str_replace('::', '_', $classname);          $classname = str_replace('::', '_', $classname);
# Line 503  class php { Line 515  class php {
515        //print "eval: $evalstr<br/>";        //print "eval: $evalstr<br/>";
516                
517        $instance = eval($evalstr);        $instance = eval($evalstr);
518        //print $evalstr . "<br>";        //print $evalstr . "<br/>";
519      } else {      } else {
520        $instance = new $classname;        $instance = new $classname;
521      }      }
# Line 567  class php { Line 579  class php {
579      }      }
580    }    }
581    
     
 }  
582    
583    //function error_handler($errno, $errstr, $errfile, $errline) {    function maintenance($type = 'system', $options = array()) {
   function php_error_handler() {  
     //print "ERROR!<br/>";  
     $error_raw = func_get_args();  
584    
585      //print Dumper($error_raw);      switch ($type) {
586    
587      $error = array(        case 'system':
588        'level' => $error_raw[0],          print "<br/><br/>";
589        'message' => $error_raw[1],          print "<p align=\"center\">We have taken down our systems for maintenance purposes. <br/>Please apologize the downtime.</p>";
590        'file' => $error_raw[2],          print "<p align=\"center\">Wir f&uuml;hren gerade Wartungsarbeiten an unseren Systemen durch. <br/>Bitte entschuldigen Sie die Unterbrechung des Betriebs.</p>";
591        'line' => $error_raw[3],          
592        'context' => &$error_raw[4],          print "<br/><br/>";
593        'object_context' => &$error_raw[4][this],          print "<p align=\"center\"><a href=\"mailto:info@top-scores.net\">Top-Scores Ltd.</a></p>";
594      );          $do_exit = 1;
595      $error[component] = $error[object_context]->_component_name;          break;
596        
597      //$output_order = array( 'message', 'component', 'file', 'line', 'level' );        case 'database':
598      $output_order = array( 'message', 'file', 'line' );     print "
599    Database error, we are already notified of this failure and working to resolve it.<br/>
600    We apologize for the inconvenience, please come back later.<br/>
601    <br/>
602    Es ist ein Datenbankfehler aufgetreten. Wir haben bereits Kenntnis von diesem Fehler, an der Lösung des Problems wird gearbeitet.<br/>
603    Bitte versuchen Sie es später nocheinmal.<br/>
604    ";
605            $do_exit = 1;
606            break;
607    
608      /*        case 'rpc':
609      $level = $error[0];          
610      $context = &$error[4];          // V0
611      $cc = &$context['this'];          //return;
612      */  
613                // V2
614                // FIXME: implement some more behaviour here!
615      //print Dumper($context);          // via constants?
616      //print Dumper($cc);          // e.g.:
617      //print Dumper($cc->_component_name);          if (!constants::get('APP_MODE_DEBUG_LIGHT')) { return; }
618    
619            // V1
620            print "<font color=\"red\"><b>FIXME! - in 'php::maintenance(rpc)'</b></font><br/>";
621            print "RPC Problems!<br/>";
622            print "Status:<br/>";
623            print Dumper($options[status]);
624            break;
625    
     // by level  
     //$do_trace = ($level <= 5);  
       
     //$c_name = $context['this']['_component_name'];  
       
     //print "c_error: $c_name<br/>";  
       
     // if component  
     //$do_trace = isset($context[this][_component_name]);  
     //$do_trace = isset($context->this[_component_name]);  
     //$do_trace = isset($cc->_component_name);  
     $do_trace = isset($error[component]);  
       
     //$do_trace = 1;  
       
     //print Dumper($context);  
       
     if ($do_trace) {  
         
       //print php::Dumper($error);  
       //exit;  
         
       //print "<hr/><b><font color=\"red\">ERROR:</font></b><br/>";  
       print "<b><font color=\"red\">ERROR:</font></b><br/> ";  
         
       foreach ($output_order as $key) {  
         print "<b>$key:</b> $error[$key]<br/>";  
       }  
         
626      }      }
627            
628        if ($options[no_exit]) { $do_exit = 0; }
629        if ($do_exit) {
630          exit;
631        }
632    
633    }    }
634    
635    
636    }
637    
638    
639  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

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