phpldapadmin/lib/Visitor.php
2009-06-30 22:05:31 +10:00

80 lines
1.7 KiB
PHP

<?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) {
$methods = array();
$class = '';
$fnct = '';
$a0 = isset($args[0]) ? $args[0] : '';
for ($i = 0; $i < strlen($a0); $i++) {
if ($class) {
if ($a0[$i] != ':') $fnct .= $a0[$i];
} 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";
array_push($methods,$call);
while ($class && ! method_exists($this,$call)) {
$class = get_parent_class($class);
$call = "$method$class$fnct";
array_push($methods,$call);
}
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);
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);
}
}
}
?>