1
|
|
|
<?php |
2
|
|
|
namespace app\controllers; |
3
|
|
|
|
4
|
|
|
class Examples extends \erdiko\controllers\Web |
5
|
|
|
{ |
6
|
|
|
use \erdiko\theme\traits\Controller; |
7
|
|
|
|
8
|
|
View Code Duplication |
public function get($request, $response, $args) |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
$this->container->logger->debug("examples"); |
11
|
|
|
$view = 'examples/list.html'; |
12
|
|
|
|
13
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
14
|
|
|
$themeData = \erdiko\theme\Config::get(); |
15
|
|
|
// $themeData['args'] = $args; // optional |
|
|
|
|
16
|
|
|
$themeData['page'] = [ |
17
|
|
|
'title' => "Erdiko Web Example", |
18
|
|
|
'hello' => "world" |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
View Code Duplication |
public function getOnecolumn($request, $response, $args) |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
$this->container->logger->debug("route: /config"); |
28
|
|
|
$view = 'layouts/1column.html'; |
29
|
|
|
|
30
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
31
|
|
|
$config = \erdiko\theme\Config::get(); |
32
|
|
|
$config['page']['title'] = "1 Column Layout"; |
33
|
|
|
|
34
|
|
|
return $this->container->theme->render($response, $view, $config); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
public function getTwocolumn($request, $response, $args) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$this->container->logger->debug("route: /config"); |
40
|
|
|
$view = 'layouts/2column.html'; |
41
|
|
|
|
42
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
43
|
|
|
$config = \erdiko\theme\Config::get(); |
44
|
|
|
$config['page']['title'] = "2 Column Layout"; |
45
|
|
|
|
46
|
|
|
return $this->container->theme->render($response, $view, $config); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
View Code Duplication |
public function getThreecolumn($request, $response, $args) |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
$this->container->logger->debug("route: /config"); |
52
|
|
|
$view = 'layouts/3column.html'; |
53
|
|
|
|
54
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
55
|
|
|
$config = \erdiko\theme\Config::get(); |
56
|
|
|
$config['page']['title'] = "3 Column Layout"; |
57
|
|
|
|
58
|
|
|
return $this->container->theme->render($response, $view, $config); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
View Code Duplication |
public function getJohn($request, $response, $args) |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
$view = 'pages/example.html'; |
64
|
|
|
|
65
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
66
|
|
|
$themeData = \erdiko\theme\Config::get(); |
67
|
|
|
$themeData['args'] = $args; // optional |
68
|
|
|
$themeData['page'] = [ |
69
|
|
|
'title' => "Erdiko Web Example" |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
View Code Duplication |
public function getMarkup($request, $response, $args) |
|
|
|
|
76
|
|
|
{ |
77
|
|
|
$view = 'examples/markup.html'; |
78
|
|
|
|
79
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
80
|
|
|
$themeData = \erdiko\theme\Config::get(); |
81
|
|
|
$themeData['args'] = $args; // optional |
82
|
|
|
$themeData['page'] = [ |
83
|
|
|
'title' => "Markup Example" |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
View Code Duplication |
public function getCarousel($request, $response, $args) |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
$view = 'examples/carousel.html'; |
92
|
|
|
|
93
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
94
|
|
|
$themeData = \erdiko\theme\Config::get(); |
95
|
|
|
$themeData['page'] = [ |
96
|
|
|
'title' => "Fullpage Example", |
97
|
|
|
'description' => "This is the description of the page." |
98
|
|
|
]; |
99
|
|
|
|
100
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getTheme($request, $response, $args) |
104
|
|
|
{ |
105
|
|
|
// $view = 'examples/theme.html'; |
|
|
|
|
106
|
|
|
$theme = new \erdiko\theme\Engine; |
107
|
|
|
$theme->title = "Theme Engine Example"; |
108
|
|
|
$theme->description = "This page is rendered using the theme engine. |
109
|
|
|
\\erdiko\\theme\\Engine"; |
110
|
|
|
|
111
|
|
|
return $this->render($response, null, $theme); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function getFlash($request, $response, $args) |
115
|
|
|
{ |
116
|
|
|
$view = 'page.html'; |
117
|
|
|
|
118
|
|
|
// Add some flash messages |
119
|
|
|
$this->container->flash->addMessage('success', 'This is a success message'); |
120
|
|
|
$this->container->flash->addMessage('info', 'This is an info message'); |
121
|
|
|
$this->container->flash->addMessage('warning', 'This is a warning message'); |
122
|
|
|
$this->container->flash->addMessage('danger', 'This is a danger (error) message'); |
123
|
|
|
|
124
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
125
|
|
|
$themeData = \erdiko\theme\Config::get(); |
126
|
|
|
$themeData['args'] = $args; |
127
|
|
|
$themeData['page'] = [ |
128
|
|
|
'title' => "Flash Message Example" |
129
|
|
|
]; |
130
|
|
|
|
131
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getGrid($request, $response, $args) |
135
|
|
|
{ |
136
|
|
|
$this->container->logger->debug("/controller"); |
137
|
|
|
$view = 'examples/grid.html'; |
138
|
|
|
|
139
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
140
|
|
|
$themeData = \erdiko\theme\Config::get(); |
141
|
|
|
// $this->container->logger->debug("config: ".print_r($config, true)); |
|
|
|
|
142
|
|
|
|
143
|
|
|
// Generate data for grid |
144
|
|
|
$item = [ |
145
|
|
|
'url' => "#", |
146
|
|
|
'image' => "/images/grid-item.png", |
147
|
|
|
'name' => "Item" |
148
|
|
|
]; |
149
|
|
|
$items = array(); |
150
|
|
|
$max = (int)$args['param']; |
151
|
|
|
$this->container->logger->debug("param: ".$max); |
152
|
|
|
|
153
|
|
View Code Duplication |
for($i = 0; $i < $max; $i++) { |
|
|
|
|
154
|
|
|
$item['name'] = "Item $i"; |
155
|
|
|
$items[] = $item; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
$themeData['page'] = [ |
159
|
|
|
'title' => "Grid Example", |
160
|
|
|
'items' => $items |
161
|
|
|
]; |
162
|
|
|
|
163
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
View Code Duplication |
public function getFullpage($request, $response, $args) |
|
|
|
|
167
|
|
|
{ |
168
|
|
|
$view = 'fullpage.html'; |
169
|
|
|
|
170
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
171
|
|
|
$themeData = \erdiko\theme\Config::get(); |
172
|
|
|
$themeData['page'] = [ |
173
|
|
|
'title' => "Fullpage Example", |
174
|
|
|
'description' => "This is the description of the page." |
175
|
|
|
]; |
176
|
|
|
|
177
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function getException($request, $response, $args) |
181
|
|
|
{ |
182
|
|
|
$view = 'page.html'; |
|
|
|
|
183
|
|
|
|
184
|
|
|
throw new \Exception("This is an exception"); |
185
|
|
|
|
186
|
|
|
// Get erdiko config, this gets application.json and loads the theme specified |
187
|
|
|
$themeData = \erdiko\theme\Config::get(); |
|
|
|
|
188
|
|
|
$themeData['page'] = [ |
189
|
|
|
'title' => "Fullpage Example", |
190
|
|
|
'description' => "This is the description of the page." |
191
|
|
|
]; |
192
|
|
|
|
193
|
|
|
return $this->container->theme->render($response, $view, $themeData); |
194
|
|
|
} |
195
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.