forked from nbuy/xoops-modules-eguide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.php
58 lines (52 loc) · 1.65 KB
/
plugins.php
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
<?php
global $hooked_function;
$hooked_function = array( 'check' => array(), 'reserve' => array(), 'cancel' => array() );
$dir = EGUIDE_PATH . '/plugins';
$basename = basename( __FILE__ );
// read plugin language file
function eguide_plugin_language( $file ) {
global $xoopsConfig;
$lang = __DIR__ . '/plugins/language';
$nlang = $lang . '/' . $xoopsConfig['language'] . '/' . $file;
if ( file_exists( $nlang ) ) {
return include_once $nlang;
}
$nlang = $lang . '/english/' . $file; // fallback
return include_once $nlang;
}
// register plugin functions
function eguide_plugin_register( $name ) {
global $hooked_function;
foreach ( array( 'check', 'reserve', 'cancel' ) as $act ) {
$func = 'eguide_' . $name . '_' . $act;
if ( function_exists( $func ) ) {
$hooked_function[ $act ][] = $func;
}
}
}
if ( $xoopsModuleConfig['use_plugins'] && is_dir( $dir ) ) {
$plugins = eguide_form_options( 'eguide_plugins', '' );
if ( $plugins ) {
foreach ( explode( ',', $plugins ) as $name ) {
$file = "$name.php";
if ( include( "$dir/$file" ) ) {
eguide_plugin_language( $file );
eguide_plugin_register( $name );
}
}
} else { // search module control plugins
$dh = opendir( $dir );
while ( $file = readdir( $dh ) ) {
if ( preg_match( '/^([\w\d]+)\.php$/', $file, $d ) ) {
$name = $d[1];
$module_handler =& xoops_gethandler( 'module' );
$module =& $module_handler->getByDirname( $name );
if ( $module && $module->getVar( 'isactive' ) && include( "$dir/$file" ) ) {
eguide_plugin_language( $file );
eguide_plugin_register( $name );
// register hook
}
}
}
}
}