From ee10fe5c2134808fff8366ea727ab75cf32affd3 Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Fri, 9 May 2025 14:39:05 +0300 Subject: [PATCH] ghjghj --- app/Controllers/MainController.php | 22 +++- app/Models/Photo.php | 2 +- app/Models/User.php | 2 +- static/js/photo.js | 4 +- .../pages/Comments/{Index.php => Index.latte} | 108 +++++++----------- views/pages/Errors/DB_42000.php | 3 - views/pages/Errors/MethodNotAllowed.php | 26 ----- views/pages/Errors/PublicProblems.latte | 1 - views/pages/Fav.php | 99 ---------------- views/pages/System/Fav.latte | 32 ++++++ views/pages/{ => System}/FavAuthors.php | 0 views/pages/{ => System}/Feed.php | 0 views/pages/{ => System}/Gallery.php | 0 views/pages/{ => System}/Live.php | 0 views/pages/{ => System}/Page.php | 0 .../{Rules.php => System/Rules/Index.php} | 0 .../Rules/Photo.php} | 0 .../Rules/Publication.php} | 0 .../Rules/Video.php} | 0 views/pages/{ => System}/Top30.latte | 0 views/pages/{ => System}/Tour.php | 0 views/pages/{ => System}/Update.php | 0 views/pages/t.php | 0 23 files changed, 93 insertions(+), 206 deletions(-) rename views/pages/Comments/{Index.php => Index.latte} (59%) delete mode 100644 views/pages/Errors/DB_42000.php delete mode 100644 views/pages/Errors/MethodNotAllowed.php delete mode 100644 views/pages/Fav.php create mode 100644 views/pages/System/Fav.latte rename views/pages/{ => System}/FavAuthors.php (100%) rename views/pages/{ => System}/Feed.php (100%) rename views/pages/{ => System}/Gallery.php (100%) rename views/pages/{ => System}/Live.php (100%) rename views/pages/{ => System}/Page.php (100%) rename views/pages/{Rules.php => System/Rules/Index.php} (100%) rename views/pages/{PhotoRules.php => System/Rules/Photo.php} (100%) rename views/pages/{PublicationRules.php => System/Rules/Publication.php} (100%) rename views/pages/{VideoRules.php => System/Rules/Video.php} (100%) rename views/pages/{ => System}/Top30.latte (100%) rename views/pages/{ => System}/Tour.php (100%) rename views/pages/{ => System}/Update.php (100%) delete mode 100644 views/pages/t.php diff --git a/app/Controllers/MainController.php b/app/Controllers/MainController.php index c45e1cd..2061d3c 100644 --- a/app/Controllers/MainController.php +++ b/app/Controllers/MainController.php @@ -8,6 +8,7 @@ use \App\Core\Page; class MainController extends NGController { + private array $params = []; public function t() { $this->render('t'); @@ -53,9 +54,22 @@ class MainController extends NGController { Page::set('Feed'); } - public static function fav() + public function fav() { - Page::set('Fav'); + $photos = DB::query('SELECT * FROM photos_favorite WHERE user_id=:uid ORDER BY id DESC LIMIT 100', array(':uid'=>Auth::userid())); + $preparedData = []; + + foreach ($photos as $p) { + echo $p['posted_at']; + $preparedData[] = [ + 'photo' => new \App\Models\Photo($p['photo_id']), + 'user' => new \App\Models\User($p['user_id']), + 'views' => DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$p['id']))[0]['COUNT(*)'], + 'date' => \App\Services\Date::zmdate($p['posted_at']) + ]; + } + $this->params['photos'] = $preparedData; + $this->render('System/Fav', $this->params); } public static function gallery() { @@ -69,9 +83,9 @@ class MainController extends NGController { Page::set('Errors/EmailVerify'); } - public static function comments() + public function comments() { - Page::set('Comments/Index'); + $this->render('Comments/Index'); } public static function tour() { diff --git a/app/Models/Photo.php b/app/Models/Photo.php index 7c6b90f..e7d1daa 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -5,7 +5,7 @@ use \App\Services\DB; class Photo { public $photoid; - private $photo; + public $photo; function __construct($photo_id) { $this->photoid = $photo_id; $this->photo = DB::query("SELECT * FROM photos WHERE id=:id", array(':id'=>$this->photoid))[0]; diff --git a/app/Models/User.php b/app/Models/User.php index e3bd6e4..0a4aba9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,7 @@ use \App\Services\DB; class User { public $userid; - private $user; + public $user; function __construct($user_id) { $this->userid = $user_id; $this->user = DB::query("SELECT * FROM users WHERE id=:id", array(':id'=>$this->userid))[0]; diff --git a/static/js/photo.js b/static/js/photo.js index fd93de2..819a681 100644 --- a/static/js/photo.js +++ b/static/js/photo.js @@ -209,8 +209,8 @@ $(document).ready(function() $('#favLink').click(function() { const url = window.location.pathname; - const segments = url.split('/'); - const id = segments[segments.length - 1]; + const segments = url.split('/'); + const id = segments[2]; var faved = parseInt($(this).attr('faved')); $(this).html(faved ? 'Добавить фото в Избранное' : 'Удалить фото из Избранного').attr('faved', faved ? 0 : 1); if (!faved) $('.toggle').attr('class', 'toggle on'); diff --git a/views/pages/Comments/Index.php b/views/pages/Comments/Index.latte similarity index 59% rename from views/pages/Comments/Index.php rename to views/pages/Comments/Index.latte index 43c54b3..2e402d2 100644 --- a/views/pages/Comments/Index.php +++ b/views/pages/Comments/Index.latte @@ -1,29 +1,6 @@ - - - - -
- - - - - - - - -
+{layout '..\@layout.latte'}
+{block content}
Лента комментариев- - - i('admin') === 1) { - $admintype = ' · Администратор сервера'; - } else if ($user->i('admin') === 2) { - $admintype = ' · Фотомодератор'; - } - if ((int)Vote::countcommrates($c['id'], -1) >= 1) { - $commclass = 'pro'; - $symb = '+'; - } else if ((int)Vote::countcommrates($c['id'], -1) < 0) { - $commclass = 'con'; - $symb = ''; - } else if ((int)Vote::countcommrates($c['id'], -1) === 0) { - $commclass = ''; - } - echo '
-
+
+ {/foreach}
- Ссылка
+ Ссылка
';
- }
- ?>
-
-
-
+
- '.$user->i('username').' · '.Date::zmdate($c['posted_at']).'
-
Фото: '.Photo::fetchAll($c['user_id']).''.$admintype.'
-
+ {$user->i(username)} · {\App\Services\Date::zmdate($c[posted_at])}
+ Фото: {\App\Models\Photo::fetchAll($c[user_id])}{$admintype}
+
-
-
-
+
+
-
+
–
|
-
Method =Page::method()?> not allowed for this page. Sorry!
- -
- Избранные фотографии- - - Auth::userid())); - foreach ($photos as $p) { - $photo = new Photo($p['photo_id']); - $user = new User($p['user_id']); - echo '
-
'; - } - ?> - - - - - |
- ||