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