/[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.1 by joko, Mon Mar 3 21:08:21 2003 UTC revision 1.3 by joko, Wed Mar 5 18:54:41 2003 UTC
# Line 5  Line 5 
5   *   *
6   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
7   * @package org.netfrag.glib   * @package org.netfrag.glib
8   * @module php   * @name php
9   *   *
10   */   */
11    
# Line 13  Line 13 
13   * $Id$   * $Id$
14   *   *
15   * $Log$   * $Log$
16     * Revision 1.3  2003/03/05 18:54:41  joko
17     * updated docu - phpDocumentor is very strict about its 'blocks'...
18     *
19     * Revision 1.2  2003/03/05 11:58:49  joko
20     * modified is_hash, mkInstance and others
21     *
22   * Revision 1.1  2003/03/03 21:08:21  joko   * Revision 1.1  2003/03/03 21:08:21  joko
23   * refactored from flib/utils   * refactored from flib/utils
24   *   *
# Line 21  Line 27 
27    
28    
29  /**  /**
  * --- php extension functions  
  *  
  *  x php::Dumper  
  *  x php::session_register_safe  
  *  x php::array_init  
  *  x php::is_hash  
  *  x php::array_join_merge  
  *  o php::merge  
  *  o php::merge_to  
  *  x php::loadModule  
  *  x php::mkInstance  
  *  
  * @author Andreas Motl <andreas.motl@ilo.de>  
  * @copyright (c) 2003 - All Rights reserved.  
  * @license GNU LGPL (GNU Lesser General Public License)  
  *  
  * @author-url http://www.netfrag.org/~joko/  
  * @license-url http://www.gnu.org/licenses/lgpl.txt  
  *  
  * @package org.netfrag.glib  
  * @module php  
  *  
  */  
   
 /**  
  * Todo:  
  *  o establish mkInstance here (move from DesignPattern::Object::mkObject)  
  *  o establish loadModule here (move from DesignPattern::Object::loadModule)  
  *  
  * Ideas:  
  *  o php::create_redirector_function('func', array( type => 'lamba|function|method', name => 'Abc::do_xyz') )  
  *  o php::create_redirector_method('class|obj_ref', 'method', $target)  
  *  o php::export_symbol(from, to) (maybe solves above two)  
  *  
  */  
   
   
   
 /**  
30   * --- shortcut functions   * --- shortcut functions
31   * Is there a mechanism in php to 'export' these methods   * Is there a mechanism in php to 'export' these methods
32   * to the global symbol table automagically?   * to the global symbol table automagically?
# Line 76  Line 43 
43   * TODO: $php::EXPORT_OK = array('Dumper', 'session_register_safe', 'mkObject', 'is_hash', 'merge_to');   * TODO: $php::EXPORT_OK = array('Dumper', 'session_register_safe', 'mkObject', 'is_hash', 'merge_to');
44   *   *
45   */   */
   
46  // this is (and will probably always be) required by the "Exporter"  // this is (and will probably always be) required by the "Exporter"
47  function &Dumper() {  function &Dumper() {
48    $args = func_get_args();    $args = func_get_args();
# Line 104  php::export_symbols(); Line 70  php::export_symbols();
70  /**  /**
71   * --- php extension functions lying in the php:: namespace   * --- php extension functions lying in the php:: namespace
72   *   *
73     * <pre>
74     *  x php::Dumper
75     *  x php::session_register_safe
76     *  x php::array_init
77     *  x php::is_hash
78     *  x php::array_join_merge
79     *  o php::merge
80     *  o php::merge_to
81     *  x php::loadModule
82     *  x php::mkInstance
83     * </pre>
84     *
85     * @author Andreas Motl <andreas.motl@ilo.de>
86     * @copyright (c) 2003 - All Rights reserved.
87     * @license GNU LGPL (GNU Lesser General Public License)
88     *
89     * @link http://www.netfrag.org/~joko/
90     * @link http://www.gnu.org/licenses/lgpl.txt
91     *
92     * @package org.netfrag.glib
93     * @name php
94     *
95     * @todo
96     * <pre>
97     * Todo:
98     *
99     *  o establish mkInstance here (move from DesignPattern::Object::mkObject)
100     *  o establish loadModule here (move from DesignPattern::Object::loadModule)
101     *
102     * Ideas:
103     *  o php::create_redirector_function('func', array( type => 'lamba|function|method', name => 'Abc::do_xyz') )
104     *  o php::create_redirector_method('class|obj_ref', 'method', $target)
105     *  o php::export_symbol(from, to) (maybe solves above two)
106     * </pre>
107     *
108   */   */
   
   
109  class php {  class php {
110    
111    
# Line 192  class php { Line 191  class php {
191    }    }
192    
193    // from: php.net - http://www.php.net/manual/en/function.array-merge-recursive.php    // from: php.net - http://www.php.net/manual/en/function.array-merge-recursive.php
194    function is_hash( $var ) {    function is_hash( $var = null ) {
195     if( is_array( $var ) ) {     if( is_array( $var ) ) {
196       $keys = array_keys( $var );       $keys = array_keys( $var );
197       $all_num = true;       $all_num = true;
# Line 314  class php { Line 313  class php {
313    function &mkComponent() {    function &mkComponent() {
314        
315      // argument handling - perl style      // argument handling - perl style
316        $arg_list = func_get_args();        $arg_list = &func_get_args();
317            
318      // trace      // trace
319        //print "php::mkInstance: " . Dumper($arg_list);        //print "php::mkInstance: " . Dumper($arg_list);
# Line 322  class php { Line 321  class php {
321        
322      // patch arglist if all arguments are passed in as a single array      // patch arglist if all arguments are passed in as a single array
323        if (sizeof($arg_list) == 1 && is_array($arg_list[0])) {        if (sizeof($arg_list) == 1 && is_array($arg_list[0])) {
324          $arg_list = $arg_list[0];          $arg_list = &$arg_list[0];
325        }        }
326            
327      //print "arg_list: $arg_list<br/>";      //print "arg_list: $arg_list<br/>";
# Line 425  class php { Line 424  class php {
424      }      }
425    }    }
426    
427    function &mkInstance($classname, $attributes = null) {    function &mkInstance($classname, $attributes = array()) {
428            
429      $oo = is_object($this);      $oo = is_object($this);
430            
# Line 475  class php { Line 474  class php {
474    
475      $args_pass = array();      $args_pass = array();
476      for ($i=0; $i<=count($attributes); $i++) {      for ($i=0; $i<=count($attributes); $i++) {
477        array_push($args_pass, '$attributes[' . $i . ']');        array_push($args_pass, '&$attributes[' . $i . ']');
478      }      }
479    
480      $arg_string = join(', ', $args_pass);      $arg_string = join(', ', $args_pass);

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

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