-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
38 lines (34 loc) · 1.08 KB
/
setup.php
File metadata and controls
38 lines (34 loc) · 1.08 KB
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
<?
/**
* Load up some information about the plugin, branch, directory etc
*/
define("PLUGIN_NAME", "shape");
define('SHAPE_BRANCH', 'v1');
define("SHAPE_DIR", dirname(__FILE__));
if(is_readable(SHAPE_DIR.'/.git/refs/heads/'.SHAPE_BRANCH)) $revision = file_get_contents(SHAPE_DIR.'/.git/refs/heads/'.SHAPE_BRANCH);
else $revision = "";
define('SHAPE_REVISION', $revision);
/**
* Find and log all the available modules
* - check cache
* - glob the current directory
* - check its readable
* - make sure its a controller
* - add to array
*/
$cache = new WaxCacheFile(CACHE_DIR."shape", "forever", 'cache', CACHE_DIR."shape/modules.cache");
if($found = $cache->get()) $found = unserialize($found);
else{
$found = array();
$path = SHAPE_DIR."/resources/app/controller/".PLUGIN_NAME."/*.php";
foreach(glob($path) as $file){
if(is_readable($file)){
$name = substr(basename($file),0,-4);
$model = new $name(false);
if($model instanceOf ShapeBaseController) $found[$name] = $name;
}
}
$cache->set(serialize($found));
}
define("CONTROLLER_LIST", serialize($found));
?>