Pannous

Pannous Commit Details

Date:2018-04-26 20:25:46 (2 years 3 months ago)
Author:Grégory Soutadé
Branch:master
Commit:deae7ca6a6e292aeca4ce763722ecb36f5de3cb7
Parents: 2c71285a151b5815863f838e890cebdc222859b8
Message:Upgrade FuelPHP to version 1.8.1

Changes:
Afuel/packages/parser/classes/view/handlebars.php (full)
Mcomposer.lock (14 diffs)
Mcomposer.phar
Mfuel/packages/auth/bootstrap.php (1 diff)
Mfuel/packages/auth/classes/auth.php (1 diff)
Mfuel/packages/auth/classes/auth/acl/driver.php (2 diffs)
Mfuel/packages/auth/classes/auth/acl/ormacl.php (1 diff)
Mfuel/packages/auth/classes/auth/acl/simpleacl.php (1 diff)
Mfuel/packages/auth/classes/auth/driver.php (1 diff)
Mfuel/packages/auth/classes/auth/exceptions.php (1 diff)
Mfuel/packages/auth/classes/auth/group/driver.php (1 diff)
Mfuel/packages/auth/classes/auth/group/ormgroup.php (1 diff)
Mfuel/packages/auth/classes/auth/group/simplegroup.php (1 diff)
Mfuel/packages/auth/classes/auth/login/driver.php (1 diff)
Mfuel/packages/auth/classes/auth/login/ormauth.php (1 diff)
Mfuel/packages/auth/classes/auth/login/simpleauth.php (3 diffs)
Mfuel/packages/auth/classes/auth/opauth.php (2 diffs)
Mfuel/packages/auth/classes/model/auth/group.php (1 diff)
Mfuel/packages/auth/classes/model/auth/grouppermission.php (1 diff)
Mfuel/packages/auth/classes/model/auth/metadata.php (1 diff)
Mfuel/packages/auth/classes/model/auth/permission.php (1 diff)
Mfuel/packages/auth/classes/model/auth/provider.php (1 diff)
Mfuel/packages/auth/classes/model/auth/role.php (1 diff)
Mfuel/packages/auth/classes/model/auth/rolepermission.php (1 diff)
Mfuel/packages/auth/classes/model/auth/user.php (2 diffs)
Mfuel/packages/auth/classes/model/auth/userpermission.php (1 diff)
Mfuel/packages/auth/config/auth.php (1 diff)
Mfuel/packages/auth/config/opauth.php (1 diff)
Mfuel/packages/auth/config/ormauth.php (1 diff)
Mfuel/packages/auth/config/simpleauth.php (1 diff)
Mfuel/packages/auth/tasks/simple2orm.php (1 diff)
Mfuel/packages/email/bootstrap.php (1 diff)
Mfuel/packages/email/classes/email.php (1 diff)
Mfuel/packages/email/classes/email/driver.php (2 diffs)
Mfuel/packages/email/classes/email/driver/mail.php (1 diff)
Mfuel/packages/email/classes/email/driver/mailgun.php (2 diffs)
Mfuel/packages/email/classes/email/driver/mandrill.php (1 diff)
Mfuel/packages/email/classes/email/driver/noop.php (1 diff)
Mfuel/packages/email/classes/email/driver/sendmail.php (1 diff)
Mfuel/packages/email/classes/email/driver/smtp.php (1 diff)
Mfuel/packages/email/config/email.php (1 diff)
Mfuel/packages/oil/bootstrap.php (1 diff)
Mfuel/packages/oil/classes/cell.php (2 diffs)
Mfuel/packages/oil/classes/command.php (4 diffs)
Mfuel/packages/oil/classes/console.php (2 diffs)
Mfuel/packages/oil/classes/exception.php (1 diff)
Mfuel/packages/oil/classes/generate.php (29 diffs)
Mfuel/packages/oil/classes/generate/admin.php (1 diff)
Mfuel/packages/oil/classes/generate/migration/actions.php (4 diffs)
Mfuel/packages/oil/classes/generate/scaffold.php (2 diffs)
Mfuel/packages/oil/classes/package.php (1 diff)
Mfuel/packages/oil/classes/refine.php (1 diff)
Mfuel/packages/oil/config/oil.php (1 diff)
Mfuel/packages/oil/phpserver.php (2 diffs)
Mfuel/packages/oil/tasks/fromdb.php (4 diffs)
Mfuel/packages/oil/views/admin/orm/actions/index.php (1 diff)
Mfuel/packages/oil/views/admin/orm/views/actions/index.php (1 diff)
Mfuel/packages/oil/views/admin/template.php (1 diff)
Mfuel/packages/orm/bootstrap.php (1 diff)
Mfuel/packages/orm/classes/belongsto.php (3 diffs)
Mfuel/packages/orm/classes/hasmany.php (3 diffs)
Mfuel/packages/orm/classes/hasone.php (3 diffs)
Mfuel/packages/orm/classes/manymany.php (3 diffs)
Mfuel/packages/orm/classes/model.php (18 diffs)
Mfuel/packages/orm/classes/model/nestedset.php (1 diff)
Mfuel/packages/orm/classes/model/soft.php (4 diffs)
Mfuel/packages/orm/classes/model/temporal.php (1 diff)
Mfuel/packages/orm/classes/observer.php (1 diff)
Mfuel/packages/orm/classes/observer/createdat.php (1 diff)
Mfuel/packages/orm/classes/observer/self.php (1 diff)
Mfuel/packages/orm/classes/observer/slug.php (1 diff)
Mfuel/packages/orm/classes/observer/typing.php (7 diffs)
Mfuel/packages/orm/classes/observer/updatedat.php (1 diff)
Mfuel/packages/orm/classes/observer/validation.php (1 diff)
Mfuel/packages/orm/classes/query.php (20 diffs)
Mfuel/packages/orm/classes/query/soft.php (1 diff)
Mfuel/packages/orm/classes/query/temporal.php (2 diffs)
Mfuel/packages/orm/classes/relation.php (1 diff)
Mfuel/packages/orm/config/orm.php (1 diff)
Mfuel/packages/parser/bootstrap.php (2 diffs)
Mfuel/packages/parser/classes/smarty/fuel/extension.php (1 diff)
Mfuel/packages/parser/classes/twig/fuel/extension.php (1 diff)
Mfuel/packages/parser/classes/view.php (4 diffs)
Mfuel/packages/parser/classes/view/dwoo.php (1 diff)
Mfuel/packages/parser/classes/view/haml.php (1 diff)
Mfuel/packages/parser/classes/view/hamltwig.php (1 diff)
Mfuel/packages/parser/classes/view/jade.php (4 diffs)
Mfuel/packages/parser/classes/view/lex.php (1 diff)
Mfuel/packages/parser/classes/view/markdown.php (1 diff)
Mfuel/packages/parser/classes/view/mustache.php (2 diffs)
Mfuel/packages/parser/classes/view/phptal.php (1 diff)
Mfuel/packages/parser/classes/view/smarty.php (1 diff)
Mfuel/packages/parser/classes/view/twig.php (1 diff)
Mfuel/packages/parser/config/parser.php (4 diffs)
Mfuel/vendor/composer/ClassLoader.php (6 diffs)
Mfuel/vendor/composer/LICENSE (1 diff)
Mfuel/vendor/composer/autoload_real.php (1 diff)
Mfuel/vendor/composer/installed.json (8 diffs)

File differences

