From f5d26107b84bb72b1df426d3a9a79ee973771a25 Mon Sep 17 00:00:00 2001
From: themohooks <81331307+themohooks@users.noreply.github.com>
Date: Sun, 21 Jul 2024 17:28:10 +0300
Subject: [PATCH] load news after creating
---
app/Controllers/Api/Admin/LoadNews.php | 20 ++++++
app/Controllers/ApiController.php | 4 ++
app/Core/Routes.php | 1 +
views/pages/Admin/News.php | 96 ++++++++++++++------------
4 files changed, 78 insertions(+), 43 deletions(-)
create mode 100644 app/Controllers/Api/Admin/LoadNews.php
diff --git a/app/Controllers/Api/Admin/LoadNews.php b/app/Controllers/Api/Admin/LoadNews.php
new file mode 100644
index 0000000..5f00b95
--- /dev/null
+++ b/app/Controllers/Api/Admin/LoadNews.php
@@ -0,0 +1,20 @@
+
' . Date::zmdate($n['time']) . '
' . $n['body'] . '
';
+ }
+ }
+}
diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php
index 2f74dec..c9934b6 100644
--- a/app/Controllers/ApiController.php
+++ b/app/Controllers/ApiController.php
@@ -17,6 +17,7 @@ use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
use \App\Controllers\Api\Profile\Update as ProfileUpdate;
use \App\Controllers\Api\Admin\Images\SetVisibility as AdminPhotoSetVisibility;
use \App\Controllers\Api\Admin\CreateNews as AdminCreateNews;
+use \App\Controllers\Api\Admin\LoadNews as AdminLoadNews;
class ApiController
{
@@ -63,6 +64,9 @@ class ApiController
public static function admincreatenews() {
return new AdminCreateNews();
}
+ public static function adminloadnews() {
+ return new AdminLoadNews();
+ }
}
\ No newline at end of file
diff --git a/app/Core/Routes.php b/app/Core/Routes.php
index 97cf220..e37c9cb 100644
--- a/app/Core/Routes.php
+++ b/app/Core/Routes.php
@@ -56,6 +56,7 @@ class Routes
Router::any('/admin', 'AdminController@index');
Router::any('/api/admin/images/setvisibility', 'ApiController@adminsetvis');
Router::any('/api/admin/createnews', 'ApiController@admincreatenews');
+ Router::any('/api/admin/loadnews', 'ApiController@adminloadnews');
}
Router::get('/logout', 'MainController@logout');
Router::get('/404', 'ExceptionRegister@notfound');
diff --git a/views/pages/Admin/News.php b/views/pages/Admin/News.php
index ebcfa81..dca4463 100644
--- a/views/pages/Admin/News.php
+++ b/views/pages/Admin/News.php
@@ -11,51 +11,61 @@ use \App\Models\User;
Создать
-
-
'.Date::zmdate($n['time']).'
'.$n['body'].'
';
-}
-?>
+
+
' . Date::zmdate($n['time']) . '
' . $n['body'] . '
';
+ }
+ ?>
+
-
\ No newline at end of file
+
+ });
+
+
+ }
+
+ });
+ }
+
\ No newline at end of file