-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCherry.php
More file actions
81 lines (74 loc) · 2.14 KB
/
Cherry.php
File metadata and controls
81 lines (74 loc) · 2.14 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* cherryphp-framework main class
* This file is cherryphp-framework main class,the project "index.php" file must be included this file.
* @author Einstein.F
* @version 0.0.3
* @license GPL
*/
class Cherry
{
public function __Construct()
{
}
public static function Prepare($config)
{
header("Access-Control-Allow-Origin:*");
Define('DS',DIRECTORY_SEPARATOR);
Define('FRAMEWORK_DIR',dirname(dirname(__FILE__))."/cherryphp");
Define('APP_DIR', dirname(dirname(__FILE__)));
spl_autoload_register(array('Cherry','LoadClass'));
Init::$Router=require(APP_DIR.DS.'router.php');
if(!empty($config)){
Init::$Config=require $config."config.php";
}else{
Init::$Config=require APP_DIR.DS.'config.php';
}
foreach (Init::$Config['define'] as $k=>$v){
Define($k,Init::$Config['define'][$k]);
}
\library\i18n\lang::setlanguage();
#spl_autoload_register(array('Cherry','appClass'));
return new self;
}
public function Execute()
{
new Dispatch();
}
public static function getConfig($params){
if (empty($params)){
return Init::$Config;
}else{
return isset(Init::$Config[$params])?Init::$Config[$params]:"";
}
}
public static function Exe($class)
{
$aa=explode("<=>",$class);
$classname=str_replace("_",DS,$aa[0]);
$action=$aa[1];
if (!empty($aa[2])){
$param=$aa[2];
}else{
$param=null;
}
$classapp=$_SERVER['DOCUMENT_ROOT'].DS.$classname.'.php';
if (is_file($classapp)){
require_once $classapp;
}
$classobj=new $aa[0];
return $classobj->$action($param);
}
public static function LoadClass($class)
{
$classname=str_replace('\\','/',$class);
$framework_class_path=FRAMEWORK_DIR.DS.$classname.'.php';
$script_class_path=APP_DIR.DS.$classname.'.php';
if (is_file($framework_class_path))
{
require_once $framework_class_path;
}else if (is_file($script_class_path)){
require_once $script_class_path;
}
}
}