class_cloud.php
1.4 KB
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
68
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: class_cloud.php 34000 2013-09-17 08:52:48Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class Cloud {
static private $_loaded = array();
public static function loadClass($className, $params = null) {
if (strpos($className, 'Cloud_') !== 0) {
$className = 'Cloud_' . $className;
}
self::loadFile($className);
$instance = call_user_func_array(array($className, 'getInstance'), (array)$params);
return $instance;
}
public static function loadFile($className) {
$items = explode('_', $className);
if ($items[0] == 'Cloud') {
unset($items[0]);
}
$loadKey = implode('_', $items);
if (isset(self::$_loaded[$loadKey])) {
return true;
}
$file = DISCUZ_ROOT . '/source/plugin/manyou/' . implode('/', $items) . '.php';
if (!is_file($file)) {
throw new Cloud_Exception('Cloud file not exists!', 50001);
}
include $file;
self::$_loaded[$loadKey] = true;
return true;
}
}
class Cloud_Exception extends Exception {
public function __construct($message, $code = 0) {
if ($message instanceof Exception) {
parent::__construct($message->getMessage(), intval($message->getCode()));
} else {
parent::__construct($message, intval($code));
}
}
}
?>