summaryrefslogtreecommitdiff
path: root/trunk/reprap/web/part-lister/framework/global.php
blob: 30086fac525ebbd9e4d62d5b9cfac8c41fec7aa2 (plain)
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
59
60
61
62
63
64
<?
	
	// Load Constants
	$f = __FILE__;

	// figure out the base dir, we're two directories past the base dir
	// so just pop them off the end
	$parts = explode("/", $f);
	array_pop($parts);
	array_pop($parts);
	$base_dir = join('/', $parts);
	
	$constants = array(
					   'APP_NAME'			=>	$application_name,
					   'ROOT_DIR_NAME'		=> 	$application_name,
					   'HOME_DIR'			=>	$base_dir,
					   'WEB_DIR' 			=>	$base_dir.'/web/', 
					   'BASE_DIR' 			=>  $base_dir.'/framework/',
					   'EXTENSIONS_DIR' 	=>  $base_dir.'/extensions/',
					   'CLASSES_DIR' 		=>  $base_dir.'/classes/',
					   'INCLUDES_DIR'		=>	$base_dir.'/includes/',
					   'VIEWS_DIR'			=>	$base_dir.'/views/',
					   'CONTROLLERS_DIR'	=>	$base_dir.'/controllers/',
					   'MODELS_DIR'			=>	$base_dir.'/models/',
					   'CRONS_DIR'			=>	$base_dir.'/cron/'
				 );
	
	foreach($constants as $c => $v) {
	 	#echo $v . "<br/>";
	 	
		define($c,$v);
	}
	
	//simply include all our files...
	include(BASE_DIR . "model.php");
	include(BASE_DIR . "view.php");
	include(BASE_DIR . "controller.php");
	include(BASE_DIR . "collection.php");
	include(BASE_DIR . "db.php");
	include(BASE_DIR . "exceptions.php");
	include(BASE_DIR . "file.php");
	
	function __autoload($class)
	{
		$class = strtolower($class);
		
		$file = MODELS_DIR . "$class.php";
		if (is_file($file))
		{
			include($file);
			return true;
		}
		
		$file = CLASSES_DIR . "$class.php";
		if (is_file($file))
		{
			include($file);
			return true;
		}
		
		return false;
	}

?>