11 if (!defined(
'XOOPS_ROOT_PATH')) die(
"Sorry, there are not <a href='../'>nothing here</a>");
15 include_once
RMCPATH.
'/class/textcleaner.php';
24 $db = XoopsDatabaseFactory::getDatabaseConnection();
26 $result =
$db->query(
"SELECT dirname FROM ".
$db->prefix(
"modules").
" WHERE isactive='1'");
29 while (list($module) =
$db->fetchRow(
$result)) {
30 if (is_dir(
$dir = XOOPS_ROOT_PATH .
"/modules/{$module}/events/")) {
31 $file_list = XoopsLists::getFileListAsArray(
$dir);
32 foreach ($file_list as
$file) {
33 if (preg_match(
'/(\.php)$/i', $file)) {
34 $file = substr($file, 0, -4);
35 $this->_preloads[
$i][
'module'] = $module;
36 $this->_preloads[
$i][
'file'] =
$file;
45 foreach ($this->_preloads as $preload) {
46 include_once XOOPS_ROOT_PATH .
'/modules/' . $preload[
'module'] .
'/events/' . $preload[
'file'].
'.php';
47 $class_name = ucfirst($preload[
'module']) . ucfirst($preload[
'file']) .
'Preload' ;
48 if (!class_exists($class_name)) {
51 $class_methods = get_class_methods($class_name);
52 foreach ($class_methods as $method) {
53 if (strpos($method,
'event') === 0) {
54 $event_name = strtolower(str_replace(
'event',
'', $method));
55 $event= array(
'class_name' => $class_name,
'method' => $method);
56 $this->_events[$event_name][] = $event;
66 public function get(){
79 if (is_dir(
$dir.
'/events')){
80 $file_list = XoopsLists::getFileListAsArray(
$dir.
'/events');
81 foreach ($file_list as
$file) {
82 if (preg_match(
'/(\.php)$/i', $file)) {
83 $file = substr($file, 0, -4);
89 foreach ($extra as $preload) {
90 include_once
$dir .
'/events/' . $preload.
'.php';
91 $class_name = ucfirst($name) . ucfirst($preload) .
'Preload' ;
92 if (!class_exists($class_name)) {
95 $class_methods = get_class_methods($class_name);
96 foreach ($class_methods as $method) {
97 if (strpos($method,
'event') === 0) {
98 $event_name = strtolower(str_replace(
'event',
'', $method));
99 $event= array(
'class_name' => $class_name,
'method' => $method);
100 $this->_events[$event_name][] = $event;
113 $event_name = strtolower(str_replace(
'.',
'', $event_name));
114 $args = func_get_args();
115 if (!isset($this->_events[$event_name]))
return $value;
119 foreach ($this->_events[$event_name] as $event) {
121 $xoopsLogger->addExtra($pre, $event[
'class_name'].
'::'.$event[
'method']);
122 $value = call_user_func_array(array($event[
'class_name'], $event[
'method']), array_slice($args, 1));