@@ -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 | } |
@@ -16,7 +16,7 @@ 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 | # Application |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | self::$uri = new Uri; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function view($name){ |
|
| 42 | + public function view($name) { |
|
| 43 | 43 | $file = $this->file($name); |
| 44 | - if(is_file($file)) require $file; |
|
| 44 | + if (is_file($file)) require $file; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function page(){ |
|
| 47 | + public function page() { |
|
| 48 | 48 | # get file |
| 49 | 49 | $file = $this->file(); |
| 50 | 50 | # get content |
@@ -62,46 +62,46 @@ discard block |
||
| 62 | 62 | # get keywords |
| 63 | 63 | $keywords = self::$keywords->get(); |
| 64 | 64 | # include for page |
| 65 | - $content = preg_replace('/<head>/',"<head>$keywords",$content); |
|
| 66 | - $content = preg_replace('/<head>/',"<head>$description",$content); |
|
| 67 | - $content = preg_replace('/<head>/',"<head>$title",$content); |
|
| 68 | - $content = preg_replace('/<\/head>/',"$css</head>",$content); |
|
| 69 | - $content = preg_replace('/<\/body>/',"$js</body>",$content); |
|
| 65 | + $content = preg_replace('/<head>/', "<head>$keywords", $content); |
|
| 66 | + $content = preg_replace('/<head>/', "<head>$description", $content); |
|
| 67 | + $content = preg_replace('/<head>/', "<head>$title", $content); |
|
| 68 | + $content = preg_replace('/<\/head>/', "$css</head>", $content); |
|
| 69 | + $content = preg_replace('/<\/body>/', "$js</body>", $content); |
|
| 70 | 70 | $minify = new MinifyHTML($content); |
| 71 | 71 | $content = $minify->compress(); |
| 72 | 72 | echo $content; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function js($query){ |
|
| 75 | + public function js($query) { |
|
| 76 | 76 | echo self::$js->compile($query); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | # $type - page,view |
| 80 | - public function file($name=false){ |
|
| 81 | - if($name === false){ |
|
| 80 | + public function file($name = false) { |
|
| 81 | + if ($name === false) { |
|
| 82 | 82 | $path = self::$config['core']['page']; |
| 83 | 83 | } else { |
| 84 | 84 | $path = self::$config['core']['view'].'/'.$name; |
| 85 | 85 | } |
| 86 | 86 | # Route |
| 87 | 87 | $uri = self::$path; |
| 88 | - array_push($uri,''); |
|
| 89 | - foreach($uri as $key=>$value){ if(empty(trim($value))) { unset($uri[$key]); continue; } } |
|
| 88 | + array_push($uri, ''); |
|
| 89 | + foreach ($uri as $key=>$value) { if (empty(trim($value))) { unset($uri[$key]); continue; } } |
|
| 90 | 90 | $uri = array_values($uri); |
| 91 | 91 | $isFile = null; |
| 92 | 92 | $currentUri = null; |
| 93 | 93 | $filePhtml = null; |
| 94 | - for($i=count($uri)-1; $i>=0; $i--){ |
|
| 95 | - $nextUri = implode('/',array_slice($uri,0,$i+1)); |
|
| 96 | - $getFile = function($type) use($path,$nextUri){ |
|
| 94 | + for ($i = count($uri)-1; $i>=0; $i--) { |
|
| 95 | + $nextUri = implode('/', array_slice($uri, 0, $i+1)); |
|
| 96 | + $getFile = function($type) use($path, $nextUri){ |
|
| 97 | 97 | $file = $path.'/'.$nextUri.'/index.'.$type; |
| 98 | - if(is_file($file)) return $file; |
|
| 98 | + if (is_file($file)) return $file; |
|
| 99 | 99 | return null; |
| 100 | 100 | }; |
| 101 | 101 | $filePhtml = $getFile('phtml'); |
| 102 | - if($filePhtml) { $currentUri = $nextUri; break; } |
|
| 102 | + if ($filePhtml) { $currentUri = $nextUri; break; } |
|
| 103 | 103 | } |
| 104 | - if($filePhtml === null) { |
|
| 104 | + if ($filePhtml === null) { |
|
| 105 | 105 | $filePhtml = $path.'/index.phtml'; |
| 106 | 106 | } |
| 107 | 107 | return $filePhtml; |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function view($name){ |
| 43 | 43 | $file = $this->file($name); |
| 44 | - if(is_file($file)) require $file; |
|
| 44 | + if(is_file($file)) { |
|
| 45 | + require $file; |
|
| 46 | + } |
|
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | public function page(){ |
@@ -95,7 +97,9 @@ discard block |
||
| 95 | 97 | $nextUri = implode('/',array_slice($uri,0,$i+1)); |
| 96 | 98 | $getFile = function($type) use($path,$nextUri){ |
| 97 | 99 | $file = $path.'/'.$nextUri.'/index.'.$type; |
| 98 | - if(is_file($file)) return $file; |
|
| 100 | + if(is_file($file)) { |
|
| 101 | + return $file; |
|
| 102 | + } |
|
| 99 | 103 | return null; |
| 100 | 104 | }; |
| 101 | 105 | $filePhtml = $getFile('phtml'); |
@@ -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 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | private static $routing; |
| 12 | 12 | private static $property; |
| 13 | 13 | |
| 14 | - public function __construct(){ |
|
| 14 | + public function __construct() { |
|
| 15 | 15 | # Config |
| 16 | 16 | self::$config = (new Config)->instance()->config; |
| 17 | 17 | # Application |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | self::$routing = new Routing; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function __get($name){ |
|
| 30 | - self::$property= $name; |
|
| 29 | + public function __get($name) { |
|
| 30 | + self::$property = $name; |
|
| 31 | 31 | return new self; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function __call($_name,$value){ |
|
| 35 | - if(isset($value[0]) && !empty($value[0]) && is_array($value[0])) extract($value[0]); |
|
| 34 | + public function __call($_name, $value) { |
|
| 35 | + if (isset($value[0]) && !empty($value[0]) && is_array($value[0])) extract($value[0]); |
|
| 36 | 36 | $file = self::$config['paths']['widget'].'/'.self::$property.'/'.$_name.'.phtml'; |
| 37 | - if(is_file($file)) require($file); |
|
| 37 | + if (is_file($file)) require($file); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | } |
@@ -32,9 +32,13 @@ |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function __call($_name,$value){ |
| 35 | - if(isset($value[0]) && !empty($value[0]) && is_array($value[0])) extract($value[0]); |
|
| 35 | + if(isset($value[0]) && !empty($value[0]) && is_array($value[0])) { |
|
| 36 | + extract($value[0]); |
|
| 37 | + } |
|
| 36 | 38 | $file = self::$config['paths']['widget'].'/'.self::$property.'/'.$_name.'.phtml'; |
| 37 | - if(is_file($file)) require($file); |
|
| 39 | + if(is_file($file)) { |
|
| 40 | + require($file); |
|
| 41 | + } |
|
| 38 | 42 | } |
| 39 | 43 | |
| 40 | 44 | } |