1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19: defined('XOOPS_ROOT_PATH') || exit('Restricted access');
20:
21: 22: 23:
24: class XoopsLoad
25: {
26:
27:
28:
29: 30: 31: 32: 33: 34:
35: public static function load($name, $type = 'core')
36: {
37: static $loaded;
38: static $deprecated;
39:
40: if (!isset($deprecated)) {
41: $deprecated = array(
42: 'uploader' => 'xoopsmediauploader',
43: 'utility' => 'xoopsutility',
44: 'captcha' => 'xoopscaptcha',
45: 'cache' => 'xoopscache',
46: 'file' => 'xoopsfile',
47: 'model' => 'xoopsmodelfactory',
48: 'calendar' => 'xoopscalendar',
49: 'userutility' => 'xoopsuserutility');
50: }
51: $name = strtolower($name);
52: if (in_array($type, array('core', 'class')) && array_key_exists($name, $deprecated)) {
53: if (isset($GLOBALS['xoopsLogger'])) {
54: $GLOBALS['xoopsLogger']->addDeprecated("xoops_load('{$name}') is deprecated, use xoops_load('{$deprecated[$name]}')");
55: } else {
56: trigger_error("xoops_load('{$name}') is deprecated, use xoops_load('{$deprecated[$name]}')", E_USER_WARNING);
57: }
58: $name = $deprecated[$name];
59: }
60:
61: $type = empty($type) ? 'core' : $type;
62: if (isset($loaded[$type][$name])) {
63: return $loaded[$type][$name];
64: }
65:
66: if (class_exists($name, false)) {
67: $loaded[$type][$name] = true;
68:
69: return true;
70: }
71: $isloaded = false;
72: switch ($type) {
73: case 'framework':
74: $isloaded = XoopsLoad::loadFramework($name);
75: break;
76: case 'class':
77: case 'core':
78: $type = 'core';
79: $isloaded = XoopsLoad::loadCore($name);
80: break;
81: default:
82: $isloaded = XoopsLoad::loadModule($name, $type);
83: break;
84: }
85: $loaded[$type][$name] = $isloaded;
86:
87: return $loaded[$type][$name];
88: }
89:
90: 91: 92: 93: 94: 95: 96:
97: public static function loadCore($name)
98: {
99: static $configs;
100:
101: if (!isset($configs)) {
102: $configs = XoopsLoad::loadCoreConfig();
103: }
104: if (isset($configs[$name])) {
105: require_once $configs[$name];
106: if (class_exists($name) && method_exists($name, '__autoload')) {
107: call_user_func(array($name, '__autoload'));
108: }
109:
110: return true;
111: } elseif (file_exists($file = XOOPS_ROOT_PATH . '/class/' . $name . '.php')) {
112: include_once $file;
113: $class = 'Xoops' . ucfirst($name);
114: if (class_exists($class)) {
115: return $class;
116: } else {
117: trigger_error('Class ' . $name . ' not found in file ' . __FILE__ . 'at line ' . __LINE__, E_USER_WARNING);
118: }
119: }
120:
121: return false;
122: }
123:
124: 125: 126: 127: 128: 129: 130:
131: public static function loadFramework($name)
132: {
133: if (!file_exists($file = XOOPS_ROOT_PATH . '/Frameworks/' . $name . '/xoops' . $name . '.php')) {
134: trigger_error('File ' . str_replace(XOOPS_ROOT_PATH, '', $file) . ' not found in file ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING);
135:
136: return false;
137: }
138: include_once $file;
139: $class = 'Xoops' . ucfirst($name);
140: if (class_exists($class)) {
141: return $class;
142: }
143: return null;
144: }
145:
146: 147: 148: 149: 150: 151: 152: 153:
154: public static function loadModule($name, $dirname = null)
155: {
156: if (empty($dirname)) {
157: return false;
158: }
159: if (file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/class/' . $name . '.php')) {
160: include_once $file;
161: if (class_exists(ucfirst($dirname) . ucfirst($name))) {
162: return true;
163: }
164: }
165:
166: return false;
167: }
168:
169: 170: 171: 172: 173:
174: public static function loadCoreConfig()
175: {
176: return $configs = array(
177: 'xoopsuserutility' => XOOPS_ROOT_PATH . '/class/userutility.php',
178: 'xoopsmediauploader' => XOOPS_ROOT_PATH . '/class/uploader.php',
179: 'xoopsutility' => XOOPS_ROOT_PATH . '/class/utility/xoopsutility.php',
180: 'xoopscaptcha' => XOOPS_ROOT_PATH . '/class/captcha/xoopscaptcha.php',
181: 'xoopscache' => XOOPS_ROOT_PATH . '/class/cache/xoopscache.php',
182: 'xoopsfile' => XOOPS_ROOT_PATH . '/class/file/xoopsfile.php',
183: 'xoopsmodelfactory' => XOOPS_ROOT_PATH . '/class/model/xoopsmodel.php',
184: 'xoopscalendar' => XOOPS_ROOT_PATH . '/class/calendar/xoopscalendar.php',
185: 'xoopskernel' => XOOPS_ROOT_PATH . '/class/xoopskernel.php',
186: 'xoopssecurity' => XOOPS_ROOT_PATH . '/class/xoopssecurity.php',
187: 'xoopslogger' => XOOPS_ROOT_PATH . '/class/logger/xoopslogger.php',
188: 'xoopspagenav' => XOOPS_ROOT_PATH . '/class/pagenav.php',
189: 'xoopslists' => XOOPS_ROOT_PATH . '/class/xoopslists.php',
190: 'xoopslocal' => XOOPS_ROOT_PATH . '/include/xoopslocal.php',
191: 'xoopslocalabstract' => XOOPS_ROOT_PATH . '/class/xoopslocal.php',
192: 'xoopseditor' => XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php',
193: 'xoopseditorhandler' => XOOPS_ROOT_PATH . '/class/xoopseditor/xoopseditor.php',
194: 'xoopsformloader' => XOOPS_ROOT_PATH . '/class/xoopsformloader.php',
195: 'xoopsformelement' => XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php',
196: 'xoopsform' => XOOPS_ROOT_PATH . '/class/xoopsform/form.php',
197: 'xoopsformlabel' => XOOPS_ROOT_PATH . '/class/xoopsform/formlabel.php',
198: 'xoopsformselect' => XOOPS_ROOT_PATH . '/class/xoopsform/formselect.php',
199: 'xoopsformpassword' => XOOPS_ROOT_PATH . '/class/xoopsform/formpassword.php',
200: 'xoopsformbutton' => XOOPS_ROOT_PATH . '/class/xoopsform/formbutton.php',
201: 'xoopsformbuttontray' => XOOPS_ROOT_PATH . '/class/xoopsform/formbuttontray.php',
202: 'xoopsformcheckbox' => XOOPS_ROOT_PATH . '/class/xoopsform/formcheckbox.php',
203: 'xoopsformselectcheckgroup' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectcheckgroup.php',
204: 'xoopsformhidden' => XOOPS_ROOT_PATH . '/class/xoopsform/formhidden.php',
205: 'xoopsformfile' => XOOPS_ROOT_PATH . '/class/xoopsform/formfile.php',
206: 'xoopsformradio' => XOOPS_ROOT_PATH . '/class/xoopsform/formradio.php',
207: 'xoopsformradioyn' => XOOPS_ROOT_PATH . '/class/xoopsform/formradioyn.php',
208: 'xoopsformselectcountry' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectcountry.php',
209: 'xoopsformselecttimezone' => XOOPS_ROOT_PATH . '/class/xoopsform/formselecttimezone.php',
210: 'xoopsformselectlang' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectlang.php',
211: 'xoopsformselectgroup' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectgroup.php',
212: 'xoopsformselectuser' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectuser.php',
213: 'xoopsformselecttheme' => XOOPS_ROOT_PATH . '/class/xoopsform/formselecttheme.php',
214: 'xoopsformselectmatchoption' => XOOPS_ROOT_PATH . '/class/xoopsform/formselectmatchoption.php',
215: 'xoopsformtext' => XOOPS_ROOT_PATH . '/class/xoopsform/formtext.php',
216: 'xoopsformtextarea' => XOOPS_ROOT_PATH . '/class/xoopsform/formtextarea.php',
217: 'xoopsformdhtmltextarea' => XOOPS_ROOT_PATH . '/class/xoopsform/formdhtmltextarea.php',
218: 'xoopsformelementtray' => XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php',
219: 'xoopsthemeform' => XOOPS_ROOT_PATH . '/class/xoopsform/themeform.php',
220: 'xoopssimpleform' => XOOPS_ROOT_PATH . '/class/xoopsform/simpleform.php',
221: 'xoopsformtextdateselect' => XOOPS_ROOT_PATH . '/class/xoopsform/formtextdateselect.php',
222: 'xoopsformdatetime' => XOOPS_ROOT_PATH . '/class/xoopsform/formdatetime.php',
223: 'xoopsformhiddentoken' => XOOPS_ROOT_PATH . '/class/xoopsform/formhiddentoken.php',
224: 'xoopsformcolorpicker' => XOOPS_ROOT_PATH . '/class/xoopsform/formcolorpicker.php',
225: 'xoopsformcaptcha' => XOOPS_ROOT_PATH . '/class/xoopsform/formcaptcha.php',
226: 'xoopsformeditor' => XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php',
227: 'xoopsformselecteditor' => XOOPS_ROOT_PATH . '/class/xoopsform/formselecteditor.php',
228: 'xoopsformcalendar' => XOOPS_ROOT_PATH . '/class/xoopsform/formcalendar.php',
229: 'xoopsformrenderer' => XOOPS_ROOT_PATH . '/class/xoopsform/renderer/XoopsFormRenderer.php',
230: 'xoopsformrendererinterface' => XOOPS_ROOT_PATH . '/class/xoopsform/renderer/XoopsFormRendererInterface.php',
231: 'xoopsformrendererlegacy' => XOOPS_ROOT_PATH . '/class/xoopsform/renderer/XoopsFormRendererLegacy.php',
232: 'xoopsformrendererbootstrap3'=> XOOPS_ROOT_PATH . '/class/xoopsform/renderer/XoopsFormRendererBootstrap3.php',
233: 'xoopsfilterinput' => XOOPS_ROOT_PATH . '/class/xoopsfilterinput.php',
234: 'xoopsrequest' => XOOPS_ROOT_PATH . '/class/xoopsrequest.php');
235: }
236:
237: 238: 239: 240: 241: 242: 243:
244: public function loadConfig($data = null)
245: {
246: if (is_array($data)) {
247: $configs = $data;
248: } else {
249: if (!empty($data)) {
250: $dirname = $data;
251: } elseif (is_object($GLOBALS['xoopsModule'])) {
252: $dirname = $GLOBALS['xoopsModule']->getVar('dirname', 'n');
253: } else {
254: return false;
255: }
256: if (file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/include/autoload.php')) {
257: if (!$configs = include $file) {
258: return false;
259: }
260: }
261: }
262:
263: return $configs = array_merge(XoopsLoad::loadCoreConfig(), $configs);
264: }
265: }
266:
267:
268:
269: 270: 271:
272: include_once XOOPS_ROOT_PATH . '/class/libraries/vendor/autoload.php';
273: