File: Visitor.php

package info (click to toggle)
phpldapadmin 1.1.0.5-6%2Blenny2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,008 kB
  • ctags: 3,949
  • sloc: php: 17,735; xml: 1,532; sh: 388; makefile: 46
file content (67 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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) {
		$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";
		while ($class && !method_exists($this,$call)) {
			$class = get_parent_class($class);
			$call = "$method$class$fnct";
		}

		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);
		}
	}
}
?>