@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | |
33 | 33 | $descriptions = [ |
34 | - 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
34 | + 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | $long_description = <<<EOT |
@@ -35,7 +35,7 @@ |
||
35 | 35 | protected \$deleted_by_field = 'deleted_by'; |
36 | 36 | "; |
37 | 37 | |
38 | -$protect = "'". implode("', '", $protected) . "'"; |
|
38 | +$protect = "'".implode("', '", $protected)."'"; |
|
39 | 39 | |
40 | 40 | //-------------------------------------------------------------------- |
41 | 41 | // Create the full model |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | protected $model_name = ''; |
40 | 40 | |
41 | - protected $table_exists = false; |
|
41 | + protected $table_exists = false; |
|
42 | 42 | |
43 | 43 | //-------------------------------------------------------------------- |
44 | 44 | |
@@ -46,32 +46,32 @@ discard block |
||
46 | 46 | { |
47 | 47 | $name = array_shift( $segments ); |
48 | 48 | |
49 | - // If a table already exists then we don't need a migration |
|
50 | - $this->load->database(); |
|
51 | - if ($this->db->table_exists($name)) |
|
52 | - { |
|
53 | - $this->table_exists = true; |
|
54 | - } |
|
49 | + // If a table already exists then we don't need a migration |
|
50 | + $this->load->database(); |
|
51 | + if ($this->db->table_exists($name)) |
|
52 | + { |
|
53 | + $this->table_exists = true; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | // If we didn't attach any fields, then we |
57 | 57 | // need to generate the barebones here. |
58 | 58 | $this->fields = CLI::option('fields'); |
59 | 59 | |
60 | - // If we don't have any fields, and no model |
|
61 | - // exists, then we need to provide some default fields. |
|
62 | - if (empty($this->fields)) |
|
63 | - { |
|
64 | - if (! $this->table_exists) |
|
65 | - { |
|
66 | - $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
|
67 | - } |
|
68 | - } |
|
60 | + // If we don't have any fields, and no model |
|
61 | + // exists, then we need to provide some default fields. |
|
62 | + if (empty($this->fields)) |
|
63 | + { |
|
64 | + if (! $this->table_exists) |
|
65 | + { |
|
66 | + $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | // Perform the steps. |
71 | - if (! $this->table_exists) |
|
72 | - { |
|
73 | - $this->makeMigration( $name ); |
|
74 | - } |
|
71 | + if (! $this->table_exists) |
|
72 | + { |
|
73 | + $this->makeMigration( $name ); |
|
74 | + } |
|
75 | 75 | $this->makeSeed($name); |
76 | 76 | $this->makeModel($name); |
77 | 77 | $this->makeController($name); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function makeSeed($name) |
100 | 100 | { |
101 | - $this->generate("seed {$name}", null, true); |
|
101 | + $this->generate("seed {$name}", null, true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | //-------------------------------------------------------------------- |
@@ -106,33 +106,33 @@ discard block |
||
106 | 106 | |
107 | 107 | public function makeModel($name) |
108 | 108 | { |
109 | - $this->load->helper('inflector'); |
|
109 | + $this->load->helper('inflector'); |
|
110 | 110 | |
111 | 111 | $name = singular($name); |
112 | 112 | $this->model_name = $name; |
113 | 113 | |
114 | - // If a table exists, we can build it from that |
|
115 | - if ($this->table_exists) |
|
116 | - { |
|
117 | - $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
118 | - } |
|
119 | - // Otherwise, we need to provide the fields to make the model out of. |
|
120 | - else |
|
121 | - { |
|
122 | - $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
123 | - } |
|
114 | + // If a table exists, we can build it from that |
|
115 | + if ($this->table_exists) |
|
116 | + { |
|
117 | + $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
118 | + } |
|
119 | + // Otherwise, we need to provide the fields to make the model out of. |
|
120 | + else |
|
121 | + { |
|
122 | + $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //-------------------------------------------------------------------- |
127 | 127 | |
128 | 128 | public function makeController($name) |
129 | 129 | { |
130 | - $options = "-model {$this->model_name} -create_views"; |
|
130 | + $options = "-model {$this->model_name} -create_views"; |
|
131 | 131 | |
132 | - if (! empty($this->fields)) |
|
133 | - { |
|
134 | - $options .= " -fields '{$this->fields}'"; |
|
135 | - } |
|
132 | + if (! empty($this->fields)) |
|
133 | + { |
|
134 | + $options .= " -fields '{$this->fields}'"; |
|
135 | + } |
|
136 | 136 | |
137 | 137 | $this->generate("controller {$name}", $options, true); |
138 | 138 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | //-------------------------------------------------------------------- |
44 | 44 | |
45 | - public function run($segments = [ ], $quiet = false) |
|
45 | + public function run($segments = [], $quiet = false) |
|
46 | 46 | { |
47 | - $name = array_shift( $segments ); |
|
47 | + $name = array_shift($segments); |
|
48 | 48 | |
49 | 49 | // If a table already exists then we don't need a migration |
50 | 50 | $this->load->database(); |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | // exists, then we need to provide some default fields. |
62 | 62 | if (empty($this->fields)) |
63 | 63 | { |
64 | - if (! $this->table_exists) |
|
64 | + if ( ! $this->table_exists) |
|
65 | 65 | { |
66 | 66 | $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Perform the steps. |
71 | - if (! $this->table_exists) |
|
71 | + if ( ! $this->table_exists) |
|
72 | 72 | { |
73 | - $this->makeMigration( $name ); |
|
73 | + $this->makeMigration($name); |
|
74 | 74 | } |
75 | 75 | $this->makeSeed($name); |
76 | 76 | $this->makeModel($name); |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | // If a table exists, we can build it from that |
115 | 115 | if ($this->table_exists) |
116 | 116 | { |
117 | - $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
117 | + $this->generate("model {$name}", "-table $name -primary_key id", TRUE); |
|
118 | 118 | } |
119 | 119 | // Otherwise, we need to provide the fields to make the model out of. |
120 | 120 | else |
121 | 121 | { |
122 | - $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
122 | + $this->generate("model {$name}", "-fields '{$this->fields}'", TRUE); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $options = "-model {$this->model_name} -create_views"; |
131 | 131 | |
132 | - if (! empty($this->fields)) |
|
132 | + if ( ! empty($this->fields)) |
|
133 | 133 | { |
134 | 134 | $options .= " -fields '{$this->fields}'"; |
135 | 135 | } |
@@ -34,36 +34,36 @@ |
||
34 | 34 | |
35 | 35 | class SeedGenerator extends \Myth\Forge\BaseGenerator { |
36 | 36 | |
37 | - public function run($segments=[], $quiet=false) |
|
37 | + public function run($segments = [], $quiet = false) |
|
38 | 38 | { |
39 | - $name = array_shift( $segments ); |
|
39 | + $name = array_shift($segments); |
|
40 | 40 | |
41 | - if ( empty( $name ) ) |
|
41 | + if (empty($name)) |
|
42 | 42 | { |
43 | - $name = CLI::prompt( 'Seed name' ); |
|
43 | + $name = CLI::prompt('Seed name'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Format to CI Standards |
47 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
48 | - if (substr( $name, -4) == 'seed') |
|
47 | + $name = str_replace('.php', '', strtolower($name)); |
|
48 | + if (substr($name, -4) == 'seed') |
|
49 | 49 | { |
50 | 50 | $name = substr($name, 0, strlen($name) - 4); |
51 | 51 | } |
52 | - $name = ucfirst($name) .'Seeder'; |
|
52 | + $name = ucfirst($name).'Seeder'; |
|
53 | 53 | |
54 | 54 | $data = [ |
55 | 55 | 'seed_name' => $name, |
56 | - 'today' => date( 'Y-m-d H:ia' ) |
|
56 | + 'today' => date('Y-m-d H:ia') |
|
57 | 57 | ]; |
58 | 58 | |
59 | - $destination = $this->determineOutputPath( 'database/seeds' ) . $name . '.php'; |
|
59 | + $destination = $this->determineOutputPath('database/seeds').$name.'.php'; |
|
60 | 60 | |
61 | 61 | if (strpos($destination, 'modules') !== false) |
62 | 62 | { |
63 | 63 | $destination = str_replace('database/', '', $destination); |
64 | 64 | } |
65 | 65 | |
66 | - if (! $this->copyTemplate( 'seed', $destination, $data, $this->overwrite) ) |
|
66 | + if ( ! $this->copyTemplate('seed', $destination, $data, $this->overwrite)) |
|
67 | 67 | { |
68 | 68 | CLI::error('Error creating seed file.'); |
69 | 69 | } |
@@ -34,21 +34,21 @@ |
||
34 | 34 | |
35 | 35 | class ViewGenerator extends \Myth\Forge\BaseGenerator { |
36 | 36 | |
37 | - public function run($segments=[], $quiet=false) |
|
37 | + public function run($segments = [], $quiet = false) |
|
38 | 38 | { |
39 | - $name = array_shift( $segments ); |
|
39 | + $name = array_shift($segments); |
|
40 | 40 | |
41 | - if ( empty( $name ) ) |
|
41 | + if (empty($name)) |
|
42 | 42 | { |
43 | - $name = CLI::prompt( 'View name' ); |
|
43 | + $name = CLI::prompt('View name'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Format to CI Standards |
47 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
47 | + $name = str_replace('.php', '', strtolower($name)); |
|
48 | 48 | |
49 | - $destination = $this->determineOutputPath( 'views' ) . $name . '.php'; |
|
49 | + $destination = $this->determineOutputPath('views').$name.'.php'; |
|
50 | 50 | |
51 | - if (! $this->createFile($destination, "The {$name}.php view file.", $this->overwrite) ) |
|
51 | + if ( ! $this->createFile($destination, "The {$name}.php view file.", $this->overwrite)) |
|
52 | 52 | { |
53 | 53 | CLI::error('Error creating view file.'); |
54 | 54 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * Start the timer... tick tock tick tock... |
186 | 186 | * ------------------------------------------------------ |
187 | 187 | */ |
188 | - $BM =& load_class('Benchmark', 'core'); |
|
188 | + $BM = & load_class('Benchmark', 'core'); |
|
189 | 189 | $BM->mark('total_execution_time_start'); |
190 | 190 | $BM->mark('loading_time:_base_classes_start'); |
191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * Instantiate the hooks class |
195 | 195 | * ------------------------------------------------------ |
196 | 196 | */ |
197 | - $EXT =& load_class('Hooks', 'core'); |
|
197 | + $EXT = & load_class('Hooks', 'core'); |
|
198 | 198 | |
199 | 199 | /* |
200 | 200 | * ------------------------------------------------------ |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * depending on another class that uses it. |
214 | 214 | * |
215 | 215 | */ |
216 | - $CFG =& load_class('Config', 'core'); |
|
216 | + $CFG = & load_class('Config', 'core'); |
|
217 | 217 | |
218 | 218 | // Do we have any manually set config items in the index.php file? |
219 | 219 | if (isset($assign_to_config) && is_array($assign_to_config)) |
@@ -291,28 +291,28 @@ discard block |
||
291 | 291 | * Instantiate the UTF-8 class |
292 | 292 | * ------------------------------------------------------ |
293 | 293 | */ |
294 | - $UNI =& load_class('Utf8', 'core'); |
|
294 | + $UNI = & load_class('Utf8', 'core'); |
|
295 | 295 | |
296 | 296 | /* |
297 | 297 | * ------------------------------------------------------ |
298 | 298 | * Instantiate the URI class |
299 | 299 | * ------------------------------------------------------ |
300 | 300 | */ |
301 | - $URI =& load_class('URI', 'core'); |
|
301 | + $URI = & load_class('URI', 'core'); |
|
302 | 302 | |
303 | 303 | /* |
304 | 304 | * ------------------------------------------------------ |
305 | 305 | * Instantiate the routing class and set the routing |
306 | 306 | * ------------------------------------------------------ |
307 | 307 | */ |
308 | - $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
308 | + $RTR = & load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
309 | 309 | |
310 | 310 | /* |
311 | 311 | * ------------------------------------------------------ |
312 | 312 | * Instantiate the output class |
313 | 313 | * ------------------------------------------------------ |
314 | 314 | */ |
315 | - $OUT =& load_class('Output', 'core'); |
|
315 | + $OUT = & load_class('Output', 'core'); |
|
316 | 316 | |
317 | 317 | /* |
318 | 318 | * ------------------------------------------------------ |
@@ -329,21 +329,21 @@ discard block |
||
329 | 329 | * Load the security class for xss and csrf support |
330 | 330 | * ----------------------------------------------------- |
331 | 331 | */ |
332 | - $SEC =& load_class('Security', 'core'); |
|
332 | + $SEC = & load_class('Security', 'core'); |
|
333 | 333 | |
334 | 334 | /* |
335 | 335 | * ------------------------------------------------------ |
336 | 336 | * Load the Input class and sanitize globals |
337 | 337 | * ------------------------------------------------------ |
338 | 338 | */ |
339 | - $IN =& load_class('Input', 'core'); |
|
339 | + $IN = & load_class('Input', 'core'); |
|
340 | 340 | |
341 | 341 | /* |
342 | 342 | * ------------------------------------------------------ |
343 | 343 | * Load the Language class |
344 | 344 | * ------------------------------------------------------ |
345 | 345 | */ |
346 | - $LANG =& load_class('Lang', 'core'); |
|
346 | + $LANG = & load_class('Lang', 'core'); |
|
347 | 347 | |
348 | 348 | /* |
349 | 349 | * ------------------------------------------------------ |
@@ -169,12 +169,10 @@ discard block |
||
169 | 169 | file_exists(APPPATH.'vendor/autoload.php') |
170 | 170 | ? require_once(APPPATH.'vendor/autoload.php') |
171 | 171 | : log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.'); |
172 | - } |
|
173 | - elseif (file_exists($composer_autoload)) |
|
172 | + } elseif (file_exists($composer_autoload)) |
|
174 | 173 | { |
175 | 174 | require_once($composer_autoload); |
176 | - } |
|
177 | - else |
|
175 | + } else |
|
178 | 176 | { |
179 | 177 | log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload); |
180 | 178 | } |
@@ -250,8 +248,7 @@ discard block |
||
250 | 248 | // This is required for mb_convert_encoding() to strip invalid characters. |
251 | 249 | // That's utilized by CI_Utf8, but it's also done for consistency with iconv. |
252 | 250 | mb_substitute_character('none'); |
253 | - } |
|
254 | - else |
|
251 | + } else |
|
255 | 252 | { |
256 | 253 | define('MB_ENABLED', FALSE); |
257 | 254 | } |
@@ -264,8 +261,7 @@ discard block |
||
264 | 261 | // iconv.internal_encoding is deprecated starting with PHP 5.6 |
265 | 262 | // and it's usage triggers E_DEPRECATED messages. |
266 | 263 | @ini_set('iconv.internal_encoding', $charset); |
267 | - } |
|
268 | - else |
|
264 | + } else |
|
269 | 265 | { |
270 | 266 | define('ICONV_ENABLED', FALSE); |
271 | 267 | } |
@@ -402,16 +398,14 @@ discard block |
||
402 | 398 | if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php')) |
403 | 399 | { |
404 | 400 | $e404 = TRUE; |
405 | - } |
|
406 | - else |
|
401 | + } else |
|
407 | 402 | { |
408 | 403 | require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php'); |
409 | 404 | |
410 | 405 | if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method)) |
411 | 406 | { |
412 | 407 | $e404 = TRUE; |
413 | - } |
|
414 | - elseif (method_exists($class, '_remap')) |
|
408 | + } elseif (method_exists($class, '_remap')) |
|
415 | 409 | { |
416 | 410 | $params = array($method, array_slice($URI->rsegments, 2)); |
417 | 411 | $method = '_remap'; |
@@ -453,8 +447,7 @@ discard block |
||
453 | 447 | $RTR->directory = ''; |
454 | 448 | } |
455 | 449 | } |
456 | - } |
|
457 | - else |
|
450 | + } else |
|
458 | 451 | { |
459 | 452 | $e404 = FALSE; |
460 | 453 | } |
@@ -470,8 +463,7 @@ discard block |
||
470 | 463 | 1 => $class, |
471 | 464 | 2 => $method |
472 | 465 | ); |
473 | - } |
|
474 | - else |
|
466 | + } else |
|
475 | 467 | { |
476 | 468 | show_404($RTR->directory.$class.'/'.$method); |
477 | 469 | } |
@@ -65,17 +65,17 @@ |
||
65 | 65 | */ |
66 | 66 | public function __construct() |
67 | 67 | { |
68 | - self::$instance =& $this; |
|
68 | + self::$instance = & $this; |
|
69 | 69 | |
70 | 70 | // Assign all the class objects that were instantiated by the |
71 | 71 | // bootstrap file (CodeIgniter.php) to local class variables |
72 | 72 | // so that CI can run as one big super object. |
73 | 73 | foreach (is_loaded() as $var => $class) |
74 | 74 | { |
75 | - $this->$var =& load_class($class); |
|
75 | + $this->$var = & load_class($class); |
|
76 | 76 | } |
77 | 77 | |
78 | - $this->load =& load_class('Loader', 'core'); |
|
78 | + $this->load = & load_class('Loader', 'core'); |
|
79 | 79 | $this->load->initialize(); |
80 | 80 | log_message('info', 'Controller Class Initialized'); |
81 | 81 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @var array |
55 | 55 | */ |
56 | - public $language = array(); |
|
56 | + public $language = array(); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * List of loaded language files |
60 | 60 | * |
61 | 61 | * @var array |
62 | 62 | */ |
63 | - public $is_loaded = array(); |
|
63 | + public $is_loaded = array(); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Class constructor |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom)) |
110 | 110 | { |
111 | - $config =& get_config(); |
|
111 | + $config = & get_config(); |
|
112 | 112 | $idiom = empty($config['language']) ? 'english' : $config['language']; |
113 | 113 | } |
114 | 114 |
@@ -266,8 +266,7 @@ |
||
266 | 266 | if ($reduce_linebreaks === TRUE) |
267 | 267 | { |
268 | 268 | $table['#<p>\n*</p>#'] = ''; |
269 | - } |
|
270 | - else |
|
269 | + } else |
|
271 | 270 | { |
272 | 271 | // If we have empty paragraph tags we add a non-breaking space |
273 | 272 | // otherwise most browsers won't treat them as true paragraphs |
@@ -113,7 +113,7 @@ |
||
113 | 113 | */ |
114 | 114 | public function __construct() |
115 | 115 | { |
116 | - $config =& get_config(); |
|
116 | + $config = & get_config(); |
|
117 | 117 | |
118 | 118 | $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; |
119 | 119 | $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '') |
@@ -129,8 +129,7 @@ discard block |
||
129 | 129 | if (is_numeric($config['log_threshold'])) |
130 | 130 | { |
131 | 131 | $this->_threshold = (int) $config['log_threshold']; |
132 | - } |
|
133 | - elseif (is_array($config['log_threshold'])) |
|
132 | + } elseif (is_array($config['log_threshold'])) |
|
134 | 133 | { |
135 | 134 | $this->_threshold = 0; |
136 | 135 | $this->_threshold_array = array_flip($config['log_threshold']); |
@@ -198,8 +197,7 @@ discard block |
||
198 | 197 | $microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000); |
199 | 198 | $date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full)); |
200 | 199 | $date = $date->format($this->_date_fmt); |
201 | - } |
|
202 | - else |
|
200 | + } else |
|
203 | 201 | { |
204 | 202 | $date = date($this->_date_fmt); |
205 | 203 | } |