diff --git a/engine/kernel/pager.php b/engine/kernel/pager.php index c769b0f..972051a 100644 --- a/engine/kernel/pager.php +++ b/engine/kernel/pager.php @@ -23,7 +23,7 @@ public function __construct(iterable $value = [], string $join = ', ') { } unset($value); $this->chunk = 5; - $this->link = new URL($GLOBALS['url'] ?? '/'); + $this->link = new URL(lot('url') ?? '/'); $this->part = 0; parent::__construct($out, $join); } diff --git a/index.php b/index.php index 6b83367..9dc0613 100755 --- a/index.php +++ b/index.php @@ -8,9 +8,9 @@ function pages(...$lot) { return \Pages::from(...$lot); } // Initialize response variable(s) - $GLOBALS['page'] = new \Page; - $GLOBALS['pager'] = new \Pager; - $GLOBALS['pages'] = new \Pages; + \lot('page', new \Page); + \lot('pager', new \Pager); + \lot('pages', new \Pages); // Set page’s condition data as early as possible, so that other // extension(s) can use it without having to enter the `route` hook $path = \trim($url->path ?? "", '/'); @@ -70,7 +70,7 @@ function route__page($content, $path, $query, $hash) { if (null !== $content) { return $content; } - \extract($GLOBALS, \EXTR_SKIP); + \extract(\lot(), \EXTR_SKIP); $path = \trim($path ?? "", '/'); $route = \trim($state->route ?? 'index', '/'); $folder = \LOT . \D . 'page' . \D . \strtr($path ?: $route, '/', \D); @@ -99,8 +99,8 @@ function route__page($content, $path, $query, $hash) { $deep = $page->deep ?? 0; $sort = $page->sort ?? [1, 'path']; $pages = \Pages::from($folder, 'page', $deep)->sort($sort); - $GLOBALS['page'] = $page; - $GLOBALS['t'][] = $page->title; + \lot('page', $page); + \lot('t')[] = $page->title; \State::set([ 'chunk' => $chunk, // Inherit current page’s `chunk` property 'count' => $count = $pages->count, // Return the total number of page(s) @@ -116,8 +116,8 @@ function route__page($content, $path, $query, $hash) { $pager->hash = $hash; $pager->path = $path ?: $route; $pager->query = $query; - $GLOBALS['pager'] = $pager = $pager->chunk($chunk, $part); - $GLOBALS['pages'] = $pages = $pages->chunk($chunk, $part); + \lot('pager', $pager = $pager->chunk($chunk, $part)); + \lot('pages', $pages = $pages->chunk($chunk, $part)); $count = $pages->count; // Total number of page(s) after chunk \State::set([ 'has' => [ @@ -150,7 +150,7 @@ function route__page($content, $path, $query, $hash) { 'pages' => false ] ]); - $GLOBALS['t'][] = i('Error'); + \lot('t')[] = \i('Error'); return ['page', [], 404]; } \Hook::set('route', __NAMESPACE__ . "\\route", 100);