| 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.6 2003/03/11 02:14:18 joko |
| 17 |
* refactored from flib/utils |
* + fixed metadata for phpDocumentor |
| 18 |
* |
* |
| 19 |
|
* Revision 1.5 2003/03/10 22:58:46 joko |
| 20 |
|
* + fixed metadata for phpDocumentor |
| 21 |
* |
* |
| 22 |
*/ |
* Revision 1.4 2003/03/05 23:16:46 joko |
| 23 |
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
|
|
|
|
/** |
|
|
* --- php extension functions |
|
| 24 |
* |
* |
| 25 |
* x php::Dumper |
* Revision 1.3 2003/03/05 18:54:41 joko |
| 26 |
* x php::session_register_safe |
* updated docu - phpDocumentor is very strict about its 'blocks'... |
|
* 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.2 2003/03/05 11:58:49 joko |
| 29 |
* @copyright (c) 2003 - All Rights reserved. |
* modified is_hash, mkInstance and others |
|
* @license GNU LGPL (GNU Lesser General Public License) |
|
| 30 |
* |
* |
| 31 |
* @author-url http://www.netfrag.org/~joko/ |
* Revision 1.1 2003/03/03 21:08:21 joko |
| 32 |
* @license-url http://www.gnu.org/licenses/lgpl.txt |
* refactored from flib/utils |
| 33 |
* |
* |
|
* @package org.netfrag.glib |
|
|
* @module php |
|
| 34 |
* |
* |
| 35 |
*/ |
*/ |
| 36 |
|
|
|
/** |
|
|
* 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) |
|
|
* |
|
|
*/ |
|
|
|
|
|
|
|
| 37 |
|
|
| 38 |
/** |
/** |
| 39 |
* --- shortcut functions |
* --- shortcut functions |
| 52 |
* 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'); |
| 53 |
* |
* |
| 54 |
*/ |
*/ |
|
|
|
| 55 |
// this is (and will probably always be) required by the "Exporter" |
// this is (and will probably always be) required by the "Exporter" |
| 56 |
function &Dumper() { |
function &Dumper() { |
| 57 |
$args = func_get_args(); |
$args = func_get_args(); |
| 77 |
|
|
| 78 |
|
|
| 79 |
/** |
/** |
| 80 |
* --- php extension functions lying in the php:: namespace |
* --- php extension functions living in the php:: namespace |
| 81 |
|
* |
| 82 |
|
* <pre> |
| 83 |
|
* x php::Dumper |
| 84 |
|
* x php::session_register_safe |
| 85 |
|
* x php::array_init |
| 86 |
|
* x php::is_hash |
| 87 |
|
* x php::array_join_merge |
| 88 |
|
* o php::merge |
| 89 |
|
* o php::merge_to |
| 90 |
|
* x php::loadModule |
| 91 |
|
* x php::mkInstance |
| 92 |
|
* </pre> |
| 93 |
|
* |
| 94 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
| 95 |
|
* @copyright (c) 2003 - All Rights reserved. |
| 96 |
|
* @license GNU LGPL (GNU Lesser General Public License) |
| 97 |
|
* |
| 98 |
|
* @link http://www.netfrag.org/~joko/ |
| 99 |
|
* @link http://www.gnu.org/licenses/lgpl.txt |
| 100 |
|
* |
| 101 |
|
* @package org.netfrag.glib |
| 102 |
|
* @name php |
| 103 |
|
* |
| 104 |
|
* <pre> |
| 105 |
|
* Todo: |
| 106 |
|
* @todo (o) establish mkInstance here (move from DesignPattern::Object::mkObject) |
| 107 |
|
* @todo (o) establish loadModule here (move from DesignPattern::Object::loadModule) |
| 108 |
|
* |
| 109 |
|
* Ideas: |
| 110 |
|
* @todo (o) php::create_redirector_function('func', array( type => 'lamba|function|method', name => 'Abc::do_xyz') ) |
| 111 |
|
* @todo (o) php::create_redirector_method('class|obj_ref', 'method', $target) |
| 112 |
|
* @todo (o) php::export_symbol(from, to) (maybe solves above two) |
| 113 |
|
* </pre> |
| 114 |
* |
* |
| 115 |
*/ |
*/ |
|
|
|
|
|
|
| 116 |
class php { |
class php { |
| 117 |
|
|
| 118 |
|
|
| 198 |
} |
} |
| 199 |
|
|
| 200 |
// 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 |
| 201 |
function is_hash( $var ) { |
function is_hash( $var = null ) { |
| 202 |
if( is_array( $var ) ) { |
if( is_array( $var ) ) { |
| 203 |
$keys = array_keys( $var ); |
$keys = array_keys( $var ); |
| 204 |
$all_num = true; |
$all_num = true; |
| 320 |
function &mkComponent() { |
function &mkComponent() { |
| 321 |
|
|
| 322 |
// argument handling - perl style |
// argument handling - perl style |
| 323 |
$arg_list = func_get_args(); |
$arg_list = &func_get_args(); |
| 324 |
|
|
| 325 |
// trace |
// trace |
| 326 |
//print "php::mkInstance: " . Dumper($arg_list); |
//print "php::mkInstance: " . Dumper($arg_list); |
| 328 |
|
|
| 329 |
// patch arglist if all arguments are passed in as a single array |
// patch arglist if all arguments are passed in as a single array |
| 330 |
if (sizeof($arg_list) == 1 && is_array($arg_list[0])) { |
if (sizeof($arg_list) == 1 && is_array($arg_list[0])) { |
| 331 |
$arg_list = $arg_list[0]; |
$arg_list = &$arg_list[0]; |
| 332 |
} |
} |
| 333 |
|
|
| 334 |
//print "arg_list: $arg_list<br/>"; |
//print "arg_list: $arg_list<br/>"; |
| 431 |
} |
} |
| 432 |
} |
} |
| 433 |
|
|
| 434 |
function &mkInstance($classname, $attributes = null) { |
function &mkInstance($classname, $attributes = array()) { |
| 435 |
|
|
| 436 |
$oo = is_object($this); |
$oo = is_object($this); |
| 437 |
|
|
| 481 |
|
|
| 482 |
$args_pass = array(); |
$args_pass = array(); |
| 483 |
for ($i=0; $i<=count($attributes); $i++) { |
for ($i=0; $i<=count($attributes); $i++) { |
| 484 |
array_push($args_pass, '$attributes[' . $i . ']'); |
array_push($args_pass, '&$attributes[' . $i . ']'); |
| 485 |
} |
} |
| 486 |
|
|
| 487 |
$arg_string = join(', ', $args_pass); |
$arg_string = join(', ', $args_pass); |