composer.lock
11
22
33
4
4
55
66
7
87
98
109
......
125124
126125
127126
128
127
129128
130129
131130
132
131
133132
134133
135134
136
135
137136
138137
139138
140
141
139
140
142141
143142
144143
......
157156
158157
159158
160
159
161160
162161
163162
......
192191
193192
194193
195
194
196195
197196
198197
199
198
200199
201200
202201
203
202
204203
205204
206205
207
208
206
207
209208
210209
211210
......
224223
225224
226225
227
226
228227
229228
230229
231
230
232231
233232
234233
235
234
236235
237236
238237
239
240
238
239
241240
242241
243242
......
256255
257256
258257
259
258
260259
261260
262261
263
262
264263
265264
266265
267
266
268267
269268
270269
271
272
270
271
273272
274273
275274
......
288287
289288
290289
291
290
292291
293292
294293
295
294
296295
297296
298297
299
298
300299
301300
302301
303
304
302
303
305304
306305
307306
......
320319
321320
322321
323
322
324323
325324
326325
......
370369
371370
372371
373
372
374373
375374
376375
......
421420
422421
423422
424
423
425424
426425
427426
......
499498
500499
501500
502
501
503502
504503
505504
......
587586
588587
589588
590
589
591590
592591
593592
......
634633
635634
636635
637
636
638637
639638
640639
641640
642641
643
642
644643
645644
646645
647
646
648647
649648
650649
651
652
650
651
653652
654653
655654
......
668667
669668
670669
671
670
672671
673672
674673
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"hash": "1a00e3df726291156b780127ee628d13",
"content-hash": "a118c44cabbfd903d6ea0cfc9ba73609",
"packages": [
{
"zend",
"zikula"
],
"time": "2017-12-29 09:13:20"
"time": "2017-12-29T09:13:20+00:00"
},
{
"name": "fuel/auth",
"version": "1.8.0.4",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/fuel/auth.git",
"reference": "83969c3c932edc94d973ca40f1567459b84c4523"
"reference": "b19a63e27903760d41a8641b8a42b1ddaaa646f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/auth/zipball/83969c3c932edc94d973ca40f1567459b84c4523",
"reference": "83969c3c932edc94d973ca40f1567459b84c4523",
"url": "https://api.github.com/repos/fuel/auth/zipball/b19a63e27903760d41a8641b8a42b1ddaaa646f2",
"reference": "b19a63e27903760d41a8641b8a42b1ddaaa646f2",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x Auth Package",
"homepage": "https://github.com/fuel/auth",
"time": "2016-10-20 18:12:06"
"time": "2018-04-18T14:45:14+00:00"
},
{
"name": "fuel/core",
],
"description": "FuelPHP 1.x Core",
"homepage": "https://github.com/fuel/core",
"time": "2017-01-15 17:41:18"
"time": "2017-01-15T17:41:18+00:00"
},
{
"name": "fuel/email",
"version": "1.8.0.4",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/fuel/email.git",
"reference": "2eab3974e4c38b9fea0a7ebbad3d4e1f20076448"
"reference": "a12df7db925c81f3ace52cdec3dfd925193c8e4b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/email/zipball/2eab3974e4c38b9fea0a7ebbad3d4e1f20076448",
"reference": "2eab3974e4c38b9fea0a7ebbad3d4e1f20076448",
"url": "https://api.github.com/repos/fuel/email/zipball/a12df7db925c81f3ace52cdec3dfd925193c8e4b",
"reference": "a12df7db925c81f3ace52cdec3dfd925193c8e4b",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x Email Package",
"homepage": "https://github.com/fuel/email",
"time": "2016-10-04 15:21:48"
"time": "2018-04-18T14:49:14+00:00"
},
{
"name": "fuel/oil",
"version": "1.8.0.4",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/fuel/oil.git",
"reference": "84ea18b9e39c3c0d31681dd2cf92fbf81b6ed90f"
"reference": "9e114422cfb0ab6d80b32d8270cf1e54e9061679"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/oil/zipball/84ea18b9e39c3c0d31681dd2cf92fbf81b6ed90f",
"reference": "84ea18b9e39c3c0d31681dd2cf92fbf81b6ed90f",
"url": "https://api.github.com/repos/fuel/oil/zipball/9e114422cfb0ab6d80b32d8270cf1e54e9061679",
"reference": "9e114422cfb0ab6d80b32d8270cf1e54e9061679",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x Oil Package",
"homepage": "https://github.com/fuel/oil",
"time": "2016-10-05 13:32:41"
"time": "2018-04-18T14:50:51+00:00"
},
{
"name": "fuel/orm",
"version": "1.8.0.1",
"version": "1.8.1.2",
"source": {
"type": "git",
"url": "https://github.com/fuel/orm.git",
"reference": "69cd98cfed4d8e34b176d87b73a35b98703235be"
"reference": "372a5ffbbef797c4532eaf0283c9483309809206"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/orm/zipball/69cd98cfed4d8e34b176d87b73a35b98703235be",
"reference": "69cd98cfed4d8e34b176d87b73a35b98703235be",
"url": "https://api.github.com/repos/fuel/orm/zipball/372a5ffbbef797c4532eaf0283c9483309809206",
"reference": "372a5ffbbef797c4532eaf0283c9483309809206",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x ORM Package",
"homepage": "https://github.com/fuel/orm",
"time": "2016-05-22 14:52:35"
"time": "2018-04-22T10:09:22+00:00"
},
{
"name": "fuel/parser",
"version": "1.8.0.4",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/fuel/parser.git",
"reference": "e647c56566ddc439801ae966821f37dc35a3c5bb"
"reference": "c8725e112ef59f70f73ddff754a9fe762229fa88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/parser/zipball/e647c56566ddc439801ae966821f37dc35a3c5bb",
"reference": "e647c56566ddc439801ae966821f37dc35a3c5bb",
"url": "https://api.github.com/repos/fuel/parser/zipball/c8725e112ef59f70f73ddff754a9fe762229fa88",
"reference": "c8725e112ef59f70f73ddff754a9fe762229fa88",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x Parser Package",
"homepage": "https://github.com/fuel/parser",
"time": "2017-01-12 17:26:53"
"time": "2018-04-18T14:52:18+00:00"
},
{
"name": "fuelphp/upload",
"file uploads",
"upload"
],
"time": "2015-11-04 17:19:56"
"time": "2015-11-04T17:19:56+00:00"
},
{
"name": "michelf/php-markdown",
"keywords": [
"markdown"
],
"time": "2013-11-29 17:09:24"
"time": "2013-11-29T17:09:24+00:00"
},
{
"name": "monolog/monolog",
"logging",
"psr-3"
],
"time": "2016-04-02 13:12:58"
"time": "2016-04-02T13:12:58+00:00"
},
{
"name": "phpseclib/phpseclib",
"x.509",
"x509"
],
"time": "2015-08-04 04:48:03"
"time": "2015-08-04T04:48:03+00:00"
},
{
"name": "psr/log",
"psr",
"psr-3"
],
"time": "2016-10-10 12:19:37"
"time": "2016-10-10T12:19:37+00:00"
}
],
"packages-dev": [
{
"name": "fuel/docs",
"version": "1.8.0.4",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/fuel/docs.git",
"reference": "4e9d8448fed580ab8e7d59206e99c340387f7dd9"
"reference": "819d65d744ef29cacec96649a6f39be28c854038"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fuel/docs/zipball/4e9d8448fed580ab8e7d59206e99c340387f7dd9",
"reference": "4e9d8448fed580ab8e7d59206e99c340387f7dd9",
"url": "https://api.github.com/repos/fuel/docs/zipball/819d65d744ef29cacec96649a6f39be28c854038",
"reference": "819d65d744ef29cacec96649a6f39be28c854038",
"shasum": ""
},
"require": {
],
"description": "FuelPHP 1.x Documenataion",
"homepage": "https://github.com/fuel/docs",
"time": "2017-01-15 17:46:37"
"time": "2018-04-17T16:29:24+00:00"
}
],
"aliases": [],
fuel/packages/auth/bootstrap.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/acl/driver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
6058
6159
6260
61
6362
6463
6564
6665
6766
68
67
68
6969
7070
7171
7272
73
74
75
76
77
78
7379
7480
7581
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
*/
public static function _parse_conditions($rights)
{
// assime it's already a rights array
if (is_array($rights))
{
return $rights;
}
if ( ! is_string($rights) or strpos($rights, '.') === false)
// no clue what this is?
if ( ! is_string($rights))
{
throw new \InvalidArgumentException('Given rights where not formatted proppery. Formatting should be like area.right or area.[right, other_right]. Received: '.$rights);
}
// deal with only area passed
elseif (strpos($rights, '.') === false)
{
$rights .= ".";
}
list($area, $rights) = explode('.', $rights);
if (substr($rights, 0, 1) == '[' and substr($rights, -1, 1) == ']')
fuel/packages/auth/classes/auth/acl/ormacl.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/acl/simpleacl.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/driver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/exceptions.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/group/driver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/group/ormgroup.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/group/simplegroup.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/login/driver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/login/ormauth.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/auth/login/simpleauth.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
301299
302300
303301
304
305
302
303
306304
307305
308306
......
310308
311309
312310
311
313312
314313
315314
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
throw new \SimpleUserUpdateException('Username cannot be changed.', 5);
}
if (array_key_exists('password', $values))
{
if (!isset($values['force_new_password']))
{
if (!isset($values['force_new_password']))
{
if (empty($values['old_password'])
or $current_values->get('password') != $this->hash_password(trim($values['old_password'])))
throw new \SimpleUserWrongPassword('Old password is invalid');
}
}
$password = trim(strval($values['password']));
if ($password === '')
{
fuel/packages/auth/classes/auth/opauth.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
359357
360358
361359
362
360
361
362
363
364
363365
364366
365367
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
protected function callback()
{
// fetch the response and decode it
$this->response = \Input::get('opauth', false) and $this->response = unserialize(base64_decode($this->response));
if ($this->response = \Input::get('opauth', false))
{
$this->response = base64_decode($this->response);
$this->response = \Str::is_json($this->response) ? json_decode($this->response, true) : unserialize($this->response);
}
// did we receive a response at all?
if ( ! $this->response)
fuel/packages/auth/classes/model/auth/group.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/grouppermission.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/metadata.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/permission.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/provider.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/role.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/rolepermission.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/classes/model/auth/user.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
......
5353
5454
5555
56
56
5757
5858
5959
6060
6161
6262
63
63
6464
6565
6666
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
'default' => 0,
'null' => false,
'form' => array('type' => 'select'),
'validation' => array('required', 'match_pattern' => array('^[1-9]\d*$')),
'validation' => array('required', 'match_pattern' => array('/^[1-9]\d*$/')),
),
'group_id' => array(
'label' => 'auth_model_user.group_id',
'default' => null,
'null' => true,
'form' => array('type' => 'select'),
'validation' => array('match_pattern' => array('^[1-9]\d*$')),
'validation' => array('match_pattern' => array('/^[1-9]\d*$/')),
),
'password' => array(
'label' => 'auth_model_user.password',
fuel/packages/auth/classes/model/auth/userpermission.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/config/auth.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/config/opauth.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/config/ormauth.php
11
22
3
3
44
55
6
6
77
88
9
9
1010
1111
1212
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/config/simpleauth.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/auth/tasks/simple2orm.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/bootstrap.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email/driver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
954952
955953
956954
957
955
958956
959957
958
960959
961960
962
963
964
965
961
966962
967963
968
969
964
970965
971966
972967
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
// we need mbstring for this
if ( ! MBSTRING)
{
throw new \RuntimeException('Email requires the multibyte package ("mbstring") package to be installed!');
throw new \RuntimeException('Email requires the multibyte ("mbstring") package to be installed!');
}
// determine the transfer encoding to be used
$transfer_encoding = ($this->config['encoding'] === 'quoted-printable') ? 'Q' : 'B' ;
// work around possible bugs with encoding by setting the encoding manually
$current_encoding = mb_internal_encoding();
mb_internal_encoding($this->config['charset']);
// encode
$header = mb_encode_mimeheader($header, $this->config['charset'], $transfer_encoding, $this->config['newline']);
mb_internal_encoding($current_encoding);
// and return it
return $header;
}
fuel/packages/email/classes/email/driver/mail.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email/driver/mailgun.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
3533
3634
3735
38
36
3937
4038
4139
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
// Standard required fields
$post_data = array(
'from' => $this->config['from']['email'],
'from' => static::format_addresses(array(array('email' => $this->config['from']['email'], 'name' => $this->config['from']['name']))),
'to' => static::format_addresses($this->to),
'subject' => $this->subject,
'html' => $message['body'],
fuel/packages/email/classes/email/driver/mandrill.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email/driver/noop.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email/driver/sendmail.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/classes/email/driver/smtp.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/email/config/email.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/bootstrap.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/classes/cell.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
231229
232230
233231
234
232
235233
236234
237235
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
$files = $unzip->extract($zip_file, $tmp_folder);
// Grab the first folder out of it (we dont know what it's called)
foreach($pkgfolders = new \GlobIterator($tmp_folder.DS.'*') as $pkgfolder)
foreach(new \GlobIterator($tmp_folder.DS.'*') as $pkgfolder)
{
if ($pkgfolder->isDir())
{
fuel/packages/oil/classes/command.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
236234
237235
238236
239
237
240238
241239
242240
......
333331
334332
335333
336
334
335
336
337
338
339
337340
338341
339342
......
342345
343346
344347
348
345349
346350
347351
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
// Respect the group options
\Cli::option('group') and $command .= ' --group '.\Cli::option('group');
\Cli::option('exclude-group') and $command .= ' --exclude-group '.\Cli::option('exclude-group');
// Respect the testsuite options
\Cli::option('testsuite') and $command .= ' --testsuite '.\Cli::option('testsuite');
protected static function print_exception(\Exception $ex)
{
\Cli::error('Uncaught exception '.get_class($ex).': '.$ex->getMessage());
// create the error message, log and display it
$msg = $ex->getCode().' - '.$ex->getMessage().' in '.$ex->getFile().' on line '.$ex->getLine();
logger(\Fuel::L_ERROR, $msg);
\Cli::error('Uncaught exception '.get_class($ex).': '.$msg);
// print a trace if not in production, don't want to spoil external logging
if (\Fuel::$env != \Fuel::PRODUCTION)
{
\Cli::error('Callstack: ');
\Cli::beep();
\Cli::option('speak') and `say --voice="Trinoids" "{$ex->getMessage()}"`;
// print any previous exception(s) too...
if (($previous = $ex->getPrevious()) != null)
{
\Cli::error('');
fuel/packages/oil/classes/console.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
201199
202200
203201
204
202
205203
206204
207205
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
return false;
}
$kw = preg_split("[^a-z0-9_]i", $code);
$kw = preg_split("/[^a-z0-9_]/i", $code);
foreach ($kw as $i)
{
if (in_array($i, $skip))
fuel/packages/oil/classes/exception.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/classes/generate.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
2927
3028
3129
32
33
34
35
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
3650
3751
52
53
54
3855
3956
4057
......
132149
133150
134151
152
153
154
135155
136156
137157
......
245265
246266
247267
268
269
270
248271
249272
250273
251274
275
276
252277
253278
254279
......
259284
260285
261286
262
287
263288
264289
265290
......
279304
280305
281306
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298307
299
300
308
309
301310
302311
303312
313
314
315
316
304317
305318
306
307
308
319
309320
310321
311322
312323
313
324
325
326
327
328
329
330
314331
315332
316333
317334
318335
336
319337
320338
321339
......
327345
328346
329347
348
330349
331350
332351
......
338357
339358
340359
360
341361
342362
343363
......
347367
348368
349369
370
350371
351372
352373
353374
354375
376
377
355378
356379
357380
......
377400
378401
379402
403
404
380405
381406
382
383
384407
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
408
409
409410
410
411
412
413
414
415
416
417
418
419
420
421
422
411
412
413
414
423415
424
425
416
417
418
419
420
421
422
423
424
425
426
426427
427
428
428429
430
429431
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467432
468433
469434
470435
471436
437
472438
473439
474
475
476
477
478
479
440
441
480442
481
443
482444
483
484
485
486
487
488
489
490
491
445
446
447
448
492449
493
494
495
496
497
498
499
450
451
500452
501453
502454
503
504455
505456
506
457
458
507459
508460
509461
510
462
463
511464
512
513465
514
515466
516467
517
518
519
520
521
468
469
470
522471
523
524472
525
526
527
528
529
530473
531
474
475
476
477
478
532479
480
533481
534482
535
483
484
536485
486
537487
538488
489
490
539491
540492
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
493
494
556495
557
558
559
560
561
562
563
496
497
564498
565499
566500
567501
568502
569
570
503
504
505
571506
572
507
573508
574509
510
511
575512
576513
577
578
579
580
514
515
516
517
581518
582
583
584
585
586
587519
588
520
589521
590
591
522
523
524
525
592526
593527
594
595
596
597
598528
599
529
600530
601
531
532
602533
534
603535
604536
605
606
607
608
609537
610
611
612
613
538
539
540
541
542
543
544
545
546
547
548
549
550
614551
615
616
617
618
619
620552
621553
622554
......
624556
625557
626558
559
627560
628561
629
630
631
632
633562
634
635
636
637
638
563
564
639565
640
566
641567
568
569
570
571
572
573
642574
643
644
645
646575
647
648576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
649591
650592
593
651594
652595
596
597
598
599
600
653601
654
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
655618
656619
657620
621
658622
659623
660624
......
756720
757721
758722
723
724
725
759726
760727
761728
......
806773
807774
808775
776
777
778
809779
810780
811781
......
836806
837807
838808
839
809
840810
841811
842812
......
863833
864834
865835
836
837
838
866839
867840
868841
869842
870843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
871859
872860
873861
......
884872
885873
886874
887
888
889
875
876
890877
891
892
878
879
880
893881
894
895
896
882
883
897884
898
899
900
901
902
903
885
886
904887
905
906
907888
908
909
910
911
889
890
912891
913892
893
894
895
896
914897
915898
916899
......
946929
947930
948931
949
932
950933
951934
952935
......
961944
962945
963946
964
947
965948
966949
967950
......
985968
986969
987970
988
989971
990972
973
991974
992975
993976
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
977
978
979
980
981
982
983
984
1118985
1119
1120
1121
1122
1123
1124
1125
1126
1127
986
987
988
989
990
991
992
993
994
995
996
997
998
1128999
1129
1000
1001
1002
1003
1004
1005
11301006
1131
1132
1133
1134
1135
1136
1137
1138
1007
1008
1009
1010
11391011
11401012
11411013
1142
1014
11431015
11441016
11451017
11461018
1147
1019
11481020
11491021
11501022
......
11821054
11831055
11841056
1057
1058
1059
11851060
11861061
11871062
......
12951170
12961171
12971172
1173
1174
1175
12981176
12991177
13001178
......
13321210
13331211
13341212
1213
1214
1215
13351216
13361217
13371218
......
15441425
15451426
15461427
1547
1428
15481429
15491430
15501431
......
15641445
15651446
15661447
1567
1448
15681449
15691450
15701451
......
16871568
16881569
16891570
1571
1572
1573
16901574
16911575
16921576
......
17171601
17181602
17191603
1604
1605
1606
17201607
17211608
17221609
......
17511638
17521639
17531640
1641
1642
1643
17541644
17551645
17561646
17571647
17581648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
17592008
17602009
2010
2011
2012
17612013
17622014
17632015
......
17702022
17712023
17722024
1773
1774
1775
2025
2026
2027
2028
2029
17762030
1777
1778
1779
1780
1781
17822031
17832032
17842033
1785
2034
17862035
1787
2036
17882037
17892038
17902039
17912040
17922041
2042
2043
2044
17932045
17942046
17952047
......
18112063
18122064
18132065
2066
2067
2068
18142069
18152070
18162071
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
public static $scaffolding = false;
private static $_default_constraints = array(
'varchar' => 255,
'char' => 255,
'int' => 11,
protected static $_field_defaults = array(
'_default_' => array(
'null' => false,
'key' => NULL,
),
'varchar' => array(
'constraint' => '255',
),
'char' => array(
'constraint' => '255',
),
'int' => array(
'constraint' => '11',
),
'decimal' => array(
'constraint' => '10,2',
),
'float' => array(
'constraint' => '10,2',
),
);
/**
*
*/
public static function config($args)
{
$file = strtolower(array_shift($args));
}
}
/**
*
*/
public static function controller($args, $build = true)
{
if ( ! ($name = \Str::lower(array_shift($args))))
$build and static::build();
}
/**
*
*/
public static function model($args, $build = true)
{
$singular = \Inflector::singularize(\Str::lower(array_shift($args)));
$args = static::normalize_args($args);
if (empty($singular) or strpos($singular, ':'))
{
throw new Exception("Command is invalid.".PHP_EOL."\tphp oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..]");
throw new Exception('No fields have been provided, the model will not know how to build the table.');
}
$plural = \Cli::option('singular') ? $singular : \Inflector::pluralize($singular);
$plural = (\Cli::option('singular') or \Cli::option('no-standardisation')) ? $singular : \Inflector::pluralize($singular);
$filename = trim(str_replace(array('_', '-'), DS, $singular), DS);
$base_path = APPPATH;
// Uppercase each part of the class name and remove hyphens
$class_name = \Inflector::classify(str_replace(array('\\', '/'), '_', $singular), false);
// Turn foo:string into "id", "foo",
$properties = implode(",\n\t\t", array_map(function($field) {
// Only take valid fields
if (($field = strstr($field, ':', true)))
{
return "'".$field."'";
}
}, $args));
// Add a comma to the end of the list
$properties = "\n\t\t" . $properties . ",";
$contents = '';
// Generate with test?
$with_test = \Cli::option('with-test');
if ($with_test) {
if ($with_test = \Cli::option('with-test'))
{
static::_create_test('Model', $class_name, $base_path);
}
// storage for the generated contents
$contents = '';
// deal with Model_Crud models first
if (\Cli::option('crud'))
{
// Make sure an id is present
strpos($properties, "'id'") === false and $properties = "'id',".$properties;
// model properties
if ( ! \Cli::option('no-properties'))
{
$contents = <<<CONTENTS
protected static \$_properties = array(
{$properties}
CONTENTS;
foreach ($args as $arg)
{
$contents .= PHP_EOL."\t\t\"".$arg['name']."\",";
}
$contents .= <<<CONTENTS
);
CONTENTS;
}
// created-at field
if($created_at = \Cli::option('created-at'))
{
is_string($created_at) or $created_at = 'created_at';
CONTENTS;
}
// updated-at field
if($updated_at = \Cli::option('updated-at'))
{
is_string($updated_at) or $updated_at = 'updated_at';
CONTENTS;
}
// mysql-timestamp field
if(\Cli::option('mysql-timestamp'))
{
$contents .= <<<CONTENTS
CONTENTS;
}
// table name used by this model
$contents .= <<<CONTENTS
protected static \$_table_name = '{$plural}';
CONTENTS;
// namespace and class definition
if ($module)
{
$model = <<<MODEL
MODEL;
}
}
// ORM models
else
{
$time_type = (\Cli::option('mysql-timestamp')) ? 'timestamp' : 'int';
$no_timestamp_default = false;
if ( \Cli::option('soft-delete'))
{
$deleted_at = \Cli::option('deleted-at', 'deleted_at');
is_string($deleted_at) or $deleted_at = 'deleted_at';
$properties .= "\n\t\t'".$deleted_at."',";
$args = array_merge($args, array($deleted_at.':'.$time_type.':null[1]'));
}
elseif (\Cli::option('temporal'))
{
$temporal_end = \Cli::option('temporal-end', 'temporal_end');
is_string($temporal_end) or $temporal_end = 'temporal_end';
$properties = "\n\t\t'".$temporal_end."'," . $properties;
$args = array_merge(array($temporal_end.':'.$time_type), $args);
$temporal_start = \Cli::option('temporal-start', 'temporal_start');
is_string($temporal_start) or $temporal_start = 'temporal_start';
$properties = "\n\t\t'".$temporal_start."'," . $properties;
$args = array_merge(array($temporal_start.':'.$time_type), $args);
$no_timestamp_default = true;
}
elseif (\Cli::option('nestedset'))
// model properties
if ( ! \Cli::option('no-properties'))
{
$title = \Cli::option('title', false);
if ($title)
{
is_string($title) or $title = 'title';
$properties = "\n\t\t'".$title."'," . $properties;
$args = array_merge(array($title.':varchar[50]'), $args);
}
$tree_id = \Cli::option('tree-id', false);
if ($tree_id)
$contents = <<<CONTENTS
protected static \$_properties = array(
CONTENTS;
foreach ($args as $arg)
{
is_string($tree_id) or $tree_id = 'tree_id';
$properties = "\n\t\t'".$tree_id."'," . $properties;
$contents .= PHP_EOL."\t\t\"".$arg['name']."\" => array(";
$contents .= PHP_EOL."\t\t\t\"label\" => \"".\Inflector::humanize($arg['name'])."\",";
$contents .= PHP_EOL."\t\t\t\"data_type\" => \"".$arg['data_type']."\",";
if (isset($arg['default']))
{
$contents .= PHP_EOL."\t\t\t\"default\" => \"".$arg['default']."\",";
}
if ($arg['data_type'] == 'enum' and isset($arg['options']))
{
$contents .= PHP_EOL."\t\t\t\"options\" => array(".$arg['constraint']."),";
}
$args = array_merge(array($tree_id.':int:unsigned'), $args);
$contents .= PHP_EOL."\t\t),";
}
$contents .= <<<CONTENTS
$right_id = \Cli::option('right-id', 'right_id');
is_string($right_id) or $right_id = 'right_id';
$properties = "\n\t\t'".$right_id."'," . $properties;
$args = array_merge(array($right_id.':int:unsigned'), $args);
$left_id = \Cli::option('left-id', 'left_id');
is_string($left_id) or $left_id = 'left_id';
$properties = "\n\t\t'".$left_id."'," . $properties;
$args = array_merge(array($left_id.':int:unsigned'), $args);
$no_timestamp_default = true;
}
if ( ! \Cli::option('no-timestamp', $no_timestamp_default))
{
$created_at = \Cli::option('created-at', 'created_at');
is_string($created_at) or $created_at = 'created_at';
$properties .= "\n\t\t'".$created_at."',";
$updated_at = \Cli::option('updated-at', 'updated_at');
is_string($updated_at) or $updated_at = 'updated_at';
$properties .= "\n\t\t'".$updated_at."',";
$timestamp_properties = array($created_at.':'.$time_type.':null[1]', $updated_at.':'.$time_type.':null[1]');
$args = array_merge($args, $timestamp_properties);
}
// Make sure an id is present
strpos($properties, "'id'") === false and $properties = "'id',".$properties;
if ( ! \Cli::option('no-properties'))
{
$contents = <<<CONTENTS
protected static \$_properties = array(
{$properties}
);
CONTENTS;
}
// determine the type of timestamp used
$mysql_timestamp = (\Cli::option('mysql-timestamp')) ? 'true' : 'false';
if ( ! \Cli::option('no-timestamp', $no_timestamp_default))
{
if(($created_at = \Cli::option('created-at')) and is_string($created_at))
{
$created_at = <<<CONTENTS
// add date observers if needed
$contents .= <<<CONTENTS
'property' => '$created_at',
protected static \$_observers = array(
CONTENTS;
}
else
{
$created_at = '';
}
if(($updated_at = \Cli::option('updated-at')) and is_string($updated_at))
{
$updated_at = <<<CONTENTS
if ( ! \Cli::option('no-timestamp') and ! \Cli::option('no-standardisation'))
{
$created_at = \Cli::option('created-at', 'created_at');
is_string($created_at) or $created_at = 'created_at';
'property' => '$updated_at',
CONTENTS;
}
else
{
$updated_at = '';
}
$updated_at = \Cli::option('updated-at', 'updated_at');
is_string($updated_at) or $updated_at = 'updated_at';
$contents .= <<<CONTENTS
protected static \$_observers = array(
'Orm\Observer_CreatedAt' => array(
'events' => array('before_insert'),
'mysql_timestamp' => $mysql_timestamp,$created_at
'property' => '$created_at',
'mysql_timestamp' => $mysql_timestamp,
),
'Orm\Observer_UpdatedAt' => array(
'events' => array('before_update'),
'mysql_timestamp' => $mysql_timestamp,$updated_at
'property' => '$updated_at',
'mysql_timestamp' => $mysql_timestamp,
),
);
CONTENTS;
}
if (\Cli::option('soft-delete'))
{
if($deleted_at !== 'deleted_at')
{
$deleted_at = <<<CONTENTS
$contents .= <<<CONTENTS
);
'deleted_field' => '{$deleted_at}',
CONTENTS;
}
else
{
$deleted_at = '';
}
$contents .= <<<CONTENTS
// add fields required for soft-delete models
if (\Cli::option('soft-delete'))
{
$deleted_at = \Cli::option('deleted_at', 'deleted_at');
is_string($deleted_at) or $deleted_at = 'deleted_at';
$contents .= <<<CONTENTS
protected static \$_soft_delete = array(
'mysql_timestamp' => $mysql_timestamp,$deleted_at
'mysql_timestamp' => $mysql_timestamp,
'deleted_field' => '{$deleted_at}',
);
CONTENTS;
}
// add fields required for temporal models
elseif (\Cli::option('temporal'))
{
if($temporal_start !== 'temporal_start')
{
$start_column = <<<CONTENTS
'start_column' => '{$temporal_start}',
CONTENTS;
}
else
{
$start_column = '';
}
if($temporal_end !== 'temporal_end')
{
$end_column = <<<CONTENTS
$temporal_start = \Cli::option('temporal-start', 'temporal_start');
is_string($temporal_start) or $temporal_start = 'temporal_start';
'end_column' => '{$temporal_end}',
CONTENTS;
}
else
{
$end_column = '';
}
$temporal_end = \Cli::option('temporal-end', 'temporal_end');
is_string($temporal_end) or $temporal_end = 'temporal_end';
$contents .= <<<CONTENTS
protected static \$_temporal = array(
'mysql_timestamp' => $mysql_timestamp,$start_column$end_column
);
'mysql_timestamp' => $mysql_timestamp,
'start_column' => '{$temporal_start}',
'end_column' => '{$temporal_end}',
protected static \$_primary_key = array('id', '{$temporal_start}', '{$temporal_end}');
);
CONTENTS;
}
// add fields required for nestedset models
elseif (\Cli::option('nestedset'))
{
if($left_id !== 'left_id')
{
$left_field = <<<CONTENTS
'left_field' => '{$left_id}',
$contents .= <<<CONTENTS
protected static \$_tree = array(
CONTENTS;
}
else
{
$left_field = '';
}
if($right_id !== 'right_id')
if ($title = \Cli::option('title', false))
{
$right_field = <<<CONTENTS
'right_field' => '{$right_id}',
is_string($title) or $title = 'title';
$contents .= <<<CONTENTS
'title_field' => '{$title}',
CONTENTS;
}
else
{
$right_field = '';
}
if($tree_id)
if ($tree_id = \Cli::option('tree-id', false))
{
$tree_field = <<<CONTENTS
is_string($tree_id) or $tree_id = 'tree_id';
$contents .= <<<CONTENTS
'tree_field' => '{$tree_id}',
CONTENTS;
}
else
{
$tree_field = '';
}
if($title)
{
$title_field = <<<CONTENTS
'title_field' => '{$title}',
$left_id = \Cli::option('left-id', 'left_id');
is_string($left_id) or $left_id = 'left_id';
$contents .= <<<CONTENTS
'left_field' => '{$left_id}',
CONTENTS;
$right_id = \Cli::option('right-id', 'right_id');
is_string($right_id) or $right_id = 'right_id';
$contents .= <<<CONTENTS
'right_field' => '{$right_id}',
CONTENTS;
}
else
{
$title_field = '';
}
if($read_only = \Cli::option('read-only') and is_string($read_only))
{
$read_only = "'" . implode("', '", $read_only) . "'";
$read_only = <<<CONTENTS
'read_only' => array($read_only),
CONTENTS;
}
else
{
$read_only = '';
}
if (! empty($left_field) or ! empty($right_field) or ! empty($tree_field) or ! empty($title_field))
{
$fields = array($left_field, $right_field, $tree_field, $title_field, $read_only);
$fields = array_filter($fields);
$fields = implode("\n", $fields);
$contents .= <<<CONTENTS
);
$contents .= <<<CONTENTS
CONTENTS;
}
// database table name
$contents .= <<<CONTENTS
protected static \$_table_name = '{$plural}';
protected static \$_tree = array(
$fields
);
CONTENTS;
}
// primary keys
$keys = array();
foreach($args as $arg)
{
if (isset($arg['indexes']))
{
foreach ($arg['indexes'] as $idx)
{
if ($idx['primary'] === true)
{
$keys[$idx['order']] = $idx['column'];
}
}
}
}
// define the primary keys
$contents .= <<<CONTENTS
protected static \$_primary_key = array('
CONTENTS;
$contents .= implode("', '", $keys);
$contents .= <<<CONTENTS
');
protected static \$_table_name = '{$plural}';
CONTENTS;
// add empty relation structures
$contents .= <<<CONTENTS
protected static \$_has_many = array(
);
protected static \$_many_many = array(
);
protected static \$_has_one = array(
);
protected static \$_belongs_to = array(
);
CONTENTS;
// define the ORM class
$model = '';
if ( \Cli::option('soft-delete'))
{
$build and static::build();
}
/**
*
*/
public static function module($args)
{
if ( ! ($module_name = strtolower(array_shift($args)) ) )
static::$create_folders && static::build();
}
/**
*
*/
public static function views($args, $subfolder, $build = true)
{
$controller = strtolower(array_shift($args));
$subnav = '';
foreach($args as $nav_item)
{
$subnav .= "\t<li class='<?php echo Arr::get(\$subnav, \"{$nav_item}\" ); ?>'><?php echo Html::anchor('{$controller}/{$nav_item}','".\Inflector::humanize($nav_item)."');?></li>\n";
$subnav .= "\t<li class='<?php echo Arr::get(\$subnav, \"{$nav_item}\" ); ?>'><?php echo Html::anchor('{$controller}/{$nav_item}','".\Inflector::humanize($nav_item)."');?></li>".PHP_EOL;
}
foreach ($args as $action)
$build and static::build();
}
/**
*
*/
public static function migration($args, $build = true)
{
// Get the migration name
$migration_name = \Str::lower(str_replace(array('-', '/'), '_', array_shift($args)));
// what type of migration do we have?
$type = explode('_', $migration_name);
// tell the generator not to standardize the fieldlist for these types
if (in_array($type[0], array('add', 'delete', 'rename', 'drop')))
{
\Cli::set_option('no-standardisation', true);
}
// normalize the arguments if needed
if ( ! empty($args))
{
$args = static::normalize_args($args);
}
if (empty($migration_name) or strpos($migration_name, ':'))
{
throw new Exception("Command is invalid.".PHP_EOL."\tphp oil g migration <migrationname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..]");
}
}
$migrations = new \GlobIterator($base_path.'migrations/*_'.$migration_name.'*');
try
$duplicates = array();
foreach($migrations = new \GlobIterator($base_path.'migrations/*_'.$migration_name.'*') as $migration)
{
$duplicates = array();
foreach($migrations as $migration)
// check if it's really a duplicate
$part = explode('_', basename($migration->getFilename(), '.php'), 2);
if ($part[1] != $migration_name)
{
// check if it's really a duplicate
$part = explode('_', basename($migration->getFilename(), '.php'), 2);
if ($part[1] != $migration_name)
$part = substr($part[1], strlen($migration_name)+1);
if ( ! is_numeric($part))
{
$part = substr($part[1], strlen($migration_name)+1);
if ( ! is_numeric($part))
{
// not a numbered suffix, but the same base classname
continue;
}
// not a numbered suffix, but the same base classname
continue;
}
$duplicates[] = $migration->getPathname();
}
}
catch (\LogicException $e)
{
throw new Exception("Unable to read existing migrations. Path does not exist, or you may have an 'open_basedir' defined");
$duplicates[] = $migration->getPathname();
}
// save the migration name, it's also used as table name
$table_name = $migration_name;
// deal with duplicates to make sure the migration name is unique
if (count($duplicates) > 0)
{
// Don't override a file
foreach ($methods as $method_name)
{
// If the miration name starts with the name of the action method
if (substr($migration_name, 0, strlen($method_name)) === $method_name)
if (substr($table_name, 0, strlen($method_name)) === $method_name)
{
/**
*Create an array of the subject the migration is about
*
*/
$subjects = array(false, false);
$matches = explode('_', str_replace($method_name . '_', '', $migration_name));
$matches = explode('_', str_replace($method_name . '_', '', $table_name));
// create_{table}
if (count($matches) == 1)
elseif (count($matches) >= 5 && in_array('to', $matches) && in_array('in', $matches))
{
$subjects = array(
implode('_', array_slice($matches, array_search('in', $matches)+1)),
implode('_', array_slice($matches, 0, array_search('to', $matches))),
implode('_', array_slice($matches, array_search('to', $matches)+1, array_search('in', $matches)-array_search('to', $matches)-1)),
implode('_', array_slice($matches, array_search('in', $matches)+1)),
);
}
// rename_table
elseif ($method_name == 'rename_table')
{
$subjects = array(
implode('_', array_slice($matches, 0, array_search('to', $matches))),
implode('_', array_slice($matches, array_search('to', $matches)+1)),
);
}
// create_{table} or drop_{table} (with underscores in table name)
elseif (count($matches) !== 0)
{
$name = str_replace(array('create_', 'add_', 'drop_', '_to_'), array('create-', 'add-', 'drop-', '-to-'), $migration_name);
if (preg_match('/^(create|drop|add)\-([a-z0-9\_]*)(\-to\-)?([a-z0-9\_]*)?$/i', $name, $deep_matches))
{
switch ($deep_matches[1])
{
case 'create' :
case 'drop' :
$subjects = array(false, $deep_matches[2]);
break;
case 'add' :
$subjects = array($deep_matches[2], $deep_matches[4]);
break;
}
}
}
// There is no subject here so just carry on with a normal empty migration
else
{
break;
}
// We always pass in fields to a migration, so lets sort them out here.
$fields = array();
foreach ($args as $field)
{
$field_array = array();
// Each paramater for a field is seperated by the : character
$parts = explode(":", $field);
// We must have the 'name:type' if nothing else!
if (count($parts) >= 2)
{
$field_array['name'] = array_shift($parts);
foreach ($parts as $part_i => $part)
{
preg_match('/([a-z0-9_-]+)(?:\[([0-9a-z_\-\,\s]+)\])?/i', $part, $part_matches);
array_shift($part_matches);
if (count($part_matches) < 1)
{
// Move onto the next part, something is wrong here...
continue;
}
$option_name = ''; // This is the name of the option to be passed to the action in a field
$option = $part_matches;
// The first option always has to be the field type
if ($part_i == 0)
{
$option_name = 'type';
$type = $option[0];
if ($type === 'string')
{
$type = 'varchar';
}
elseif ($type === 'integer')
{
$type = 'int';
}
if ( ! in_array($type, array('text', 'blob', 'datetime', 'date', 'timestamp', 'time')))
{
if ( ! isset($option[1]) || $option[1] == NULL)
{
if (isset(self::$_default_constraints[$type]))
{
$field_array['constraint'] = self::$_default_constraints[$type];
}
}
else
{
// should support field_name:enum[value1,value2]
if ($type === 'enum')
{
$values = explode(',', $option[1]);
$option[1] = '"'.implode('","', $values).'"';
$field_array['constraint'] = $option[1];
}
// should support field_name:decimal[10,2]
elseif (in_array($type, array('decimal', 'float')))
{
$field_array['constraint'] = $option[1];
}
else
{
$field_array['constraint'] = (int) $option[1];
}
}
}
$option = $type;
}
else
{
// This allows you to put any number of :option or :option[val] into your field and these will...
// ... always be passed through to the action making it really easy to add extra options for a field
$option_name = array_shift($option);
if (count($option) > 0)
{
$option = $option[0];
}
else
{
$option = true;
}
}
// rename_table
elseif ($method_name == 'rename_table')
{
$subjects = array(
implode('_', array_slice($matches, 0, array_search('to', $matches))),
implode('_', array_slice($matches, array_search('to', $matches)+1)),
);
}
// deal with some special cases
switch ($option_name)
{
case 'auto_increment':
case 'null':
case 'unsigned':
$option = (bool) $option;
break;
}
// create_{table} or drop_{table} (with underscores in table name)
elseif (count($matches) !== 0)
{
$name = str_replace(array('create_', 'add_', 'drop_', '_to_'), array('create-', 'add-', 'drop-', '-to-'), $table_name);
if (preg_match('/^(create|drop|add)\-([a-z0-9\_]*)(\-to\-)?([a-z0-9\_]*)?$/i', $name, $deep_matches))
{
switch ($deep_matches[1])
{
case 'create' :
case 'drop' :
$subjects = array(false, $deep_matches[2]);
break;
$field_array[$option_name] = $option;
case 'add' :
$subjects = array($deep_matches[2], $deep_matches[4]);
break;
}
}
}
}
$fields[] = $field_array;
}
else
{
// Invalid field passed in
continue;
}
// There is no subject here so just carry on with a normal empty migration
else
{
break;
}
// Call the magic action which returns an array($up, $down) for the migration
$migration = call_user_func(__NAMESPACE__ . "\Generate_Migration_Actions::{$method_name}", $subjects, $fields);
$migration = call_user_func(__NAMESPACE__ . "\Generate_Migration_Actions::{$method_name}", $subjects, $args);
}
}
// Build the migration
list($up, $down)=$migration;
list($up, $down) = $migration;
// If we don't have any, bail out
if (empty($up) and empty($down))
$build and static::build();
}
/**
*
*/
public static function task($args, $build = true)
{
$build and static::build();
}
/**
*
*/
public static function help()
{
$output = <<<HELP
\Cli::write($output);
}
/**
*
*/
public static function package($args, $build = true)
{
$name = str_replace(array('/', '_', '-'), '', \Str::lower(array_shift($args)));
static::create($path . 'classes' . DS . $name . DS . 'driver.php', $output);
$bootstrap = "\n\t'{$class_name}\\\\{$class_name}_Driver' => __DIR__ . '/classes/{$name}/driver.php',";
$bootstrap = PHP_EOL."\t'{$class_name}\\\\{$class_name}_Driver' => __DIR__ . '/classes/{$name}/driver.php',";
if (is_array($drivers))
{
foreach ($drivers as $driver)
}
CLASS;
$bootstrap .= "\n\t'{$class_name}\\\\{$class_name}_{$driver_name}' => __DIR__ . '/classes/{$name}/{$driver}.php',";
$bootstrap .= PHP_EOL."\t'{$class_name}\\\\{$class_name}_{$driver_name}' => __DIR__ . '/classes/{$name}/{$driver}.php',";
static::create($path . 'classes' . DS . $name . DS . $driver . '.php', $output);
}
}
$build and static::build();
}
/**
*
*/
public static function create($filepath, $contents, $type = 'file')
{
$directory = dirname($filepath);
);
}
/**
*
*/
public static function build()
{
foreach (static::$create_folders as $folder)
return $result;
}
/**
*
*/
public static function class_name($name)
{
return str_replace(array(' ', '-'), '_', ucwords(str_replace('_', ' ', $name)));
}
/**
*
*/
public static function normalize_args(array $args)
{
// normalized result
$normalized = array('id' => null);
// loop over the field names passed
foreach ($args as $field)
{
// check what we got
if (is_array($field))
{
// make sure we have the correct format
if (isset($field['name']))
{
// deal with some generics
if ($field['data_type'] === 'string')
{
$field['data_type'] = 'varchar';
}
elseif ($field['data_type'] === 'integer')
{
$field['data_type'] = 'int';
}
elseif (strpos($field['data_type'], ' unsigned') !== false)
{
$field['data_type'] = explode(' ', $field['data_type']);
$field['data_type'] = $field['data_type'][0];
$field['unsigned'] = true;
}
// deal with some constraint quirks
if (empty($field['constraint']))
{
if (isset($field['display']))
{
$field['constraint'] = $field['display'];
}
elseif (isset($field['numeric_precision']))
{
$field['constraint'] = $field['numeric_precision'].','.$field['numeric_scale'];
}
}
// deal with the different constraint types
if ($field['data_type'] === 'enum' or $field['data_type'] === 'set' )
{
// avoid double quoting
if (strpos($field['constraint'], '"') !== 0)
{
$values = explode(',', $field['constraint']);
$field['constraint'] = '"'.implode('","', $values).'"';
}
}
// should support field_name:decimal[10,2]
elseif (in_array($field['data_type'], array('decimal', 'float', 'double')))
{
// leave as-is
}
// should support any other constraint
elseif (isset($field['constraint']))
{
$field['constraint'] = (int) $field['constraint'];
}
// output from list_columns, we're done here!
$normalized[$field['name']] = $field;
}
}
else
{
// we need to split a field string into components
$field_array = array();
// Each paramater for a field is seperated by the : character
$parts = explode(":", $field);
// We must have the 'name:type' if nothing else!
if (count($parts) >= 2)
{
// make sure we have default values
$field_array = static::$_field_defaults['_default_'];
// extract the field name
$field_array['name'] = array_shift($parts);
// process the remaining parts
foreach ($parts as $part_i => $part)
{
// split the part
preg_match('/([a-z0-9_-]+)(?:\[([0-9a-z_\-\,\s]+)\])?/i', $part, $part_matches);
array_shift($part_matches);
if ( ! count($part_matches))
{
// Move onto the next part, something is wrong here...
continue;
}
// The first option always has to be the field type
if (empty($field_array['data_type']))
{
// determine the field datatype
$type = $part_matches[0];
// deal with some generics
if ($type === 'string')
{
$type = 'varchar';
}
elseif ($type === 'integer')
{
$type = 'int';
}
// add the defaults for this datatype
if (isset(static::$_field_defaults[$type]))
{
$field_array = array_merge(static::$_field_defaults[$type], $field_array);
}
// deal with any field constraints
if (isset($part_matches[1]) and $part_matches[1])
{
// should support field_name:enum[value1,value2] and field_name:set[value1,value2]
if ($type === 'enum' or $type === 'set')
{
$values = explode(',', $part_matches[1]);
$part_matches[1] = '"'.implode('","', $values).'"';
$field_array['constraint'] = $part_matches[1];
}
// should support field_name:decimal[10,2]
elseif (in_array($type, array('decimal', 'float')))
{
$field_array['constraint'] = $part_matches[1];
}
// should support any other constraint
else
{
$field_array['constraint'] = (int) $part_matches[1];
}
}
// so we can add this next
$option = 'data_type';
$part_matches = $type;
}
else
{
// This allows you to put any number of :option or :option[val] into your field and these will...
// ... always be passed through to the action making it really easy to add extra options for a field
$option = array_shift($part_matches);
if (count($part_matches) > 0)
{
$option = $part_matches[0];
}
else
{
$part_matches = true;
}
}
// deal with some special cases
switch ($option)
{
case 'auto_increment':
case 'null':
case 'unsigned':
$part_matches = (bool) $part_matches;
break;
}
$field_array[$option] = $part_matches;
}
$normalized[$field_array['name']] = $field_array;
}
else
{
// Invalid field passed in
continue;
}
}
}
// Check if we have a primary key
$pk = false;
foreach ($args as $arg)
{
if (isset($arg['indexes']))
{
foreach ($arg['indexes'] as $idx)
{
if ($idx['primary'])
{
$pk = true;
break;
}
}
}
}
// keep track of the primary keys added
$pk_counter = 0;
// add a PK if none are present
if ( ! $pk and ! \Cli::option('no-standardisation'))
{
// define the default key column
$normalized['id'] = array('name' => 'id', 'data_type' => 'int', 'unsigned' => true, 'null' => false, 'auto_increment' => true, 'constraint' => '11');
// and it's primary index
$normalized['id']['indexes'] = array('PRIMARY' => array(
'name' => 'PRIMARY', 'column' => 'id', 'order' => strval(++$pk_counter), 'type' => 'BTREE', 'primary' => true, 'unique' => true, 'null' => false, 'ascending' => true,
));
}
elseif ($normalized['id'] === null)
{
// remove the dummy
unset($normalized['id']);
}
// some other optional columns in case of ORM
if ( ! \Cli::option('crud'))
{
$time_type = (\Cli::option('mysql-timestamp')) ? 'timestamp' : 'int';
$no_timestamp_default = false;
// closure used to add a new field
$add_field = function($args, $name, $type, $options = array()) use($pk_counter) {
// create the field
$field = static::$_field_defaults['_default_'];
// add the defaults for this datatype
if (isset(static::$_field_defaults[$type]))
{
$field = array_merge(static::$_field_defaults[$type], $field);
}
// add the data
$field['name'] = $name;
$field['type'] = $type;
$field['data_type'] = $type;
// need to add an index?
if (isset($options['key']))
{
// add a primary key
if ($options['key'] == 'PRI')
{
$field['indexes'] = array('PRIMARY' => array(
'name' => 'PRIMARY', 'column' => $name, 'order' => strval(++$pk_counter), 'type' => 'BTREE', 'primary' => true, 'unique' => true, 'null' => false, 'ascending' => true,
));
}
unset($options['key']);
}
// return the result
return array_merge($args, array($name => array_merge($field, $options)));
};
// additional column for soft-delete models
if ( \Cli::option('soft-delete'))
{
$deleted_at = \Cli::option('deleted-at', 'deleted_at');
is_string($deleted_at) or $deleted_at = 'deleted_at';
if ( ! isset($normalized[$deleted_at]))
{
$normalized = $add_field($normalized, $deleted_at, $time_type, array('null' => true, 'unsigned' => true));
}
}
// additional column for temporal models
elseif (\Cli::option('temporal'))
{
$temporal_start = \Cli::option('temporal-start', 'temporal_start');
is_string($temporal_start) or $temporal_start = 'temporal_start';
if ( ! isset($normalized[$temporal_start]))
{
$normalized = $add_field($normalized, $temporal_start, $time_type, array('key' => 'PRI', 'null' => true, 'unsigned' => true));
}
$temporal_end = \Cli::option('temporal-end', 'temporal_end');
is_string($temporal_end) or $temporal_end = 'temporal_end';
if ( ! isset($normalized[$temporal_end]))
{
$normalized = $add_field($normalized, $temporal_end, $time_type, array('key' => 'PRI', 'null' => true, 'unsigned' => true));
}
\Cli::set_option('no-timestamp', true);
}
// additional columns for nestedset models
elseif (\Cli::option('nestedset'))
{
if ($title = \Cli::option('title', false))
{
is_string($title) or $title = 'title';
if ( ! isset($normalized[$title]))
{
$normalized = $add_field($normalized, $title, 'varchar', array('null' => true, 'constraint' => '50'));
}
}
if ($tree_id = \Cli::option('tree-id', false))
{
is_string($tree_id) or $tree_id = 'tree_id';
if ( ! isset($normalized[$tree_id]))
{
$normalized = $add_field($normalized, $tree_id, 'int', array('constraint' => '11', 'unsigned' => true));
}
}
$left_id = \Cli::option('left-id', 'left_id');
is_string($left_id) or $left_id = 'left_id';
if ( ! isset($normalized[$left_id]))
{
$normalized = $add_field($normalized, $left_id, 'int', array('constraint' => '11', 'unsigned' => true));
}
$right_id = \Cli::option('right-id', 'right_id');
is_string($right_id) or $right_id = 'right_id';
if ( ! isset($normalized[$right_id]))
{
$normalized = $add_field($normalized, $right_id, 'int', array('constraint' => '11', 'unsigned' => true));
}
}
if ( ! \Cli::option('no-timestamp') and ! \Cli::option('no-standardisation'))
{
$created_at = \Cli::option('created-at', 'created_at');
is_string($created_at) or $created_at = 'created_at';
if ( ! isset($normalized[$created_at]))
{
$normalized = $add_field($normalized, $created_at, $time_type, array('null' => true, 'unsigned' => true));
}
$updated_at = \Cli::option('updated-at', 'updated_at');
is_string($updated_at) or $updated_at = 'updated_at';
if ( ! isset($normalized[$updated_at]))
{
$normalized = $add_field($normalized, $updated_at, $time_type, array('null' => true, 'unsigned' => true));
}
}
}
// return the normalized result
return $normalized;
}
// Helper methods
/**
*
*/
private static function _find_migration_number()
{
$base_path = APPPATH;
}
}
$files = new \GlobIterator($base_path .'migrations/*_*.php');
try
foreach(new \GlobIterator($base_path .'migrations/*_*.php') as $file)
{
$migrations[] = $file->getPathname();
}
if ( ! empty($migrations))
{
$migrations = array();
foreach($files as $file)
{
$migrations[] = $file->getPathname();
}
sort($migrations);
list($last) = explode('_', basename(end($migrations)));
}
catch (\LogicException $e)
else
{
throw new Exception("Unable to read existing migrations. Path does not exist, or you may have an 'open_basedir' defined");
$last = 0;
}
return str_pad($last + 1, 3, '0', STR_PAD_LEFT);
}
/**
*
*/
private static function _update_current_version($version)
{
if (is_file($app_path = APPPATH.'config'.DS.'migrations.php'))
static::create($app_path, $contents, 'config');
}
/**
*
*/
private static function _create_test($type, $class_name, $base_path, $nav_item = '')
{
$filepath = $base_path.strtolower('tests'.DS.$type.DS.ucwords($class_name));
fuel/packages/oil/classes/generate/admin.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/classes/generate/migration/actions.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
2119
2220
2321
24
22
2523
2624
2725
26
27
28
29
2830
29
31
32
33
34
35
36
37
38
39
40
41
42
43
3044
3145
32
46
47
48
49
50
51
52
53
54
55
3356
3457
35
36
37
58
59
60
61
62
63
64
3865
39
66
67
4068
41
69
70
71
4272
43
73
74
4475
45
46
76
77
78
79
80
81
4782
48
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
49105
50
106
51107
52108
53109
54
55
56
57
58
110
111
112
113
114
115
116
117
118
119
120
121
59122
60
123
61124
125
62126
127
128
129
130
131
63132
64
65
66
67
133
68134
69135
70
71
72
73
74
75
76
77
78
79
80
136
137
81138
82139
83140
84141
85142
86
87
143
144
145
146
147
148
149
150
151
152
153
88154
89
155
156
157
158
90159
91
160
161
92162
93
163
164
94165
95
166
167
96168
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
169
170
115171
116
172
173
174
117175
118
119
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
120201
121202
122
203
204
123205
124206
125207
......
131213
132214
133215
134
216
135217
136218
137
138
219
220
221
222
223
224
225
226
227
228
229
139230
140
231
232
233
234
235
236
237
238
239
240
141241
142242
143
243
244
245
246
247
248
249
250
251
252
144253
145254
146
147
255
256
257
258
148259
149
260
261
262
150263
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
264
173265
174266
175
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
176285
177286
178
179
287
288
180289
181290
182291
183
184
292
293
185294
186295
187296
188297
189298
190
299
300
301
302
303
304
305
306
307
308
191309
192310
311
312
313
314
193315
194316
195317
196318
319
197320
198321
199322
......
201324
202325
203326
204
205
327
328
329
330
331
332
206333
207
208
209
210
211
334
335
336
337
338
212339
213
340
341
214342
215
343
344
345
346
347
216348
217
218
219
220
221
222
223
224
349
350
351
352
225353
226
227
228
229
230
231
232
233
234
235
236
354
355
356
357
358
359
360
361
362
363
364
237365
238
239
240
241
242
243
366
367
244368
245
246
247
248
249
250
251
252
369
370
371
372
373
253374
254
255
256
375
376
377
378
379
257380
258
259
260
261
262
263
264
381
382
383
384
385
386
387
388
389
390
391
392
393
394
265395
266
267
268396
269
270
271
272
273
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
274422
423
424
425
426
275427
276428
277
278
429
430
279431
432
433
280434
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
* @packageFuel
* @subpackageOil
* @categoryCore
* @authorTom Arnfeld
* @authorTom Arnfeld, Harro Verton
*/
class Generate_Migration_Actions
{
/*****************************************************************************************************
* Each migration action should return an array with two items, 0 being the up and 1 the being down. *
*****************************************************************************************************/
/**
* Each migration action should return an array with two items, 0 being the up and 1 the being down.
*In the methods below, the subjects array contains two elements:
*
*- In a migration named 'create_users' the subject is 'users' since thats what we want to create
*So it would be the second object in the array
*array(false, 'users')
*
*- In a migration named 'add_name_to_users' the object is 'name' and the subject is 'users'.
*So again 'users' would be the second object, but 'name' would be the first
*array('name', 'users')
*
*- In case there are multiple objects, the array can have more objects. The subject will always be
*last. So in a migration name 'rename_fullname_to_lastname_in_users, the array would contain
* array('fullname', 'lastname', 'users')
*/
// create_{tablename}
/**
* Generate the up and down migration code for table creation
*
* oil command: create_{tablename}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function create($subjects, $fields)
{
$field_str = '';
$defined_columns = array();
$have_id = false;
if (count($subjects) != 2)
{
throw new \FuelException('Incorrect number of arguments for "create"');
}
// temp storage
$table_prefix = '';
foreach($fields as $field)
// if we didn't get generated data, take the prefix into account
if ( ! \Cli::option('no-standardisation'))
{
$name = array_shift($field);
$active_db = \Config::get('db.active');
$table_prefix = \Config::get('db.'.$active_db.'.table_prefix');
}
$name === 'id' and $have_id = true;
// generate the code for the fields
list($field_up_str, $not_used, $pks, $idx) = static::_generate_field_string($fields);
$field_opts = array();
foreach($field as $option => $val)
// construct the primary key list
$pk_str = '';
if ($pks)
{
$pk_str = array();
foreach ($pks as $pk)
{
if($val === true)
$pk_str[$pk['order']] = $pk['column'];
}
ksort($pk_str);
$pk_str = ", array('".implode("', '", $pk_str)."')";
}
// generate the up() code
$up = <<<UP
\DBUtil::create_table('{$table_prefix}{$subjects[1]}', array(
$field_up_str
)$pk_str);
UP;
// generate the down() code
$down = '';
if ($idx)
{
// transform the index data
$tidx = array();
foreach ($idx as $idxval)
{
if ( ! isset($tidx[$idxval['name']]))
{
$field_opts[] = "'$option' => true";
$tidx[$idxval['name']] = array((int)$idxval['order'] => $idxval);
}
else
{
if(is_int($val))
{
$field_opts[] = "'$option' => $val";
}
else
$tidx[$idxval['name']][(int)$idxval['order']] = $idxval;
}
}
$up .= PHP_EOL;
foreach ($tidx as $name => $idx)
{
$field = array();
foreach ($idx as $fidx)
{
$fidx['column'] = \DB::quote_identifier($fidx['column']);
if ( ! $fidx['ascending'])
{
$field_opts[] = "'$option' => '$val'";
$fidx['column'] .= ' DESC';
}
$field[] = $fidx['column'];
}
$unique = reset($idx);
$unique = $unique['unique'] ? ' UNUQUE' : '';
$field = implode(', ', $field);
$up .= PHP_EOL."\t\t\\DB::query('CREATE{$unique} INDEX {$name} ON {$table_prefix}{$subjects[1]}({$field})')->execute();";
$down .= PHP_EOL."\t\t\\DB::query('DROP INDEX {$name} ON {$table_prefix}{$subjects[1]}')->execute();";
}
$field_opts = implode(', ', $field_opts);
$field_str .= "\t\t\t'$name' => array({$field_opts}),".PHP_EOL;
$defined_columns[$name] = true;
$down = ltrim($down, PHP_EOL).PHP_EOL.PHP_EOL;
}
// ID Field
$have_id or $field_str = "\t\t\t'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true),".PHP_EOL . $field_str;
$up = <<<UP
\DBUtil::create_table('{$subjects[1]}', array(
$field_str
), array('id'));
UP;
$down = <<<DOWN
\DBUtil::drop_table('{$subjects[1]}');
$down .= <<<DOWN
\DBUtil::drop_table('{$table_prefix}{$subjects[1]}');
DOWN;
return array($up, $down);
}
// add_{thing}_to_{tablename}
public static function add($subjects, $fields, $reverse = false)
/**
* Generate the up and down migration code for table deletion
*
* oil command: drop_{tablename}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function drop($subjects, $fields)
{
$field_up_str = '';
if (count($subjects) != 2)
{
throw new \FuelException('Incorrect number of arguments for "drop"');
}
foreach($fields as $field)
// make sure the table we're about to drop exists
if ( ! \DBUtil::table_exists($subjects[1]))
{
$name = array_shift($field);
throw new \FuelException('Can not generate the migration. The table "'.$subjects[1].'" does not exist');
}
$field_opts = array();
// in case of drop, we don't have field data, so fetch that first
$fields = Generate::normalize_args(\DB::list_columns($subjects[1]));
foreach($field as $option => $val)
{
if($val === true)
{
$field_opts[] = "'$option' => true";
}
else
{
if(is_int($val))
{
$field_opts[] = "'$option' => $val";
}
else
{
$field_opts[] = "'$option' => '$val'";
}
}
}
// same commands as for create
$result = static::create($subjects, $fields);
$field_opts = implode(', ', $field_opts);
// but then in reverse order
return array($result[1], $result[0]);
}
$field_up_str .= "\t\t\t'$name' => array({$field_opts}),".PHP_EOL;
$field_down[] = "\t\t\t'$name'".PHP_EOL;
/**
* Generate the up and down migration code for adding a field to a table
*
* oil command: add_{thing}_to_{tablename}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function add($subjects, $fields)
{
if (count($subjects) != 2)
{
throw new \FuelException('Incorrect number of arguments for "add"');
}
// temp storage
$table_prefix = '';
// if we didn't get generated data, take the prefix into account
if ( ! \Cli::option('no-standardisation'))
{
$active_db = \Config::get('db.active');
$table_prefix = \Config::get('db.'.$active_db.'.table_prefix');
}
$field_down_str = implode(',', $field_down);
// generate the code for the fields
list($field_up_str, $field_down_str, $not_used, $not_used) = static::_generate_field_string($fields);
$up = <<<UP
\DBUtil::add_fields('{$subjects[1]}', array(
$field_down_str
));
DOWN;
return $reverse ? array($down, $up) : array($up, $down);
return array($up, $down);
}
// delete_{thing}_from_{tablename}
public static function delete($subjects, $fields, $reverse = false)
/**
* Generate the up and down migration code for deleting a field from a table
*
* oil command: delete_{thing}_from_{tablename}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function delete($subjects, $fields)
{
return static::add($subjects, $fields, true);
if (count($subjects) != 2)
{
throw new \FuelException('Incorrect number of arguments for "delete"');
}
// same commands as for add
$result = static::add($subjects, $fields);
// but then in reverse order
return array($result[1], $result[0]);
}
// rename_field_{fieldname}_to_{newfieldname}_in_{table}
/**
* Generate the up and down migration code for deleting a field from a table
*
* oil command: rename_field_{fieldname}_to_{newfieldname}_in_{table}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function rename_field($subjects, $fields)
{
$column_list = \DB::list_columns($subjects[0], $subjects[1]);
$column = $column_list[$subjects[1]];
if (count($subjects) != 3)
{
throw new \FuelException('Incorrect number of arguments for "rename_field"');
}
switch ($column['type'])
// make sure the table we're about to rename a field in exists
$table = end($subjects);
if ( ! \DBUtil::table_exists($table))
{
case 'float':
$constraint = '\''.$column['numeric_precision'].', '.$column['numeric_scale'].'\'';
break;
case 'int':
$constraint = $column['display'];
break;
case 'string':
switch ($column['data_type'])
{
case 'binary':
case 'varbinary':
case 'char':
case 'varchar':
$constraint = $column['character_maximum_length'];
break;
case 'enum':
case 'set':
$constraint = '"\''.implode('\',\'', $column['options']).'\'"';
break;
}
break;
throw new \FuelException('Can not generate the migration. The table "'.$table.'" does not exist');
}
$constraint_str = isset($constraint) ? ", 'constraint' => $constraint" : '';
// make sure the old field exists, and the new field doesn't
$column = \DB::list_columns($table, $subjects[1]);
if ( ! empty($column))
{
throw new \FuelException('Can not generate the migration. The field "'.$subjects[1].'" already exists in "'.$table.'"');
}
$column = \DB::list_columns($table, $subjects[0]);
if (empty($column))
{
throw new \FuelException('Can not generate the migration. The field "'.$subjects[0].'" does not exist in "'.$table.'"');
}
// generate the code for the fields
list($field_up_str, $field_down_str, $not_used, $not_used) = static::_generate_field_string($column);
// modify for different dbutil syntax
$field_down_str = str_replace('array(', 'array(\'name\' => \''.$subjects[0].'\', ', str_replace($subjects[0], $subjects[1], $field_up_str));
$field_up_str = str_replace('array(', 'array(\'name\' => \''.$subjects[1].'\', ', $field_up_str);
$up = <<<UP
\DBUtil::modify_fields('{$subjects[0]}', array(
\t\t\t'{$subjects[1]}' => array('name' => '{$subjects[2]}', 'type' => '{$column['data_type']}'$constraint_str)
\DBUtil::modify_fields('{$table}', array(
$field_up_str
));
UP;
$down = <<<DOWN
\DBUtil::modify_fields('{$subjects[0]}', array(
\t\t\t'{$subjects[2]}' => array('name' => '{$subjects[1]}', 'type' => '{$column['data_type']}'$constraint_str)
\DBUtil::modify_fields('{$table}', array(
$field_down_str
));
DOWN;
return array($up, $down);
}
// rename_table_{tablename}_to_{newtablename}
/**
* Generate the up and down migration code for deleting a field from a table
*
* oil command: rename_table_{tablename}_to_{newtablename}
*
* @param array
* @param array
*
* @return array(up, down)
*/
public static function rename_table($subjects, $fields)
{
if (count($subjects) != 2)
{
throw new \FuelException('Incorrect number of arguments for "rename_table"');
}
$up = <<<UP
\DBUtil::rename_table('{$subjects[0]}', '{$subjects[1]}');
UP;
$down = <<<DOWN
\DBUtil::rename_table('{$subjects[1]}', '{$subjects[0]}');
DOWN;
return array($up, $down);
}
// drop_{tablename}
public static function drop($subjects, $fields)
// helpers
/**
* generate the field definitions for up, down, and indexes
*/
protected static function _generate_field_string($fields)
{
$up = <<<UP
\DBUtil::drop_table('{$subjects[1]}');
UP;
$field_str = '';
$column_list = \DB::list_columns($subjects[1]);
// temp vars
$idx = array();
$pks = array();
$field_up_str = '';
$fields_down = array();
foreach ($column_list as $column)
// loop over the fields
foreach($fields as $name => $field)
{
switch ($column['type'])
// storage for the translated field options
$field_opts = array();
// loop over the field options
foreach($field as $option => $val)
{
case 'float':
$constraint = '\''.$column['numeric_precision'].', '.$column['numeric_scale'].'\'';
break;
case 'int':
$constraint = $column['display'];
break;
case 'string':
switch ($column['data_type'])
// deal with index data first
if ($option == 'indexes')
{
foreach ($val as $validx)
{
case 'binary':
case 'varbinary':
case 'char':
case 'varchar':
$constraint = $column['character_maximum_length'];
break;
case 'enum':
case 'set':
$constraint = '"\''.implode('\',\'', $column['options']).'\'"';
break;
// deal with primary indexes
if ($validx['primary'])
{
$pks[] = $validx;
}
// secondary index
else
{
$idx[] = $validx;
}
}
break;
}
$constraint_str = isset($constraint) ? ", 'constraint' => $constraint" : '';
$auto_increment = $column['extra'] == 'auto_increment' ? ", 'auto_increment' => true" : '';
$default_str = $column['default'] != null ? ", 'default' => '{$column['default']}'" : ", 'null' => true";
continue;
}
if ($column['key'] == 'PRI')
{
$primary_keys[] = "'{$column['name']}'";
}
elseif ($column['key'] == 'MUL')
{
$indexes[] = $column['name'];
}
// skip option data from describe not supported by DBUtil::create_table()
if (in_array($option, array('indexes', 'key', 'max', 'min', 'name', 'type', 'ordinal_position', 'display', 'comment', 'privileges', 'collation_name', 'options', 'character_maximum_length', 'numeric_precision', 'numeric_scale', 'exact')))
{
continue;
}
$field_str .= "\t\t\t'{$column['name']}' => array('type' => '{$column['data_type']}'{$default_str}{$constraint_str}{$auto_increment}),".PHP_EOL;
unset($constraint);
}
// skip empty constraints
if ($option == 'constraint' and empty($val))
{
continue;
}
$primary_keys = implode(',', $primary_keys);
$down = <<<DOWN
\DBUtil::create_table('{$subjects[1]}', array(
$field_str
), array($primary_keys));
DOWN;
$down .= PHP_EOL;
// rename options if need be
if ($option == 'data_type')
{
$option = 'type';
}
if ($option == 'extra')
{
if ($val != 'auto_increment')
{
continue;
}
$option = 'auto_increment';
$val = true;
}
$active_db = \Config::get('db.active');
$table_prefix = \Config::get('db.'.$active_db.'.table_prefix');
if (isset($indexes))
{
foreach ($indexes as $field)
{
$down .= "\t\t\\DB::query(\"CREATE INDEX {$field}_idx ON {$table_prefix}{$subjects[1]} (`{$field}`)\")->execute();".PHP_EOL;
// create the options based on the value type
if ($val === true)
{
$field_opts[] = "'$option' => true";
}
elseif ($val === false)
{
$field_opts[] = "'$option' => false";
}
elseif (is_null($val))
{
// skip value
}
elseif (is_int($val))
{
$field_opts[] = "'$option' => $val";
}
elseif (is_array($val))
{
// skip value
}
else
{
$field_opts[] = "'$option' => '$val'";
}
}
$field_opts = implode(', ', $field_opts);
$field_up_str .= "\t\t\t'$name' => array({$field_opts}),".PHP_EOL;
$fields_down[] = "\t\t\t'$name'".PHP_EOL;
}
return array($up, $down);
}
$field_up_str = rtrim($field_up_str, PHP_EOL);
$field_down_str = rtrim(implode(',', $fields_down), PHP_EOL);
return array($field_up_str, $field_down_str, $pks, $idx);
}
}
fuel/packages/oil/classes/generate/scaffold.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
5957
6058
6159
62
63
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
6476
65
77
78
6679
67
80
81
82
83
84
6885
6986
70
71
72
73
74
87
88
89
90
91
92
7593
7694
7795
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
$data['fields'] = array();
foreach (array_slice($args, 1) as $arg)
{
// Parse the argument for each field in a pattern of name:type[constraint]
preg_match(static::$fields_regex, $arg, $matches);
// parse the argument for each field in a pattern of name:type[constraint]
if (is_string($arg))
{
preg_match(static::$fields_regex, $arg, $matches);
if ( ! isset($matches[1]))
{
throw new Exception('Unable to determine the field definition for "'.$arg.'". Ensure they are name:type');
}
$data['fields'][] = array(
'name' => \Str::lower($matches[1]),
'type' => isset($matches[2]) ? $matches[2] : 'string',
'constraint' => isset($matches[4]) ? $matches[4] : null,
);
}
if ( ! isset($matches[1]))
// argument is an array with a column definition
elseif (is_array($arg))
{
throw new Exception('Unable to determine the field definition for "'.$arg.'". Ensure they are name:type');
$data['fields'][] = array(
'name' => $arg['name'],
'type' => $arg['type'],
'constraint' => $arg['constraint'],
);
}
$data['fields'][] = array(
'name' => \Str::lower($matches[1]),
'type' => isset($matches[2]) ? $matches[2] : 'string',
'constraint' => isset($matches[4]) ? $matches[4] : null,
);
// huh?
else
{
// skip it
logger(\Fuel::L_DEBUG, 'Generate_Scaffold::forge(): incorrect argument type passed');
}
}
$name = array_shift($args);
fuel/packages/oil/classes/package.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/classes/refine.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/config/oil.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/oil/phpserver.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
3432
3533
3634
35
3736
3837
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
else
{
// route requests though the normal path
$_SERVER['SCRIPT_NAME'] = __FILE__;
include $_SERVER['DOCUMENT_ROOT'].'/index.php';
}
fuel/packages/oil/tasks/fromdb.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
247245
248246
249247
250
251
252
253
254
255
256
257
258
259
260
261248
262249
263250
......
274261
275262
276263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
277286
278287
279288
......
295304
296305
297306
298
307
299308
300309
301310
302311
303312
304313
305
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
306330
307331
308332
309
333
310334
311335
312
313
314
336
337
315338
316339
317340
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
*/
protected static function arguments($table, $type = 'model')
{
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// construct the arguments list, starting with the table name
switch ($type)
{
$include_timestamps = false;
$timestamp_is_int = true;
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// get the list of indexes from the table
try
{
$indexes = \DB::list_indexes(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// process the columns found
foreach ($columns as $column)
{
// check if we have such a column, and filter out some default values
if (isset($column[$idx]) and ! in_array($column[$idx], array('65535', '4294967295')))
{
$constraint = '['.$column[$idx].']';
$constraint = $column[$idx];
break;
}
}
// if it's an enum column, list the available options
if (in_array($column['data_type'], array('set', 'enum')))
{
$constraint = '['.implode(',', $column['options']).']';
$constraint = implode(',', $column['options']);
}
// store the constraint
$column['constraint'] = $constraint;
// fetch index information
$column['indexes'] = array();
foreach ($indexes as $index)
{
// check if we have an index on the current column
if ($column['name'] == $index['column'])
{
// add the index details for this field
$column['indexes'][$index['name']] = $index;
}
}
// store the column in the argument list
$arguments[] = $column['name'].':'.$column['data_type'].$constraint;
$arguments[$column['name']] = $column;
}
// set the switches for the code generation
\Cli::set_option('no-timestamp', $include_timestamps === false);
\Cli::set_option('mysql-timestamp', $timestamp_is_int === false);
// tell oil not to fiddle with column information
\Cli::set_option('no-standardisation', true);
// return the generated argument list
return $arguments;
fuel/packages/oil/views/admin/orm/actions/index.php
1
2
3
1
2
3
4
5
6
7
8
9
10
11
$data['<?php echo $plural_name ?>'] = Model_<?php echo $model_name; ?>::find('all');
$this->template->title = "<?php echo ucfirst($plural_name); ?>";
$this->template->content = View::forge('<?php echo $view_path; ?>/index', $data);
$query = Model_<?php echo $model_name; ?>::query();
$pagination = Pagination::forge(array(
'total_items' => $query->count(),
'uri_segment' => 'page',
));
$data['<?php echo $plural_name ?>'] = $query->rows_offset($pagination->offset)
->rows_limit($pagination->per_page)
->get();
$this->template->set_global('pagination',$pagination,true);
$this->template->title = "<?php echo ucfirst($plural_name); ?>";
$this->template->content = View::forge('<?php echo $view_path; ?>/index', $data);
fuel/packages/oil/views/admin/orm/views/actions/index.php
2727
2828
2929
30
3031
3132
3233
</td>
</tr>
<?php echo '<?php endforeach; ?>'; ?>
<?php echo $pagination;?>
</tbody>
</table>
fuel/packages/oil/views/admin/template.php
3535
3636
3737
38
39
38
4039
4140
4241
</li>
<?php
$files = new GlobIterator(APPPATH.'classes/controller/admin/*.php');
foreach($files as $file)
foreach(new GlobIterator(APPPATH.'classes/controller/admin/*.php') as $file)
{
$section_segment = $file->getBasename('.php');
$section_title = Inflector::humanize($section_segment);
fuel/packages/orm/bootstrap.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
fuel/packages/orm/classes/belongsto.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
6361
6462
6563
64
6665
67
68
69
70
71
7266
7367
7468
......
10498
10599
106100
101
102
103
104
107105
108106
109107
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
}
$conditions = \Arr::merge($this->conditions, $conditions);
$query->_parse_where_array(\Arr::get($conditions, 'where', array()));
foreach (\Arr::get($conditions, 'where', array()) as $key => $condition)
{
is_array($condition) or $condition = array($key, '=', $condition);
$query->where($condition);
}
return $query->get_one();
}
{
$condition[0] = $alias_to.'.'.$condition[0];
}
if (count($condition) == 2) // From Query::_where()
{
$condition = array($condition[0], '=', $condition[1]);
}
is_string($condition[2]) and $condition[2] = \Db::quote($condition[2], $model['connection']);
$model['join_on'][] = $condition;
fuel/packages/orm/classes/hasmany.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
5755
5856
5957
60
61
62
63
64
65
58
6659
6760
6861
......
111104
112105
113106
107
108
109
110
114111
115112
116113
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.8
* @version 1.8.1
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2016 Fuel Development Team
* @copyright 2010 - 2018 Fuel Development Team
* @link http://fuelphp.com
*/
}
$conditions = \Arr::merge($this->conditions, $conditions);
foreach (\Arr::get($conditions, 'where', array()) as $key => $condition)
{
is_array($condition) or $condition = array($key, '=', $condition);
$query->where($condition);
}
$query->_parse_where_array(\Arr::get($conditions, 'where', array()));
foreach (\Arr::get($conditions, 'order_by', array()) as $field => $direction)
{
{
$condition[0] = $alias_to.'.'.$condition[0];
}
if (count($condition) == 2) // From Query::_where()
{
$condition = array($condition[0], '=', $condition[1]);
}
is_string($condition[2]) and $condition[2] = \Db::quote($condition[2], $model['connection']);
$model['join_on'][] = $condition;
fuel/packages/orm/classes/hasone.php
11
22
3
4
5
3
64
75
8
6
97
108
11
9
1210
1311
1412
......
5957
6058
6159
62
63
64
65
66
67
60
6861
6962
7063
......
10194
10295
10396
97
98
99
100
104101
105102
106103
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel