@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | $theme = empty($this->theme) ? $this->default_theme : $this->theme; |
88 | 88 | |
89 | - if (! isset($this->folders[$theme])) { |
|
90 | - throw new \LogicException( sprintf( lang('theme.bad_folder'), $theme ) ); |
|
89 | + if ( ! isset($this->folders[$theme])) { |
|
90 | + throw new \LogicException(sprintf(lang('theme.bad_folder'), $theme)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $this->active_theme = $theme; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // Make the path available within views. |
96 | 96 | $this->vars['theme_path'] = $this->folders[$theme]; |
97 | 97 | |
98 | - return $this->display($this->folders[$theme] . '/' . $this->layout); |
|
98 | + return $this->display($this->folders[$theme].'/'.$this->layout); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | //-------------------------------------------------------------------- |
@@ -123,12 +123,11 @@ discard block |
||
123 | 123 | |
124 | 124 | $module = $this->ci->router->fetch_module(); |
125 | 125 | |
126 | - if (! empty($module) && substr($dir, -strlen($module .'/')) == $module . '/') { |
|
126 | + if ( ! empty($module) && substr($dir, -strlen($module.'/')) == $module.'/') { |
|
127 | 127 | $dir = ''; |
128 | 128 | } |
129 | 129 | |
130 | - $view = ! empty($this->view) ? $this->view : |
|
131 | - $dir . $this->ci->router->fetch_class() . '/' . $this->ci->router->fetch_method(); |
|
130 | + $view = ! empty($this->view) ? $this->view : $dir.$this->ci->router->fetch_class().'/'.$this->ci->router->fetch_method(); |
|
132 | 131 | |
133 | 132 | return $this->display($view); |
134 | 133 | } |
@@ -153,12 +152,12 @@ discard block |
||
153 | 152 | * @param string $cache_name A custom name for the cached file. |
154 | 153 | * @return mixed |
155 | 154 | */ |
156 | - public function display($view, $data = array(), $cache_time = 0, $cache_name=null) |
|
155 | + public function display($view, $data = array(), $cache_time = 0, $cache_name = null) |
|
157 | 156 | { |
158 | 157 | if (empty($cache_name)) |
159 | 158 | { |
160 | - $cache_name = 'theme_view_' . $view . '_' . $this->ci->router->fetch_class() . '_' . $this->ci->router->fetch_method(); |
|
161 | - $cache_name = str_replace( '/', '_', $cache_name ); |
|
159 | + $cache_name = 'theme_view_'.$view.'_'.$this->ci->router->fetch_class().'_'.$this->ci->router->fetch_method(); |
|
160 | + $cache_name = str_replace('/', '_', $cache_name); |
|
162 | 161 | } |
163 | 162 | |
164 | 163 | if ($cache_time == 0 || ! $output = $this->ci->cache->get($cache_name)) |
@@ -167,43 +166,43 @@ discard block |
||
167 | 166 | $variant_view = NULL; |
168 | 167 | |
169 | 168 | // Pull out the theme from the view, if given. |
170 | - if ( strpos( $view, ':' ) !== FALSE ) |
|
169 | + if (strpos($view, ':') !== FALSE) |
|
171 | 170 | { |
172 | - list( $theme, $view ) = explode( ':', $view ); |
|
171 | + list($theme, $view) = explode(':', $view); |
|
173 | 172 | |
174 | 173 | $theme = str_replace('{theme}', $this->active_theme, $theme); |
175 | 174 | } |
176 | 175 | |
177 | - if ( ! empty( $theme ) && isset( $this->folders[ $theme ] ) ) |
|
176 | + if ( ! empty($theme) && isset($this->folders[$theme])) |
|
178 | 177 | { |
179 | - $view = rtrim( $this->folders[ $theme ], '/' ) . '/' . $view; |
|
178 | + $view = rtrim($this->folders[$theme], '/').'/'.$view; |
|
180 | 179 | } |
181 | 180 | |
182 | - if (! is_array($data)) |
|
181 | + if ( ! is_array($data)) |
|
183 | 182 | { |
184 | 183 | $data = []; |
185 | 184 | } |
186 | 185 | |
187 | - $data = array_merge( $this->vars, $data ); |
|
186 | + $data = array_merge($this->vars, $data); |
|
188 | 187 | |
189 | 188 | // if using a variant, add it to the view name. |
190 | - if ( ! empty( $this->current_variant ) ) |
|
189 | + if ( ! empty($this->current_variant)) |
|
191 | 190 | { |
192 | - $variant_view = $view . $this->variants[ $this->current_variant ]; |
|
191 | + $variant_view = $view.$this->variants[$this->current_variant]; |
|
193 | 192 | |
194 | 193 | $output = $this->loadView($variant_view, $data); |
195 | 194 | } |
196 | 195 | |
197 | 196 | // If that didn't find anything, then try it without a variant |
198 | - if ( empty( $output ) ) |
|
197 | + if (empty($output)) |
|
199 | 198 | { |
200 | 199 | $output = $this->loadView($view, $data); |
201 | 200 | } |
202 | 201 | |
203 | 202 | // Cache it |
204 | - if ((int)$cache_time > 0) |
|
203 | + if ((int) $cache_time > 0) |
|
205 | 204 | { |
206 | - $this->ci->cache->save($cache_name, $output, (int)$cache_time * 60); |
|
205 | + $this->ci->cache->save($cache_name, $output, (int) $cache_time * 60); |
|
207 | 206 | } |
208 | 207 | } |
209 | 208 | |
@@ -232,14 +231,14 @@ discard block |
||
232 | 231 | * @param string $cache_name // Number of MINUTES to cache output |
233 | 232 | * @return mixed|void |
234 | 233 | */ |
235 | - public function call($command, $cache_time=0, $cache_name=null) |
|
234 | + public function call($command, $cache_time = 0, $cache_name = null) |
|
236 | 235 | { |
237 | 236 | if (empty($cache_name)) |
238 | 237 | { |
239 | - $cache_name = 'theme_call_' . md5( $command ); |
|
238 | + $cache_name = 'theme_call_'.md5($command); |
|
240 | 239 | } |
241 | 240 | |
242 | - if (! $output = $this->ci->cache->get($cache_name)) { |
|
241 | + if ( ! $output = $this->ci->cache->get($cache_name)) { |
|
243 | 242 | $parts = explode(' ', $command); |
244 | 243 | |
245 | 244 | list($class, $method) = explode(':', array_shift($parts)); |
@@ -256,7 +255,7 @@ discard block |
||
256 | 255 | continue; |
257 | 256 | } |
258 | 257 | |
259 | - $params[ $p[0] ] = $p[1]; |
|
258 | + $params[$p[0]] = $p[1]; |
|
260 | 259 | } |
261 | 260 | |
262 | 261 | // Let PHP try to autoload it through any available autoloaders |
@@ -266,20 +265,20 @@ discard block |
||
266 | 265 | $class = new $class(); |
267 | 266 | } else { |
268 | 267 | $this->ci->load->library($class); |
269 | - $class =& $this->ci->$class; |
|
268 | + $class = & $this->ci->$class; |
|
270 | 269 | } |
271 | 270 | |
272 | - if (! method_exists($class, $method)) { |
|
273 | - throw new \RuntimeException( sprintf( lang('themer.bad_callback'), $class, $method ) ); |
|
271 | + if ( ! method_exists($class, $method)) { |
|
272 | + throw new \RuntimeException(sprintf(lang('themer.bad_callback'), $class, $method)); |
|
274 | 273 | } |
275 | 274 | |
276 | 275 | // Call the class with our parameters |
277 | 276 | $output = $class->{$method}($params); |
278 | 277 | |
279 | 278 | // Cache it |
280 | - if ((int)$cache_time > 0) |
|
279 | + if ((int) $cache_time > 0) |
|
281 | 280 | { |
282 | - $this->ci->cache->save($cache_name, $output, (int)$cache_time * 60); |
|
281 | + $this->ci->cache->save($cache_name, $output, (int) $cache_time * 60); |
|
283 | 282 | } |
284 | 283 | } |
285 | 284 | |
@@ -479,7 +478,7 @@ discard block |
||
479 | 478 | { |
480 | 479 | $theme = empty($this->theme) ? $this->default_theme : $this->theme; |
481 | 480 | |
482 | - if (! isset($this->folders[ $theme ])) |
|
481 | + if ( ! isset($this->folders[$theme])) |
|
483 | 482 | { |
484 | 483 | return null; |
485 | 484 | } |
@@ -569,24 +568,24 @@ discard block |
||
569 | 568 | // First - does it exist in the current theme? |
570 | 569 | $theme = ! empty($this->active_theme) ? $this->active_theme : $this->default_theme; |
571 | 570 | $theme = ! empty($this->folders[$theme]) ? $this->folders[$theme] : $theme; |
572 | - $theme = rtrim($theme, '/ ') .'/'; |
|
571 | + $theme = rtrim($theme, '/ ').'/'; |
|
573 | 572 | |
574 | - if (file_exists($theme ."{$view}.php")) |
|
573 | + if (file_exists($theme."{$view}.php")) |
|
575 | 574 | { |
576 | - $output = $this->ci->load->view_path( $theme . $view, $data, TRUE ); |
|
575 | + $output = $this->ci->load->view_path($theme.$view, $data, TRUE); |
|
577 | 576 | } |
578 | 577 | |
579 | 578 | // Next, if it's a real file with path, then load it |
580 | - elseif ( realpath( $view . '.php' ) ) |
|
579 | + elseif (realpath($view.'.php')) |
|
581 | 580 | { |
582 | - $output = $this->ci->load->view_path( $view, $data, TRUE ); |
|
581 | + $output = $this->ci->load->view_path($view, $data, TRUE); |
|
583 | 582 | } |
584 | 583 | |
585 | 584 | // Otherwise, treat it as a standard view, which means |
586 | 585 | // application/views will override any modules. (See HMVC/Loader) |
587 | 586 | else |
588 | 587 | { |
589 | - $output = $this->ci->load->view( $view, $data, TRUE ); |
|
588 | + $output = $this->ci->load->view($view, $data, TRUE); |
|
590 | 589 | } |
591 | 590 | |
592 | 591 | return $output; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Zend\Escaper\Escaper; |
4 | 4 | |
5 | -if (! function_exists('esc')) |
|
5 | +if ( ! function_exists('esc')) |
|
6 | 6 | { |
7 | 7 | /** |
8 | 8 | * Escapes strings to make them safe for use |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - function esc($data, $context='html', $escaper=null) |
|
31 | + function esc($data, $context = 'html', $escaper = null) |
|
32 | 32 | { |
33 | 33 | if (is_array($data)) |
34 | 34 | { |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | |
41 | 41 | $context = strtolower($context); |
42 | 42 | |
43 | - if (! is_object($escaper)) |
|
43 | + if ( ! is_object($escaper)) |
|
44 | 44 | { |
45 | 45 | $escaper = new Escaper(config_item('charset')); |
46 | 46 | } |
47 | 47 | |
48 | 48 | // Valid context? |
49 | - if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
49 | + if ( ! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
50 | 50 | { |
51 | - throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
51 | + throw new \InvalidArgumentException('Invalid Context type: '.$context); |
|
52 | 52 | } |
53 | 53 | |
54 | - if (! is_string($data)) |
|
54 | + if ( ! is_string($data)) |
|
55 | 55 | { |
56 | 56 | return $data; |
57 | 57 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param array $options |
74 | 74 | * @return mixed |
75 | 75 | */ |
76 | - abstract public function row($options=[], \Closure $c); |
|
76 | + abstract public function row($options = [], \Closure $c); |
|
77 | 77 | |
78 | 78 | //-------------------------------------------------------------------- |
79 | 79 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param array $attributes |
95 | 95 | * @return mixed |
96 | 96 | */ |
97 | - abstract public function column($options=[], \Closure $c); |
|
97 | + abstract public function column($options = [], \Closure $c); |
|
98 | 98 | |
99 | 99 | //-------------------------------------------------------------------- |
100 | 100 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param callable $c |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - abstract public function navbar($options=[], \Closure $c); |
|
113 | + abstract public function navbar($options = [], \Closure $c); |
|
114 | 114 | |
115 | 115 | //-------------------------------------------------------------------- |
116 | 116 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param string $url |
123 | 123 | * @return string |
124 | 124 | */ |
125 | - abstract public function navbarTitle($title, $url='#'); |
|
125 | + abstract public function navbarTitle($title, $url = '#'); |
|
126 | 126 | |
127 | 127 | //-------------------------------------------------------------------- |
128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param callable $c |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - abstract public function navbarRight($options=[], \Closure $c); |
|
139 | + abstract public function navbarRight($options = [], \Closure $c); |
|
140 | 140 | |
141 | 141 | //-------------------------------------------------------------------- |
142 | 142 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param array $options |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - abstract public function navItem($title, $url, $options=[], $isActive=false); |
|
151 | + abstract public function navItem($title, $url, $options = [], $isActive = false); |
|
152 | 152 | |
153 | 153 | //-------------------------------------------------------------------- |
154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param array $options |
160 | 160 | * @param callable $c |
161 | 161 | */ |
162 | - abstract public function navDropdown($title,$options=[], \Closure $c); |
|
162 | + abstract public function navDropdown($title, $options = [], \Closure $c); |
|
163 | 163 | |
164 | 164 | //-------------------------------------------------------------------- |
165 | 165 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param callable $c |
180 | 180 | * @return mixed |
181 | 181 | */ |
182 | - abstract public function breadcrumb($options=[], \Closure $c); |
|
182 | + abstract public function breadcrumb($options = [], \Closure $c); |
|
183 | 183 | |
184 | 184 | //-------------------------------------------------------------------- |
185 | 185 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param array $options |
199 | 199 | * @return mixed |
200 | 200 | */ |
201 | - abstract public function button($title, $style='default', $size='default', $options=[]); |
|
201 | + abstract public function button($title, $style = 'default', $size = 'default', $options = []); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Creates a simple link styled as a button. |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param array $options |
213 | 213 | * @return mixed |
214 | 214 | */ |
215 | - abstract public function buttonLink($title, $url='#', $style='default', $size='default', $options=[]); |
|
215 | + abstract public function buttonLink($title, $url = '#', $style = 'default', $size = 'default', $options = []); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Creates button groups wrapping HTML. |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param callable $c |
244 | 244 | * @return mixed |
245 | 245 | */ |
246 | - abstract public function buttonDropdown($title, $style='default', $size='default', $options=[], \Closure $c); |
|
246 | + abstract public function buttonDropdown($title, $style = 'default', $size = 'default', $options = [], \Closure $c); |
|
247 | 247 | |
248 | 248 | //-------------------------------------------------------------------- |
249 | 249 | // Notices |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param bool $closable |
260 | 260 | * @return mixed |
261 | 261 | */ |
262 | - abstract public function notice($content, $style='success', $closable=true); |
|
262 | + abstract public function notice($content, $style = 'success', $closable = true); |
|
263 | 263 | |
264 | 264 | //-------------------------------------------------------------------- |
265 | 265 | // Forms |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return mixed |
278 | 278 | */ |
279 | - abstract public function inputWrap($label_text, $options=[], \Closure $c); |
|
279 | + abstract public function inputWrap($label_text, $options = [], \Closure $c); |
|
280 | 280 | |
281 | 281 | //-------------------------------------------------------------------- |
282 | 282 | // Utility Methods |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | protected function runClosure(\Closure $c) |
292 | 292 | { |
293 | - if (! is_callable($c)) return ''; |
|
293 | + if ( ! is_callable($c)) return ''; |
|
294 | 294 | |
295 | 295 | ob_start(); |
296 | 296 | $c(); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param bool $fullClassString |
312 | 312 | * @return array |
313 | 313 | */ |
314 | - protected function parseStandardOptions($options, $initial_classes='', $fullClassString=false) |
|
314 | + protected function parseStandardOptions($options, $initial_classes = '', $fullClassString = false) |
|
315 | 315 | { |
316 | 316 | return [ |
317 | 317 | $this->buildClassString($initial_classes, $options, $fullClassString), |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param array $options |
349 | 349 | * @return array |
350 | 350 | */ |
351 | - protected function buildClassString($initial, $options, $buildEntireString=false) |
|
351 | + protected function buildClassString($initial, $options, $buildEntireString = false) |
|
352 | 352 | { |
353 | 353 | $classes = explode(' ', $initial); |
354 | 354 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | { |
405 | 405 | if (isset($options['attributes']) && ! is_array($options['attributes'])) |
406 | 406 | { |
407 | - $options['attributes'] = [ $options['attributes'] ]; |
|
407 | + $options['attributes'] = [$options['attributes']]; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | return isset($options['attributes']) ? implode($options['attributes']) : ''; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param array $options |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function row($options=[], \Closure $c) |
|
54 | + public function row($options = [], \Closure $c) |
|
55 | 55 | { |
56 | 56 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'row', true); |
57 | 57 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param array $attributes |
84 | 84 | * @return mixed |
85 | 85 | */ |
86 | - public function column($options=[], \Closure $c) |
|
86 | + public function column($options = [], \Closure $c) |
|
87 | 87 | { |
88 | 88 | // Build our classes |
89 | 89 | $classes = ''; |
@@ -93,28 +93,28 @@ discard block |
||
93 | 93 | switch ($size) |
94 | 94 | { |
95 | 95 | case 's': |
96 | - $classes .= ' col-xs-'. $value; |
|
96 | + $classes .= ' col-xs-'.$value; |
|
97 | 97 | break; |
98 | 98 | case 'm': |
99 | - $classes .= ' col-sm-'. $value; |
|
99 | + $classes .= ' col-sm-'.$value; |
|
100 | 100 | break; |
101 | 101 | case 'l': |
102 | - $classes .= ' col-md-'. $value; |
|
102 | + $classes .= ' col-md-'.$value; |
|
103 | 103 | break; |
104 | 104 | case 'xl': |
105 | - $classes .= ' col-lg-'. $value; |
|
105 | + $classes .= ' col-lg-'.$value; |
|
106 | 106 | break; |
107 | 107 | case 's-offset': |
108 | - $classes .= ' col-xs-offset-'. $value; |
|
108 | + $classes .= ' col-xs-offset-'.$value; |
|
109 | 109 | break; |
110 | 110 | case 'm-offset': |
111 | - $classes .= ' col-sm-offset-'. $value; |
|
111 | + $classes .= ' col-sm-offset-'.$value; |
|
112 | 112 | break; |
113 | 113 | case 'l-offset': |
114 | - $classes .= ' col-md-offset-'. $value; |
|
114 | + $classes .= ' col-md-offset-'.$value; |
|
115 | 115 | break; |
116 | 116 | case 'xl-offset': |
117 | - $classes .= ' col-lg-offset-'. $value; |
|
117 | + $classes .= ' col-lg-offset-'.$value; |
|
118 | 118 | break; |
119 | 119 | } |
120 | 120 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param callable $c |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - public function navbar($options=[], \Closure $c) |
|
147 | + public function navbar($options = [], \Closure $c) |
|
148 | 148 | { |
149 | 149 | $output = ''; |
150 | 150 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param string $url |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function navbarTitle($title, $url='#') |
|
199 | + public function navbarTitle($title, $url = '#') |
|
200 | 200 | { |
201 | 201 | return '<div class="navbar-header"> |
202 | 202 | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1"> |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | <span class="icon-bar"></span> |
206 | 206 | <span class="icon-bar"></span> |
207 | 207 | </button> |
208 | - <a class="navbar-brand" href="'. $url .'">'. $title .'</a> |
|
208 | + <a class="navbar-brand" href="'. $url.'">'.$title.'</a> |
|
209 | 209 | </div>'; |
210 | 210 | } |
211 | 211 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param callable $c |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - public function navbarRight($options=[], \Closure $c) |
|
224 | + public function navbarRight($options = [], \Closure $c) |
|
225 | 225 | { |
226 | 226 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'nav navbar-nav navbar-right', true); |
227 | 227 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param array $options |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public function navItem($title, $url='#', $options=[], $isActive=false) |
|
255 | + public function navItem($title, $url = '#', $options = [], $isActive = false) |
|
256 | 256 | { |
257 | 257 | $this->states['activeNavTitle'] = $title; |
258 | 258 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $options |
273 | 273 | * @param callable $c |
274 | 274 | */ |
275 | - public function navDropdown($title,$options=[], \Closure $c) |
|
275 | + public function navDropdown($title, $options = [], \Closure $c) |
|
276 | 276 | { |
277 | 277 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'dropdown', true); |
278 | 278 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | //-------------------------------------------------------------------- |
303 | 303 | |
304 | - public function sideNav($options=[], \Closure $c) |
|
304 | + public function sideNav($options = [], \Closure $c) |
|
305 | 305 | { |
306 | 306 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'nav nav-pills nav-stacked', true); |
307 | 307 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param callable $c |
324 | 324 | * @return mixed |
325 | 325 | */ |
326 | - public function breadcrumb($options=[], \Closure $c) |
|
326 | + public function breadcrumb($options = [], \Closure $c) |
|
327 | 327 | { |
328 | 328 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'breadcrumb', true); |
329 | 329 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param array $options |
368 | 368 | * @return mixed |
369 | 369 | */ |
370 | - public function button($title, $style='default', $size='default', $options=[]) |
|
370 | + public function button($title, $style = 'default', $size = 'default', $options = []) |
|
371 | 371 | { |
372 | - $tag= "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
372 | + $tag = "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
373 | 373 | |
374 | 374 | return $this->renderButtonElement($title, $style, $size, $options, $tag); |
375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param array $options |
389 | 389 | * @return mixed |
390 | 390 | */ |
391 | - public function buttonLink($title, $url='#', $style='default', $size='default', $options=[]) |
|
391 | + public function buttonLink($title, $url = '#', $style = 'default', $size = 'default', $options = []) |
|
392 | 392 | { |
393 | 393 | $tag = "<a href='{$url}' {classes} {id} {attributes} role='button'>{$title}</a>"; |
394 | 394 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $valid_styles = ['default', 'primary', 'success', 'info', 'warning', 'danger']; |
411 | 411 | $valid_sizes = ['default', 'small', 'xsmall', 'large']; |
412 | 412 | |
413 | - if (! in_array($style, $valid_styles)) |
|
413 | + if ( ! in_array($style, $valid_styles)) |
|
414 | 414 | { |
415 | 415 | $style = 'default'; |
416 | 416 | $options['attributes'][] = 'data-error="Invalid Style passed to button method."'; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $classes = 'btn '; |
420 | 420 | |
421 | 421 | // Sizes |
422 | - switch($size) |
|
422 | + switch ($size) |
|
423 | 423 | { |
424 | 424 | case 'small': |
425 | 425 | $classes .= 'btn-sm '; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param callable $c |
527 | 527 | * @return mixed |
528 | 528 | */ |
529 | - public function buttonDropdown($title, $style='default', $size='default', $options=[], \Closure $c) |
|
529 | + public function buttonDropdown($title, $style = 'default', $size = 'default', $options = [], \Closure $c) |
|
530 | 530 | { |
531 | 531 | $tag = "<button type='button' {classes} data-toggle='dropdown'> |
532 | 532 | {title} <span class='caret'></span> |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * @param bool $closable |
559 | 559 | * @return mixed |
560 | 560 | */ |
561 | - public function notice($content, $style='success', $closable=true, $options=[]) |
|
561 | + public function notice($content, $style = 'success', $closable = true, $options = []) |
|
562 | 562 | { |
563 | 563 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'alert', false); |
564 | 564 | |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | * |
614 | 614 | * @return mixed |
615 | 615 | */ |
616 | - public function inputWrap($label_text, $options=[], \Closure $c) |
|
616 | + public function inputWrap($label_text, $options = [], \Closure $c) |
|
617 | 617 | { |
618 | 618 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'form-group', true); |
619 | 619 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $options |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function row($options=[], \Closure $c) |
|
61 | + public function row($options = [], \Closure $c) |
|
62 | 62 | { |
63 | 63 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'row', true); |
64 | 64 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param array $attributes |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - public function column($options=[], \Closure $c) |
|
93 | + public function column($options = [], \Closure $c) |
|
94 | 94 | { |
95 | 95 | // Build our classes |
96 | 96 | $classes = ''; |
@@ -100,33 +100,33 @@ discard block |
||
100 | 100 | switch ($size) |
101 | 101 | { |
102 | 102 | case 's': |
103 | - $classes .= ' small-'. $value; |
|
103 | + $classes .= ' small-'.$value; |
|
104 | 104 | break; |
105 | 105 | case 'm': |
106 | - $classes .= ' medium-'. $value; |
|
106 | + $classes .= ' medium-'.$value; |
|
107 | 107 | break; |
108 | 108 | case 'l': |
109 | - $classes .= ' large-'. $value; |
|
109 | + $classes .= ' large-'.$value; |
|
110 | 110 | break; |
111 | 111 | case 'xl': |
112 | - $classes .= ' large-'. $value; |
|
112 | + $classes .= ' large-'.$value; |
|
113 | 113 | break; |
114 | 114 | case 's-offset': |
115 | - $classes .= ' small-offset-'. $value; |
|
115 | + $classes .= ' small-offset-'.$value; |
|
116 | 116 | break; |
117 | 117 | case 'm-offset': |
118 | - $classes .= ' medium-offset-'. $value; |
|
118 | + $classes .= ' medium-offset-'.$value; |
|
119 | 119 | break; |
120 | 120 | case 'l-offset': |
121 | - $classes .= ' large-offset-'. $value; |
|
121 | + $classes .= ' large-offset-'.$value; |
|
122 | 122 | break; |
123 | 123 | case 'xl-offset': |
124 | - $classes .= ' large-offset-'. $value; |
|
124 | + $classes .= ' large-offset-'.$value; |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - $classes = $this->buildClassString($classes .' columns', $options, true); |
|
129 | + $classes = $this->buildClassString($classes.' columns', $options, true); |
|
130 | 130 | |
131 | 131 | $id = $this->buildIdFromOptions($options); |
132 | 132 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param callable $c |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function navbar($options=[], \Closure $c) |
|
158 | + public function navbar($options = [], \Closure $c) |
|
159 | 159 | { |
160 | 160 | $output = ''; |
161 | 161 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param string $url |
206 | 206 | * @return string |
207 | 207 | */ |
208 | - public function navbarTitle($title, $url='#') |
|
208 | + public function navbarTitle($title, $url = '#') |
|
209 | 209 | { |
210 | 210 | return "<ul class='title-area'> |
211 | 211 | <li class='name'> |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | * @param callable $c |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - public function navbarRight($options=[], \Closure $c) |
|
230 | + public function navbarRight($options = [], \Closure $c) |
|
231 | 231 | { |
232 | 232 | $output = ''; |
233 | 233 | |
234 | - if (! isset($this->states['nav-section-open'])) |
|
234 | + if ( ! isset($this->states['nav-section-open'])) |
|
235 | 235 | { |
236 | 236 | $output .= "<section class='top-bar-section'>\n"; |
237 | 237 | $this->states['nav-section-open'] = true; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | * @param callable $c |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function navbarLeft($options=[], \Closure $c) |
|
269 | + public function navbarLeft($options = [], \Closure $c) |
|
270 | 270 | { |
271 | 271 | $output = ''; |
272 | 272 | |
273 | - if (! isset($this->states['nav-section-open'])) |
|
273 | + if ( ! isset($this->states['nav-section-open'])) |
|
274 | 274 | { |
275 | 275 | $output .= "<section class='top-bar-section'>\n"; |
276 | 276 | $this->states['nav-section-open'] = true; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param array $options |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - public function navItem($title, $url='#', $options=[], $active=false) |
|
314 | + public function navItem($title, $url = '#', $options = [], $active = false) |
|
315 | 315 | { |
316 | 316 | $options['active'] = $active; |
317 | 317 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param array $options |
334 | 334 | * @param callable $c |
335 | 335 | */ |
336 | - public function navDropdown($title,$options=[], \Closure $c) |
|
336 | + public function navDropdown($title, $options = [], \Closure $c) |
|
337 | 337 | { |
338 | 338 | $classes = $this->buildClassString('has-dropdown', $options, true); |
339 | 339 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | //-------------------------------------------------------------------- |
368 | 368 | |
369 | - public function sideNav($options=[], \Closure $c) |
|
369 | + public function sideNav($options = [], \Closure $c) |
|
370 | 370 | { |
371 | 371 | $classes = $this->buildClassString('side-nav', $options, true); |
372 | 372 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @param callable $c |
393 | 393 | * @return mixed |
394 | 394 | */ |
395 | - public function breadcrumb($options=[], \Closure $c) |
|
395 | + public function breadcrumb($options = [], \Closure $c) |
|
396 | 396 | { |
397 | 397 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'breadcrumbs', true); |
398 | 398 | |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | * @param array $options |
434 | 434 | * @return mixed |
435 | 435 | */ |
436 | - public function button($title, $style='default', $size='default', $options=[]) |
|
436 | + public function button($title, $style = 'default', $size = 'default', $options = []) |
|
437 | 437 | { |
438 | - $tag= "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
438 | + $tag = "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
439 | 439 | |
440 | 440 | return $this->renderButtonElement($title, $style, $size, $options, $tag); |
441 | 441 | } |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | * @param array $options |
455 | 455 | * @return mixed |
456 | 456 | */ |
457 | - public function buttonLink($title, $url='#', $style='default', $size='default', $options=[]) |
|
457 | + public function buttonLink($title, $url = '#', $style = 'default', $size = 'default', $options = []) |
|
458 | 458 | { |
459 | - $class = isset($options['class']) ? $options['class'] .' button' : 'button'; |
|
459 | + $class = isset($options['class']) ? $options['class'].' button' : 'button'; |
|
460 | 460 | $options['class'] = $class; |
461 | 461 | |
462 | 462 | $tag = "<a {classes} {id} {attributes} role='button'>{$title}</a>"; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $valid_styles = ['default', 'primary', 'success', 'info', 'warning', 'danger']; |
480 | 480 | $valid_sizes = ['default', 'small', 'xsmall', 'large']; |
481 | 481 | |
482 | - if (! in_array($style, $valid_styles)) |
|
482 | + if ( ! in_array($style, $valid_styles)) |
|
483 | 483 | { |
484 | 484 | $style = 'default'; |
485 | 485 | $options['attributes'][] = 'data-error="Invalid Style passed to button method."'; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $classes = 'btn '; |
489 | 489 | |
490 | 490 | // Sizes |
491 | - switch($size) |
|
491 | + switch ($size) |
|
492 | 492 | { |
493 | 493 | case 'small': |
494 | 494 | $classes .= 'small '; |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | // If we're in a button group we need to wrap each item in li tags. |
537 | 537 | if (isset($this->states['inButtonGroup'])) |
538 | 538 | { |
539 | - $tag = '<li>'. $tag .'</li>'; |
|
539 | + $tag = '<li>'.$tag.'</li>'; |
|
540 | 540 | } |
541 | 541 | return $tag; |
542 | 542 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @param callable $c |
603 | 603 | * @return mixed |
604 | 604 | */ |
605 | - public function buttonDropdown($title, $style='default', $size='default', $options=[], \Closure $c) |
|
605 | + public function buttonDropdown($title, $style = 'default', $size = 'default', $options = [], \Closure $c) |
|
606 | 606 | { |
607 | 607 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'button split', true); |
608 | 608 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @param bool $closable |
633 | 633 | * @return mixed |
634 | 634 | */ |
635 | - public function notice($content, $style='success', $closable=true, $options=[]) |
|
635 | + public function notice($content, $style = 'success', $closable = true, $options = []) |
|
636 | 636 | { |
637 | 637 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'alert-box ', false); |
638 | 638 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param array $segments |
57 | 57 | * @param bool $quiet |
58 | 58 | */ |
59 | - public function run($segments=[], $quiet=false) |
|
59 | + public function run($segments = [], $quiet = false) |
|
60 | 60 | { |
61 | 61 | // Show an index? |
62 | 62 | if (empty($segments[0])) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->scaffold($segments, $quiet); |
76 | 76 | break; |
77 | 77 | default: |
78 | - if (! $quiet) |
|
78 | + if ( ! $quiet) |
|
79 | 79 | { |
80 | 80 | CLI::write('Nothing to do.', 'green'); |
81 | 81 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | { |
90 | 90 | CLI::write("\nAvailable API Generators"); |
91 | 91 | |
92 | - CLI::write( CLI::color('install', 'yellow') .' install Creates migrations, alters config file for desired authentication' ); |
|
93 | - CLI::write( CLI::color('scaffold', 'yellow') .' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files' ); |
|
92 | + CLI::write(CLI::color('install', 'yellow').' install Creates migrations, alters config file for desired authentication'); |
|
93 | + CLI::write(CLI::color('scaffold', 'yellow').' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | //-------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param $segments |
106 | 106 | * @param $quiet |
107 | 107 | */ |
108 | - private function scaffold( $segments, $quiet ) |
|
108 | + private function scaffold($segments, $quiet) |
|
109 | 109 | { |
110 | 110 | $this->load->helper('inflector'); |
111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | if (empty($resource)) |
120 | 120 | { |
121 | - $resource = strtolower( CLI::prompt('Resource name') ); |
|
121 | + $resource = strtolower(CLI::prompt('Resource name')); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | // Resources should be plural, but we'll need a singular name also. |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | |
139 | 139 | if (empty($model)) |
140 | 140 | { |
141 | - $model = $this->detectModel( $resource_single ); |
|
141 | + $model = $this->detectModel($resource_single); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /* |
145 | 145 | * Start Building |
146 | 146 | */ |
147 | - $this->destination = APPPATH .'controllers/'; |
|
148 | - if (! empty($version)) |
|
147 | + $this->destination = APPPATH.'controllers/'; |
|
148 | + if ( ! empty($version)) |
|
149 | 149 | { |
150 | - $this->destination .= $version .'/'; |
|
150 | + $this->destination .= $version.'/'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Controller |
154 | - if (! $this->createController($resource_single, $resource_plural, $version) ) |
|
154 | + if ( ! $this->createController($resource_single, $resource_plural, $version)) |
|
155 | 155 | { |
156 | 156 | CLI::error('Unknown error creating Controller.'); |
157 | 157 | exit(1); |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Language Files |
161 | - if (! $this->createLanguage($resource_single, $resource_plural, $version, $model) ) |
|
161 | + if ( ! $this->createLanguage($resource_single, $resource_plural, $version, $model)) |
|
162 | 162 | { |
163 | 163 | CLI::error('Unknown error creating Language File.'); |
164 | 164 | exit(1); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // Blueprint File |
168 | 168 | if ($blueprint) |
169 | 169 | { |
170 | - if (! $this->createBlueprint($resource_single, $resource_plural, $version, $model) ) |
|
170 | + if ( ! $this->createBlueprint($resource_single, $resource_plural, $version, $model)) |
|
171 | 171 | { |
172 | 172 | CLI::error('Unknown error creating Blueprint file.'); |
173 | 173 | exit(1); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // Modify Routes |
178 | - if (! $this->addRoutes($resource_plural, $version) ) |
|
178 | + if ( ! $this->addRoutes($resource_plural, $version)) |
|
179 | 179 | { |
180 | 180 | CLI::error('Unknown error adding Routes.'); |
181 | 181 | exit(1); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | CLI::write("\nVersions are simply controller folders (i.e. controllers/v1/...)"); |
196 | 196 | CLI::write("(Enter 'na' for no version folder)"); |
197 | 197 | |
198 | - $version = strtolower( CLI::prompt('Version name', 'v1') ); |
|
198 | + $version = strtolower(CLI::prompt('Version name', 'v1')); |
|
199 | 199 | $version = $version == 'na' ? '' : $version; |
200 | 200 | |
201 | 201 | return $version; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | private function askBlueprint() |
212 | 212 | { |
213 | 213 | CLI::write("\nAPI Blueprint is a plain-text API documentation starter."); |
214 | - CLI::write("See: ". CLI::color('https://apiblueprint.org', 'light_blue')); |
|
214 | + CLI::write("See: ".CLI::color('https://apiblueprint.org', 'light_blue')); |
|
215 | 215 | |
216 | 216 | $make_blueprint = CLI::prompt('Create Blueprint file?', ['y', 'n']); |
217 | 217 | |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | |
223 | 223 | private function detectModel($name) |
224 | 224 | { |
225 | - $model_name = ucfirst($name) .'_model.php'; |
|
225 | + $model_name = ucfirst($name).'_model.php'; |
|
226 | 226 | |
227 | - if (! file_exists(APPPATH .'models/'. $model_name)) |
|
227 | + if ( ! file_exists(APPPATH.'models/'.$model_name)) |
|
228 | 228 | { |
229 | 229 | CLI::write("\nUnable to find model named: {$model_name}"); |
230 | 230 | $model_name = CLI::prompt('Model filename'); |
231 | 231 | } |
232 | 232 | else |
233 | 233 | { |
234 | - CLI::write("Using model: ". CLI::color($model_name, 'yellow') ); |
|
234 | + CLI::write("Using model: ".CLI::color($model_name, 'yellow')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $model_name; |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | * @internal param $name |
251 | 251 | * |
252 | 252 | */ |
253 | - private function createController( $single, $plural, $version ) |
|
253 | + private function createController($single, $plural, $version) |
|
254 | 254 | { |
255 | 255 | $data = [ |
256 | - 'today' => date( 'Y-m-d H:ia' ), |
|
257 | - 'model_name' => strtolower($single) .'_model', |
|
256 | + 'today' => date('Y-m-d H:ia'), |
|
257 | + 'model_name' => strtolower($single).'_model', |
|
258 | 258 | 'plural' => $plural, |
259 | 259 | 'single' => $single, |
260 | 260 | 'class_name' => ucfirst($plural), |
261 | 261 | 'version' => $version |
262 | 262 | ]; |
263 | 263 | |
264 | - $destination = $this->destination . ucfirst($plural) .'.php'; |
|
264 | + $destination = $this->destination.ucfirst($plural).'.php'; |
|
265 | 265 | |
266 | - return $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ); |
|
266 | + return $this->copyTemplate('controller', $destination, $data, $this->overwrite); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | //-------------------------------------------------------------------- |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return $this |
279 | 279 | */ |
280 | - private function createLanguage( $single, $plural, $version ) |
|
280 | + private function createLanguage($single, $plural, $version) |
|
281 | 281 | { |
282 | 282 | $data = [ |
283 | 283 | 'plural' => $plural, |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | 'uc_plural' => ucfirst($plural), |
287 | 287 | ]; |
288 | 288 | |
289 | - $destination = APPPATH ."language/english/api_{$plural}_lang.php"; |
|
289 | + $destination = APPPATH."language/english/api_{$plural}_lang.php"; |
|
290 | 290 | |
291 | - return $this->copyTemplate( 'lang', $destination, $data, $this->overwrite ); |
|
291 | + return $this->copyTemplate('lang', $destination, $data, $this->overwrite); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | //-------------------------------------------------------------------- |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | * @internal param $name |
307 | 307 | * |
308 | 308 | */ |
309 | - private function createBlueprint( $single, $plural, $version, $model ) |
|
309 | + private function createBlueprint($single, $plural, $version, $model) |
|
310 | 310 | { |
311 | 311 | $version = rtrim($version, '/'); |
312 | - if (! empty($version)) |
|
312 | + if ( ! empty($version)) |
|
313 | 313 | { |
314 | 314 | $version .= '/'; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Load the model so we can use the correct table to use |
318 | - $model = strtolower( str_replace('.php', '', $model) ); |
|
319 | - $this->load->model( $model, $model, true ); |
|
318 | + $model = strtolower(str_replace('.php', '', $model)); |
|
319 | + $this->load->model($model, $model, true); |
|
320 | 320 | |
321 | 321 | $obj = $this->formatObject($model); |
322 | 322 | |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | 'formatted' => $obj |
332 | 332 | ]; |
333 | 333 | |
334 | - $destination = APPPATH .'docs/api/'. $version . $plural .'.md'; |
|
334 | + $destination = APPPATH.'docs/api/'.$version.$plural.'.md'; |
|
335 | 335 | |
336 | - $success = $this->copyTemplate( 'blueprint', $destination, $data, $this->overwrite ); |
|
336 | + $success = $this->copyTemplate('blueprint', $destination, $data, $this->overwrite); |
|
337 | 337 | |
338 | - if (! $this->updateTOC($plural, $version)) |
|
338 | + if ( ! $this->updateTOC($plural, $version)) |
|
339 | 339 | { |
340 | 340 | CLI::write("\tUnable to modify the toc file.", 'light_red'); |
341 | 341 | } |
@@ -353,21 +353,21 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return $this|bool |
355 | 355 | */ |
356 | - private function updateTOC( $plural, $version ) |
|
356 | + private function updateTOC($plural, $version) |
|
357 | 357 | { |
358 | - $path = APPPATH .'docs/_toc.ini'; |
|
358 | + $path = APPPATH.'docs/_toc.ini'; |
|
359 | 359 | |
360 | 360 | // We need a TOC file to exist if we're going to modify it silly. |
361 | - if (! file_exists($path)) |
|
361 | + if ( ! file_exists($path)) |
|
362 | 362 | { |
363 | - if (! $this->copyTemplate('toc', $path)) |
|
363 | + if ( ! $this->copyTemplate('toc', $path)) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | 369 | $version = rtrim($version, '/ '); |
370 | - if (! empty($version)) |
|
370 | + if ( ! empty($version)) |
|
371 | 371 | { |
372 | 372 | $version .= '/'; |
373 | 373 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return string |
391 | 391 | */ |
392 | - private function formatObject( $model ) |
|
392 | + private function formatObject($model) |
|
393 | 393 | { |
394 | 394 | $fields = $this->db->field_data($this->$model->table_name); |
395 | 395 | |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return $this |
450 | 450 | */ |
451 | - private function addRoutes( $plural, $version ) |
|
451 | + private function addRoutes($plural, $version) |
|
452 | 452 | { |
453 | - $path = APPPATH .'config/routes.php'; |
|
453 | + $path = APPPATH.'config/routes.php'; |
|
454 | 454 | |
455 | 455 | $version = rtrim($version, ', '); |
456 | - if (! empty($version)) |
|
456 | + if ( ! empty($version)) |
|
457 | 457 | { |
458 | - $version .='/'; |
|
458 | + $version .= '/'; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | $content = "\$routes->resources('{$version}{$plural}');\n"; |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | */ |
477 | 477 | private function install( ) |
478 | 478 | { |
479 | - CLI::write("Available Auth Types: ". CLI::color('basic, digest, none', 'yellow') ); |
|
479 | + CLI::write("Available Auth Types: ".CLI::color('basic, digest, none', 'yellow')); |
|
480 | 480 | |
481 | - $this->auth_type = trim( CLI::prompt('Auth type') ); |
|
481 | + $this->auth_type = trim(CLI::prompt('Auth type')); |
|
482 | 482 | |
483 | 483 | switch ($this->auth_type) |
484 | 484 | { |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | |
532 | 532 | // Update the config setting |
533 | 533 | $content = "config['api.enable_logging'] = true;"; |
534 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"] ); |
|
534 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"]); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | //-------------------------------------------------------------------- |
538 | 538 | |
539 | 539 | |
540 | - private function makeMigration( $tpl, $name ) |
|
540 | + private function makeMigration($tpl, $name) |
|
541 | 541 | { |
542 | 542 | // Create the migration |
543 | 543 | $this->load->library('migration'); |
544 | 544 | |
545 | 545 | $destination = $this->migration->determine_migration_path('app', true); |
546 | 546 | |
547 | - $file = $this->migration->make_name( $name ); |
|
547 | + $file = $this->migration->make_name($name); |
|
548 | 548 | |
549 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
549 | + $destination = rtrim($destination, '/').'/'.$file; |
|
550 | 550 | |
551 | - if (! $this->copyTemplate( $tpl, $destination, [], true) ) |
|
551 | + if ( ! $this->copyTemplate($tpl, $destination, [], true)) |
|
552 | 552 | { |
553 | 553 | CLI::error('Error creating migration file.'); |
554 | 554 | } |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param $type |
565 | 565 | */ |
566 | - private function setAuthType( $type ) |
|
566 | + private function setAuthType($type) |
|
567 | 567 | { |
568 | 568 | $content = "config['api.auth_type'] = '{$type}';"; |
569 | 569 | |
570 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"] ); |
|
570 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"]); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | //-------------------------------------------------------------------- |
@@ -47,49 +47,49 @@ discard block |
||
47 | 47 | |
48 | 48 | //-------------------------------------------------------------------- |
49 | 49 | |
50 | - public function run( $segments = [ ], $quiet = FALSE ) |
|
50 | + public function run($segments = [], $quiet = FALSE) |
|
51 | 51 | { |
52 | - $name = array_shift( $segments ); |
|
52 | + $name = array_shift($segments); |
|
53 | 53 | |
54 | - if ( empty( $name ) ) |
|
54 | + if (empty($name)) |
|
55 | 55 | { |
56 | - $name = CLI::prompt( 'Controller name' ); |
|
56 | + $name = CLI::prompt('Controller name'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Format to CI Standards |
60 | - $name = ucfirst( $name ); |
|
60 | + $name = ucfirst($name); |
|
61 | 61 | |
62 | - if ( $quiet === FALSE ) |
|
62 | + if ($quiet === FALSE) |
|
63 | 63 | { |
64 | - $this->collectOptions( $name ); |
|
64 | + $this->collectOptions($name); |
|
65 | 65 | } |
66 | 66 | else |
67 | 67 | { |
68 | - $this->quietSetOptions( $name ); |
|
68 | + $this->quietSetOptions($name); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $data = [ |
72 | 72 | 'controller_name' => $name, |
73 | - 'today' => date( 'Y-m-d H:ia' ) |
|
73 | + 'today' => date('Y-m-d H:ia') |
|
74 | 74 | ]; |
75 | 75 | |
76 | - $data = array_merge( $data, $this->options ); |
|
76 | + $data = array_merge($data, $this->options); |
|
77 | 77 | |
78 | 78 | if ($data['themed'] == 'y' || $data['themed'] === true) |
79 | 79 | { |
80 | 80 | $data['base_class'] = 'ThemedController'; |
81 | 81 | } |
82 | 82 | |
83 | - $destination = $this->determineOutputPath( 'controllers' ) . $name . '.php'; |
|
83 | + $destination = $this->determineOutputPath('controllers').$name.'.php'; |
|
84 | 84 | |
85 | - if ( ! $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ) ) |
|
85 | + if ( ! $this->copyTemplate('controller', $destination, $data, $this->overwrite)) |
|
86 | 86 | { |
87 | - CLI::error( 'Error creating new files' ); |
|
87 | + CLI::error('Error creating new files'); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( CLI::option( 'create_views' ) && $this->options['themed'] == 'y' ) |
|
90 | + if (CLI::option('create_views') && $this->options['themed'] == 'y') |
|
91 | 91 | { |
92 | - $this->createViews( $name ); |
|
92 | + $this->createViews($name); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return TRUE; |
@@ -97,20 +97,20 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | - protected function quietSetOptions( $name ) |
|
100 | + protected function quietSetOptions($name) |
|
101 | 101 | { |
102 | 102 | $options = CLI::getOptions(); |
103 | 103 | |
104 | - if ( ! empty( $options['model'] ) ) |
|
104 | + if ( ! empty($options['model'])) |
|
105 | 105 | { |
106 | 106 | $this->options['model'] = $options['model']; |
107 | 107 | |
108 | 108 | // Format per CI |
109 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
109 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
110 | 110 | { |
111 | 111 | $this->options['model'] .= '_model'; |
112 | 112 | } |
113 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
113 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
114 | 114 | |
115 | 115 | $this->options['themed'] = 'y'; |
116 | 116 | } |
@@ -120,36 +120,34 @@ discard block |
||
120 | 120 | |
121 | 121 | //-------------------------------------------------------------------- |
122 | 122 | |
123 | - protected function collectOptions( $name ) |
|
123 | + protected function collectOptions($name) |
|
124 | 124 | { |
125 | 125 | $options = CLI::getOptions(); |
126 | 126 | |
127 | 127 | // Model? |
128 | - $this->options['model'] = empty( $options['model'] ) ? |
|
129 | - CLI::prompt( 'Model Name? (empty is fine)' ) : |
|
130 | - $options['model']; |
|
128 | + $this->options['model'] = empty($options['model']) ? |
|
129 | + CLI::prompt('Model Name? (empty is fine)') : $options['model']; |
|
131 | 130 | |
132 | 131 | // Format per CI |
133 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
132 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
134 | 133 | { |
135 | 134 | $this->options['model'] .= '_model'; |
136 | 135 | } |
137 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
136 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
138 | 137 | |
139 | 138 | // If we're using a model, then force the use of a themed controller. |
140 | - if ( ! empty( $this->options['model'] ) ) |
|
139 | + if ( ! empty($this->options['model'])) |
|
141 | 140 | { |
142 | 141 | $options['themed'] = 'y'; |
143 | 142 | } |
144 | 143 | |
145 | 144 | // Themed Controller? |
146 | - $this->options['themed'] = empty( $options['themed'] ) ? |
|
147 | - CLI::prompt( 'Is a Themed Controller?', [ 'y', 'n' ] ) : |
|
148 | - $options['themed']; |
|
145 | + $this->options['themed'] = empty($options['themed']) ? |
|
146 | + CLI::prompt('Is a Themed Controller?', ['y', 'n']) : $options['themed']; |
|
149 | 147 | |
150 | 148 | $this->options['themed'] = $this->options['themed'] == 'y' ? TRUE : FALSE; |
151 | 149 | |
152 | - if ( $this->options['themed'] ) |
|
150 | + if ($this->options['themed']) |
|
153 | 151 | { |
154 | 152 | $this->options['base_class'] = 'ThemedController'; |
155 | 153 | } |
@@ -160,35 +158,35 @@ discard block |
||
160 | 158 | /** |
161 | 159 | * Generates the standard views for our CRUD methods. |
162 | 160 | */ |
163 | - protected function createViews( $name ) |
|
161 | + protected function createViews($name) |
|
164 | 162 | { |
165 | - $this->load->helper( 'inflector' ); |
|
163 | + $this->load->helper('inflector'); |
|
166 | 164 | |
167 | 165 | $data = [ |
168 | 166 | 'name' => $name, |
169 | 167 | 'lower_name' => strtolower($name), |
170 | - 'single_name' => singular( $name ), |
|
171 | - 'plural_name' => plural( $name ), |
|
168 | + 'single_name' => singular($name), |
|
169 | + 'plural_name' => plural($name), |
|
172 | 170 | 'fields' => $this->prepareFields() |
173 | 171 | ]; |
174 | 172 | |
175 | - $subfolder = empty( $this->module ) ? '/' . strtolower($name) : '/'. $data['lower_name']; |
|
173 | + $subfolder = empty($this->module) ? '/'.strtolower($name) : '/'.$data['lower_name']; |
|
176 | 174 | |
177 | 175 | // Index |
178 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'index.php'; |
|
179 | - $this->copyTemplate( 'view_index', $destination, $data, $this->overwrite ); |
|
176 | + $destination = $this->determineOutputPath('views'.$subfolder).'index.php'; |
|
177 | + $this->copyTemplate('view_index', $destination, $data, $this->overwrite); |
|
180 | 178 | |
181 | 179 | // Create |
182 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'create.php'; |
|
183 | - $this->copyTemplate( 'view_create', $destination, $data, $this->overwrite ); |
|
180 | + $destination = $this->determineOutputPath('views'.$subfolder).'create.php'; |
|
181 | + $this->copyTemplate('view_create', $destination, $data, $this->overwrite); |
|
184 | 182 | |
185 | 183 | // Show |
186 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'show.php'; |
|
187 | - $this->copyTemplate( 'view_show', $destination, $data, $this->overwrite ); |
|
184 | + $destination = $this->determineOutputPath('views'.$subfolder).'show.php'; |
|
185 | + $this->copyTemplate('view_show', $destination, $data, $this->overwrite); |
|
188 | 186 | |
189 | 187 | // Index |
190 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'update.php'; |
|
191 | - $this->copyTemplate( 'view_update', $destination, $data, $this->overwrite ); |
|
188 | + $destination = $this->determineOutputPath('views'.$subfolder).'update.php'; |
|
189 | + $this->copyTemplate('view_update', $destination, $data, $this->overwrite); |
|
192 | 190 | } |
193 | 191 | |
194 | 192 | //-------------------------------------------------------------------- |
@@ -199,14 +197,14 @@ discard block |
||
199 | 197 | */ |
200 | 198 | protected function prepareFields() |
201 | 199 | { |
202 | - $fields = CLI::option( 'fields' ); |
|
200 | + $fields = CLI::option('fields'); |
|
203 | 201 | |
204 | - if ( empty( $fields ) ) |
|
202 | + if (empty($fields)) |
|
205 | 203 | { |
206 | 204 | // If we have a model, we can get our fields from there |
207 | - if (! empty($this->options['model'])) |
|
205 | + if ( ! empty($this->options['model'])) |
|
208 | 206 | { |
209 | - $fields = $this->getFieldsFromModel( $this->options['model'] ); |
|
207 | + $fields = $this->getFieldsFromModel($this->options['model']); |
|
210 | 208 | |
211 | 209 | if (empty($fields)) |
212 | 210 | { |
@@ -219,15 +217,15 @@ discard block |
||
219 | 217 | } |
220 | 218 | } |
221 | 219 | |
222 | - $fields = explode( ' ', $fields ); |
|
220 | + $fields = explode(' ', $fields); |
|
223 | 221 | |
224 | - $new_fields = [ ]; |
|
222 | + $new_fields = []; |
|
225 | 223 | |
226 | - foreach ( $fields as $field ) |
|
224 | + foreach ($fields as $field) |
|
227 | 225 | { |
228 | - $pop = [ NULL, NULL, NULL ]; |
|
229 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
230 | - $type = strtolower( $type ); |
|
226 | + $pop = [NULL, NULL, NULL]; |
|
227 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
228 | + $type = strtolower($type); |
|
231 | 229 | |
232 | 230 | // Ignore list |
233 | 231 | if (in_array($field, ['created_on', 'modified_on'])) |
@@ -277,16 +275,16 @@ discard block |
||
277 | 275 | |
278 | 276 | //-------------------------------------------------------------------- |
279 | 277 | |
280 | - private function getFieldsFromModel( $model ) |
|
278 | + private function getFieldsFromModel($model) |
|
281 | 279 | { |
282 | 280 | $this->load->model($model); |
283 | 281 | |
284 | - if (! $this->db->table_exists( $this->$model->table() )) |
|
282 | + if ( ! $this->db->table_exists($this->$model->table())) |
|
285 | 283 | { |
286 | 284 | return ''; |
287 | 285 | } |
288 | 286 | |
289 | - $fields = $this->db->field_data( $this->$model->table() ); |
|
287 | + $fields = $this->db->field_data($this->$model->table()); |
|
290 | 288 | |
291 | 289 | $return = ''; |
292 | 290 | |
@@ -294,14 +292,14 @@ discard block |
||
294 | 292 | // it would have been passed on the CLI |
295 | 293 | foreach ($fields as $field) |
296 | 294 | { |
297 | - $temp = $field->name .':'. $field->type; |
|
295 | + $temp = $field->name.':'.$field->type; |
|
298 | 296 | |
299 | - if (! empty($field->max_length)) |
|
297 | + if ( ! empty($field->max_length)) |
|
300 | 298 | { |
301 | - $temp .= ':'. $field->max_length; |
|
299 | + $temp .= ':'.$field->max_length; |
|
302 | 300 | } |
303 | 301 | |
304 | - $return .= ' '. $temp; |
|
302 | + $return .= ' '.$temp; |
|
305 | 303 | } |
306 | 304 | |
307 | 305 | return $return; |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | //-------------------------------------------------------------------- |
6 | 6 | |
7 | 7 | $model_string = $model ? "'{$model}'" : 'null'; |
8 | -$lower_model = trim( strtolower($model_string), "' " ); |
|
8 | +$lower_model = trim(strtolower($model_string), "' "); |
|
9 | 9 | $lower_model_esc = strpos($lower_model, 'null') !== false ? 'null' : "'{$lower_model}'"; |
10 | -$lower_controller = strtolower($controller_name); |
|
10 | +$lower_controller = strtolower($controller_name); |
|
11 | 11 | |
12 | 12 | //-------------------------------------------------------------------- |
13 | 13 | // Build our Methods |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | $index_method = ''; |
23 | 23 | |
24 | -if (! empty($model) ) |
|
24 | +if ( ! empty($model)) |
|
25 | 25 | { |
26 | 26 | $index_method = <<<EOD |
27 | 27 | \$this->load->library('table'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | $create_method = ''; |
44 | 44 | |
45 | -if (! empty($model)) |
|
45 | +if ( ! empty($model)) |
|
46 | 46 | { |
47 | 47 | $create_method = <<<EOD |
48 | 48 | \$this->load->helper('form'); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | $show_method = ''; |
72 | 72 | |
73 | -if (! empty($model)) |
|
73 | +if ( ! empty($model)) |
|
74 | 74 | { |
75 | 75 | $show_method = <<<EOD |
76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | $update_method = ''; |
94 | 94 | |
95 | -if (! empty($model)) |
|
95 | +if ( ! empty($model)) |
|
96 | 96 | { |
97 | 97 | $update_method = <<<EOD |
98 | 98 | \$this->load->helper('form'); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | $delete_method = ''; |
125 | 125 | |
126 | -if (! empty($model)) |
|
126 | +if ( ! empty($model)) |
|
127 | 127 | { |
128 | 128 | $delete_method = <<<EOD |
129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | foreach ($fields as $field) |
15 | 15 | { |
16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
16 | + echo $uikit->inputWrap(humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | 17 | |
18 | 18 | switch ($field['type']) |
19 | 19 | { |