@@ -219,7 +219,6 @@ |
||
219 | 219 | /** |
220 | 220 | * Execute the query built. |
221 | 221 | * |
222 | - * @param string $query custom query. |
|
223 | 222 | * |
224 | 223 | * @return $this |
225 | 224 | */ |
@@ -12,68 +12,68 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * Get the table name. |
|
17 | - * |
|
18 | - * @return string with the table name. |
|
19 | - */ |
|
20 | - public function getSource() |
|
21 | - { |
|
22 | - return strtolower(implode('', array_slice(explode('\\', get_class($this)), -1))); |
|
23 | - } |
|
15 | + /** |
|
16 | + * Get the table name. |
|
17 | + * |
|
18 | + * @return string with the table name. |
|
19 | + */ |
|
20 | + public function getSource() |
|
21 | + { |
|
22 | + return strtolower(implode('', array_slice(explode('\\', get_class($this)), -1))); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Find and return all. |
|
27 | - * |
|
28 | - * @return array |
|
29 | - */ |
|
30 | - public function findAll() |
|
31 | - { |
|
32 | - $this->db->select() |
|
33 | - ->from($this->getSource()); |
|
25 | + /** |
|
26 | + * Find and return all. |
|
27 | + * |
|
28 | + * @return array |
|
29 | + */ |
|
30 | + public function findAll() |
|
31 | + { |
|
32 | + $this->db->select() |
|
33 | + ->from($this->getSource()); |
|
34 | 34 | |
35 | - $this->db->execute(); |
|
36 | - $this->db->setFetchModeClass(__CLASS__); |
|
37 | - return $this->db->fetchAll(); |
|
38 | - } |
|
35 | + $this->db->execute(); |
|
36 | + $this->db->setFetchModeClass(__CLASS__); |
|
37 | + return $this->db->fetchAll(); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get object properties. |
|
42 | - * |
|
43 | - * @return array with object properties. |
|
44 | - */ |
|
45 | - public function getProperties() |
|
46 | - { |
|
47 | - $properties = get_object_vars($this); |
|
48 | - unset($properties['di']); |
|
49 | - unset($properties['db']); |
|
40 | + /** |
|
41 | + * Get object properties. |
|
42 | + * |
|
43 | + * @return array with object properties. |
|
44 | + */ |
|
45 | + public function getProperties() |
|
46 | + { |
|
47 | + $properties = get_object_vars($this); |
|
48 | + unset($properties['di']); |
|
49 | + unset($properties['db']); |
|
50 | 50 | |
51 | - return $properties; |
|
52 | - } |
|
51 | + return $properties; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Find and return specific. |
|
57 | - * |
|
58 | - * @return this |
|
59 | - */ |
|
60 | - public function find($id) |
|
61 | - { |
|
55 | + /** |
|
56 | + * Find and return specific. |
|
57 | + * |
|
58 | + * @return this |
|
59 | + */ |
|
60 | + public function find($id) |
|
61 | + { |
|
62 | 62 | $this->db->select() |
63 | - ->from($this->getSource()) |
|
64 | - ->where("id = ?"); |
|
63 | + ->from($this->getSource()) |
|
64 | + ->where("id = ?"); |
|
65 | 65 | |
66 | 66 | $this->db->execute([$id]); |
67 | 67 | return $this->db->fetchInto($this); |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Save current object/row. |
|
72 | - * |
|
73 | - * @param array $values key/values to save or empty to use object properties. |
|
74 | - * |
|
75 | - * @return boolean true or false if saving went okey. |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Save current object/row. |
|
72 | + * |
|
73 | + * @param array $values key/values to save or empty to use object properties. |
|
74 | + * |
|
75 | + * @return boolean true or false if saving went okey. |
|
76 | + */ |
|
77 | 77 | public function save($values = []) |
78 | 78 | { |
79 | 79 | |
@@ -86,150 +86,150 @@ discard block |
||
86 | 86 | } else { |
87 | 87 | return $this->create($values); |
88 | 88 | } |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Set object properties. |
|
93 | - * |
|
94 | - * @param array $properties with properties to set. |
|
95 | - * |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function setProperties($properties) |
|
99 | - { |
|
100 | - // Update object with incoming values, if any |
|
101 | - if (!empty($properties)) { |
|
102 | - foreach ($properties as $key => $val) { |
|
103 | - $this->$key = $val; |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
91 | + /** |
|
92 | + * Set object properties. |
|
93 | + * |
|
94 | + * @param array $properties with properties to set. |
|
95 | + * |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function setProperties($properties) |
|
99 | + { |
|
100 | + // Update object with incoming values, if any |
|
101 | + if (!empty($properties)) { |
|
102 | + foreach ($properties as $key => $val) { |
|
103 | + $this->$key = $val; |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Create new row. |
|
110 | - * |
|
111 | - * @param array $values key/values to save. |
|
112 | - * |
|
113 | - * @return boolean true or false if saving went okey. |
|
114 | - */ |
|
115 | - public function create($values) |
|
116 | - { |
|
117 | - $keys = array_keys($values); |
|
118 | - $values = array_values($values); |
|
108 | + /** |
|
109 | + * Create new row. |
|
110 | + * |
|
111 | + * @param array $values key/values to save. |
|
112 | + * |
|
113 | + * @return boolean true or false if saving went okey. |
|
114 | + */ |
|
115 | + public function create($values) |
|
116 | + { |
|
117 | + $keys = array_keys($values); |
|
118 | + $values = array_values($values); |
|
119 | 119 | |
120 | - $this->db->insert( |
|
121 | - $this->getSource(), |
|
122 | - $keys |
|
123 | - ); |
|
120 | + $this->db->insert( |
|
121 | + $this->getSource(), |
|
122 | + $keys |
|
123 | + ); |
|
124 | 124 | |
125 | - $res = $this->db->execute($values); |
|
125 | + $res = $this->db->execute($values); |
|
126 | 126 | |
127 | - $this->id = $this->db->lastInsertId(); |
|
127 | + $this->id = $this->db->lastInsertId(); |
|
128 | 128 | |
129 | - return $res; |
|
130 | - } |
|
129 | + return $res; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * Update row. |
|
135 | - * |
|
136 | - * @param array $values key/values to save. |
|
137 | - * |
|
138 | - * @return boolean true or false if saving went okey. |
|
139 | - */ |
|
140 | - public function update($values) |
|
141 | - { |
|
142 | - $keys = array_keys($values); |
|
143 | - $values = array_values($values); |
|
133 | + /** |
|
134 | + * Update row. |
|
135 | + * |
|
136 | + * @param array $values key/values to save. |
|
137 | + * |
|
138 | + * @return boolean true or false if saving went okey. |
|
139 | + */ |
|
140 | + public function update($values) |
|
141 | + { |
|
142 | + $keys = array_keys($values); |
|
143 | + $values = array_values($values); |
|
144 | 144 | |
145 | - // Its update, remove id and use as where-clause |
|
146 | - unset($keys['id']); |
|
147 | - $values[] = $this->id; |
|
145 | + // Its update, remove id and use as where-clause |
|
146 | + unset($keys['id']); |
|
147 | + $values[] = $this->id; |
|
148 | 148 | |
149 | - $this->db->update( |
|
150 | - $this->getSource(), |
|
151 | - $keys, |
|
152 | - "id = ?" |
|
153 | - ); |
|
149 | + $this->db->update( |
|
150 | + $this->getSource(), |
|
151 | + $keys, |
|
152 | + "id = ?" |
|
153 | + ); |
|
154 | 154 | |
155 | - return $this->db->execute($values); |
|
156 | - } |
|
155 | + return $this->db->execute($values); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Delete row. |
|
160 | - * |
|
161 | - * @param integer $id to delete. |
|
162 | - * |
|
163 | - * @return boolean true or false if deleting went okey. |
|
164 | - */ |
|
165 | - public function delete($id) |
|
166 | - { |
|
167 | - $this->db->delete( |
|
168 | - $this->getSource(), |
|
169 | - 'id = ?' |
|
170 | - ); |
|
158 | + /** |
|
159 | + * Delete row. |
|
160 | + * |
|
161 | + * @param integer $id to delete. |
|
162 | + * |
|
163 | + * @return boolean true or false if deleting went okey. |
|
164 | + */ |
|
165 | + public function delete($id) |
|
166 | + { |
|
167 | + $this->db->delete( |
|
168 | + $this->getSource(), |
|
169 | + 'id = ?' |
|
170 | + ); |
|
171 | 171 | |
172 | - return $this->db->execute([$id]); |
|
173 | - } |
|
172 | + return $this->db->execute([$id]); |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * Build a select-query. |
|
178 | - * |
|
179 | - * @param string $columns which columns to select. |
|
180 | - * |
|
181 | - * @return $this |
|
182 | - */ |
|
183 | - public function query($columns = '*') |
|
184 | - { |
|
185 | - $this->db->select($columns) |
|
186 | - ->from($this->getSource()); |
|
176 | + /** |
|
177 | + * Build a select-query. |
|
178 | + * |
|
179 | + * @param string $columns which columns to select. |
|
180 | + * |
|
181 | + * @return $this |
|
182 | + */ |
|
183 | + public function query($columns = '*') |
|
184 | + { |
|
185 | + $this->db->select($columns) |
|
186 | + ->from($this->getSource()); |
|
187 | 187 | |
188 | - return $this; |
|
189 | - } |
|
188 | + return $this; |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
192 | - * Build the where part. |
|
193 | - * |
|
194 | - * @param string $condition for building the where part of the query. |
|
195 | - * |
|
196 | - * @return $this |
|
197 | - */ |
|
198 | - public function where($condition) |
|
199 | - { |
|
200 | - $this->db->where($condition); |
|
191 | + /** |
|
192 | + * Build the where part. |
|
193 | + * |
|
194 | + * @param string $condition for building the where part of the query. |
|
195 | + * |
|
196 | + * @return $this |
|
197 | + */ |
|
198 | + public function where($condition) |
|
199 | + { |
|
200 | + $this->db->where($condition); |
|
201 | 201 | |
202 | - return $this; |
|
203 | - } |
|
202 | + return $this; |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Build the where part. |
|
207 | - * |
|
208 | - * @param string $condition for building the where part of the query. |
|
209 | - * |
|
210 | - * @return $this |
|
211 | - */ |
|
212 | - public function andWhere($condition) |
|
213 | - { |
|
214 | - $this->db->andWhere($condition); |
|
205 | + /** |
|
206 | + * Build the where part. |
|
207 | + * |
|
208 | + * @param string $condition for building the where part of the query. |
|
209 | + * |
|
210 | + * @return $this |
|
211 | + */ |
|
212 | + public function andWhere($condition) |
|
213 | + { |
|
214 | + $this->db->andWhere($condition); |
|
215 | 215 | |
216 | - return $this; |
|
217 | - } |
|
216 | + return $this; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Execute the query built. |
|
221 | - * |
|
222 | - * @param string $query custom query. |
|
223 | - * |
|
224 | - * @return $this |
|
225 | - */ |
|
226 | - public function execute($params = []) |
|
227 | - { |
|
228 | - $this->db->execute($this->db->getSQL(), $params); |
|
229 | - $this->db->setFetchModeClass(__CLASS__); |
|
219 | + /** |
|
220 | + * Execute the query built. |
|
221 | + * |
|
222 | + * @param string $query custom query. |
|
223 | + * |
|
224 | + * @return $this |
|
225 | + */ |
|
226 | + public function execute($params = []) |
|
227 | + { |
|
228 | + $this->db->execute($this->db->getSQL(), $params); |
|
229 | + $this->db->setFetchModeClass(__CLASS__); |
|
230 | 230 | |
231 | - return $this->db->fetchAll(); |
|
232 | - } |
|
231 | + return $this->db->fetchAll(); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | ?> |
@@ -139,7 +139,7 @@ |
||
139 | 139 | */ |
140 | 140 | public function update($values) |
141 | 141 | { |
142 | - $keys = array_keys($values); |
|
142 | + $keys = array_keys($values); |
|
143 | 143 | $values = array_values($values); |
144 | 144 | |
145 | 145 | // Its update, remove id and use as where-clause |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * @return void |
13 | 13 | */ |
14 | 14 | spl_autoload_register( |
15 | - function ($class) { |
|
15 | + function($class) { |
|
16 | 16 | |
17 | 17 | // project-specific namespace prefix |
18 | 18 | //$prefix = 'Foo\\Bar\\'; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | class Movie extends \Jovis\DatabaseModel\CDatabaseModel |
8 | 8 | { |
9 | 9 | |
10 | - public function init() |
|
11 | - { |
|
10 | + public function init() |
|
11 | + { |
|
12 | 12 | $this->db->dropTableIfExists('movie') |
13 | - ->execute(); |
|
13 | + ->execute(); |
|
14 | 14 | |
15 | 15 | $this->db->createTable( |
16 | 16 | 'movie', |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | $this->db->insert( |
29 | 29 | 'movie', |
30 | 30 | ['title', 'director', 'length', 'year'] |
31 | - ); |
|
31 | + ); |
|
32 | 32 | |
33 | - $this->db->execute(['Kalles drömmar', 'Gustav Andersson', '120', '1977']); |
|
33 | + $this->db->execute(['Kalles drömmar', 'Gustav Andersson', '120', '1977']); |
|
34 | 34 | |
35 | - $this->db->insert( |
|
35 | + $this->db->insert( |
|
36 | 36 | 'movie', |
37 | 37 | ['title', 'director', 'length', 'year'] |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | - $this->db->execute(['Gustavs drömmar', 'Kalle Andersson', '101', '2007']); |
|
40 | + $this->db->execute(['Gustavs drömmar', 'Kalle Andersson', '101', '2007']); |
|
41 | 41 | |
42 | - $this->db->insert( |
|
42 | + $this->db->insert( |
|
43 | 43 | 'movie', |
44 | 44 | ['title', 'director', 'length', 'year'] |
45 | - ); |
|
45 | + ); |
|
46 | 46 | |
47 | - $this->db->execute(['Mammas drömmar', 'Johanna Andersson', '25', '2010']); |
|
47 | + $this->db->execute(['Mammas drömmar', 'Johanna Andersson', '25', '2010']); |
|
48 | 48 | |
49 | - $this->db->insert( |
|
49 | + $this->db->insert( |
|
50 | 50 | 'movie', |
51 | 51 | ['title', 'director', 'length', 'year'] |
52 | - ); |
|
52 | + ); |
|
53 | 53 | |
54 | - $this->db->execute(['Goda kakor', 'Hannes Andersson', '110', '1954']); |
|
54 | + $this->db->execute(['Goda kakor', 'Hannes Andersson', '110', '1954']); |
|
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | |
9 | 9 | class CHTMLTable{ |
10 | 10 | |
11 | - private $data; |
|
11 | + private $data; |
|
12 | 12 | |
13 | - //tar emot en headline som enkel array och data som tvådimensionell array |
|
14 | - public function __construct($headline, $data){ |
|
13 | + //tar emot en headline som enkel array och data som tvådimensionell array |
|
14 | + public function __construct($headline, $data){ |
|
15 | 15 | $this->data = $data; |
16 | 16 | $this->headline = $headline; |
17 | - } |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * skapar en tabell (sträng) med rubriker från den endimensionella |
|
21 | - * arrayen $headline och innehåll från |
|
22 | - * den tvådimensionella arrayen $data array |
|
23 | - * |
|
24 | - * @return string $html, sträng innehållande en tabell |
|
25 | - */ |
|
19 | + /** |
|
20 | + * skapar en tabell (sträng) med rubriker från den endimensionella |
|
21 | + * arrayen $headline och innehåll från |
|
22 | + * den tvådimensionella arrayen $data array |
|
23 | + * |
|
24 | + * @return string $html, sträng innehållande en tabell |
|
25 | + */ |
|
26 | 26 | |
27 | - public function getTable(){ |
|
27 | + public function getTable(){ |
|
28 | 28 | |
29 | 29 | $table = ""; |
30 | 30 | |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | <table class> |
33 | 33 | <tr class='rows'>"; |
34 | 34 | |
35 | - foreach($this->headline as $h) { |
|
36 | - $table.= "<th>" . $h ."</th>"; |
|
37 | - } |
|
35 | + foreach($this->headline as $h) { |
|
36 | + $table.= "<th>" . $h ."</th>"; |
|
37 | + } |
|
38 | 38 | |
39 | - $table .= "</tr>"; |
|
40 | - foreach($this->data as $d){ |
|
41 | - $table .= "<tr>"; |
|
42 | - foreach ($d as $v) { |
|
43 | - $table .= "<td>$v</td>"; |
|
44 | - } |
|
45 | - $table .= "</tr>"; |
|
46 | - } |
|
47 | - $table .="</table></div>"; |
|
39 | + $table .= "</tr>"; |
|
40 | + foreach($this->data as $d){ |
|
41 | + $table .= "<tr>"; |
|
42 | + foreach ($d as $v) { |
|
43 | + $table .= "<td>$v</td>"; |
|
44 | + } |
|
45 | + $table .= "</tr>"; |
|
46 | + } |
|
47 | + $table .="</table></div>"; |
|
48 | 48 | |
49 | - return $table; |
|
50 | - } |
|
49 | + return $table; |
|
50 | + } |
|
51 | 51 | } |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -class CHTMLTable{ |
|
9 | +class CHTMLTable { |
|
10 | 10 | |
11 | 11 | private $data; |
12 | 12 | |
13 | 13 | //tar emot en headline som enkel array och data som tvådimensionell array |
14 | - public function __construct($headline, $data){ |
|
14 | + public function __construct($headline, $data) { |
|
15 | 15 | $this->data = $data; |
16 | 16 | $this->headline = $headline; |
17 | 17 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return string $html, sträng innehållande en tabell |
25 | 25 | */ |
26 | 26 | |
27 | - public function getTable(){ |
|
27 | + public function getTable() { |
|
28 | 28 | |
29 | 29 | $table = ""; |
30 | 30 | |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | <table class> |
33 | 33 | <tr class='rows'>"; |
34 | 34 | |
35 | - foreach($this->headline as $h) { |
|
36 | - $table.= "<th>" . $h ."</th>"; |
|
35 | + foreach ($this->headline as $h) { |
|
36 | + $table .= "<th>" . $h . "</th>"; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $table .= "</tr>"; |
40 | - foreach($this->data as $d){ |
|
40 | + foreach ($this->data as $d) { |
|
41 | 41 | $table .= "<tr>"; |
42 | 42 | foreach ($d as $v) { |
43 | 43 | $table .= "<td>$v</td>"; |
44 | 44 | } |
45 | 45 | $table .= "</tr>"; |
46 | 46 | } |
47 | - $table .="</table></div>"; |
|
47 | + $table .= "</table></div>"; |
|
48 | 48 | |
49 | 49 | return $table; |
50 | 50 | } |
@@ -10,63 +10,63 @@ |
||
10 | 10 | { |
11 | 11 | use \Anax\DI\TInjectable; |
12 | 12 | |
13 | - /** |
|
14 | - * Lists all instances of the model, (databasetable) except for noListing. |
|
15 | - * |
|
16 | - * @param $noListing params not to be listed |
|
17 | - * @param $model model object to list (create an html table from) |
|
18 | - * |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function listAction($noListing = NULL, $model) |
|
22 | - { |
|
13 | + /** |
|
14 | + * Lists all instances of the model, (databasetable) except for noListing. |
|
15 | + * |
|
16 | + * @param $noListing params not to be listed |
|
17 | + * @param $model model object to list (create an html table from) |
|
18 | + * |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function listAction($noListing = NULL, $model) |
|
22 | + { |
|
23 | 23 | |
24 | - $this->model = $model; |
|
25 | - $this->model->setDI($this->di); |
|
24 | + $this->model = $model; |
|
25 | + $this->model->setDI($this->di); |
|
26 | 26 | |
27 | - $all = $this->model->findAll(); |
|
27 | + $all = $this->model->findAll(); |
|
28 | 28 | |
29 | - $aContent; |
|
29 | + $aContent; |
|
30 | 30 | |
31 | - //gör om arrayen av objekt till en array av arrayer |
|
32 | - foreach ($all as $key1=>$value) { |
|
31 | + //gör om arrayen av objekt till en array av arrayer |
|
32 | + foreach ($all as $key1=>$value) { |
|
33 | 33 | foreach ($value as $key2=>$v){ |
34 | - if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
35 | - $aContent[$key1][$key2] = $v; |
|
36 | - } |
|
34 | + if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
35 | + $aContent[$key1][$key2] = $v; |
|
36 | + } |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | 39 | |
40 | 40 | |
41 | - $aHeading = []; |
|
42 | - //hittar objektens parametrar/tabellens kolumnnamn och skapar |
|
43 | - //en ny array av rubriker |
|
44 | - foreach ($all as $key1=>$value) { |
|
41 | + $aHeading = []; |
|
42 | + //hittar objektens parametrar/tabellens kolumnnamn och skapar |
|
43 | + //en ny array av rubriker |
|
44 | + foreach ($all as $key1=>$value) { |
|
45 | 45 | foreach ($value as $key2=>$v){ |
46 | - if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
47 | - $aHeading[] = $key2; |
|
48 | - } |
|
46 | + if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
47 | + $aHeading[] = $key2; |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | break; |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - $this->chtml = new \Jovis\HTMLTable\CHTMLTable($aHeading, $aContent); |
|
53 | + $this->chtml = new \Jovis\HTMLTable\CHTMLTable($aHeading, $aContent); |
|
54 | 54 | |
55 | - $htmltable = $this->chtml->getTable(); |
|
56 | - $source = $this->model->getSource(); |
|
55 | + $htmltable = $this->chtml->getTable(); |
|
56 | + $source = $this->model->getSource(); |
|
57 | 57 | |
58 | 58 | |
59 | - $this->theme->setTitle("Visa alla användare"); |
|
60 | - $this->views->add('table/list-all', [ |
|
61 | - 'title' => $source, |
|
62 | - 'htmltable' => $htmltable, |
|
63 | - ]); |
|
64 | - } |
|
59 | + $this->theme->setTitle("Visa alla användare"); |
|
60 | + $this->views->add('table/list-all', [ |
|
61 | + 'title' => $source, |
|
62 | + 'htmltable' => $htmltable, |
|
63 | + ]); |
|
64 | + } |
|
65 | 65 | |
66 | - public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
66 | + public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
67 | 67 | $model->setDI($this->di); |
68 | 68 | $model->init(); |
69 | - } |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | ?> |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | //gör om arrayen av objekt till en array av arrayer |
32 | 32 | foreach ($all as $key1=>$value) { |
33 | - foreach ($value as $key2=>$v){ |
|
33 | + foreach ($value as $key2=>$v) { |
|
34 | 34 | if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
35 | 35 | $aContent[$key1][$key2] = $v; |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | //hittar objektens parametrar/tabellens kolumnnamn och skapar |
43 | 43 | //en ny array av rubriker |
44 | 44 | foreach ($all as $key1=>$value) { |
45 | - foreach ($value as $key2=>$v){ |
|
45 | + foreach ($value as $key2=>$v) { |
|
46 | 46 | if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
47 | 47 | $aHeading[] = $key2; |
48 | 48 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ]); |
64 | 64 | } |
65 | 65 | |
66 | - public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
66 | + public function initAction($model) { //används för att befolka databasen, bara för att testa |
|
67 | 67 | $model->setDI($this->di); |
68 | 68 | $model->init(); |
69 | 69 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | ]); |
43 | 43 | |
44 | 44 | $noListing = array('password', 'Password', 'pwd'); //namn på kolumner vi inte vill ha med i tabellen |
45 | - //sin skrivs ut |
|
45 | + //sin skrivs ut |
|
46 | 46 | |
47 | 47 | |
48 | 48 |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require __DIR__.'/config_with_app.php'; |
|
3 | +require __DIR__ . '/config_with_app.php'; |
|
4 | 4 | |
5 | 5 | $app->url->setUrlType(\Anax\Url\CUrl::URL_CLEAN); |
6 | 6 | |
7 | 7 | |
8 | 8 | // Create services and inject into the app. |
9 | -$di = new \Anax\DI\CDIFactoryDefault(); |
|
9 | +$di = new \Anax\DI\CDIFactoryDefault(); |
|
10 | 10 | |
11 | 11 | $di->set('TableController', function() use ($di){ |
12 | 12 | $controller = new \Jovis\HTMLTable\TableController(); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | $app->theme->setTitle("HTML-tabell"); |
34 | 34 | |
35 | - $model = new Jovis\DatabaseModel\Movie(); // modellen man vill skriva ut som html-tabell |
|
35 | + $model = new Jovis\DatabaseModel\Movie(); // modellen man vill skriva ut som html-tabell |
|
36 | 36 | |
37 | 37 | |
38 | - $app->dispatcher->forward([ //används bara för att skapa tabell och befolka databasen, för test |
|
38 | + $app->dispatcher->forward([//används bara för att skapa tabell och befolka databasen, för test |
|
39 | 39 | 'controller' => 'table', |
40 | 40 | 'action' => 'init', |
41 | 41 | 'params' => [$model], |