diff --git a/core/bootstrap.php b/core/bootstrap.php
index c7cdbd4..13e0852 100644
--- a/core/bootstrap.php
+++ b/core/bootstrap.php
@@ -7,12 +7,16 @@
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
- /*ob_start(function($buffer) {
- Template::set('CLEAR_CACHE_LINK_NAME', 'Сброс файлового кэша');
- Template::set('ADMIN_PANEL_LINK_NAME', 'Панель администратора');
- Template::set('REFRESH_PAGE_LINK_NAME', 'Перезагрузить страницу');
- return Template::render($buffer);
- });*/
+ ob_start(function($buffer) {
+ try {
+ Template::set('CLEAR_CACHE_LINK_NAME', 'Сброс файлового кэша');
+ Template::set('ADMIN_PANEL_LINK_NAME', 'Панель администратора');
+ Template::set('REFRESH_PAGE_LINK_NAME', 'Перезагрузить страницу');
+ return Template::render($buffer);
+ } catch(Throwable $e) {
+ return $e->getMessage();
+ }
+ });
define('START_TIME', microtime(true)); // засекаем время старта скрипта
define('CORE_LOADED', true); // флаг корректного запуска
diff --git a/core/lib/Core/Helpers/Pagination.class.php b/core/lib/Core/Helpers/Pagination.class.php
new file mode 100644
index 0000000..9d4bb97
--- /dev/null
+++ b/core/lib/Core/Helpers/Pagination.class.php
@@ -0,0 +1,71 @@
+ self::$total_pages) {
+ self::$page = self::$total_pages;
+ }
+ $start = self::$page * self::$limit - self::$limit;
+ $limit = $start . ', ' . self::$limit;
+
+ return $limit;
+
+ }
+
+ /**
+ * Вывод пагинации на страницу
+ *
+ * @param string $paginator_name
+ * @param array $params
+ */
+ public static function show($paginator_name = 'page', $params = []): void
+ {
+ $url = '?';
+ foreach ($params as $key => $value) {
+ $url .= $key . '=' . $value . '&';
+ }
+
+ if (self::$page != 1) {
+ $prevPage = '
‹';
+ } else {
+ $prevPage = '‹';
+ }
+ if (self::$page != self::$total_pages) {
+ $nextPage = '›';
+ } else {
+ $nextPage = '›';
+ }
+ echo '';
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Core/Helpers/SystemFunctions.class.php b/core/lib/Core/Helpers/SystemFunctions.class.php
index d55fa9b..e7bc632 100644
--- a/core/lib/Core/Helpers/SystemFunctions.class.php
+++ b/core/lib/Core/Helpers/SystemFunctions.class.php
@@ -333,9 +333,9 @@
public static function arrayToTable($var, string $title = ''): ?string
{
$tableStyle = 'border: 1px solid #7b9ea3;border-collapse: collapse;';
- $tdBoldStyle = 'padding: 10px;border: 1px solid #7b9ea3;background: powderblue;font-weight: bold; text-align: center;';
+ $tdBoldStyle = 'padding: 10px;border: 1px solid #7b9ea3;background: powderblue;font-weight: bold; text-align: center;color: #226770;text-shadow: #7b9ea3 0px 0px 2px;';
$tdStyle = 'padding: 10px;border: 1px solid #7b9ea3;';
- $thStyle = 'background: #b0e0e6;font-size: 1.3em;padding: 10px;';
+ $thStyle = 'background: #b0e0e6;font-size: 1.3em;padding: 10px;background: linear-gradient(0deg, #b0e0e6, #90c1c7);color: #226770;text-shadow: #7b9ea3 1px 1px 0px;';
if (is_array($var)) {
$table = '';
if ($title) {
diff --git a/index.php b/index.php
index c987ec7..7f5589d 100644
--- a/index.php
+++ b/index.php
@@ -3,9 +3,10 @@
use Core\CoreException;
use Core\ExternalServices\Telegram;
use Core\Models\{User, DB};
- use Core\Helpers\{SystemFunctions, Cache, Log, Mail, Zip};
+ use Core\Helpers\{SystemFunctions, Cache, Log, Mail, Zip, Pagination};
require_once $_SERVER['DOCUMENT_ROOT'] . '/core/bootstrap.php';
+ echo '';
echo '{{ADMIN_PANEL_LINK_NAME}} | {{CLEAR_CACHE_LINK_NAME}} | {{REFRESH_PAGE_LINK_NAME}}
';
@@ -25,13 +26,21 @@
echo SystemFunctions::arrayToTable($user->getAllUserData(), 'Информация о пользователе');
}
+//echo SystemFunctions::arrayToTable(Cache::getCacheInfo(), 'Информация о кэше');
- echo SystemFunctions::arrayToTable(Cache::getCacheInfo(), 'Информация о кэше');
-$arPosts = (DB::getInstance())->query('select * from d_posts where post_type="post" and post_status="publish" order by id desc limit 10');
+
+
+
+$count = (int)(DB::getInstance())->query('select count(*) as count from d_posts where post_type="post" and post_status="publish"')[0]['count'];
+Pagination::execute($_REQUEST['page'], $count, 3);
+$limit = Pagination::getLimit();
+
+$arPosts = (DB::getInstance())->query('select * from d_posts where post_type="post" and post_status="publish" order by id desc limit ' . $limit);
+
$arResult = [];
foreach($arPosts as $post) {
- $arResult[] = [
+ $arResult[$post['ID']] = [
'title' => $post['post_title'],
'postname' => $post['post_name'],
'date' => $post['post_date'],
@@ -40,5 +49,8 @@ foreach($arPosts as $post) {
];
}
+echo '';
echo SystemFunctions::arrayToTable($arResult, 'Статьи');
\ No newline at end of file