This commit is contained in:
themohooks 2025-02-11 20:38:42 +03:00
parent 82888d6e06
commit 558a5cb4c0
4 changed files with 21 additions and 24 deletions

View file

@ -13,20 +13,13 @@ class Load
public function __construct() public function __construct()
{ {
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid', array(':pid' => explode('/', $_SERVER['REQUEST_URI'])[4]));
$photo = new Photo(explode('/', $_SERVER['REQUEST_URI'])[4]); $photo = new Photo(explode('/', $_SERVER['REQUEST_URI'])[4]);
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid ORDER BY CASE WHEN id = :pinnedid THEN 0 ELSE 1 END, id ASC', array(':pid' => explode('/', $_SERVER['REQUEST_URI'])[4], ':pinnedid' => $photo->i('pinnedcomment_id')));
$number = 1; $number = 1;
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();
}
foreach ($comments as $c) { foreach ($comments as $c) {
$comm = new Comment($c); $comm = new Comment($c);
$photo = new Photo($c['photo_id']); $photo = new Photo($c['photo_id']);
if ($comm->content('deleted') != 'true' && (int)$photo->i('pinnedcomment_id') != (int)$c['id']) { if ($comm->content('deleted') != 'true') {
if ($number % 2 == 0) { if ($number % 2 == 0) {
$class = 's11'; $class = 's11';
} else { } else {

View file

@ -78,8 +78,9 @@ const pinComment = (postId) => {
} }
const url = window.location.pathname; const url = window.location.pathname;
const segments = url.split('/'); const segments = url.split('/');
const id = segments[segments.length - 1]; const id = segments[2];
console.log(segments);
$.ajax({ $.ajax({
@ -121,7 +122,7 @@ const editComment = (postId, body, modalid) => {
Notify.noty('success', 'Успешно отредактировано!'); Notify.noty('success', 'Успешно отредактировано!');
const url = window.location.pathname; const url = window.location.pathname;
const segments = url.split('/'); const segments = url.split('/');
const id = segments[segments.length - 1]; const id = segments[2];
$.ajax({ $.ajax({

View file

@ -165,17 +165,20 @@ $(document).ready(function()
var placeElement = document.getElementById('place');
$('#place').autocompleteHL({ if (placeElement) {
minLength: 3, $('#place').autocompleteHL({
source: function(request, response) minLength: 3,
{ source: function(request, response)
var cid = $('#search_cid').val(); {
if (cid != 0) var cid = $('#search_cid').val();
$.getJSON('/api/geodb/search', { place: request.term }, response).fail(function(jx) { alert(jx.responseText); }); if (cid != 0)
else response(null); $.getJSON('/api/geodb/search', { place: request.term }, response).fail(function(jx) { alert(jx.responseText); });
} else response(null);
}); }
});
}
$('#image').click(function() $('#image').click(function()

View file

@ -587,7 +587,7 @@ if ($photo->i('id') !== null) {
<?php <?php
if ($photo->i('moderated') === 1) { if ($photo->i('moderated') === 1) {
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid', array(':pid' => $id)); $comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid ORDER BY CASE WHEN id = :pinnedid THEN 0 ELSE 1 END, id ASC', array(':pid' => $id, ':pinnedid' => $photo->i('pinnedcomment_id')));
$commcount = 0; $commcount = 0;
foreach ($comments as $c) { foreach ($comments as $c) {
if (json_decode($c['content'], true)['deleted'] != 'true') { if (json_decode($c['content'], true)['deleted'] != 'true') {