@@ -4,28 +4,28 @@ |
||
4 | 4 | |
5 | 5 | class Url |
6 | 6 | { |
7 | - protected $app; |
|
7 | + protected $app; |
|
8 | 8 | |
9 | - public function __construct(Application $app) |
|
10 | - { |
|
9 | + public function __construct(Application $app) |
|
10 | + { |
|
11 | 11 | $this->app = $app; |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - public function link($path) |
|
15 | - { |
|
14 | + public function link($path) |
|
15 | + { |
|
16 | 16 | $link = $this->app->request->link(); |
17 | 17 | |
18 | 18 | $path = rtrim($path, '/'); |
19 | 19 | $path = ltrim($path, '/'); |
20 | 20 | |
21 | 21 | return $link . '/' . $path; |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - public function redirectTo($path, $num = 0) |
|
25 | - { |
|
24 | + public function redirectTo($path, $num = 0) |
|
25 | + { |
|
26 | 26 | if ($path == 'error') $this->app->session->set('error', true); |
27 | 27 | |
28 | 28 | header('Refresh: ' . $num . '; URL=' . $this->link($path)); |
29 | 29 | exit; |
30 | - } |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | public function redirectTo($path, $num = 0) |
25 | 25 | { |
26 | - if ($path == 'error') $this->app->session->set('error', true); |
|
26 | + if ($path == 'error') { |
|
27 | + $this->app->session->set('error', true); |
|
28 | + } |
|
27 | 29 | |
28 | 30 | header('Refresh: ' . $num . '; URL=' . $this->link($path)); |
29 | 31 | exit; |
@@ -3,75 +3,75 @@ discard block |
||
3 | 3 | use System\Application; |
4 | 4 | |
5 | 5 | if (! function_exists('pre')) { |
6 | - function pre($var) { |
|
6 | + function pre($var) { |
|
7 | 7 | echo '<pre>'; |
8 | 8 | print_r($var); |
9 | 9 | echo '</pre>'; |
10 | - } |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if (! function_exists('array_get')) { |
14 | - function array_get($array, $key, $default = null) |
|
15 | - { |
|
14 | + function array_get($array, $key, $default = null) |
|
15 | + { |
|
16 | 16 | return $array[$key] ?: $default; |
17 | - } |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | if (! function_exists('app')) { |
21 | - function app() |
|
22 | - { |
|
21 | + function app() |
|
22 | + { |
|
23 | 23 | return Application::getInstance(); |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (! function_exists('_e')) { |
28 | - function _e($value) |
|
29 | - { |
|
28 | + function _e($value) |
|
29 | + { |
|
30 | 30 | return htmlspecialchars($value); |
31 | - } |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | if (! function_exists('getLastIndex')) { |
35 | - function getLastIndex($index) |
|
36 | - { |
|
35 | + function getLastIndex($index) |
|
36 | + { |
|
37 | 37 | $array = explode('\\', $index); |
38 | 38 | return end($array); |
39 | - } |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | if (! function_exists('url')) { |
43 | - function url($path) { |
|
43 | + function url($path) { |
|
44 | 44 | $app = Application::getInstance(); |
45 | 45 | return $app->url->link($path); |
46 | - } |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | if (! function_exists('assets')) { |
50 | - function assets($path) |
|
51 | - { |
|
50 | + function assets($path) |
|
51 | + { |
|
52 | 52 | $app = Application::getInstance(); |
53 | 53 | return $app->url->link('public' . DS . $path); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | if (! function_exists('remove_space')) { |
58 | - function remove_space($str) { |
|
58 | + function remove_space($str) { |
|
59 | 59 | return str_replace(' ', '-', $str); |
60 | - } |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if (! function_exists('remove_dash')) { |
64 | - function remove_dash($str) { |
|
64 | + function remove_dash($str) { |
|
65 | 65 | return str_replace('-', ' ', $str); |
66 | - } |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if (! function_exists('clean_name_url')) { |
70 | 70 | function clean_name_url($class = null) { |
71 | 71 | |
72 | - $app = Application::getInstance(); |
|
72 | + $app = Application::getInstance(); |
|
73 | 73 | |
74 | - if (! $class) { |
|
74 | + if (! $class) { |
|
75 | 75 | |
76 | 76 | $class = debug_backtrace()[1]['class']; |
77 | 77 | |
@@ -84,40 +84,40 @@ discard block |
||
84 | 84 | $class = strtolower($class); |
85 | 85 | |
86 | 86 | $class = '/' . $class . '/'; |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - $url = $app->request->url(); |
|
89 | + $url = $app->request->url(); |
|
90 | 90 | |
91 | - $name = str_replace($class, '', $url); |
|
91 | + $name = str_replace($class, '', $url); |
|
92 | 92 | |
93 | - $name = remove_dash($name); |
|
93 | + $name = remove_dash($name); |
|
94 | 94 | |
95 | - return $name; |
|
96 | - } |
|
95 | + return $name; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if (! function_exists('text_char_limit')) { |
100 | - function text_char_limit($text, $limit) { |
|
100 | + function text_char_limit($text, $limit) { |
|
101 | 101 | if (strlen($text) > $limit) { |
102 | - return substr($text, 0, $limit) . '...'; |
|
102 | + return substr($text, 0, $limit) . '...'; |
|
103 | + } |
|
103 | 104 | } |
104 | - } |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | if (! function_exists('array_equal')) { |
108 | - function array_equal($a, $b) { |
|
108 | + function array_equal($a, $b) { |
|
109 | 109 | return ( |
110 | - is_array($a) |
|
110 | + is_array($a) |
|
111 | 111 | && is_array($b) |
112 | 112 | && count($a) == count($b) |
113 | 113 | && array_diff($a, $b) === array_diff($b, $a) |
114 | 114 | ); |
115 | - } |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | if (! function_exists('redirect_after')) { |
119 | - function redirect_after($num) { |
|
119 | + function redirect_after($num) { |
|
120 | 120 | $app = Application::getInstance(); |
121 | 121 | $app->url->redirectTo('/', $num); |
122 | - } |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use System\Application; |
4 | 4 | |
5 | -if (! function_exists('pre')) { |
|
5 | +if (!function_exists('pre')) { |
|
6 | 6 | function pre($var) { |
7 | 7 | echo '<pre>'; |
8 | 8 | print_r($var); |
@@ -10,28 +10,28 @@ discard block |
||
10 | 10 | } |
11 | 11 | } |
12 | 12 | |
13 | -if (! function_exists('array_get')) { |
|
13 | +if (!function_exists('array_get')) { |
|
14 | 14 | function array_get($array, $key, $default = null) |
15 | 15 | { |
16 | 16 | return $array[$key] ?: $default; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if (! function_exists('app')) { |
|
20 | +if (!function_exists('app')) { |
|
21 | 21 | function app() |
22 | 22 | { |
23 | 23 | return Application::getInstance(); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | -if (! function_exists('_e')) { |
|
27 | +if (!function_exists('_e')) { |
|
28 | 28 | function _e($value) |
29 | 29 | { |
30 | 30 | return htmlspecialchars($value); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -if (! function_exists('getLastIndex')) { |
|
34 | +if (!function_exists('getLastIndex')) { |
|
35 | 35 | function getLastIndex($index) |
36 | 36 | { |
37 | 37 | $array = explode('\\', $index); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -if (! function_exists('url')) { |
|
42 | +if (!function_exists('url')) { |
|
43 | 43 | function url($path) { |
44 | 44 | $app = Application::getInstance(); |
45 | 45 | return $app->url->link($path); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (! function_exists('assets')) { |
|
49 | +if (!function_exists('assets')) { |
|
50 | 50 | function assets($path) |
51 | 51 | { |
52 | 52 | $app = Application::getInstance(); |
@@ -54,24 +54,24 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -if (! function_exists('remove_space')) { |
|
57 | +if (!function_exists('remove_space')) { |
|
58 | 58 | function remove_space($str) { |
59 | 59 | return str_replace(' ', '-', $str); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -if (! function_exists('remove_dash')) { |
|
63 | +if (!function_exists('remove_dash')) { |
|
64 | 64 | function remove_dash($str) { |
65 | 65 | return str_replace('-', ' ', $str); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if (! function_exists('clean_name_url')) { |
|
69 | +if (!function_exists('clean_name_url')) { |
|
70 | 70 | function clean_name_url($class = null) { |
71 | 71 | |
72 | 72 | $app = Application::getInstance(); |
73 | 73 | |
74 | - if (! $class) { |
|
74 | + if (!$class) { |
|
75 | 75 | |
76 | 76 | $class = debug_backtrace()[1]['class']; |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $class = strtolower($class); |
85 | 85 | |
86 | - $class = '/' . $class . '/'; |
|
86 | + $class = '/' . $class . '/'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $url = $app->request->url(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | -if (! function_exists('text_char_limit')) { |
|
99 | +if (!function_exists('text_char_limit')) { |
|
100 | 100 | function text_char_limit($text, $limit) { |
101 | 101 | if (strlen($text) > $limit) { |
102 | 102 | return substr($text, 0, $limit) . '...'; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if (! function_exists('array_equal')) { |
|
107 | +if (!function_exists('array_equal')) { |
|
108 | 108 | function array_equal($a, $b) { |
109 | 109 | return ( |
110 | 110 | is_array($a) |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | -if (! function_exists('redirect_after')) { |
|
118 | +if (!function_exists('redirect_after')) { |
|
119 | 119 | function redirect_after($num) { |
120 | 120 | $app = Application::getInstance(); |
121 | 121 | $app->url->redirectTo('/', $num); |