2009-06-30 10:46:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Classes and functions for the template engines.
|
|
|
|
*
|
2009-06-30 10:46:00 +00:00
|
|
|
* @author The phpLDAPadmin development team
|
2009-07-01 06:09:17 +00:00
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**/
|
|
|
|
# To make it easier to debug this script, define these constants, which will add some __METHOD__ location displays to the rendered text.
|
|
|
|
define('DEBUGTMP',0);
|
|
|
|
define('DEBUGTMPSUB',0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract Visitor class
|
2009-06-30 10:46:00 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
* @package phpLDAPadmin
|
|
|
|
* @subpackage Templates
|
2009-06-30 10:46:00 +00:00
|
|
|
*/
|
2009-07-01 06:09:17 +00:00
|
|
|
abstract class Visitor {
|
|
|
|
# The server that was used to configure the templates
|
|
|
|
protected $server_id;
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function __call($method,$args) {
|
2022-01-14 06:29:20 +00:00
|
|
|
# This mapping array allows to map effective class names to
|
|
|
|
# function name suffixes.
|
|
|
|
# It has been introduced when class Attribute has been renamed
|
|
|
|
# to PLAAttribute to avoid a name clash with the built-in
|
|
|
|
# class of PHP 8.
|
|
|
|
# Entering a class name mapping here allows to rename the
|
|
|
|
# class without having to rename the methods too.
|
|
|
|
static $classmap = array('PLAAttribute' => 'Attribute');
|
|
|
|
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! in_array($method,array('get','visit','draw')))
|
|
|
|
debug_dump_backtrace(sprintf('Incorrect use of method loading [%s]',$method),1);
|
|
|
|
|
2009-06-30 12:05:31 +00:00
|
|
|
$methods = array();
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$fnct = array_shift($args);
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$object = $args[0];
|
2009-06-30 12:05:31 +00:00
|
|
|
|
2022-01-14 06:29:20 +00:00
|
|
|
for ($class = get_class($object); $class; $class = get_parent_class($class)) {
|
|
|
|
$call = isset($classmap[$class])? "$method$fnct$classmap[$class]": "$method$fnct$class";
|
|
|
|
array_push($methods,$call);
|
|
|
|
if (method_exists($this,$call))
|
|
|
|
break;
|
2009-07-01 06:09:17 +00:00
|
|
|
if (defined('DEBUGTMP') && DEBUGTMP)
|
|
|
|
printf('<font size=-2><i>Class (%s): Method doesnt exist (%s,%s)</i></font><br />',$class,get_class($this),$call);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (defined('DEBUGTMP') && DEBUGTMP)
|
|
|
|
printf('<font size=-2><i>Calling Methods: %s</i></font><br />',implode('|',$methods));
|
|
|
|
|
|
|
|
if (defined('DEBUGTMP') && DEBUGTMP && method_exists($this,$call))
|
|
|
|
printf('<font size=-2>Method Exists: %s::%s (%s)</font><br />',get_class($this),$call,$args);
|
2009-06-30 12:05:31 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (method_exists($this,$call)) {
|
2011-10-06 00:43:40 +00:00
|
|
|
$r = call_user_func_array(array($this,$call),$args);
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (isset($r))
|
|
|
|
return $r;
|
|
|
|
else
|
|
|
|
return;
|
2009-06-30 10:46:00 +00:00
|
|
|
|
|
|
|
} elseif (DEBUG_ENABLED) {
|
2009-08-19 03:39:37 +00:00
|
|
|
debug_log('Doesnt exist param (%s,%s)',1,0,__FILE__,__LINE__,__METHOD__,$method,$fnct);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
printf('<font size=-2><i>NO Methods: %s</i></font><br />',implode('|',$methods));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the LDAP server ID
|
|
|
|
*
|
|
|
|
* @return int Server ID
|
|
|
|
*/
|
|
|
|
public function getServerID() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',129,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->server_id);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (isset($this->server_id))
|
|
|
|
return $this->server_id;
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return this LDAP Server object
|
|
|
|
*
|
|
|
|
* @return object DataStore Server
|
|
|
|
*/
|
|
|
|
protected function getServer() {
|
2009-08-19 03:39:37 +00:00
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
return $_SESSION[APPCONFIG]->getServer($this->getServerID());
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|