@@ -85,6 +85,10 @@ |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | # $type - page,view |
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
88 | 92 | public function file($name=false){ |
89 | 93 | if($name === false){ |
90 | 94 | $path = self::$config['core']['page']; |
@@ -100,17 +100,17 @@ |
||
100 | 100 | $currentUri = null; |
101 | 101 | $filePhtml = null; |
102 | 102 | for($i=count($uri)-1; $i>=0; $i--){ |
103 | - $nextUri = implode('/',array_slice($uri,0,$i+1)); |
|
104 | - $getFile = function($type) use($path,$nextUri){ |
|
103 | + $nextUri = implode('/',array_slice($uri,0,$i+1)); |
|
104 | + $getFile = function($type) use($path,$nextUri){ |
|
105 | 105 | $file = $path.'/'.$nextUri.'/index.'.$type; |
106 | 106 | if(is_file($file)) return $file; |
107 | 107 | return null; |
108 | - }; |
|
109 | - $filePhtml = $getFile('phtml'); |
|
110 | - if($filePhtml) { $currentUri = $nextUri; break; } |
|
108 | + }; |
|
109 | + $filePhtml = $getFile('phtml'); |
|
110 | + if($filePhtml) { $currentUri = $nextUri; break; } |
|
111 | 111 | } |
112 | 112 | if($filePhtml === null) { |
113 | - $filePhtml = $path.'/index.phtml'; |
|
113 | + $filePhtml = $path.'/index.phtml'; |
|
114 | 114 | } |
115 | 115 | return $filePhtml; |
116 | 116 | } |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | self::$path = explode('/',parse_url(urldecode($_SERVER['REQUEST_URI']))['path']); |
26 | 26 | foreach(self::$path as $key=>$value){ |
27 | 27 | $value = trim($value); |
28 | - if(empty($value)) unset(self::$path[$key]); |
|
28 | + if(empty($value)) { |
|
29 | + unset(self::$path[$key]); |
|
30 | + } |
|
29 | 31 | } |
30 | 32 | self::$path = array_values(self::$path); |
31 | 33 | # Application |
@@ -47,15 +49,20 @@ discard block |
||
47 | 49 | # Uri |
48 | 50 | self::$uri = explode('/',$_SERVER['REQUEST_URI']); |
49 | 51 | foreach(self::$uri as $key=>$value){ |
50 | - if(empty($value)) unset(self::$uri[$key]); |
|
51 | - else self::$uri[$key] = urldecode($value); |
|
52 | + if(empty($value)) { |
|
53 | + unset(self::$uri[$key]); |
|
54 | + } else { |
|
55 | + self::$uri[$key] = urldecode($value); |
|
56 | + } |
|
52 | 57 | } |
53 | 58 | self::$uri = array_values(self::$uri); |
54 | 59 | } |
55 | 60 | |
56 | 61 | public function view($name){ |
57 | 62 | $file = $this->file($name); |
58 | - if(is_file($file)) require $file; |
|
63 | + if(is_file($file)) { |
|
64 | + require $file; |
|
65 | + } |
|
59 | 66 | } |
60 | 67 | |
61 | 68 | public function page(){ |
@@ -103,7 +110,9 @@ discard block |
||
103 | 110 | $nextUri = implode('/',array_slice($uri,0,$i+1)); |
104 | 111 | $getFile = function($type) use($path,$nextUri){ |
105 | 112 | $file = $path.'/'.$nextUri.'/index.'.$type; |
106 | - if(is_file($file)) return $file; |
|
113 | + if(is_file($file)) { |
|
114 | + return $file; |
|
115 | + } |
|
107 | 116 | return null; |
108 | 117 | }; |
109 | 118 | $filePhtml = $getFile('phtml'); |
@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | private static $keywords; |
17 | 17 | private static $uri; |
18 | 18 | |
19 | - public function __construct(){ |
|
19 | + public function __construct() { |
|
20 | 20 | # Config |
21 | 21 | self::$config = (new Config)->get(); |
22 | 22 | # Host |
23 | 23 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST'])['host']; |
24 | 24 | # Url |
25 | - self::$path = explode('/',parse_url(urldecode($_SERVER['REQUEST_URI']))['path']); |
|
26 | - foreach(self::$path as $key=>$value){ |
|
25 | + self::$path = explode('/', parse_url(urldecode($_SERVER['REQUEST_URI']))['path']); |
|
26 | + foreach (self::$path as $key=>$value) { |
|
27 | 27 | $value = trim($value); |
28 | - if(empty($value)) unset(self::$path[$key]); |
|
28 | + if (empty($value)) unset(self::$path[$key]); |
|
29 | 29 | } |
30 | 30 | self::$path = array_values(self::$path); |
31 | 31 | # Application |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | # Keywords |
46 | 46 | self::$keywords = new Keywords; |
47 | 47 | # Uri |
48 | - self::$uri = explode('/',$_SERVER['REQUEST_URI']); |
|
49 | - foreach(self::$uri as $key=>$value){ |
|
50 | - if(empty($value)) unset(self::$uri[$key]); |
|
48 | + self::$uri = explode('/', $_SERVER['REQUEST_URI']); |
|
49 | + foreach (self::$uri as $key=>$value) { |
|
50 | + if (empty($value)) unset(self::$uri[$key]); |
|
51 | 51 | else self::$uri[$key] = urldecode($value); |
52 | 52 | } |
53 | 53 | self::$uri = array_values(self::$uri); |
54 | 54 | } |
55 | 55 | |
56 | - public function view($name){ |
|
56 | + public function view($name) { |
|
57 | 57 | $file = $this->file($name); |
58 | - if(is_file($file)) require $file; |
|
58 | + if (is_file($file)) require $file; |
|
59 | 59 | } |
60 | 60 | |
61 | - public function page(){ |
|
61 | + public function page() { |
|
62 | 62 | # get file |
63 | 63 | $file = $this->file(); |
64 | 64 | # get content |
@@ -76,46 +76,46 @@ discard block |
||
76 | 76 | # get keywords |
77 | 77 | $keywords = self::$keywords->get(); |
78 | 78 | # include for page |
79 | - $content = preg_replace('/<head>/',"<head>$keywords",$content); |
|
80 | - $content = preg_replace('/<head>/',"<head>$description",$content); |
|
81 | - $content = preg_replace('/<head>/',"<head>$title",$content); |
|
82 | - $content = preg_replace('/<\/head>/',"$css</head>",$content); |
|
83 | - $content = preg_replace('/<\/body>/',"$js</body>",$content); |
|
79 | + $content = preg_replace('/<head>/', "<head>$keywords", $content); |
|
80 | + $content = preg_replace('/<head>/', "<head>$description", $content); |
|
81 | + $content = preg_replace('/<head>/', "<head>$title", $content); |
|
82 | + $content = preg_replace('/<\/head>/', "$css</head>", $content); |
|
83 | + $content = preg_replace('/<\/body>/', "$js</body>", $content); |
|
84 | 84 | $minify = new MinifyHTML($content); |
85 | 85 | $content = $minify->compress(); |
86 | 86 | echo $content; |
87 | 87 | } |
88 | 88 | |
89 | - public function js($query){ |
|
89 | + public function js($query) { |
|
90 | 90 | echo self::$js->compile($query); |
91 | 91 | } |
92 | 92 | |
93 | 93 | # $type - page,view |
94 | - public function file($name=false){ |
|
95 | - if($name === false){ |
|
94 | + public function file($name = false) { |
|
95 | + if ($name === false) { |
|
96 | 96 | $path = self::$config['core']['page']; |
97 | 97 | } else { |
98 | 98 | $path = self::$config['core']['view'].'/'.$name; |
99 | 99 | } |
100 | 100 | # Route |
101 | 101 | $uri = self::$path; |
102 | - array_push($uri,''); |
|
103 | - foreach($uri as $key=>$value){ if(empty(trim($value))) { unset($uri[$key]); continue; } } |
|
102 | + array_push($uri, ''); |
|
103 | + foreach ($uri as $key=>$value) { if (empty(trim($value))) { unset($uri[$key]); continue; } } |
|
104 | 104 | $uri = array_values($uri); |
105 | 105 | $isFile = null; |
106 | 106 | $currentUri = null; |
107 | 107 | $filePhtml = null; |
108 | - for($i=count($uri)-1; $i>=0; $i--){ |
|
109 | - $nextUri = implode('/',array_slice($uri,0,$i+1)); |
|
110 | - $getFile = function($type) use($path,$nextUri){ |
|
108 | + for ($i = count($uri)-1; $i>=0; $i--) { |
|
109 | + $nextUri = implode('/', array_slice($uri, 0, $i+1)); |
|
110 | + $getFile = function($type) use($path, $nextUri){ |
|
111 | 111 | $file = $path.'/'.$nextUri.'/index.'.$type; |
112 | - if(is_file($file)) return $file; |
|
112 | + if (is_file($file)) return $file; |
|
113 | 113 | return null; |
114 | 114 | }; |
115 | 115 | $filePhtml = $getFile('phtml'); |
116 | - if($filePhtml) { $currentUri = $nextUri; break; } |
|
116 | + if ($filePhtml) { $currentUri = $nextUri; break; } |
|
117 | 117 | } |
118 | - if($filePhtml === null) { |
|
118 | + if ($filePhtml === null) { |
|
119 | 119 | $filePhtml = $path.'/index.phtml'; |
120 | 120 | } |
121 | 121 | return $filePhtml; |
@@ -7,23 +7,23 @@ |
||
7 | 7 | private static $config; |
8 | 8 | private static $application = []; |
9 | 9 | |
10 | - public function __construct(){ |
|
10 | + public function __construct() { |
|
11 | 11 | self::$config = (new Config)->get(); |
12 | 12 | } |
13 | 13 | |
14 | - public function __get($name){ |
|
15 | - array_push(self::$application,$name); |
|
14 | + public function __get($name) { |
|
15 | + array_push(self::$application, $name); |
|
16 | 16 | return (new self); |
17 | 17 | } |
18 | 18 | |
19 | - public function __call($name,$value){ |
|
20 | - array_push(self::$application,$name); |
|
21 | - $file = implode('/',self::$application); |
|
19 | + public function __call($name, $value) { |
|
20 | + array_push(self::$application, $name); |
|
21 | + $file = implode('/', self::$application); |
|
22 | 22 | $file = self::$config['core']['apps'].'/'.$file.'.php'; |
23 | 23 | self::$application = []; |
24 | - if(is_file($file)) { |
|
24 | + if (is_file($file)) { |
|
25 | 25 | $result = require($file); |
26 | - if(is_callable($result)) $result = call_user_func_array($result,$value); |
|
26 | + if (is_callable($result)) $result = call_user_func_array($result, $value); |
|
27 | 27 | return $result; |
28 | 28 | } |
29 | 29 | } |
@@ -23,7 +23,9 @@ |
||
23 | 23 | self::$application = []; |
24 | 24 | if(is_file($file)) { |
25 | 25 | $result = require($file); |
26 | - if(is_callable($result)) $result = call_user_func_array($result,$value); |
|
26 | + if(is_callable($result)) { |
|
27 | + $result = call_user_func_array($result,$value); |
|
28 | + } |
|
27 | 29 | return $result; |
28 | 30 | } |
29 | 31 | } |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | public static $config = []; |
7 | 7 | |
8 | - public function __construct($config=[]){ |
|
9 | - self::$config = array_merge(self::$config,$config); |
|
8 | + public function __construct($config = []) { |
|
9 | + self::$config = array_merge(self::$config, $config); |
|
10 | 10 | } |
11 | 11 | |
12 | - public function get(){ |
|
12 | + public function get() { |
|
13 | 13 | return self::$config; |
14 | 14 | } |
15 | 15 |
@@ -7,31 +7,31 @@ |
||
7 | 7 | private static $host; |
8 | 8 | private static $config; |
9 | 9 | |
10 | - public function __construct(){ |
|
10 | + public function __construct() { |
|
11 | 11 | # Config |
12 | 12 | self::$config = (new Config)->get(); |
13 | 13 | # Host |
14 | 14 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST']); |
15 | - if(isset(self::$host['host'])) self::$host = self::$host['host']; |
|
15 | + if (isset(self::$host['host'])) self::$host = self::$host['host']; |
|
16 | 16 | else self::$host = '/'; |
17 | 17 | } |
18 | 18 | |
19 | - public function add($css){ |
|
20 | - if(!is_array($css)) $css = [$css]; |
|
21 | - self::$list = array_merge(self::$list,$css); |
|
19 | + public function add($css) { |
|
20 | + if (!is_array($css)) $css = [$css]; |
|
21 | + self::$list = array_merge(self::$list, $css); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function get(){ |
|
24 | + public function get() { |
|
25 | 25 | $css = array_unique(self::$list); |
26 | 26 | $code = ''; |
27 | - foreach($css as $name){ |
|
27 | + foreach ($css as $name) { |
|
28 | 28 | $file = self::$config['core']['css'].'/'.$name.'.css'; |
29 | - if(is_file($file)) $code .= file_get_contents($file); |
|
29 | + if (is_file($file)) $code .= file_get_contents($file); |
|
30 | 30 | } |
31 | 31 | return "<style>$code</style>"; |
32 | 32 | } |
33 | 33 | |
34 | - public function compile(){ |
|
34 | + public function compile() { |
|
35 | 35 | # ... |
36 | 36 | } |
37 | 37 |
@@ -12,12 +12,17 @@ discard block |
||
12 | 12 | self::$config = (new Config)->get(); |
13 | 13 | # Host |
14 | 14 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST']); |
15 | - if(isset(self::$host['host'])) self::$host = self::$host['host']; |
|
16 | - else self::$host = '/'; |
|
15 | + if(isset(self::$host['host'])) { |
|
16 | + self::$host = self::$host['host']; |
|
17 | + } else { |
|
18 | + self::$host = '/'; |
|
19 | + } |
|
17 | 20 | } |
18 | 21 | |
19 | 22 | public function add($css){ |
20 | - if(!is_array($css)) $css = [$css]; |
|
23 | + if(!is_array($css)) { |
|
24 | + $css = [$css]; |
|
25 | + } |
|
21 | 26 | self::$list = array_merge(self::$list,$css); |
22 | 27 | } |
23 | 28 | |
@@ -26,7 +31,9 @@ discard block |
||
26 | 31 | $code = ''; |
27 | 32 | foreach($css as $name){ |
28 | 33 | $file = self::$config['core']['css'].'/'.$name.'.css'; |
29 | - if(is_file($file)) $code .= file_get_contents($file); |
|
34 | + if(is_file($file)) { |
|
35 | + $code .= file_get_contents($file); |
|
36 | + } |
|
30 | 37 | } |
31 | 38 | return "<style>$code</style>"; |
32 | 39 | } |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | - public function add($title){ |
|
9 | - if(!is_array($title)) $title = [$title]; |
|
10 | - self::$memory = array_merge(self::$memory,$title); |
|
8 | + public function add($title) { |
|
9 | + if (!is_array($title)) $title = [$title]; |
|
10 | + self::$memory = array_merge(self::$memory, $title); |
|
11 | 11 | return $this; |
12 | 12 | } |
13 | 13 | |
14 | - public function get(){ |
|
14 | + public function get() { |
|
15 | 15 | self::$memory = array_reverse(self::$memory); |
16 | - foreach(self::$memory as $key=>$value){ |
|
16 | + foreach (self::$memory as $key=>$value) { |
|
17 | 17 | $value = urldecode($value); |
18 | 18 | self::$memory[$key] = $value; |
19 | 19 | } |
20 | - return '<meta name="description" content="'.implode(' ',self::$memory).'">'; |
|
20 | + return '<meta name="description" content="'.implode(' ', self::$memory).'">'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } |
@@ -6,7 +6,9 @@ |
||
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | 8 | public function add($title){ |
9 | - if(!is_array($title)) $title = [$title]; |
|
9 | + if(!is_array($title)) { |
|
10 | + $title = [$title]; |
|
11 | + } |
|
10 | 12 | self::$memory = array_merge(self::$memory,$title); |
11 | 13 | return $this; |
12 | 14 | } |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | - public function add($title){ |
|
9 | - if(!is_array($title)) $title = [$title]; |
|
10 | - self::$memory = array_merge(self::$memory,$title); |
|
8 | + public function add($title) { |
|
9 | + if (!is_array($title)) $title = [$title]; |
|
10 | + self::$memory = array_merge(self::$memory, $title); |
|
11 | 11 | return $this; |
12 | 12 | } |
13 | 13 | |
14 | - public function get(){ |
|
14 | + public function get() { |
|
15 | 15 | self::$memory = array_reverse(self::$memory); |
16 | - foreach(self::$memory as $key=>$value){ |
|
16 | + foreach (self::$memory as $key=>$value) { |
|
17 | 17 | $value = urldecode($value); |
18 | 18 | self::$memory[$key] = $value; |
19 | 19 | } |
20 | - return '<meta name="keywords" content="'.implode(',',self::$memory).'">'; |
|
20 | + return '<meta name="keywords" content="'.implode(',', self::$memory).'">'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } |
@@ -6,7 +6,9 @@ |
||
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | 8 | public function add($title){ |
9 | - if(!is_array($title)) $title = [$title]; |
|
9 | + if(!is_array($title)) { |
|
10 | + $title = [$title]; |
|
11 | + } |
|
10 | 12 | self::$memory = array_merge(self::$memory,$title); |
11 | 13 | return $this; |
12 | 14 | } |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | |
8 | 8 | $config = (new Config)->get(); |
9 | 9 | |
10 | - if(!isset($_SERVER['HTTP_ACCEPT'])) $_SERVER['HTTP_ACCEPT'] = '*/*'; |
|
10 | + if(!isset($_SERVER['HTTP_ACCEPT'])) { |
|
11 | + $_SERVER['HTTP_ACCEPT'] = '*/*'; |
|
12 | + } |
|
11 | 13 | $acceptSrc = explode(',',$_SERVER['HTTP_ACCEPT']); |
12 | 14 | foreach($acceptSrc as $key=>$value){ |
13 | 15 | $value = explode('/',$value); |
@@ -44,15 +46,21 @@ discard block |
||
44 | 46 | $func = require_once($file); |
45 | 47 | $reflection = new \ReflectionFunction($func); |
46 | 48 | foreach($reflection->getParameters() as $key=>$value){ |
47 | - if(isset($params[$value->name])) $stableParams[$value->name] = $params[$value->name]; |
|
48 | - else $stableParams[$value->name] = null; |
|
49 | + if(isset($params[$value->name])) { |
|
50 | + $stableParams[$value->name] = $params[$value->name]; |
|
51 | + } else { |
|
52 | + $stableParams[$value->name] = null; |
|
53 | + } |
|
49 | 54 | } |
50 | 55 | $name = explode('/',$method); |
51 | 56 | $count = count($name)-1; |
52 | 57 | $app = new Application; |
53 | 58 | foreach($name as $key=>$var){ |
54 | - if($count == $key) $app = call_user_method_array($var,$app,$stableParams); |
|
55 | - else $app = $app->{$var}; |
|
59 | + if($count == $key) { |
|
60 | + $app = call_user_method_array($var,$app,$stableParams); |
|
61 | + } else { |
|
62 | + $app = $app->{$var}; |
|
63 | + } |
|
56 | 64 | } |
57 | 65 | $result[$method] = $app; |
58 | 66 | } |
@@ -5,31 +5,31 @@ discard block |
||
5 | 5 | |
6 | 6 | private static $js; |
7 | 7 | |
8 | - public function __construct(){ |
|
8 | + public function __construct() { |
|
9 | 9 | |
10 | 10 | $config = (new Config)->get(); |
11 | 11 | |
12 | - if(!isset($_SERVER['HTTP_ACCEPT'])) $_SERVER['HTTP_ACCEPT'] = '*/*'; |
|
13 | - $acceptSrc = explode(',',$_SERVER['HTTP_ACCEPT']); |
|
14 | - foreach($acceptSrc as $key=>$value){ |
|
15 | - $value = explode('/',$value); |
|
16 | - $value[1] = explode(';',$value[1]); |
|
12 | + if (!isset($_SERVER['HTTP_ACCEPT'])) $_SERVER['HTTP_ACCEPT'] = '*/*'; |
|
13 | + $acceptSrc = explode(',', $_SERVER['HTTP_ACCEPT']); |
|
14 | + foreach ($acceptSrc as $key=>$value) { |
|
15 | + $value = explode('/', $value); |
|
16 | + $value[1] = explode(';', $value[1]); |
|
17 | 17 | $name = array_shift($value[1]); |
18 | 18 | $data = []; |
19 | - foreach($value[1] as $k=>$v){ |
|
20 | - $v = explode('=',$v); |
|
19 | + foreach ($value[1] as $k=>$v) { |
|
20 | + $v = explode('=', $v); |
|
21 | 21 | $data[$v[0]] = $v[1]; |
22 | 22 | } |
23 | 23 | $accept[$value[0]][$name] = $data; |
24 | 24 | } |
25 | 25 | |
26 | - unset($acceptSrc,$key,$value,$name,$data,$k,$v); |
|
26 | + unset($acceptSrc, $key, $value, $name, $data, $k, $v); |
|
27 | 27 | |
28 | 28 | $requestUri = parse_url($_SERVER['REQUEST_URI']); |
29 | - if($requestUri['path'] == '/javascript.js'){ |
|
29 | + if ($requestUri['path'] == '/javascript.js') { |
|
30 | 30 | header('Content-Type: application/javascript'); |
31 | - if(isset($requestUri['query'])){ |
|
32 | - $query = explode(':',$requestUri['query']); |
|
31 | + if (isset($requestUri['query'])) { |
|
32 | + $query = explode(':', $requestUri['query']); |
|
33 | 33 | (new Content)->js($query); |
34 | 34 | } |
35 | 35 | exit; |
@@ -40,30 +40,30 @@ discard block |
||
40 | 40 | header('Access-Control-Allow-Credentials: true'); |
41 | 41 | header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT'); |
42 | 42 | |
43 | - if(isset($accept['application']['view'])){ |
|
43 | + if (isset($accept['application']['view'])) { |
|
44 | 44 | header('Content-Type: text/html'); |
45 | 45 | (new RestApi)->view(); |
46 | - } else if(isset($accept['application']['widget'])){ |
|
46 | + } else if (isset($accept['application']['widget'])) { |
|
47 | 47 | header('Content-Type: text/html'); |
48 | 48 | (new RestApi)->widget(); |
49 | - } else if(isset($accept['application']['apps'])){ |
|
49 | + } else if (isset($accept['application']['apps'])) { |
|
50 | 50 | header('Content-Type: application/json'); |
51 | - $query = json_decode(file_get_contents('php://input'),1); |
|
51 | + $query = json_decode(file_get_contents('php://input'), 1); |
|
52 | 52 | $result = []; |
53 | - foreach($query as $method=>$params){ |
|
53 | + foreach ($query as $method=>$params) { |
|
54 | 54 | $stableParams = []; |
55 | 55 | $file = $config['core']['apps'].'/'.$method.'.php'; |
56 | 56 | $func = require_once($file); |
57 | 57 | $reflection = new \ReflectionFunction($func); |
58 | - foreach($reflection->getParameters() as $key=>$value){ |
|
59 | - if(isset($params[$value->name])) $stableParams[$value->name] = $params[$value->name]; |
|
58 | + foreach ($reflection->getParameters() as $key=>$value) { |
|
59 | + if (isset($params[$value->name])) $stableParams[$value->name] = $params[$value->name]; |
|
60 | 60 | else $stableParams[$value->name] = null; |
61 | 61 | } |
62 | - $name = explode('/',$method); |
|
62 | + $name = explode('/', $method); |
|
63 | 63 | $count = count($name)-1; |
64 | 64 | $app = new Application; |
65 | - foreach($name as $key=>$var){ |
|
66 | - if($count == $key) $app = call_user_method_array($var,$app,$stableParams); |
|
65 | + foreach ($name as $key=>$var) { |
|
66 | + if ($count == $key) $app = call_user_method_array($var, $app, $stableParams); |
|
67 | 67 | else $app = $app->{$var}; |
68 | 68 | } |
69 | 69 | $result[$method] = $app; |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | - public function add($title){ |
|
9 | - if(!is_array($title)) $title = [$title]; |
|
10 | - self::$memory = array_merge(self::$memory,$title); |
|
8 | + public function add($title) { |
|
9 | + if (!is_array($title)) $title = [$title]; |
|
10 | + self::$memory = array_merge(self::$memory, $title); |
|
11 | 11 | return $this; |
12 | 12 | } |
13 | 13 | |
14 | - public function get(){ |
|
14 | + public function get() { |
|
15 | 15 | self::$memory = array_reverse(self::$memory); |
16 | - foreach(self::$memory as $key=>$value){ |
|
16 | + foreach (self::$memory as $key=>$value) { |
|
17 | 17 | $value = urldecode($value); |
18 | 18 | self::$memory[$key] = $value; |
19 | 19 | } |
20 | - return '<title>'.implode(' - ',self::$memory).'</title>'; |
|
20 | + return '<title>'.implode(' - ', self::$memory).'</title>'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } |
@@ -6,7 +6,9 @@ |
||
6 | 6 | private static $memory = []; |
7 | 7 | |
8 | 8 | public function add($title){ |
9 | - if(!is_array($title)) $title = [$title]; |
|
9 | + if(!is_array($title)) { |
|
10 | + $title = [$title]; |
|
11 | + } |
|
10 | 12 | self::$memory = array_merge(self::$memory,$title); |
11 | 13 | return $this; |
12 | 14 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | class View { |
5 | 5 | |
6 | 6 | public function __get($name){ |
7 | - (new Content)->view($name); |
|
7 | + (new Content)->view($name); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | class View { |
5 | 5 | |
6 | - public function __get($name){ |
|
6 | + public function __get($name) { |
|
7 | 7 | (new Content)->view($name); |
8 | 8 | } |
9 | 9 |