1 <?php
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 class P3AdminModule extends CWebModule {
33
34 public $yiicCommand = "./yiic";
35
36 public function init() {
37
38
39
40 $this->setImport(array(
41 'p3admin.models.*',
42 'p3admin.components.*',
43 ));
44
45
46 $metadata = Yii::createComponent(array('class' => 'vendor.phundament.p3admin.components.Metadata'));
47 $this->setComponent('metadata', $metadata);
48 }
49
50 public function beforeControllerAction($controller, $action) {
51 if (parent::beforeControllerAction($controller, $action)) {
52
53
54 Yii::app()->controller->menu = array(
55 array('label' => 'Show Settings', 'url' => array('settings')),
56 );
57 if (Yii::app()->getModule("p3admin")->params["install"]) {
58 EUserFlash::setWarningMessage("P3AdminModule installation mode is active, access is NOT restricted!<br/>" .
59 "Update P3AdminModule config, when you've finished the setup of the application." .
60 "<pre>" .
61 "'p3admin' => array(<br/>" .
62 " 'params' => array('install' => false),<br/>" .
63 "),</pre>", "install");
64 }
65 return true;
66 }
67 else
68 return false;
69 }
70
71 public static function findModules() {
72
73 $dir = Yii::app()->basePath;
74
75 $return = array();
76 if (is_dir($dir . DIRECTORY_SEPARATOR . "extensions")) {
77 foreach (scandir($dir . DIRECTORY_SEPARATOR . "extensions") AS $module) {
78 if ((($module != ".") && ($module != "..")) && (is_dir($dir . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . $module) && strstr($module, ".") === false)) {
79
80 $return[] = $module;
81 }
82 }
83 }
84 return $return;
85 }
86
87 public static function findApplicationControllers() {
88
89 $dir = Yii::app()->basePath;
90
91 $return = array();
92 foreach (scandir($dir . DIRECTORY_SEPARATOR . "controllers") AS $controller) {
93 if (substr($controller, 0, 1) != "." && (is_file($dir . DIRECTORY_SEPARATOR . "controllers" . DIRECTORY_SEPARATOR . $controller))) {
94
95 $return[] = str_replace('Controller.php', '', strtolower($controller[0]) . substr($controller, 1));
96 }
97 }
98 return $return;
99 }
100
101 }
102