forked from extern/egroupware
nicer implementation of CreateObject and some small fixes
This commit is contained in:
parent
42f8c9182e
commit
7135243d06
@ -616,7 +616,7 @@ class Etemplate extends Etemplate\Widget\Template
|
||||
/**
|
||||
* disables all cells with name == $name
|
||||
*
|
||||
* @param sting $name cell-name
|
||||
* @param string $name cell-name
|
||||
* @param boolean $disabled =true disable or enable a cell, default true=disable
|
||||
* @return reference to attribute
|
||||
* @deprecated use disableElement($name, $disabled=true)
|
||||
|
@ -11,15 +11,14 @@
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @package api
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
// this is only neccessary, if header.inc.php is not included, but api/src/autoload.php directly
|
||||
// this is only necessary, if header.inc.php is not included, but api/src/autoload.php directly
|
||||
if (!defined('EGW_SERVER_ROOT'))
|
||||
{
|
||||
define('EGW_SERVER_ROOT', dirname(dirname(__DIR__)));
|
||||
define('EGW_INCLUDE_ROOT', EGW_SERVER_ROOT);
|
||||
define('EGW_API_INC', EGW_SERVER_ROOT.'/phpgwapi/inc');
|
||||
if (file_exists(EGW_SERVER_ROOT.'/phpgwapi/inc')) define('EGW_API_INC', EGW_SERVER_ROOT.'/phpgwapi/inc');
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
}
|
||||
|
||||
|
@ -61,33 +61,8 @@ function CreateObject($class)
|
||||
require_once(EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
|
||||
}
|
||||
$args = func_get_args();
|
||||
switch(count($args))
|
||||
{
|
||||
case 1:
|
||||
$obj = new $classname;
|
||||
break;
|
||||
case 2:
|
||||
$obj = new $classname($args[1]);
|
||||
break;
|
||||
case 3:
|
||||
$obj = new $classname($args[1],$args[2]);
|
||||
break;
|
||||
case 4:
|
||||
$obj = new $classname($args[1],$args[2],$args[3]);
|
||||
break;
|
||||
default:
|
||||
$code = '$obj = new ' . $classname . '(';
|
||||
foreach(array_keys($args) as $n)
|
||||
{
|
||||
if ($n)
|
||||
{
|
||||
$code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
|
||||
}
|
||||
}
|
||||
$code .= ');';
|
||||
eval($code);
|
||||
break;
|
||||
}
|
||||
array_shift($args);
|
||||
$obj = new $classname(...$args);
|
||||
if (!is_object($obj))
|
||||
{
|
||||
echo "<p>CreateObject('$class'): Cant instanciate class!!!<br />\n".function_backtrace(1)."</p>\n";
|
||||
|
Loading…
Reference in New Issue
Block a user