phpldapadmin/lib/Visitor.php

80 lines
1.7 KiB
PHP
Raw Normal View History

2009-06-30 10:46:00 +00:00
<?php
// $Header
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Visit an entry and its attributes and perform a treatment
* @see EntryReader
* @see EntryWriter
*/
class Visitor {
public function __call($method,$args) {
2009-06-30 12:05:31 +00:00
$methods = array();
2009-06-30 10:46:00 +00:00
$class = '';
$fnct = '';
$a0 = isset($args[0]) ? $args[0] : '';
2009-06-30 12:05:31 +00:00
2009-06-30 10:46:00 +00:00
for ($i = 0; $i < strlen($a0); $i++) {
if ($class) {
if ($a0[$i] != ':') $fnct .= $a0[$i];
2009-06-30 12:05:31 +00:00
2009-06-30 10:46:00 +00:00
} else {
if ($a0[$i] != ':') {
$fnct .= $a0[$i];
} else {
$class = $fnct;
$fnct = '';
}
}
}
$obj = isset($args[1]) ? $args[1] : null;
if (! $obj) {
if (DEBUG_ENABLED)
debug_log('null param (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,$method,$class,$fnct);
return;
}
if (! $class)
$class = get_class($obj);
if (DEBUG_ENABLED)
$c = $class;
$call = "$method$class$fnct";
2009-06-30 12:05:31 +00:00
array_push($methods,$call);
while ($class && ! method_exists($this,$call)) {
2009-06-30 10:46:00 +00:00
$class = get_parent_class($class);
$call = "$method$class$fnct";
2009-06-30 12:05:31 +00:00
array_push($methods,$call);
2009-06-30 10:46:00 +00:00
}
2009-06-30 12:05:31 +00:00
if (defined('TMPDEBUG') && TMPDEBUG)
printf('<font size=-2><i>Calling Methods: %s</i></font><br >',join('|',$methods));
if (defined('TMPDEBUG') && TMPDEBUG && method_exists($this,$call))
printf('<font size=-2><b>Invoking Method: %s::%s</b></font><br >',get_class($this),$call);
2009-06-30 10:46:00 +00:00
if ($class) {
$call .= '($obj';
for ($i = 2; $i < count($args); $i++) {
$call .= ',$args['.$i.']';
}
$call .= ');';
eval('$r = $this->'.$call);
if (isset($r)) return $r;
else return;
} elseif (DEBUG_ENABLED) {
debug_log('Doesnt exist param (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,$method,$c,$fnct);
}
}
}
?>