import mtweb.0.4.1
[mtweb] / web / app / env / modules / mw_env_init.php
1 <?php
2
3   class mw_env_init extends mw_env
4   {
5
6     function init()
7     { $init_files = array();
8       if(($plugins = $this->plugins()) !== false)
9       { foreach($plugins as $plugin_name => $plugin)
10         { $init_path = $this->path("plugins").$plugin_name."/app/init/";
11           if
12           (    $plugin["installed"]
13             && $plugin["enabled"]
14             && file_exists($init_path)
15             && is_dir($init_path)
16           )
17           { if($dh = opendir($init_path))
18             { $files = array();
19               while(($file = readdir($dh)) !== false)
20               { if
21                 (    substr($file, 0, 1) != "."
22                   && !is_dir($init_path.$file)
23                   && strcmp(substr($file, -4), ".php") == 0
24                   && !isset($init_files[$file])
25                 ) $init_files[$file] = $init_path;
26               }
27               closedir($dh);
28               
29             }
30             else $this->erreur("impossible d'ouvrir le dossier init du plugin ".$plugin_name, true);
31           }
32           if($this->check_stop()) return;
33         }
34         $init_path = $this->path("app")."init/";
35         if
36         (    file_exists($init_path)
37           && is_dir($init_path)
38         )
39         { if($dh = opendir($init_path))
40           { $files = array();
41             while(($file = readdir($dh)) !== false)
42             { if
43               (    substr($file, 0, 1) != "."
44                 && !is_dir($init_path.$file)
45                 && strcmp(substr($file, -4), ".php") == 0
46               ) $init_files[$file] = $init_path;
47             }
48             closedir($dh);
49           }
50           else $this->erreur("impossible d'ouvrir le dossier init du plugin ".$plugin_name, true);
51         }
52       }
53       if($this->check_stop()) return;
54       if($init_files)
55       { ksort($init_files);
56         foreach($init_files as $file => $init_path)
57         { require $init_path.$file;
58           if($this->check_stop()) return;
59         }
60       }
61     }
62
63   }
64
65 ?>