create-prisma-php-app 4.1.0-beta.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.php +263 -135
- package/dist/index.js +1 -1
- package/dist/prisma-php.js +1 -1
- package/dist/public/js/main.js +1 -2
- package/dist/public/js/pp-reactive-v1.js +1 -42
- package/dist/settings/bs-config.ts +16 -3
- package/dist/settings/vite-plugins/generate-global-types.ts +246 -0
- package/dist/src/Lib/Auth/Auth.php +16 -23
- package/dist/src/app/layout.php +2 -3
- package/dist/ts/main.ts +0 -1
- package/dist/tsconfig.json +1 -1
- package/dist/vite.config.ts +20 -6
- package/package.json +4 -4
- package/dist/public/js/pp-loop.js +0 -1
- package/dist/public/js/pp-portal.js +0 -1
- package/dist/public/js/pp-utilities.js +0 -1
- /package/dist/{src/app → public}/favicon.ico +0 -0
package/dist/bootstrap.php
CHANGED
|
@@ -26,7 +26,6 @@ use PP\CacheHandler;
|
|
|
26
26
|
use PP\ErrorHandler;
|
|
27
27
|
use Firebase\JWT\JWT;
|
|
28
28
|
use Firebase\JWT\Key;
|
|
29
|
-
use PP\PartialRenderer;
|
|
30
29
|
|
|
31
30
|
final class Bootstrap extends RuntimeException
|
|
32
31
|
{
|
|
@@ -40,8 +39,6 @@ final class Bootstrap extends RuntimeException
|
|
|
40
39
|
public static bool $isContentVariableIncluded = false;
|
|
41
40
|
public static bool $secondRequestC69CD = false;
|
|
42
41
|
public static array $requestFilesData = [];
|
|
43
|
-
public static array $partialSelectors = [];
|
|
44
|
-
public static bool $isPartialRequest = false;
|
|
45
42
|
|
|
46
43
|
private string $context;
|
|
47
44
|
|
|
@@ -106,24 +103,20 @@ final class Bootstrap extends RuntimeException
|
|
|
106
103
|
self::authenticateUserToken();
|
|
107
104
|
|
|
108
105
|
self::$requestFilePath = APP_PATH . Request::$pathname;
|
|
109
|
-
self::$parentLayoutPath = APP_PATH . '/layout.php';
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
if (!empty(self::$layoutsToInclude)) {
|
|
108
|
+
self::$parentLayoutPath = self::$layoutsToInclude[0];
|
|
109
|
+
self::$isParentLayout = true;
|
|
110
|
+
} else {
|
|
111
|
+
self::$parentLayoutPath = APP_PATH . '/layout.php';
|
|
112
|
+
self::$isParentLayout = false;
|
|
113
|
+
}
|
|
113
114
|
|
|
114
115
|
self::$isContentVariableIncluded = self::containsChildren(self::$parentLayoutPath);
|
|
115
116
|
if (!self::$isContentVariableIncluded) {
|
|
116
117
|
self::$isContentIncluded = true;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
self::$isPartialRequest =
|
|
120
|
-
!empty(Request::$data['ppSync71163'])
|
|
121
|
-
&& !empty(Request::$data['selectors'])
|
|
122
|
-
&& self::$secondRequestC69CD;
|
|
123
|
-
|
|
124
|
-
if (self::$isPartialRequest) {
|
|
125
|
-
self::$partialSelectors = (array)Request::$data['selectors'];
|
|
126
|
-
}
|
|
127
120
|
self::$requestFilesData = PrismaPHPSettings::$includeFiles;
|
|
128
121
|
|
|
129
122
|
ErrorHandler::checkFatalError();
|
|
@@ -270,60 +263,191 @@ final class Bootstrap extends RuntimeException
|
|
|
270
263
|
}
|
|
271
264
|
}
|
|
272
265
|
|
|
273
|
-
$
|
|
274
|
-
|
|
275
|
-
$
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
266
|
+
$layoutsToInclude = self::collectLayouts($pathname, $groupFolder, $dynamicRoute ?? null);
|
|
267
|
+
} else {
|
|
268
|
+
$includePath = $baseDir . self::getFilePrecedence();
|
|
269
|
+
$layoutsToInclude = self::collectRootLayouts();
|
|
270
|
+
}
|
|
279
271
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
272
|
+
return [
|
|
273
|
+
'path' => $includePath,
|
|
274
|
+
'layouts' => $layoutsToInclude,
|
|
275
|
+
'pathname' => $pathname,
|
|
276
|
+
'uri' => $requestUri
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private static function collectLayouts(string $pathname, ?string $groupFolder, ?string $dynamicRoute): array
|
|
281
|
+
{
|
|
282
|
+
$layoutsToInclude = [];
|
|
283
|
+
$baseDir = APP_PATH;
|
|
284
|
+
|
|
285
|
+
$rootLayout = $baseDir . '/layout.php';
|
|
286
|
+
if (self::fileExistsCached($rootLayout)) {
|
|
287
|
+
$layoutsToInclude[] = $rootLayout;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
$groupName = null;
|
|
291
|
+
$groupParentPath = '';
|
|
292
|
+
$pathAfterGroup = '';
|
|
293
|
+
|
|
294
|
+
if ($groupFolder) {
|
|
295
|
+
$normalizedGroupFolder = str_replace('\\', '/', $groupFolder);
|
|
296
|
+
|
|
297
|
+
if (preg_match('#^\.?/src/app/(.+)/\(([^)]+)\)/(.+)$#', $normalizedGroupFolder, $matches)) {
|
|
298
|
+
$groupParentPath = $matches[1];
|
|
299
|
+
$groupName = $matches[2];
|
|
300
|
+
$pathAfterGroup = dirname($matches[3]);
|
|
301
|
+
if ($pathAfterGroup === '.') {
|
|
302
|
+
$pathAfterGroup = '';
|
|
303
|
+
}
|
|
304
|
+
} elseif (preg_match('#^\.?/src/app/\(([^)]+)\)/(.+)$#', $normalizedGroupFolder, $matches)) {
|
|
305
|
+
$groupName = $matches[1];
|
|
306
|
+
$pathAfterGroup = dirname($matches[2]);
|
|
307
|
+
if ($pathAfterGroup === '.') {
|
|
308
|
+
$pathAfterGroup = '';
|
|
283
309
|
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if ($groupName && $groupParentPath) {
|
|
314
|
+
$currentPath = $baseDir;
|
|
315
|
+
foreach (explode('/', $groupParentPath) as $segment) {
|
|
316
|
+
if (empty($segment)) continue;
|
|
284
317
|
|
|
285
318
|
$currentPath .= '/' . $segment;
|
|
286
319
|
$potentialLayoutPath = $currentPath . '/layout.php';
|
|
320
|
+
|
|
287
321
|
if (self::fileExistsCached($potentialLayoutPath) && !in_array($potentialLayoutPath, $layoutsToInclude, true)) {
|
|
288
322
|
$layoutsToInclude[] = $potentialLayoutPath;
|
|
289
323
|
}
|
|
290
324
|
}
|
|
291
325
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
326
|
+
$groupLayoutPath = $baseDir . '/' . $groupParentPath . "/($groupName)/layout.php";
|
|
327
|
+
if (self::fileExistsCached($groupLayoutPath)) {
|
|
328
|
+
$layoutsToInclude[] = $groupLayoutPath;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (!empty($pathAfterGroup)) {
|
|
332
|
+
$currentPath = $baseDir . '/' . $groupParentPath . "/($groupName)";
|
|
333
|
+
foreach (explode('/', $pathAfterGroup) as $segment) {
|
|
334
|
+
if (empty($segment)) continue;
|
|
335
|
+
|
|
336
|
+
$currentPath .= '/' . $segment;
|
|
337
|
+
$potentialLayoutPath = $currentPath . '/layout.php';
|
|
338
|
+
|
|
339
|
+
if (self::fileExistsCached($potentialLayoutPath) && !in_array($potentialLayoutPath, $layoutsToInclude, true)) {
|
|
340
|
+
$layoutsToInclude[] = $potentialLayoutPath;
|
|
300
341
|
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} elseif ($groupName && !$groupParentPath) {
|
|
345
|
+
$groupLayoutPath = $baseDir . "/($groupName)/layout.php";
|
|
346
|
+
if (self::fileExistsCached($groupLayoutPath)) {
|
|
347
|
+
$layoutsToInclude[] = $groupLayoutPath;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (!empty($pathAfterGroup)) {
|
|
351
|
+
$currentPath = $baseDir . "/($groupName)";
|
|
352
|
+
foreach (explode('/', $pathAfterGroup) as $segment) {
|
|
353
|
+
if (empty($segment)) continue;
|
|
354
|
+
|
|
355
|
+
$currentPath .= '/' . $segment;
|
|
356
|
+
$potentialLayoutPath = $currentPath . '/layout.php';
|
|
301
357
|
|
|
302
|
-
$
|
|
303
|
-
|
|
304
|
-
if (self::fileExistsCached($potentialDynamicRoute) && !in_array($potentialDynamicRoute, $layoutsToInclude, true)) {
|
|
305
|
-
$layoutsToInclude[] = $potentialDynamicRoute;
|
|
358
|
+
if (self::fileExistsCached($potentialLayoutPath) && !in_array($potentialLayoutPath, $layoutsToInclude, true)) {
|
|
359
|
+
$layoutsToInclude[] = $potentialLayoutPath;
|
|
306
360
|
}
|
|
307
361
|
}
|
|
308
362
|
}
|
|
363
|
+
} else {
|
|
364
|
+
$currentPath = $baseDir;
|
|
365
|
+
foreach (explode('/', $pathname) as $segment) {
|
|
366
|
+
if (empty($segment)) continue;
|
|
309
367
|
|
|
310
|
-
|
|
311
|
-
$
|
|
368
|
+
$currentPath .= '/' . $segment;
|
|
369
|
+
$potentialLayoutPath = $currentPath . '/layout.php';
|
|
370
|
+
|
|
371
|
+
if ($potentialLayoutPath === $rootLayout) {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (self::fileExistsCached($potentialLayoutPath) && !in_array($potentialLayoutPath, $layoutsToInclude, true)) {
|
|
376
|
+
$layoutsToInclude[] = $potentialLayoutPath;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (isset($dynamicRoute) && !empty($dynamicRoute)) {
|
|
382
|
+
$currentDynamicPath = $baseDir;
|
|
383
|
+
foreach (explode('/', $dynamicRoute) as $segment) {
|
|
384
|
+
if (empty($segment) || $segment === 'src' || $segment === 'app') {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
$currentDynamicPath .= '/' . $segment;
|
|
389
|
+
$potentialDynamicRoute = $currentDynamicPath . '/layout.php';
|
|
390
|
+
if (self::fileExistsCached($potentialDynamicRoute) && !in_array($potentialDynamicRoute, $layoutsToInclude, true)) {
|
|
391
|
+
$layoutsToInclude[] = $potentialDynamicRoute;
|
|
392
|
+
}
|
|
312
393
|
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (empty($layoutsToInclude)) {
|
|
397
|
+
$layoutsToInclude = self::findFirstGroupLayout();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return $layoutsToInclude;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
private static function collectRootLayouts(): array
|
|
404
|
+
{
|
|
405
|
+
$layoutsToInclude = [];
|
|
406
|
+
$baseDir = APP_PATH;
|
|
407
|
+
$rootLayout = $baseDir . '/layout.php';
|
|
408
|
+
|
|
409
|
+
if (self::fileExistsCached($rootLayout)) {
|
|
410
|
+
$layoutsToInclude[] = $rootLayout;
|
|
313
411
|
} else {
|
|
314
|
-
$
|
|
412
|
+
$layoutsToInclude = self::findFirstGroupLayout();
|
|
413
|
+
|
|
414
|
+
if (empty($layoutsToInclude)) {
|
|
415
|
+
return [];
|
|
416
|
+
}
|
|
315
417
|
}
|
|
316
418
|
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
419
|
+
return $layoutsToInclude;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
private static function findFirstGroupLayout(): array
|
|
423
|
+
{
|
|
424
|
+
$baseDir = APP_PATH;
|
|
425
|
+
$layoutsToInclude = [];
|
|
426
|
+
|
|
427
|
+
if (is_dir($baseDir)) {
|
|
428
|
+
$items = scandir($baseDir);
|
|
429
|
+
foreach ($items as $item) {
|
|
430
|
+
if ($item === '.' || $item === '..') {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (preg_match('/^\([^)]+\)$/', $item)) {
|
|
435
|
+
$groupLayoutPath = $baseDir . '/' . $item . '/layout.php';
|
|
436
|
+
if (self::fileExistsCached($groupLayoutPath)) {
|
|
437
|
+
$layoutsToInclude[] = $groupLayoutPath;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return $layoutsToInclude;
|
|
323
445
|
}
|
|
324
446
|
|
|
325
447
|
private static function getFilePrecedence(): ?string
|
|
326
448
|
{
|
|
449
|
+
$baseDir = APP_PATH;
|
|
450
|
+
|
|
327
451
|
foreach (PrismaPHPSettings::$routeFiles as $route) {
|
|
328
452
|
if (pathinfo($route, PATHINFO_EXTENSION) !== 'php') {
|
|
329
453
|
continue;
|
|
@@ -335,6 +459,27 @@ final class Bootstrap extends RuntimeException
|
|
|
335
459
|
return '/index.php';
|
|
336
460
|
}
|
|
337
461
|
}
|
|
462
|
+
|
|
463
|
+
if (is_dir($baseDir)) {
|
|
464
|
+
$items = scandir($baseDir);
|
|
465
|
+
foreach ($items as $item) {
|
|
466
|
+
if ($item === '.' || $item === '..') {
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (preg_match('/^\([^)]+\)$/', $item)) {
|
|
471
|
+
$groupDir = $baseDir . '/' . $item;
|
|
472
|
+
|
|
473
|
+
if (file_exists($groupDir . '/route.php')) {
|
|
474
|
+
return '/' . $item . '/route.php';
|
|
475
|
+
}
|
|
476
|
+
if (file_exists($groupDir . '/index.php')) {
|
|
477
|
+
return '/' . $item . '/index.php';
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
338
483
|
return null;
|
|
339
484
|
}
|
|
340
485
|
|
|
@@ -424,17 +569,22 @@ final class Bootstrap extends RuntimeException
|
|
|
424
569
|
}
|
|
425
570
|
}
|
|
426
571
|
} elseif (strpos($normalizedRoute, '[...') !== false) {
|
|
427
|
-
|
|
572
|
+
$cleanedRoute = preg_replace('/\(.+\)/', '', $normalizedRoute);
|
|
573
|
+
$cleanedRoute = preg_replace('/\/+/', '/', $cleanedRoute);
|
|
574
|
+
$staticPart = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedRoute);
|
|
575
|
+
$staticSegments = array_filter(explode('/', $staticPart));
|
|
576
|
+
$minRequiredSegments = count($staticSegments);
|
|
577
|
+
|
|
578
|
+
if (count($pathnameSegments) < $minRequiredSegments) {
|
|
428
579
|
continue;
|
|
429
580
|
}
|
|
430
581
|
|
|
431
|
-
$cleanedNormalizedRoute =
|
|
432
|
-
$
|
|
433
|
-
$dynamicSegmentRoute = preg_replace('/\[\.\.\..*?\].*/', '', $cleanedNormalizedRoute);
|
|
582
|
+
$cleanedNormalizedRoute = $cleanedRoute;
|
|
583
|
+
$dynamicSegmentRoute = $staticPart;
|
|
434
584
|
|
|
435
585
|
if (strpos("/src/app/$normalizedPathname", $dynamicSegmentRoute) === 0) {
|
|
436
586
|
$trimmedPathname = str_replace($dynamicSegmentRoute, '', "/src/app/$normalizedPathname");
|
|
437
|
-
$pathnameParts = explode('/', trim($trimmedPathname, '/'));
|
|
587
|
+
$pathnameParts = $trimmedPathname === '' ? [] : explode('/', trim($trimmedPathname, '/'));
|
|
438
588
|
|
|
439
589
|
if (preg_match('/\[\.\.\.(.*?)\]/', $normalizedRoute, $matches)) {
|
|
440
590
|
$dynamicParam = $matches[1];
|
|
@@ -451,18 +601,14 @@ final class Bootstrap extends RuntimeException
|
|
|
451
601
|
|
|
452
602
|
if (strpos($normalizedRoute, 'index.php') !== false) {
|
|
453
603
|
$segmentMatch = "[...$dynamicParam]";
|
|
454
|
-
$index = array_search($segmentMatch, $filteredRouteSegments);
|
|
455
604
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
605
|
+
$dynamicRoutePathname = str_replace($segmentMatch, implode('/', $pathnameParts), $cleanedNormalizedRoute);
|
|
606
|
+
$dynamicRoutePathnameDirname = rtrim(dirname($dynamicRoutePathname), '/');
|
|
607
|
+
$expectedPathname = rtrim("/src/app/$normalizedPathname", '/');
|
|
459
608
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
$pathnameMatch = $normalizedRoute;
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
609
|
+
if ($expectedPathname === $dynamicRoutePathnameDirname) {
|
|
610
|
+
$pathnameMatch = $normalizedRoute;
|
|
611
|
+
break;
|
|
466
612
|
}
|
|
467
613
|
}
|
|
468
614
|
}
|
|
@@ -483,6 +629,7 @@ final class Bootstrap extends RuntimeException
|
|
|
483
629
|
if (pathinfo($route, PATHINFO_EXTENSION) !== 'php') {
|
|
484
630
|
continue;
|
|
485
631
|
}
|
|
632
|
+
|
|
486
633
|
$normalizedRoute = trim(str_replace('\\', '/', $route), '.');
|
|
487
634
|
$cleanedRoute = preg_replace('/\/\([^)]+\)/', '', $normalizedRoute);
|
|
488
635
|
|
|
@@ -494,22 +641,26 @@ final class Bootstrap extends RuntimeException
|
|
|
494
641
|
}
|
|
495
642
|
}
|
|
496
643
|
|
|
497
|
-
|
|
498
|
-
|
|
644
|
+
if (!$bestMatch) {
|
|
645
|
+
foreach (PrismaPHPSettings::$routeFiles as $route) {
|
|
646
|
+
if (pathinfo($route, PATHINFO_EXTENSION) !== 'php') {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
499
649
|
|
|
500
|
-
|
|
501
|
-
{
|
|
502
|
-
$lastSlashPos = strrpos($pathname, '/');
|
|
503
|
-
if ($lastSlashPos === false) {
|
|
504
|
-
return "";
|
|
505
|
-
}
|
|
650
|
+
$normalizedRoute = trim(str_replace('\\', '/', $route), '.');
|
|
506
651
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
652
|
+
if (preg_match('/\/\(([^)]+)\)\//', $normalizedRoute, $matches)) {
|
|
653
|
+
$cleanedRoute = preg_replace('/\/\([^)]+\)/', '', $normalizedRoute);
|
|
654
|
+
|
|
655
|
+
if ($cleanedRoute === $routeFile || $cleanedRoute === $indexFile) {
|
|
656
|
+
$bestMatch = $normalizedRoute;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
510
661
|
}
|
|
511
662
|
|
|
512
|
-
return
|
|
663
|
+
return $bestMatch;
|
|
513
664
|
}
|
|
514
665
|
|
|
515
666
|
private static function singleDynamicRoute($pathnameSegments, $routeSegments)
|
|
@@ -578,7 +729,7 @@ final class Bootstrap extends RuntimeException
|
|
|
578
729
|
}
|
|
579
730
|
}
|
|
580
731
|
|
|
581
|
-
public static function
|
|
732
|
+
public static function containsChildren($filePath): bool
|
|
582
733
|
{
|
|
583
734
|
if (!self::fileExistsCached($filePath)) {
|
|
584
735
|
return false;
|
|
@@ -589,28 +740,31 @@ final class Bootstrap extends RuntimeException
|
|
|
589
740
|
return false;
|
|
590
741
|
}
|
|
591
742
|
|
|
592
|
-
$pattern = '/\<\?=\s*MainLayout::\$
|
|
743
|
+
$pattern = '/\<\?=\s*MainLayout::\$children\s*;?\s*\?>|echo\s*MainLayout::\$children\s*;?/';
|
|
593
744
|
return (bool) preg_match($pattern, $fileContent);
|
|
594
745
|
}
|
|
595
746
|
|
|
596
|
-
private static function
|
|
747
|
+
private static function convertToArrayObject($data)
|
|
597
748
|
{
|
|
598
|
-
if (!
|
|
599
|
-
return
|
|
749
|
+
if (!is_array($data)) {
|
|
750
|
+
return $data;
|
|
600
751
|
}
|
|
601
752
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return false;
|
|
753
|
+
if (empty($data)) {
|
|
754
|
+
return $data;
|
|
605
755
|
}
|
|
606
756
|
|
|
607
|
-
$
|
|
608
|
-
return (bool) preg_match($pattern, $fileContent);
|
|
609
|
-
}
|
|
757
|
+
$isAssoc = array_keys($data) !== range(0, count($data) - 1);
|
|
610
758
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
759
|
+
if ($isAssoc) {
|
|
760
|
+
$obj = new stdClass();
|
|
761
|
+
foreach ($data as $key => $value) {
|
|
762
|
+
$obj->$key = self::convertToArrayObject($value);
|
|
763
|
+
}
|
|
764
|
+
return $obj;
|
|
765
|
+
} else {
|
|
766
|
+
return array_map([self::class, 'convertToArrayObject'], $data);
|
|
767
|
+
}
|
|
614
768
|
}
|
|
615
769
|
|
|
616
770
|
public static function wireCallback(): void
|
|
@@ -989,40 +1143,32 @@ try {
|
|
|
989
1143
|
}
|
|
990
1144
|
|
|
991
1145
|
if (!empty(Bootstrap::$contentToInclude) && !empty(Request::$fileToInclude)) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
MainLayout::$childLayoutChildren = ob_get_clean();
|
|
996
|
-
}
|
|
1146
|
+
ob_start();
|
|
1147
|
+
require_once Bootstrap::$contentToInclude;
|
|
1148
|
+
MainLayout::$children = ob_get_clean();
|
|
997
1149
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
continue;
|
|
1001
|
-
}
|
|
1150
|
+
if (count(Bootstrap::$layoutsToInclude) > 1) {
|
|
1151
|
+
$nestedLayouts = array_slice(Bootstrap::$layoutsToInclude, 1);
|
|
1002
1152
|
|
|
1003
|
-
|
|
1004
|
-
Bootstrap
|
|
1005
|
-
|
|
1153
|
+
foreach (array_reverse($nestedLayouts) as $layoutPath) {
|
|
1154
|
+
if (!Bootstrap::containsChildren($layoutPath)) {
|
|
1155
|
+
Bootstrap::$isChildContentIncluded = true;
|
|
1156
|
+
}
|
|
1006
1157
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1158
|
+
ob_start();
|
|
1159
|
+
require_once $layoutPath;
|
|
1160
|
+
MainLayout::$children = ob_get_clean();
|
|
1161
|
+
}
|
|
1010
1162
|
}
|
|
1011
1163
|
} else {
|
|
1012
1164
|
ob_start();
|
|
1013
1165
|
require_once APP_PATH . '/not-found.php';
|
|
1014
|
-
MainLayout::$
|
|
1166
|
+
MainLayout::$children = ob_get_clean();
|
|
1015
1167
|
|
|
1016
1168
|
http_response_code(404);
|
|
1017
1169
|
CacheHandler::$isCacheable = false;
|
|
1018
1170
|
}
|
|
1019
1171
|
|
|
1020
|
-
if (Bootstrap::$isParentLayout && !empty(Bootstrap::$contentToInclude)) {
|
|
1021
|
-
ob_start();
|
|
1022
|
-
require_once Bootstrap::$contentToInclude;
|
|
1023
|
-
MainLayout::$childLayoutChildren = ob_get_clean();
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
1172
|
if (!Bootstrap::$isContentIncluded && !Bootstrap::$isChildContentIncluded) {
|
|
1027
1173
|
if (!Bootstrap::$secondRequestC69CD) {
|
|
1028
1174
|
Bootstrap::createUpdateRequestData();
|
|
@@ -1034,7 +1180,7 @@ try {
|
|
|
1034
1180
|
if (file_exists($file)) {
|
|
1035
1181
|
ob_start();
|
|
1036
1182
|
require_once $file;
|
|
1037
|
-
MainLayout::$
|
|
1183
|
+
MainLayout::$children .= ob_get_clean();
|
|
1038
1184
|
}
|
|
1039
1185
|
}
|
|
1040
1186
|
}
|
|
@@ -1051,10 +1197,15 @@ try {
|
|
|
1051
1197
|
}
|
|
1052
1198
|
}
|
|
1053
1199
|
|
|
1054
|
-
MainLayout::$children
|
|
1200
|
+
MainLayout::$children .= Bootstrap::getLoadingsFiles();
|
|
1055
1201
|
|
|
1056
1202
|
ob_start();
|
|
1057
|
-
|
|
1203
|
+
if (file_exists(Bootstrap::$parentLayoutPath)) {
|
|
1204
|
+
require_once Bootstrap::$parentLayoutPath;
|
|
1205
|
+
} else {
|
|
1206
|
+
echo MainLayout::$children;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1058
1209
|
MainLayout::$html = ob_get_clean();
|
|
1059
1210
|
MainLayout::$html = TemplateCompiler::compile(MainLayout::$html);
|
|
1060
1211
|
MainLayout::$html = TemplateCompiler::injectDynamicContent(MainLayout::$html);
|
|
@@ -1066,37 +1217,14 @@ try {
|
|
|
1066
1217
|
CacheHandler::saveCache(Request::$decodedUri, MainLayout::$html);
|
|
1067
1218
|
}
|
|
1068
1219
|
|
|
1069
|
-
if (Bootstrap::$isPartialRequest) {
|
|
1070
|
-
$parts = PartialRenderer::extract(
|
|
1071
|
-
MainLayout::$html,
|
|
1072
|
-
Bootstrap::$partialSelectors
|
|
1073
|
-
);
|
|
1074
|
-
|
|
1075
|
-
if (count($parts) === 1) {
|
|
1076
|
-
echo reset($parts);
|
|
1077
|
-
} else {
|
|
1078
|
-
header('Content-Type: application/json');
|
|
1079
|
-
echo json_encode(
|
|
1080
|
-
['success' => true, 'fragments' => $parts],
|
|
1081
|
-
JSON_UNESCAPED_UNICODE
|
|
1082
|
-
);
|
|
1083
|
-
}
|
|
1084
|
-
exit;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
1220
|
echo MainLayout::$html;
|
|
1088
1221
|
} else {
|
|
1089
1222
|
$layoutPath = Bootstrap::$isContentIncluded
|
|
1090
1223
|
? Bootstrap::$parentLayoutPath
|
|
1091
1224
|
: (Bootstrap::$layoutsToInclude[0] ?? '');
|
|
1092
1225
|
|
|
1093
|
-
$message = "The layout file does not contain <?php echo MainLayout::\$
|
|
1094
|
-
$htmlMessage = "<div class='error'>The layout file does not contain <?php echo MainLayout::\$
|
|
1095
|
-
|
|
1096
|
-
if (Bootstrap::$isContentIncluded) {
|
|
1097
|
-
$message = "The parent layout file does not contain <?php echo MainLayout::\$children; ?> Or <?= MainLayout::\$children ?><br><strong>$layoutPath</strong>";
|
|
1098
|
-
$htmlMessage = "<div class='error'>The parent layout file does not contain <?php echo MainLayout::\$children; ?> Or <?= MainLayout::\$children ?><br><strong>$layoutPath</strong></div>";
|
|
1099
|
-
}
|
|
1226
|
+
$message = "The layout file does not contain <?php echo MainLayout::\$children; ?> or <?= MainLayout::\$children ?>\n<strong>$layoutPath</strong>";
|
|
1227
|
+
$htmlMessage = "<div class='error'>The layout file does not contain <?php echo MainLayout::\$children; ?> or <?= MainLayout::\$children ?><br><strong>$layoutPath</strong></div>";
|
|
1100
1228
|
|
|
1101
1229
|
$errorDetails = Bootstrap::isAjaxOrXFileRequestOrRouteFile() ? $message : $htmlMessage;
|
|
1102
1230
|
|