Skip to content

Commit

Permalink
Use lot() Function
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Mar 12, 2024
1 parent b5b4779 commit c526692
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion engine/kernel/pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "", '/');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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' => [
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c526692

Please sign in to comment.