1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: |
|
12: |
|
13: | if (substr(XOOPS_VERSION, 0, 9) < 'XOOPS 2.3') {
|
14: | trigger_error('The package only works for XOOPS 2.3+', E_USER_ERROR);
|
15: | }
|
16: |
|
17: | if (!defined('FRAMEWORKS_ART_FUNCTIONS_INI')):
|
18: | define('FRAMEWORKS_ART_FUNCTIONS_INI', true);
|
19: |
|
20: | define('FRAMEWORKS_ROOT_PATH', XOOPS_ROOT_PATH . '/Frameworks');
|
21: |
|
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: |
|
31: | function load_objectHandler($handler = '', $dirname = 'art')
|
32: | {
|
33: | if (empty($handler)) {
|
34: | $handlerClass = 'ArtObject';
|
35: | $fileName = 'object.php';
|
36: | } else {
|
37: | $handlerClass = 'ArtObject' . ucfirst($handler) . 'Handler';
|
38: | $fileName = "object.{$handler}.php";
|
39: | }
|
40: |
|
41: | class_exists($handlerClass) || require_once FRAMEWORKS_ROOT_PATH . "/{$dirname}/{$fileName}";
|
42: |
|
43: | return class_exists($handlerClass);
|
44: | }
|
45: |
|
46: | |
47: | |
48: |
|
49: | function load_object()
|
50: | {
|
51: | return load_objectHandler();
|
52: | }
|
53: |
|
54: | |
55: | |
56: | |
57: | |
58: | |
59: | |
60: |
|
61: | function load_functions($group = '', $dirname = 'art')
|
62: | {
|
63: | $dirname = ('' == $dirname) ? 'art' : $dirname;
|
64: | $constant = strtoupper("frameworks_{$dirname}_functions" . ($group ? "_{$group}" : ''));
|
65: | if (defined($constant)) {
|
66: | return true;
|
67: | }
|
68: |
|
69: | return include_once FRAMEWORKS_ROOT_PATH . "/{$dirname}/functions.{$group}" . (empty($group) ? '' : '.') . 'php';
|
70: | }
|
71: |
|
72: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | |
83: |
|
84: | function mod_loadFunctions($group = '', $dirname = '')
|
85: | {
|
86: | $dirname = !empty($dirname) ? $dirname : $GLOBALS['xoopsModule']->getVar('dirname', 'n');
|
87: | $constant = strtoupper("{$dirname}_functions" . ($group ? "_{$group}" : '') . '_loaded');
|
88: | if (defined($constant)) {
|
89: | return true;
|
90: | }
|
91: | $filename = XOOPS_ROOT_PATH . "/modules/{$dirname}/include/functions.{$group}" . (empty($group) ? '' : '.') . 'php';
|
92: |
|
93: | return include_once $filename;
|
94: | }
|
95: |
|
96: | |
97: | |
98: | |
99: | |
100: | |
101: | |
102: | |
103: | |
104: | |
105: |
|
106: | function mod_loadRenderer($class, $dirname = '')
|
107: | {
|
108: | $dirname = !empty($dirname) ? $dirname : $GLOBALS['xoopsModule']->getVar('dirname', 'n');
|
109: | $renderer = ucfirst($dirname) . ucfirst($class) . 'Renderer';
|
110: | if (!class_exists($renderer)) {
|
111: | require_once XOOPS_ROOT_PATH . "/modules/{$dirname}/class/{$class}.renderer.php";
|
112: | }
|
113: | $instance = eval("{$renderer}::instance()");
|
114: |
|
115: | return $instance;
|
116: | }
|
117: |
|
118: | |
119: | |
120: | |
121: | |
122: |
|
123: | if (!function_exists('mod_constant')) {
|
124: | |
125: | |
126: | |
127: | |
128: |
|
129: | function mod_constant($name)
|
130: | {
|
131: | if (!empty($GLOBALS['VAR_PREFIXU']) && @defined($GLOBALS['VAR_PREFIXU'] . '_' . strtoupper($name))) {
|
132: | return constant($GLOBALS['VAR_PREFIXU'] . '_' . strtoupper($name));
|
133: | } elseif (!empty($GLOBALS['xoopsModule']) && @defined(strtoupper($GLOBALS['xoopsModule']->getVar('dirname', 'n') . '_' . $name))) {
|
134: | return constant(strtoupper($GLOBALS['xoopsModule']->getVar('dirname', 'n') . '_' . $name));
|
135: | } elseif (defined(strtoupper($name))) {
|
136: | return constant(strtoupper($name));
|
137: | } else {
|
138: | return str_replace('_', ' ', strtolower($name));
|
139: | }
|
140: | }
|
141: | }
|
142: |
|
143: | |
144: | |
145: | |
146: | |
147: | |
148: |
|
149: | if (!function_exists('mod_DB_prefix')) { |
150: | |
151: | |
152: | |
153: | |
154: | |
155: |
|
156: | function mod_DB_prefix($name, $isRel = false)
|
157: | {
|
158: | $relative_name = $GLOBALS['MOD_DB_PREFIX'] . '_' . $name;
|
159: | if ($isRel) {
|
160: | return $relative_name;
|
161: | }
|
162: |
|
163: | return $GLOBALS['xoopsDB']->prefix($relative_name);
|
164: | }
|
165: | }
|
166: |
|
167: | |
168: | |
169: | |
170: | |
171: |
|
172: | if (!function_exists('xoops_message')):
|
173: | |
174: | |
175: | |
176: |
|
177: | function xoops_message($message, $userlevel = 0)
|
178: | {
|
179: | global $xoopsUser;
|
180: |
|
181: | $level = 1;
|
182: | if (!$xoopsUser) {
|
183: | $level = 0;
|
184: | } elseif ($xoopsUser->isAdmin()) {
|
185: | $level = 99;
|
186: | }
|
187: | if ($userlevel > $level) {
|
188: | return null;
|
189: | }
|
190: |
|
191: | echo "<div style=\"clear:both;\"> </div>";
|
192: | if (is_array($message) || is_object($message)) {
|
193: | echo '<div><pre>';
|
194: | print_r($message);
|
195: | echo '</pre></div>';
|
196: | } else {
|
197: | echo "<div>{$message}</div>";
|
198: | }
|
199: | echo "<div style=\"clear:both;\"> </div>";
|
200: | }
|
201: | endif;
|
202: | |
203: | |
204: | |
205: | |
206: |
|
207: | function mod_message($message)
|
208: | {
|
209: | global $xoopsModuleConfig;
|
210: | if (!empty($xoopsModuleConfig['do_debug'])) {
|
211: | if (is_array($message) || is_object($message)) {
|
212: | echo '<div><pre>';
|
213: | print_r($message);
|
214: | echo '</pre></div>';
|
215: | } else {
|
216: | echo "<div>$message</div>";
|
217: | }
|
218: | }
|
219: |
|
220: | return true;
|
221: | }
|
222: |
|
223: | |
224: | |
225: | |
226: | |
227: | |
228: |
|
229: | function mod_getDirname($current_path = null)
|
230: | {
|
231: | if (DIRECTORY_SEPARATOR !== '/') {
|
232: | $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path);
|
233: | }
|
234: | $url_arr = explode('/', strstr($current_path, '/modules/'));
|
235: |
|
236: | return $url_arr[2];
|
237: | }
|
238: |
|
239: | |
240: | |
241: | |
242: | |
243: | |
244: | |
245: | |
246: | |
247: |
|
248: | function mod_isModuleAction($dirname = 'system')
|
249: | {
|
250: | $ret = @(
|
251: | !empty($GLOBALS['xoopsModule']) && 'system' === $GLOBALS['xoopsModule']->getVar('dirname', 'n') &&
|
252: | ($dirname == $_POST['dirname'] || $dirname == $_POST['module']) &&
|
253: | ('update_ok' === $_POST['op'] || 'install_ok' === $_POST['op'] || 'uninstall_ok' === $_POST['op']) &&
|
254: | 'modulesadmin' === $_POST['fct']);
|
255: |
|
256: | return $ret;
|
257: | }
|
258: |
|
259: | endif;
|
260: | |