<?php class core { private static $_tables; public static function t($name) { return self::_make_obj($name, "table", DISCUZ_TABLE_EXTENDABLE); } protected static function _make_obj($name, $type, $extendable=false, $p=array()) { $pluginid = null; //根据$name的首字母是否为#,确定是否要调用插件目录中的类 if ($name[0] == "#") { list(, $pluginid, $name) = explode("#", $name); } $cname = $type."_".$name; if (!isset(self::$_tables[$cname])) { //bool class_exists(string $class_name [,bool $autoload = true]) //检查指定的类是否已定义 //class_name 类名 //autoload 是否默认调用__autoload if (!class_exists($cname, false)) { self::import(($pluginid ? "plugin/".$pluginid : "class")."/".$type."/".$name); } if ($extendable) { self::$_tables[$cname] = new discuz_container(); switch (count($p)) { case 0: self::$_tables[$cname]->obj = new $cname();break; case 1: self::$_tables[$cname]->obj = new $cname($p[1]);break; case 2: self::$_tables[$cname]->obj = new $cname($p[1], $p[2]);break; case 3: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3]);break; case 4: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4]);break; case 5: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4], $p[5]);break; default: $ref = new ReflectionClass($cname); self::$_tables[$cname]->obj = $ref->newInstanceArgs($p); unset($ref); break; } } else { self::$_tables[$cname] = new $cname(); } } return self::$_tables[$cname]; } } ?>