@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | use Stichoza\GoogleTranslate\TranslateClient; |
16 | 16 | |
17 | 17 | class translation { |
18 | - use service; |
|
19 | - private static $base_url = 'http://translate.google.cn/translate_a/single'; |
|
18 | + use service; |
|
19 | + private static $base_url = 'http://translate.google.cn/translate_a/single'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param string|array $text |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | * @return string|array |
26 | 26 | * @throws \Exception |
27 | 27 | */ |
28 | - public static function __($text, $array = [], $lang = 'en') { |
|
29 | - $translate_object = new TranslateClient(); |
|
30 | - $translate_object->setUrlBase(self::$base_url); |
|
31 | - $translate_object->setTarget($lang); |
|
32 | - if(gettype($text) === 'array') { |
|
33 | - $translated = []; |
|
34 | - foreach ($text as $item) { |
|
35 | - $translated[] = $translate_object->translate($item); |
|
36 | - } |
|
37 | - if(!empty($array)) { |
|
38 | - foreach ($text as $text_id => $item) { |
|
39 | - if(isset($array[$text_id])) { |
|
40 | - foreach ($array[$text_id] as $id => $value) { |
|
41 | - $id = $id+1; |
|
42 | - $translated[$text_id] = str_replace(["\$ {$id}", "\${$id}"], $value, $translated[$text_id]); |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
48 | - else { |
|
49 | - $translated = $translate_object->translate($text); |
|
50 | - if(!empty($array)) { |
|
51 | - foreach ($array as $id => $value) { |
|
52 | - $id = $id+1; |
|
53 | - $translated = str_replace(["\$ {$id}", "\${$id}"], $value, $translated); |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
57 | - return $translated; |
|
58 | - } |
|
28 | + public static function __($text, $array = [], $lang = 'en') { |
|
29 | + $translate_object = new TranslateClient(); |
|
30 | + $translate_object->setUrlBase(self::$base_url); |
|
31 | + $translate_object->setTarget($lang); |
|
32 | + if(gettype($text) === 'array') { |
|
33 | + $translated = []; |
|
34 | + foreach ($text as $item) { |
|
35 | + $translated[] = $translate_object->translate($item); |
|
36 | + } |
|
37 | + if(!empty($array)) { |
|
38 | + foreach ($text as $text_id => $item) { |
|
39 | + if(isset($array[$text_id])) { |
|
40 | + foreach ($array[$text_id] as $id => $value) { |
|
41 | + $id = $id+1; |
|
42 | + $translated[$text_id] = str_replace(["\$ {$id}", "\${$id}"], $value, $translated[$text_id]); |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | + else { |
|
49 | + $translated = $translate_object->translate($text); |
|
50 | + if(!empty($array)) { |
|
51 | + foreach ($array as $id => $value) { |
|
52 | + $id = $id+1; |
|
53 | + $translated = str_replace(["\$ {$id}", "\${$id}"], $value, $translated); |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | + return $translated; |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | $translate_object = new TranslateClient(); |
30 | 30 | $translate_object->setUrlBase(self::$base_url); |
31 | 31 | $translate_object->setTarget($lang); |
32 | - if(gettype($text) === 'array') { |
|
32 | + if (gettype($text) === 'array') { |
|
33 | 33 | $translated = []; |
34 | 34 | foreach ($text as $item) { |
35 | 35 | $translated[] = $translate_object->translate($item); |
36 | 36 | } |
37 | - if(!empty($array)) { |
|
37 | + if (!empty($array)) { |
|
38 | 38 | foreach ($text as $text_id => $item) { |
39 | - if(isset($array[$text_id])) { |
|
39 | + if (isset($array[$text_id])) { |
|
40 | 40 | foreach ($array[$text_id] as $id => $value) { |
41 | - $id = $id+1; |
|
41 | + $id = $id + 1; |
|
42 | 42 | $translated[$text_id] = str_replace(["\$ {$id}", "\${$id}"], $value, $translated[$text_id]); |
43 | 43 | } |
44 | 44 | } |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | } |
48 | 48 | else { |
49 | 49 | $translated = $translate_object->translate($text); |
50 | - if(!empty($array)) { |
|
50 | + if (!empty($array)) { |
|
51 | 51 | foreach ($array as $id => $value) { |
52 | - $id = $id+1; |
|
52 | + $id = $id + 1; |
|
53 | 53 | $translated = str_replace(["\$ {$id}", "\${$id}"], $value, $translated); |
54 | 54 | } |
55 | 55 | } |
@@ -44,8 +44,7 @@ |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | - } |
|
48 | - else { |
|
47 | + } else { |
|
49 | 48 | $translated = $translate_object->translate($text); |
50 | 49 | if(!empty($array)) { |
51 | 50 | foreach ($array as $id => $value) { |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function get_services($component) { |
70 | - $services = []; |
|
71 | - $component = str_replace(['{', '}'], '', $component); |
|
70 | + $services = []; |
|
71 | + $component = str_replace(['{', '}'], '', $component); |
|
72 | 72 | foreach ($component::load_services() as $name => $service_to_load) { |
73 | 73 | if($service_to_load !== null) { |
74 | 74 | if (is_file($service_to_load['path'])) { |
@@ -77,59 +77,59 @@ discard block |
||
77 | 77 | $services[$name] = new $class(); |
78 | 78 | } |
79 | 79 | } |
80 | - } |
|
81 | - return $services; |
|
82 | - } |
|
80 | + } |
|
81 | + return $services; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | private static function clean_path($path) { |
85 | - if(substr($path, 0, 11) !== '/phoponent' && substr($path, 0, 11) !== 'phoponent/') { |
|
86 | - $path = str_replace('index.php/', '', $path); |
|
87 | - if (strstr($path, 0, 1) === '/') { |
|
88 | - $path = 'phoponent/app' . $path; |
|
89 | - } elseif (strstr($path, 0, 1) !== '/') { |
|
90 | - $path = 'phoponent/app/' . $path; |
|
91 | - } |
|
85 | + if(substr($path, 0, 11) !== '/phoponent' && substr($path, 0, 11) !== 'phoponent/') { |
|
86 | + $path = str_replace('index.php/', '', $path); |
|
87 | + if (strstr($path, 0, 1) === '/') { |
|
88 | + $path = 'phoponent/app' . $path; |
|
89 | + } elseif (strstr($path, 0, 1) !== '/') { |
|
90 | + $path = 'phoponent/app/' . $path; |
|
91 | + } |
|
92 | 92 | |
93 | - if (!strstr($path, '.') && substr($path, strlen($path) - 1, 1) !== '/') { |
|
94 | - $path .= '/index.html'; |
|
95 | - } elseif (!strstr($path, '.') && substr($path, strlen($path) - 1, 1) === '/') { |
|
96 | - $path .= 'index.html'; |
|
97 | - } |
|
98 | - } |
|
99 | - return $path; |
|
100 | - } |
|
93 | + if (!strstr($path, '.') && substr($path, strlen($path) - 1, 1) !== '/') { |
|
94 | + $path .= '/index.html'; |
|
95 | + } elseif (!strstr($path, '.') && substr($path, strlen($path) - 1, 1) === '/') { |
|
96 | + $path .= 'index.html'; |
|
97 | + } |
|
98 | + } |
|
99 | + return $path; |
|
100 | + } |
|
101 | 101 | |
102 | - public static function parse($path) { |
|
102 | + public static function parse($path) { |
|
103 | 103 | $path = self::clean_path($path); |
104 | 104 | |
105 | - if(is_file($path)) { |
|
105 | + if(is_file($path)) { |
|
106 | 106 | $file_content = file_get_contents($path); |
107 | - if(explode('.', $path)[count(explode('.', $path))-1] === 'php') { |
|
108 | - $file_content = include $path; |
|
107 | + if(explode('.', $path)[count(explode('.', $path))-1] === 'php') { |
|
108 | + $file_content = include $path; |
|
109 | 109 | } |
110 | 110 | self::parse_template_content($file_content); |
111 | - return $file_content; |
|
112 | - } |
|
113 | - return ''; |
|
114 | - } |
|
111 | + return $file_content; |
|
112 | + } |
|
113 | + return ''; |
|
114 | + } |
|
115 | 115 | |
116 | - public static function parse_template_content(&$template) { |
|
117 | - // balise banales avec contenu |
|
118 | - // sans attributs |
|
119 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments(), function ($matches) use (&$template) { |
|
120 | - $class = str_replace('-', '_', $matches[1]); |
|
121 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
122 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
123 | - require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
|
116 | + public static function parse_template_content(&$template) { |
|
117 | + // balise banales avec contenu |
|
118 | + // sans attributs |
|
119 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments(), function ($matches) use (&$template) { |
|
120 | + $class = str_replace('-', '_', $matches[1]); |
|
121 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
122 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
123 | + require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
|
124 | 124 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
125 | - /** |
|
126 | - * @var xphp_tag $tag |
|
127 | - */ |
|
128 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
129 | - $tag->value($matches[2]); |
|
130 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
131 | - } |
|
132 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
125 | + /** |
|
126 | + * @var xphp_tag $tag |
|
127 | + */ |
|
128 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
129 | + $tag->value($matches[2]); |
|
130 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
131 | + } |
|
132 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
133 | 133 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
134 | 134 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
135 | 135 | /** |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | $tag->value($matches[2]); |
140 | 140 | $template = str_replace($matches[0], $tag->render(), $template); |
141 | 141 | } |
142 | - }, $template); |
|
143 | - // sans attributs mais avec un espace |
|
144 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces(), function ($matches) use (&$template) { |
|
145 | - $class = str_replace('-', '_', $matches[1]); |
|
146 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
147 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
142 | + }, $template); |
|
143 | + // sans attributs mais avec un espace |
|
144 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces(), function ($matches) use (&$template) { |
|
145 | + $class = str_replace('-', '_', $matches[1]); |
|
146 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
147 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
148 | 148 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
149 | 149 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
150 | - /** |
|
151 | - * @var xphp_tag $tag |
|
152 | - */ |
|
153 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
154 | - $tag->value($matches[2]); |
|
155 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
156 | - } |
|
157 | - elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
150 | + /** |
|
151 | + * @var xphp_tag $tag |
|
152 | + */ |
|
153 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
154 | + $tag->value($matches[2]); |
|
155 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
156 | + } |
|
157 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
158 | 158 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
159 | 159 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
160 | 160 | /** |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | $tag->value($matches[2]); |
165 | 165 | $template = str_replace($matches[0], $tag->render(), $template); |
166 | 166 | } |
167 | - }, $template); |
|
168 | - // avec attributs |
|
169 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_arguments(), function ($matches) use (&$template) { |
|
170 | - $class = str_replace('-', '_', $matches[1]); |
|
167 | + }, $template); |
|
168 | + // avec attributs |
|
169 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_arguments(), function ($matches) use (&$template) { |
|
170 | + $class = str_replace('-', '_', $matches[1]); |
|
171 | 171 | |
172 | - $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
172 | + $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
173 | 173 | $arguments_array = []; |
174 | 174 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
175 | 175 | $arguments_array[] = $matches[1]; |
@@ -223,23 +223,23 @@ discard block |
||
223 | 223 | } |
224 | 224 | $template = str_replace($matches[0], $tag->render(), $template); |
225 | 225 | } |
226 | - }, $template); |
|
226 | + }, $template); |
|
227 | 227 | |
228 | - // balises banales sans contenu |
|
229 | - // sans attributs |
|
230 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments(), function ($matches) use (&$template) { |
|
231 | - $class = str_replace('-', '_', $matches[1]); |
|
232 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
233 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
228 | + // balises banales sans contenu |
|
229 | + // sans attributs |
|
230 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments(), function ($matches) use (&$template) { |
|
231 | + $class = str_replace('-', '_', $matches[1]); |
|
232 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
233 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
234 | 234 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
235 | 235 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
236 | - /** |
|
237 | - * @var xphp_tag $tag |
|
238 | - */ |
|
239 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
240 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
241 | - } |
|
242 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
236 | + /** |
|
237 | + * @var xphp_tag $tag |
|
238 | + */ |
|
239 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
240 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
241 | + } |
|
242 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
243 | 243 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
244 | 244 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
245 | 245 | /** |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
249 | 249 | $template = str_replace($matches[0], $tag->render(), $template); |
250 | 250 | } |
251 | - }, $template); |
|
252 | - // sans attributs mais avec un espace |
|
253 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces(), function ($matches) use (&$template) { |
|
254 | - $class = str_replace('-', '_', $matches[1]); |
|
255 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
256 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
251 | + }, $template); |
|
252 | + // sans attributs mais avec un espace |
|
253 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces(), function ($matches) use (&$template) { |
|
254 | + $class = str_replace('-', '_', $matches[1]); |
|
255 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
256 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
257 | 257 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
258 | 258 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
259 | - /** |
|
260 | - * @var xphp_tag $tag |
|
261 | - */ |
|
262 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
263 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
264 | - } |
|
265 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
259 | + /** |
|
260 | + * @var xphp_tag $tag |
|
261 | + */ |
|
262 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
263 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
264 | + } |
|
265 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
266 | 266 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
267 | 267 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
268 | 268 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
272 | 272 | $template = str_replace($matches[0], $tag->render(), $template); |
273 | 273 | } |
274 | - }, $template); |
|
275 | - // avec attributs |
|
276 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments(), function ($matches) use (&$template) { |
|
277 | - $class = str_replace('-', '_', $matches[1]); |
|
278 | - $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
274 | + }, $template); |
|
275 | + // avec attributs |
|
276 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments(), function ($matches) use (&$template) { |
|
277 | + $class = str_replace('-', '_', $matches[1]); |
|
278 | + $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
279 | 279 | $arguments_array = []; |
280 | 280 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
281 | 281 | $arguments_array[] = $matches[1]; |
@@ -330,23 +330,23 @@ discard block |
||
330 | 330 | } |
331 | 331 | $template = str_replace($matches[0], $tag->render(), $template); |
332 | 332 | } |
333 | - }, $template); |
|
333 | + }, $template); |
|
334 | 334 | |
335 | - // balises autofermantes |
|
336 | - // sans attributs |
|
337 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments(), function ($matches) use (&$template) { |
|
338 | - $class = str_replace('-', '_', $matches[1]); |
|
339 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
340 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
335 | + // balises autofermantes |
|
336 | + // sans attributs |
|
337 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments(), function ($matches) use (&$template) { |
|
338 | + $class = str_replace('-', '_', $matches[1]); |
|
339 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
340 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
341 | 341 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
342 | 342 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
343 | - /** |
|
344 | - * @var xphp_tag $tag |
|
345 | - */ |
|
346 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
347 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
348 | - } |
|
349 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
343 | + /** |
|
344 | + * @var xphp_tag $tag |
|
345 | + */ |
|
346 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
347 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
348 | + } |
|
349 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
350 | 350 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
351 | 351 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
352 | 352 | /** |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
356 | 356 | $template = str_replace($matches[0], $tag->render(), $template); |
357 | 357 | } |
358 | - }, $template); |
|
359 | - // sans attributs mais avec un espace |
|
360 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments_and_spaces(), function ($matches) use (&$template) { |
|
361 | - $class = str_replace('-', '_', $matches[1]); |
|
362 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
363 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
358 | + }, $template); |
|
359 | + // sans attributs mais avec un espace |
|
360 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments_and_spaces(), function ($matches) use (&$template) { |
|
361 | + $class = str_replace('-', '_', $matches[1]); |
|
362 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
363 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
364 | 364 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
365 | 365 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
366 | - /** |
|
367 | - * @var xphp_tag $tag |
|
368 | - */ |
|
369 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
370 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
371 | - } |
|
372 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
366 | + /** |
|
367 | + * @var xphp_tag $tag |
|
368 | + */ |
|
369 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
370 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
371 | + } |
|
372 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
373 | 373 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
374 | 374 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
375 | 375 | /** |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
379 | 379 | $template = str_replace($matches[0], $tag->render(), $template); |
380 | 380 | } |
381 | - }, $template); |
|
382 | - // avec attributs |
|
383 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_with_arguments(), function ($matches) use (&$template) { |
|
384 | - $class = str_replace('-', '_', $matches[1]); |
|
385 | - $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
381 | + }, $template); |
|
382 | + // avec attributs |
|
383 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_with_arguments(), function ($matches) use (&$template) { |
|
384 | + $class = str_replace('-', '_', $matches[1]); |
|
385 | + $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
|
386 | 386 | $arguments_array = []; |
387 | 387 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
388 | 388 | $arguments_array[] = $matches[1]; |
@@ -404,24 +404,24 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | $arguments = $arguments_array; |
407 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
408 | - require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
407 | + if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
408 | + require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
|
409 | 409 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
410 | 410 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
411 | - /** |
|
412 | - * @var xphp_tag $tag |
|
413 | - */ |
|
414 | - $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
415 | - foreach ($arguments as $argument => $valeur) { |
|
416 | - if ($argument === 'value') { |
|
417 | - $tag->value($valeur); |
|
418 | - } else { |
|
419 | - $tag->attribute($argument, $valeur); |
|
420 | - } |
|
421 | - } |
|
422 | - $template = str_replace($matches[0], $tag->render(), $template); |
|
423 | - } |
|
424 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
411 | + /** |
|
412 | + * @var xphp_tag $tag |
|
413 | + */ |
|
414 | + $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
|
415 | + foreach ($arguments as $argument => $valeur) { |
|
416 | + if ($argument === 'value') { |
|
417 | + $tag->value($valeur); |
|
418 | + } else { |
|
419 | + $tag->attribute($argument, $valeur); |
|
420 | + } |
|
421 | + } |
|
422 | + $template = str_replace($matches[0], $tag->render(), $template); |
|
423 | + } |
|
424 | + elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
425 | 425 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
426 | 426 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
427 | 427 | /** |
@@ -437,6 +437,6 @@ discard block |
||
437 | 437 | } |
438 | 438 | $template = str_replace($matches[0], $tag->render(), $template); |
439 | 439 | } |
440 | - }, $template); |
|
441 | - } |
|
440 | + }, $template); |
|
441 | + } |
|
442 | 442 | } |
443 | 443 | \ No newline at end of file |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | $models = []; |
21 | 21 | $dir = opendir("phoponent/app/components/{$type}/{$component}/models"); |
22 | 22 | while (($file = readdir($dir)) !== false) { |
23 | - if($file !== '.' && $file !== '..') { |
|
24 | - if(is_file("phoponent/app/components/custom/{$component}/models/{$file}")) { |
|
23 | + if ($file !== '.' && $file !== '..') { |
|
24 | + if (is_file("phoponent/app/components/custom/{$component}/models/{$file}")) { |
|
25 | 25 | require_once "phoponent/app/components/core/{$component}/models/{$file}"; |
26 | 26 | require_once "phoponent/app/components/custom/{$component}/models/{$file}"; |
27 | 27 | $class_tag = "\phoponent\app\component\custom\{$component}"; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $model_class = "\\phoponent\\app\\component\\custom\\$component\\mvc\\model\\$model"; |
30 | 30 | $models[$model] = new $model_class(self::get_services($class_tag), $component); |
31 | 31 | } |
32 | - elseif(is_file("phoponent/app/components/core/{$component}/models/{$file}")) { |
|
32 | + elseif (is_file("phoponent/app/components/core/{$component}/models/{$file}")) { |
|
33 | 33 | require_once "phoponent/app/components/core/{$component}/models/{$file}"; |
34 | 34 | $class_tag = "\phoponent\app\component\core\{$component}"; |
35 | 35 | $model = str_replace('.php', '', $file); |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $views = []; |
46 | 46 | $dir = opendir("phoponent/app/components/{$type}/{$component}/views"); |
47 | 47 | while (($file = readdir($dir)) !== false) { |
48 | - if($file !== '.' && $file !== '..') { |
|
49 | - if(is_file("phoponent/app/components/custom/{$component}/views/{$file}")) { |
|
48 | + if ($file !== '.' && $file !== '..') { |
|
49 | + if (is_file("phoponent/app/components/custom/{$component}/views/{$file}")) { |
|
50 | 50 | require_once "phoponent/app/components/core/{$component}/views/{$file}"; |
51 | 51 | require_once "phoponent/app/components/custom/{$component}/views/{$file}"; |
52 | 52 | $view = str_replace('.view.php', '', $file); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $views[$view] = new $view_class("phoponent/app/components/custom/{$component}/views"); |
56 | 56 | $views[$view]->set_parent(new $view_parent_class("phoponent/app/components/core/{$component}/views")); |
57 | 57 | } |
58 | - elseif(is_file("phoponent/app/components/core/{$component}/views/{$file}")) { |
|
58 | + elseif (is_file("phoponent/app/components/core/{$component}/views/{$file}")) { |
|
59 | 59 | require_once "phoponent/app/components/core/{$component}/views/{$file}"; |
60 | 60 | $view = str_replace('.view.php', '', $file); |
61 | 61 | $view_class = "\\phoponent\\app\\component\\core\\$component\\mvc\\view\\$view"; |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | $services = []; |
71 | 71 | $component = str_replace(['{', '}'], '', $component); |
72 | 72 | foreach ($component::load_services() as $name => $service_to_load) { |
73 | - if($service_to_load !== null) { |
|
73 | + if ($service_to_load !== null) { |
|
74 | 74 | if (is_file($service_to_load['path'])) { |
75 | 75 | Auto::dependencie('services', explode('\\', $service_to_load['class'])[count(explode('\\', $service_to_load['class'])) - 1]); |
76 | - $class = '\\' . $service_to_load['class']; |
|
76 | + $class = '\\'.$service_to_load['class']; |
|
77 | 77 | $services[$name] = new $class(); |
78 | 78 | } |
79 | 79 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | private static function clean_path($path) { |
85 | - if(substr($path, 0, 11) !== '/phoponent' && substr($path, 0, 11) !== 'phoponent/') { |
|
85 | + if (substr($path, 0, 11) !== '/phoponent' && substr($path, 0, 11) !== 'phoponent/') { |
|
86 | 86 | $path = str_replace('index.php/', '', $path); |
87 | 87 | if (strstr($path, 0, 1) === '/') { |
88 | - $path = 'phoponent/app' . $path; |
|
88 | + $path = 'phoponent/app'.$path; |
|
89 | 89 | } elseif (strstr($path, 0, 1) !== '/') { |
90 | - $path = 'phoponent/app/' . $path; |
|
90 | + $path = 'phoponent/app/'.$path; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | if (!strstr($path, '.') && substr($path, strlen($path) - 1, 1) !== '/') { |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | public static function parse($path) { |
103 | 103 | $path = self::clean_path($path); |
104 | 104 | |
105 | - if(is_file($path)) { |
|
105 | + if (is_file($path)) { |
|
106 | 106 | $file_content = file_get_contents($path); |
107 | - if(explode('.', $path)[count(explode('.', $path))-1] === 'php') { |
|
107 | + if (explode('.', $path)[count(explode('.', $path)) - 1] === 'php') { |
|
108 | 108 | $file_content = include $path; |
109 | 109 | } |
110 | 110 | self::parse_template_content($file_content); |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | public static function parse_template_content(&$template) { |
117 | 117 | // balise banales avec contenu |
118 | 118 | // sans attributs |
119 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments(), function ($matches) use (&$template) { |
|
119 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments(), function($matches) use (&$template) { |
|
120 | 120 | $class = str_replace('-', '_', $matches[1]); |
121 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
121 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
122 | 122 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
123 | 123 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
124 | 124 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $tag->value($matches[2]); |
130 | 130 | $template = str_replace($matches[0], $tag->render(), $template); |
131 | 131 | } |
132 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
132 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
133 | 133 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
134 | 134 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
135 | 135 | /** |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | } |
142 | 142 | }, $template); |
143 | 143 | // sans attributs mais avec un espace |
144 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces(), function ($matches) use (&$template) { |
|
144 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces(), function($matches) use (&$template) { |
|
145 | 145 | $class = str_replace('-', '_', $matches[1]); |
146 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
146 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
147 | 147 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
148 | 148 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
149 | 149 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | } |
167 | 167 | }, $template); |
168 | 168 | // avec attributs |
169 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_arguments(), function ($matches) use (&$template) { |
|
169 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_arguments(), function($matches) use (&$template) { |
|
170 | 170 | $class = str_replace('-', '_', $matches[1]); |
171 | 171 | |
172 | 172 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
173 | 173 | $arguments_array = []; |
174 | - preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
|
174 | + preg_replace_callback(regexp::regexp_for_parse_attributs(), function($matches) use (&$arguments_array) { |
|
175 | 175 | $arguments_array[] = $matches[1]; |
176 | 176 | }, $arguments); |
177 | - preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
|
177 | + preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function($matches) use (&$arguments_array) { |
|
178 | 178 | $arguments_array[] = $matches[1]; |
179 | 179 | }, $arguments); |
180 | 180 | foreach ($arguments_array as $id => $arg) { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $arguments_array['value'] = $matches[3]; |
191 | 191 | $arguments = $arguments_array; |
192 | 192 | |
193 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
193 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
194 | 194 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
195 | 195 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
196 | 196 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | // balises banales sans contenu |
229 | 229 | // sans attributs |
230 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments(), function ($matches) use (&$template) { |
|
230 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments(), function($matches) use (&$template) { |
|
231 | 231 | $class = str_replace('-', '_', $matches[1]); |
232 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
232 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
233 | 233 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
234 | 234 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
235 | 235 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
240 | 240 | $template = str_replace($matches[0], $tag->render(), $template); |
241 | 241 | } |
242 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
242 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
243 | 243 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
244 | 244 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
245 | 245 | /** |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | } |
251 | 251 | }, $template); |
252 | 252 | // sans attributs mais avec un espace |
253 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces(), function ($matches) use (&$template) { |
|
253 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces(), function($matches) use (&$template) { |
|
254 | 254 | $class = str_replace('-', '_', $matches[1]); |
255 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
255 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
256 | 256 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
257 | 257 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
258 | 258 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
263 | 263 | $template = str_replace($matches[0], $tag->render(), $template); |
264 | 264 | } |
265 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
265 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
266 | 266 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
267 | 267 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
268 | 268 | /** |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | } |
274 | 274 | }, $template); |
275 | 275 | // avec attributs |
276 | - preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments(), function ($matches) use (&$template) { |
|
276 | + preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments(), function($matches) use (&$template) { |
|
277 | 277 | $class = str_replace('-', '_', $matches[1]); |
278 | 278 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
279 | 279 | $arguments_array = []; |
280 | - preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
|
280 | + preg_replace_callback(regexp::regexp_for_parse_attributs(), function($matches) use (&$arguments_array) { |
|
281 | 281 | $arguments_array[] = $matches[1]; |
282 | 282 | }, $arguments); |
283 | 283 | |
284 | - preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
|
284 | + preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function($matches) use (&$arguments_array) { |
|
285 | 285 | $arguments_array[] = $matches[1]; |
286 | 286 | }, $arguments); |
287 | 287 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | $arguments = $arguments_array; |
300 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
300 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
301 | 301 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
302 | 302 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
303 | 303 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | } |
315 | 315 | $template = str_replace($matches[0], $tag->render(), $template); |
316 | 316 | } |
317 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
317 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
318 | 318 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
319 | 319 | $class_tag = "\\phoponent\\app\\component\\core\\class"; |
320 | 320 | /** |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | |
335 | 335 | // balises autofermantes |
336 | 336 | // sans attributs |
337 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments(), function ($matches) use (&$template) { |
|
337 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments(), function($matches) use (&$template) { |
|
338 | 338 | $class = str_replace('-', '_', $matches[1]); |
339 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
339 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
340 | 340 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
341 | 341 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
342 | 342 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
347 | 347 | $template = str_replace($matches[0], $tag->render(), $template); |
348 | 348 | } |
349 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
349 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
350 | 350 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
351 | 351 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
352 | 352 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | } |
358 | 358 | }, $template); |
359 | 359 | // sans attributs mais avec un espace |
360 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments_and_spaces(), function ($matches) use (&$template) { |
|
360 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments_and_spaces(), function($matches) use (&$template) { |
|
361 | 361 | $class = str_replace('-', '_', $matches[1]); |
362 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
362 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
363 | 363 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
364 | 364 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
365 | 365 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
370 | 370 | $template = str_replace($matches[0], $tag->render(), $template); |
371 | 371 | } |
372 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
372 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
373 | 373 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
374 | 374 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
375 | 375 | /** |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | } |
381 | 381 | }, $template); |
382 | 382 | // avec attributs |
383 | - preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_with_arguments(), function ($matches) use (&$template) { |
|
383 | + preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_with_arguments(), function($matches) use (&$template) { |
|
384 | 384 | $class = str_replace('-', '_', $matches[1]); |
385 | 385 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
386 | 386 | $arguments_array = []; |
387 | - preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
|
387 | + preg_replace_callback(regexp::regexp_for_parse_attributs(), function($matches) use (&$arguments_array) { |
|
388 | 388 | $arguments_array[] = $matches[1]; |
389 | 389 | }, $arguments); |
390 | 390 | |
391 | - preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
|
391 | + preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function($matches) use (&$arguments_array) { |
|
392 | 392 | $arguments_array[] = $matches[1]; |
393 | 393 | }, $arguments); |
394 | 394 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | $arguments = $arguments_array; |
407 | - if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
407 | + if (is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
|
408 | 408 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
409 | 409 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
410 | 410 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | $template = str_replace($matches[0], $tag->render(), $template); |
423 | 423 | } |
424 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
424 | + elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
425 | 425 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
426 | 426 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
427 | 427 | /** |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | $model = str_replace('.php', '', $file); |
29 | 29 | $model_class = "\\phoponent\\app\\component\\custom\\$component\\mvc\\model\\$model"; |
30 | 30 | $models[$model] = new $model_class(self::get_services($class_tag), $component); |
31 | - } |
|
32 | - elseif(is_file("phoponent/app/components/core/{$component}/models/{$file}")) { |
|
31 | + } elseif(is_file("phoponent/app/components/core/{$component}/models/{$file}")) { |
|
33 | 32 | require_once "phoponent/app/components/core/{$component}/models/{$file}"; |
34 | 33 | $class_tag = "\phoponent\app\component\core\{$component}"; |
35 | 34 | $model = str_replace('.php', '', $file); |
@@ -54,8 +53,7 @@ discard block |
||
54 | 53 | $view_parent_class = "\\phoponent\\app\\component\\core\\$component\\mvc\\view\\$view"; |
55 | 54 | $views[$view] = new $view_class("phoponent/app/components/custom/{$component}/views"); |
56 | 55 | $views[$view]->set_parent(new $view_parent_class("phoponent/app/components/core/{$component}/views")); |
57 | - } |
|
58 | - elseif(is_file("phoponent/app/components/core/{$component}/views/{$file}")) { |
|
56 | + } elseif(is_file("phoponent/app/components/core/{$component}/views/{$file}")) { |
|
59 | 57 | require_once "phoponent/app/components/core/{$component}/views/{$file}"; |
60 | 58 | $view = str_replace('.view.php', '', $file); |
61 | 59 | $view_class = "\\phoponent\\app\\component\\core\\$component\\mvc\\view\\$view"; |
@@ -128,8 +126,7 @@ discard block |
||
128 | 126 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
129 | 127 | $tag->value($matches[2]); |
130 | 128 | $template = str_replace($matches[0], $tag->render(), $template); |
131 | - } |
|
132 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
129 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
133 | 130 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
134 | 131 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
135 | 132 | /** |
@@ -153,8 +150,7 @@ discard block |
||
153 | 150 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
154 | 151 | $tag->value($matches[2]); |
155 | 152 | $template = str_replace($matches[0], $tag->render(), $template); |
156 | - } |
|
157 | - elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
153 | + } elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
158 | 154 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
159 | 155 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
160 | 156 | /** |
@@ -206,8 +202,7 @@ discard block |
||
206 | 202 | } |
207 | 203 | } |
208 | 204 | $template = str_replace($matches[0], $tag->render(), $template); |
209 | - } |
|
210 | - elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
205 | + } elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
211 | 206 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
212 | 207 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
213 | 208 | /** |
@@ -238,8 +233,7 @@ discard block |
||
238 | 233 | */ |
239 | 234 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
240 | 235 | $template = str_replace($matches[0], $tag->render(), $template); |
241 | - } |
|
242 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
236 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
243 | 237 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
244 | 238 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
245 | 239 | /** |
@@ -261,8 +255,7 @@ discard block |
||
261 | 255 | */ |
262 | 256 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
263 | 257 | $template = str_replace($matches[0], $tag->render(), $template); |
264 | - } |
|
265 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
258 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
266 | 259 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
267 | 260 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
268 | 261 | /** |
@@ -313,8 +306,7 @@ discard block |
||
313 | 306 | } |
314 | 307 | } |
315 | 308 | $template = str_replace($matches[0], $tag->render(), $template); |
316 | - } |
|
317 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
309 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
318 | 310 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
319 | 311 | $class_tag = "\\phoponent\\app\\component\\core\\class"; |
320 | 312 | /** |
@@ -345,8 +337,7 @@ discard block |
||
345 | 337 | */ |
346 | 338 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
347 | 339 | $template = str_replace($matches[0], $tag->render(), $template); |
348 | - } |
|
349 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
340 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
350 | 341 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
351 | 342 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
352 | 343 | /** |
@@ -368,8 +359,7 @@ discard block |
||
368 | 359 | */ |
369 | 360 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
370 | 361 | $template = str_replace($matches[0], $tag->render(), $template); |
371 | - } |
|
372 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
362 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
373 | 363 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
374 | 364 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
375 | 365 | /** |
@@ -420,8 +410,7 @@ discard block |
||
420 | 410 | } |
421 | 411 | } |
422 | 412 | $template = str_replace($matches[0], $tag->render(), $template); |
423 | - } |
|
424 | - elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
413 | + } elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
|
425 | 414 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
426 | 415 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
427 | 416 | /** |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | use phoponent\loading\Auto; |
15 | 15 | |
16 | 16 | class xphp_tag { |
17 | - protected $attributs = []; |
|
18 | - protected $value = ''; |
|
19 | - private $models = []; |
|
17 | + protected $attributs = []; |
|
18 | + protected $value = ''; |
|
19 | + private $models = []; |
|
20 | 20 | private $views = []; |
21 | 21 | private $services = []; |
22 | 22 | private $styles = []; |
@@ -34,73 +34,73 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | public function attribute($name=null, $value=null) { |
37 | - if(is_null($value)) { |
|
38 | - if(is_null($name)) { |
|
39 | - return $this->attributs; |
|
40 | - } |
|
41 | - return isset($this->attributs[$name]) ? $this->attributs[$name] : null; |
|
42 | - } |
|
43 | - |
|
44 | - if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
45 | - && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
46 | - $value = substr($value, 1, strlen($value)); |
|
47 | - $value = substr($value, 0, strlen($value)-1); |
|
48 | - } |
|
49 | - |
|
50 | - $this->attributs[$name] = $value; |
|
51 | - return $this; |
|
52 | - } |
|
53 | - |
|
54 | - protected function set_style($selector, $styles) { |
|
55 | - $this->styles[$selector] = $styles; |
|
56 | - } |
|
57 | - |
|
58 | - protected function get_style() { |
|
59 | - return $this->styles; |
|
60 | - } |
|
61 | - |
|
62 | - protected function add_style_to_page() { |
|
63 | - //TODO incruster le style du composant dans le template de base |
|
64 | - return $this->template; |
|
65 | - } |
|
66 | - |
|
67 | - public function value($value = null) { |
|
68 | - if(is_null($value)) { |
|
69 | - return $this->value; |
|
70 | - } |
|
71 | - if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
72 | - && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
73 | - $value = substr($value, 1, strlen($value)); |
|
74 | - $value = substr($value, 0, strlen($value)-1); |
|
75 | - } |
|
76 | - |
|
77 | - $this->value = $value; |
|
78 | - return $this; |
|
79 | - } |
|
80 | - |
|
81 | - public function render():string { |
|
82 | - return ''; |
|
83 | - } |
|
84 | - |
|
85 | - public function get_class() { |
|
86 | - return __CLASS__; |
|
87 | - } |
|
88 | - |
|
89 | - protected function get_models() { |
|
90 | - return array_keys($this->models); |
|
37 | + if(is_null($value)) { |
|
38 | + if(is_null($name)) { |
|
39 | + return $this->attributs; |
|
40 | + } |
|
41 | + return isset($this->attributs[$name]) ? $this->attributs[$name] : null; |
|
42 | + } |
|
43 | + |
|
44 | + if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
45 | + && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
46 | + $value = substr($value, 1, strlen($value)); |
|
47 | + $value = substr($value, 0, strlen($value)-1); |
|
48 | + } |
|
49 | + |
|
50 | + $this->attributs[$name] = $value; |
|
51 | + return $this; |
|
91 | 52 | } |
92 | 53 | |
93 | - /** |
|
94 | - * @param $name |
|
95 | - * @return model |
|
96 | - */ |
|
54 | + protected function set_style($selector, $styles) { |
|
55 | + $this->styles[$selector] = $styles; |
|
56 | + } |
|
57 | + |
|
58 | + protected function get_style() { |
|
59 | + return $this->styles; |
|
60 | + } |
|
61 | + |
|
62 | + protected function add_style_to_page() { |
|
63 | + //TODO incruster le style du composant dans le template de base |
|
64 | + return $this->template; |
|
65 | + } |
|
66 | + |
|
67 | + public function value($value = null) { |
|
68 | + if(is_null($value)) { |
|
69 | + return $this->value; |
|
70 | + } |
|
71 | + if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
72 | + && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
73 | + $value = substr($value, 1, strlen($value)); |
|
74 | + $value = substr($value, 0, strlen($value)-1); |
|
75 | + } |
|
76 | + |
|
77 | + $this->value = $value; |
|
78 | + return $this; |
|
79 | + } |
|
80 | + |
|
81 | + public function render():string { |
|
82 | + return ''; |
|
83 | + } |
|
84 | + |
|
85 | + public function get_class() { |
|
86 | + return __CLASS__; |
|
87 | + } |
|
88 | + |
|
89 | + protected function get_models() { |
|
90 | + return array_keys($this->models); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param $name |
|
95 | + * @return model |
|
96 | + */ |
|
97 | 97 | public function get_model($name) { |
98 | - $name = "{$name}"; |
|
98 | + $name = "{$name}"; |
|
99 | 99 | return isset($this->models[$name]) ? $this->models[$name] : null; |
100 | 100 | } |
101 | 101 | |
102 | 102 | public function get_views() { |
103 | - return array_keys($this->views); |
|
103 | + return array_keys($this->views); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * @return view |
109 | 109 | */ |
110 | 110 | public function get_view($name) { |
111 | - $name = "{$name}"; |
|
111 | + $name = "{$name}"; |
|
112 | 112 | return isset($this->views[$name]) ? $this->views[$name] : null; |
113 | 113 | } |
114 | 114 | |
115 | - public function get_services() { |
|
116 | - return array_keys($this->services); |
|
117 | - } |
|
115 | + public function get_services() { |
|
116 | + return array_keys($this->services); |
|
117 | + } |
|
118 | 118 | |
119 | - public function get_service($name) { |
|
120 | - return isset($this->services[$name]) ? $this->services[$name] : null; |
|
121 | - } |
|
119 | + public function get_service($name) { |
|
120 | + return isset($this->services[$name]) ? $this->services[$name] : null; |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | \ No newline at end of file |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | return Auto::dependencie('services'); |
34 | 34 | } |
35 | 35 | |
36 | - public function attribute($name=null, $value=null) { |
|
37 | - if(is_null($value)) { |
|
38 | - if(is_null($name)) { |
|
36 | + public function attribute($name = null, $value = null) { |
|
37 | + if (is_null($value)) { |
|
38 | + if (is_null($name)) { |
|
39 | 39 | return $this->attributs; |
40 | 40 | } |
41 | 41 | return isset($this->attributs[$name]) ? $this->attributs[$name] : null; |
42 | 42 | } |
43 | 43 | |
44 | - if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
45 | - && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
44 | + if ((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'") |
|
45 | + && (substr($value, strlen($value) - 1, 1) === '"' || substr($value, strlen($value) - 1, 1) === "'")) { |
|
46 | 46 | $value = substr($value, 1, strlen($value)); |
47 | - $value = substr($value, 0, strlen($value)-1); |
|
47 | + $value = substr($value, 0, strlen($value) - 1); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $this->attributs[$name] = $value; |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | public function value($value = null) { |
68 | - if(is_null($value)) { |
|
68 | + if (is_null($value)) { |
|
69 | 69 | return $this->value; |
70 | 70 | } |
71 | - if((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'" ) |
|
72 | - && (substr($value, strlen($value)-1, 1) === '"' || substr($value, strlen($value)-1, 1) === "'" )) { |
|
71 | + if ((substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'") |
|
72 | + && (substr($value, strlen($value) - 1, 1) === '"' || substr($value, strlen($value) - 1, 1) === "'")) { |
|
73 | 73 | $value = substr($value, 1, strlen($value)); |
74 | - $value = substr($value, 0, strlen($value)-1); |
|
74 | + $value = substr($value, 0, strlen($value) - 1); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $this->value = $value; |
@@ -14,52 +14,52 @@ |
||
14 | 14 | use phoponent\framework\traits\static_class; |
15 | 15 | |
16 | 16 | class command { |
17 | - use static_class; |
|
17 | + use static_class; |
|
18 | 18 | |
19 | - private static function clean_argv($argv) { |
|
20 | - unset($argv[0]); |
|
21 | - $argv_tmp = []; |
|
22 | - foreach ($argv as $item) { |
|
23 | - $argv_tmp[] = $item; |
|
24 | - } |
|
25 | - return $argv_tmp; |
|
26 | - } |
|
19 | + private static function clean_argv($argv) { |
|
20 | + unset($argv[0]); |
|
21 | + $argv_tmp = []; |
|
22 | + foreach ($argv as $item) { |
|
23 | + $argv_tmp[] = $item; |
|
24 | + } |
|
25 | + return $argv_tmp; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param $argv |
|
30 | - * @throws Exception |
|
31 | - */ |
|
32 | - public static function go($argv) { |
|
33 | - $argv = self::clean_argv($argv); |
|
34 | - if(empty($argv) || (!empty($argv) && $argv[0] === '-h') || (!empty($argv) && $argv[0] === '--help')) { |
|
35 | - $argv = self::clean_argv($argv); |
|
36 | - if(is_file("phoponent/commands/help.php")) { |
|
37 | - require_once "phoponent/commands/help.php"; |
|
38 | - } |
|
39 | - else { |
|
40 | - throw new Exception("command help not found !"); |
|
41 | - } |
|
42 | - $command = new help($argv); |
|
43 | - $command->execute(); |
|
44 | - return; |
|
45 | - } |
|
46 | - $command = explode(':', $argv[0]); |
|
47 | - $command_class = $command[0]; |
|
48 | - $command_method = isset($command[1]) ? $command[1] : null; |
|
49 | - $argv = self::clean_argv($argv); |
|
50 | - if(is_file("phoponent/commands/{$command_class}.php")) { |
|
51 | - require_once "phoponent/commands/{$command_class}.php"; |
|
52 | - } |
|
53 | - else { |
|
54 | - throw new Exception("command {$command_class} not found !"); |
|
55 | - } |
|
56 | - $command_class = "\\phoponent\\framework\\command\\{$command_class}"; |
|
57 | - $command_obj = new $command_class($argv); |
|
58 | - if($command_method) { |
|
28 | + /** |
|
29 | + * @param $argv |
|
30 | + * @throws Exception |
|
31 | + */ |
|
32 | + public static function go($argv) { |
|
33 | + $argv = self::clean_argv($argv); |
|
34 | + if(empty($argv) || (!empty($argv) && $argv[0] === '-h') || (!empty($argv) && $argv[0] === '--help')) { |
|
35 | + $argv = self::clean_argv($argv); |
|
36 | + if(is_file("phoponent/commands/help.php")) { |
|
37 | + require_once "phoponent/commands/help.php"; |
|
38 | + } |
|
39 | + else { |
|
40 | + throw new Exception("command help not found !"); |
|
41 | + } |
|
42 | + $command = new help($argv); |
|
43 | + $command->execute(); |
|
44 | + return; |
|
45 | + } |
|
46 | + $command = explode(':', $argv[0]); |
|
47 | + $command_class = $command[0]; |
|
48 | + $command_method = isset($command[1]) ? $command[1] : null; |
|
49 | + $argv = self::clean_argv($argv); |
|
50 | + if(is_file("phoponent/commands/{$command_class}.php")) { |
|
51 | + require_once "phoponent/commands/{$command_class}.php"; |
|
52 | + } |
|
53 | + else { |
|
54 | + throw new Exception("command {$command_class} not found !"); |
|
55 | + } |
|
56 | + $command_class = "\\phoponent\\framework\\command\\{$command_class}"; |
|
57 | + $command_obj = new $command_class($argv); |
|
58 | + if($command_method) { |
|
59 | 59 | $command_obj->execute($command_method); |
60 | 60 | } |
61 | 61 | else { |
62 | 62 | $command_obj->execute(); |
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function go($argv) { |
33 | 33 | $argv = self::clean_argv($argv); |
34 | - if(empty($argv) || (!empty($argv) && $argv[0] === '-h') || (!empty($argv) && $argv[0] === '--help')) { |
|
34 | + if (empty($argv) || (!empty($argv) && $argv[0] === '-h') || (!empty($argv) && $argv[0] === '--help')) { |
|
35 | 35 | $argv = self::clean_argv($argv); |
36 | - if(is_file("phoponent/commands/help.php")) { |
|
36 | + if (is_file("phoponent/commands/help.php")) { |
|
37 | 37 | require_once "phoponent/commands/help.php"; |
38 | 38 | } |
39 | 39 | else { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $command_class = $command[0]; |
48 | 48 | $command_method = isset($command[1]) ? $command[1] : null; |
49 | 49 | $argv = self::clean_argv($argv); |
50 | - if(is_file("phoponent/commands/{$command_class}.php")) { |
|
50 | + if (is_file("phoponent/commands/{$command_class}.php")) { |
|
51 | 51 | require_once "phoponent/commands/{$command_class}.php"; |
52 | 52 | } |
53 | 53 | else { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | $command_class = "\\phoponent\\framework\\command\\{$command_class}"; |
57 | 57 | $command_obj = new $command_class($argv); |
58 | - if($command_method) { |
|
58 | + if ($command_method) { |
|
59 | 59 | $command_obj->execute($command_method); |
60 | 60 | } |
61 | 61 | else { |
@@ -35,8 +35,7 @@ discard block |
||
35 | 35 | $argv = self::clean_argv($argv); |
36 | 36 | if(is_file("phoponent/commands/help.php")) { |
37 | 37 | require_once "phoponent/commands/help.php"; |
38 | - } |
|
39 | - else { |
|
38 | + } else { |
|
40 | 39 | throw new Exception("command help not found !"); |
41 | 40 | } |
42 | 41 | $command = new help($argv); |
@@ -49,16 +48,14 @@ discard block |
||
49 | 48 | $argv = self::clean_argv($argv); |
50 | 49 | if(is_file("phoponent/commands/{$command_class}.php")) { |
51 | 50 | require_once "phoponent/commands/{$command_class}.php"; |
52 | - } |
|
53 | - else { |
|
51 | + } else { |
|
54 | 52 | throw new Exception("command {$command_class} not found !"); |
55 | 53 | } |
56 | 54 | $command_class = "\\phoponent\\framework\\command\\{$command_class}"; |
57 | 55 | $command_obj = new $command_class($argv); |
58 | 56 | if($command_method) { |
59 | 57 | $command_obj->execute($command_method); |
60 | - } |
|
61 | - else { |
|
58 | + } else { |
|
62 | 59 | $command_obj->execute(); |
63 | 60 | } |
64 | 61 | } |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | private static $file_path = 'phoponent/framework/debug.info'; |
18 | 18 | |
19 | 19 | public static function set_debug() { |
20 | - if(!is_file(self::$file_path)) { |
|
20 | + if (!is_file(self::$file_path)) { |
|
21 | 21 | file_put_contents(self::$file_path, self::FALSE); |
22 | 22 | } |
23 | - if((integer)file_get_contents(self::$file_path) === 1) { |
|
23 | + if ((integer)file_get_contents(self::$file_path) === 1) { |
|
24 | 24 | file_put_contents(self::$file_path, self::FALSE); |
25 | 25 | } |
26 | 26 | else { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | public static function get_debug(): bool { |
32 | - if(!is_file(self::$file_path)) { |
|
32 | + if (!is_file(self::$file_path)) { |
|
33 | 33 | file_put_contents(self::$file_path, self::FALSE); |
34 | 34 | } |
35 | 35 | return (boolean)(integer)file_get_contents(self::$file_path); |
@@ -22,8 +22,7 @@ |
||
22 | 22 | } |
23 | 23 | if((integer)file_get_contents(self::$file_path) === 1) { |
24 | 24 | file_put_contents(self::$file_path, self::FALSE); |
25 | - } |
|
26 | - else { |
|
25 | + } else { |
|
27 | 26 | file_put_contents(self::$file_path, self::TRUE); |
28 | 27 | } |
29 | 28 | } |
@@ -12,58 +12,58 @@ |
||
12 | 12 | use phoponent\framework\traits\static_class; |
13 | 13 | |
14 | 14 | class regexp { |
15 | - use static_class; |
|
15 | + use static_class; |
|
16 | 16 | |
17 | - public static function get_regexp_for_autoclosed_tags_without_arguments():string { |
|
18 | - return '`\<'.self::get_regexp_for_tag_name().'\/\>`'; |
|
19 | - } |
|
20 | - public static function get_regexp_for_autoclosed_tags_without_arguments_and_spaces():string { |
|
21 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\/\>`'; |
|
22 | - } |
|
23 | - public static function get_regexp_for_autoclosed_tags_with_arguments():string { |
|
24 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'\/\>`'; |
|
25 | - } |
|
17 | + public static function get_regexp_for_autoclosed_tags_without_arguments():string { |
|
18 | + return '`\<'.self::get_regexp_for_tag_name().'\/\>`'; |
|
19 | + } |
|
20 | + public static function get_regexp_for_autoclosed_tags_without_arguments_and_spaces():string { |
|
21 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\/\>`'; |
|
22 | + } |
|
23 | + public static function get_regexp_for_autoclosed_tags_with_arguments():string { |
|
24 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'\/\>`'; |
|
25 | + } |
|
26 | 26 | |
27 | - public static function get_regexp_for_no_autoclosed_tags_with_content_and_arguments():string { |
|
28 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
29 | - } |
|
30 | - public static function get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces():string { |
|
31 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
32 | - } |
|
33 | - public static function get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments():string { |
|
34 | - return '`\<'.self::get_regexp_for_tag_name().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
35 | - } |
|
27 | + public static function get_regexp_for_no_autoclosed_tags_with_content_and_arguments():string { |
|
28 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
29 | + } |
|
30 | + public static function get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces():string { |
|
31 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
32 | + } |
|
33 | + public static function get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments():string { |
|
34 | + return '`\<'.self::get_regexp_for_tag_name().'\>'.self::get_regexp_for_content().'\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
35 | + } |
|
36 | 36 | |
37 | - public static function get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments():string { |
|
38 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
39 | - } |
|
40 | - public static function get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces():string { |
|
41 | - return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
42 | - } |
|
43 | - public static function get_regexp_for_no_autoclosed_tags_without_content_and_arguments():string { |
|
44 | - return '`\<'.self::get_regexp_for_tag_name().'\>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
45 | - } |
|
37 | + public static function get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments():string { |
|
38 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_attributs().'>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
39 | + } |
|
40 | + public static function get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces():string { |
|
41 | + return '`\<'.self::get_regexp_for_tag_name().self::get_regexp_for_juste_space().'\>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
42 | + } |
|
43 | + public static function get_regexp_for_no_autoclosed_tags_without_content_and_arguments():string { |
|
44 | + return '`\<'.self::get_regexp_for_tag_name().'\>\<\/'.self::get_regexp_for_tag_name(true).'\>`'; |
|
45 | + } |
|
46 | 46 | |
47 | - private static function get_regexp_for_content():string { |
|
48 | - return '([\ a-zA-Z0-9\=\-\_\\\'\"\%\é\&\;\,\:\/\!\§\*ù\$\^\#\{\}\[\]\(\)\+\\n\\t]+)'; |
|
47 | + private static function get_regexp_for_content():string { |
|
48 | + return '([\ a-zA-Z0-9\=\-\_\\\'\"\%\é\&\;\,\:\/\!\§\*ù\$\^\#\{\}\[\]\(\)\+\\n\\t]+)'; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function get_regexp_for_attributs():string { |
52 | - return '\ ([\ a-zA-Z0-9\=\-\_\\\'\"\%\é\&\;\,\:\/\.\!\§\*ù\$\^\#\{\}\[\]\(\)\+\\n\\t]+)'; |
|
52 | + return '\ ([\ a-zA-Z0-9\=\-\_\\\'\"\%\é\&\;\,\:\/\.\!\§\*ù\$\^\#\{\}\[\]\(\)\+\\n\\t]+)'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | private static function get_regexp_for_juste_space():string { |
56 | - return '[\ ]+'; |
|
56 | + return '[\ ]+'; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | private static function get_regexp_for_tag_name($close = false):string { |
60 | - $start = $close ? '' : '('; |
|
61 | - $end = $close ? '' : ')'; |
|
62 | - return $start.'[A-Z][A-Za-z0-9\-\_]+'.$end; |
|
60 | + $start = $close ? '' : '('; |
|
61 | + $end = $close ? '' : ')'; |
|
62 | + return $start.'[A-Z][A-Za-z0-9\-\_]+'.$end; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public static function regexp_for_parse_attributs_with_only_integers():string { |
66 | - return '`([\w\-]+\=\\d+)+`'; |
|
66 | + return '`([\w\-]+\=\\d+)+`'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function regexp_for_parse_attributs():string { |
@@ -4,7 +4,7 @@ |
||
4 | 4 | use phoponent\framework\traits\model; |
5 | 5 | |
6 | 6 | class Title extends \phoponent\app\component\core\HomeTitle\mvc\model\Title { |
7 | - use model; |
|
7 | + use model; |
|
8 | 8 | public function get_title($title) { |
9 | 9 | return is_null($title) ? 'Accueil' : $title; |
10 | 10 | } |
@@ -4,12 +4,12 @@ |
||
4 | 4 | use phoponent\framework\classe\xphp_tag; |
5 | 5 | |
6 | 6 | class HomeTitle extends \phoponent\app\component\core\HomeTitle { |
7 | - public function render(): string { |
|
7 | + public function render(): string { |
|
8 | 8 | $title = $this->get_model('Title') |
9 | - ->get_title($this->attribute('title')); |
|
10 | - return $this->get_view('HomeTitle') |
|
11 | - ->set_vars([ |
|
12 | - 'title' => $title, |
|
13 | - ])->render(); |
|
14 | - } |
|
9 | + ->get_title($this->attribute('title')); |
|
10 | + return $this->get_view('HomeTitle') |
|
11 | + ->set_vars([ |
|
12 | + 'title' => $title, |
|
13 | + ])->render(); |
|
14 | + } |
|
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -10,48 +10,48 @@ |
||
10 | 10 | class table extends \phoponent\app\component\core\Table\mvc\model\table { |
11 | 11 | use model; |
12 | 12 | |
13 | - private function get_array_keys($array) { |
|
14 | - return array_keys($array); |
|
15 | - } |
|
13 | + private function get_array_keys($array) { |
|
14 | + return array_keys($array); |
|
15 | + } |
|
16 | 16 | |
17 | 17 | public function get_datas_from_json($file) { |
18 | - $file = __DIR__."/../{$file}"; |
|
19 | - /** |
|
20 | - * @var json_reader $json_reader_service |
|
21 | - */ |
|
22 | - $json_reader_service = $this->get_service('json_reader'); |
|
23 | - return $json_reader_service |
|
24 | - ->set_file($file) |
|
25 | - ->get('datas'); |
|
18 | + $file = __DIR__."/../{$file}"; |
|
19 | + /** |
|
20 | + * @var json_reader $json_reader_service |
|
21 | + */ |
|
22 | + $json_reader_service = $this->get_service('json_reader'); |
|
23 | + return $json_reader_service |
|
24 | + ->set_file($file) |
|
25 | + ->get('datas'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function genere_header(array $json_datas, tr $tr_view, th $th_view) { |
29 | - $json_datas = $this->get_array_keys((array)$json_datas[0]); |
|
30 | - $header = ''; |
|
31 | - foreach ($json_datas as $json_data) { |
|
32 | - foreach ((array)$json_data as $data) { |
|
33 | - $new_th_view = $th_view; |
|
34 | - $header .= $new_th_view->set_vars(['text' => $data])->render(); |
|
35 | - } |
|
36 | - } |
|
37 | - $tr_view->set_vars(['text' => $header]); |
|
38 | - return $tr_view->render(); |
|
39 | - } |
|
29 | + $json_datas = $this->get_array_keys((array)$json_datas[0]); |
|
30 | + $header = ''; |
|
31 | + foreach ($json_datas as $json_data) { |
|
32 | + foreach ((array)$json_data as $data) { |
|
33 | + $new_th_view = $th_view; |
|
34 | + $header .= $new_th_view->set_vars(['text' => $data])->render(); |
|
35 | + } |
|
36 | + } |
|
37 | + $tr_view->set_vars(['text' => $header]); |
|
38 | + return $tr_view->render(); |
|
39 | + } |
|
40 | 40 | |
41 | - public function genere_body(array $json_datas, tr $tr_view, td $td_view) { |
|
42 | - $lines = ''; |
|
43 | - foreach ($json_datas as $id => $json_data) { |
|
44 | - $json_data = (array)$json_data; |
|
45 | - $header_keys = $this->get_array_keys($json_data); |
|
46 | - $tr = $tr_view; |
|
47 | - $line = ''; |
|
48 | - foreach ($header_keys as $header_key) { |
|
49 | - $td = $td_view; |
|
50 | - $line .= $td->set_vars(['text' => ''.$json_data[$header_key]])->render(); |
|
51 | - } |
|
52 | - $lines .= $tr->set_vars(['text' => $line])->render(); |
|
53 | - } |
|
54 | - return $lines; |
|
41 | + public function genere_body(array $json_datas, tr $tr_view, td $td_view) { |
|
42 | + $lines = ''; |
|
43 | + foreach ($json_datas as $id => $json_data) { |
|
44 | + $json_data = (array)$json_data; |
|
45 | + $header_keys = $this->get_array_keys($json_data); |
|
46 | + $tr = $tr_view; |
|
47 | + $line = ''; |
|
48 | + foreach ($header_keys as $header_key) { |
|
49 | + $td = $td_view; |
|
50 | + $line .= $td->set_vars(['text' => ''.$json_data[$header_key]])->render(); |
|
51 | + } |
|
52 | + $lines .= $tr->set_vars(['text' => $line])->render(); |
|
53 | + } |
|
54 | + return $lines; |
|
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
31 | 31 | foreach ($json_datas as $json_data) { |
32 | 32 | foreach ((array)$json_data as $data) { |
33 | 33 | $new_th_view = $th_view; |
34 | - $header .= $new_th_view->set_vars(['text' => $data])->render(); |
|
34 | + $header .= $new_th_view->set_vars(['text' => $data])->render(); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | $tr_view->set_vars(['text' => $header]); |