@@ -10,48 +10,48 @@ |
||
10 | 10 | class 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]); |
@@ -4,5 +4,5 @@ |
||
4 | 4 | use phoponent\framework\traits\view; |
5 | 5 | |
6 | 6 | class td { |
7 | - use view; |
|
7 | + use view; |
|
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -4,5 +4,5 @@ |
||
4 | 4 | use phoponent\framework\traits\view; |
5 | 5 | |
6 | 6 | class tr { |
7 | - use view; |
|
7 | + use view; |
|
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -4,5 +4,5 @@ |
||
4 | 4 | use phoponent\framework\traits\view; |
5 | 5 | |
6 | 6 | class th { |
7 | - use view; |
|
7 | + use view; |
|
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -2,42 +2,42 @@ |
||
2 | 2 | namespace phoponent\app\component\core; |
3 | 3 | |
4 | 4 | use Exception; |
5 | - use phoponent\app\component\core\Table\mvc\model\table_model; |
|
6 | - use phoponent\framework\classe\xphp_tag; |
|
7 | - use phoponent\framework\service\translation; |
|
5 | + use phoponent\app\component\core\Table\mvc\model\table_model; |
|
6 | + use phoponent\framework\classe\xphp_tag; |
|
7 | + use phoponent\framework\service\translation; |
|
8 | 8 | |
9 | - class Table extends xphp_tag { |
|
9 | + class Table extends xphp_tag { |
|
10 | 10 | |
11 | - /** |
|
12 | - * @return string |
|
13 | - * @throws Exception |
|
14 | - */ |
|
15 | - public function render():string { |
|
16 | - /** |
|
17 | - * @var table_model $model |
|
18 | - */ |
|
19 | - $model = $this->get_model('table'); |
|
20 | - $my_name = 'Nicolas'; |
|
21 | - $json_datas = $model->get_datas_from_json($this->attribute('file')); |
|
11 | + /** |
|
12 | + * @return string |
|
13 | + * @throws Exception |
|
14 | + */ |
|
15 | + public function render():string { |
|
16 | + /** |
|
17 | + * @var table_model $model |
|
18 | + */ |
|
19 | + $model = $this->get_model('table'); |
|
20 | + $my_name = 'Nicolas'; |
|
21 | + $json_datas = $model->get_datas_from_json($this->attribute('file')); |
|
22 | 22 | |
23 | 23 | |
24 | - $header_view = $model->genere_header( |
|
25 | - $json_datas, |
|
26 | - $this->get_view('tr'), |
|
27 | - $this->get_view('th') |
|
28 | - ); |
|
29 | - $lines = $model->genere_body( |
|
30 | - $json_datas, |
|
31 | - $this->get_view('tr'), |
|
32 | - $this->get_view('td') |
|
33 | - ); |
|
24 | + $header_view = $model->genere_header( |
|
25 | + $json_datas, |
|
26 | + $this->get_view('tr'), |
|
27 | + $this->get_view('th') |
|
28 | + ); |
|
29 | + $lines = $model->genere_body( |
|
30 | + $json_datas, |
|
31 | + $this->get_view('tr'), |
|
32 | + $this->get_view('td') |
|
33 | + ); |
|
34 | 34 | $table = $this->get_view('table') |
35 | - ->set_vars([ |
|
36 | - 'text_in_french' => translation::__($this->attribute('text_to_translate'), [$my_name], 'fr'), |
|
37 | - 'text_in_english' => translation::__($this->attribute('text_to_translate'), [$my_name]), |
|
38 | - 'header' => $header_view, |
|
39 | - 'lines' => $lines |
|
40 | - ])->render(); |
|
35 | + ->set_vars([ |
|
36 | + 'text_in_french' => translation::__($this->attribute('text_to_translate'), [$my_name], 'fr'), |
|
37 | + 'text_in_english' => translation::__($this->attribute('text_to_translate'), [$my_name]), |
|
38 | + 'header' => $header_view, |
|
39 | + 'lines' => $lines |
|
40 | + ])->render(); |
|
41 | 41 | |
42 | 42 | return $table; |
43 | 43 | } |
@@ -3,11 +3,11 @@ |
||
3 | 3 | |
4 | 4 | use phoponent\framework\classe\xphp_tag; |
5 | 5 | |
6 | - class Main extends xphp_tag { |
|
6 | + class Main extends xphp_tag { |
|
7 | 7 | public function render():string { |
8 | - return $this->get_view('Main') |
|
9 | - ->set_vars([ |
|
10 | - 'title' => $this->attribute('title') |
|
11 | - ])->render(); |
|
8 | + return $this->get_view('Main') |
|
9 | + ->set_vars([ |
|
10 | + 'title' => $this->attribute('title') |
|
11 | + ])->render(); |
|
12 | 12 | } |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use phoponent\framework\classe\xphp_tag; |
5 | 5 | |
6 | - class Mon_component extends xphp_tag { |
|
6 | + class Mon_component extends xphp_tag { |
|
7 | 7 | public function render():string { |
8 | 8 | $hello_world = $this->get_model('my_Mon_component')->get_hello_world(); |
9 | 9 | $view = $this->get_view('my_Mon_component') |
@@ -4,17 +4,17 @@ |
||
4 | 4 | use phoponent\framework\classe\xphp_tag; |
5 | 5 | |
6 | 6 | class Mon_premier_tag extends xphp_tag { |
7 | - public function render(): string { |
|
8 | - $model = $this->get_model('props_gestion') |
|
7 | + public function render(): string { |
|
8 | + $model = $this->get_model('props_gestion') |
|
9 | 9 | ->set('id', $this->attribute('id').(!is_null($this->attribute('date')) ? '-'.$this->attribute('date') : '')) |
10 | 10 | ->set('class', $this->attribute('class')) |
11 | 11 | ->set('value', $this->value() !== '' ? $this->value() : __CLASS__); |
12 | - list($class, $id, $content) = $model->get('infos'); |
|
12 | + list($class, $id, $content) = $model->get('infos'); |
|
13 | 13 | |
14 | - return $this->get_view('balise')->set_vars([ |
|
15 | - 'id' => $id, |
|
14 | + return $this->get_view('balise')->set_vars([ |
|
15 | + 'id' => $id, |
|
16 | 16 | 'class' => $class, |
17 | 17 | 'content' => $content, |
18 | 18 | ])->render(); |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | use phoponent\framework\classe\xphp_tag; |
5 | 5 | |
6 | 6 | class Clock extends xphp_tag { |
7 | - public function render(): string { |
|
8 | - $result = $this->get_view('horloge')->render(); |
|
9 | - return $result; |
|
10 | - } |
|
7 | + public function render(): string { |
|
8 | + $result = $this->get_view('horloge')->render(); |
|
9 | + return $result; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |