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