nativegallery/app/Controllers/Api/Images/Comments/Load.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2024-07-05 11:51:14 +03:00
<?php
2024-07-06 09:57:51 +03:00
namespace App\Controllers\Api\Images\Comments;
2024-07-05 11:51:14 +03:00
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
2025-02-09 03:12:54 +03:00
use App\Models\{User, Vote, Comment, Photo};
2024-07-05 11:51:14 +03:00
2024-07-06 09:57:51 +03:00
class Load
2024-07-05 11:51:14 +03:00
{
public function __construct()
{
2024-10-08 21:42:55 +03:00
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid', array(':pid' => explode('/', $_SERVER['REQUEST_URI'])[4]));
2025-02-09 03:12:54 +03:00
$photo = new Photo(explode('/', $_SERVER['REQUEST_URI'])[4]);
2024-09-12 17:28:20 +03:00
$number = 1;
2025-02-09 03:12:54 +03:00
if ((int)$photo->i('pinnedcomment_id') != 0) {
$comm = new Comment(DB::query('SELECT * FROM photos_comments WHERE id=:id', array(':id'=>$photo->i('pinnedcomment_id')))[0]);
$class = 's1';
$comm->class($class);
$number++;
$comm->i();
}
2024-07-05 11:51:14 +03:00
foreach ($comments as $c) {
2024-09-12 17:28:20 +03:00
$comm = new Comment($c);
2025-02-09 03:12:54 +03:00
$photo = new Photo($c['photo_id']);
if ($comm->content('deleted') != 'true' && (int)$photo->i('pinnedcomment_id') != (int)$c['id']) {
2024-10-08 21:42:55 +03:00
if ($number % 2 == 0) {
$class = 's11';
} else {
$class = 's1';
}
$comm->class($class);
$number++;
$comm->i();
2024-09-12 17:28:20 +03:00
}
2024-07-05 11:51:14 +03:00
}
}
}