mirror of
https://github.com/claradex/nativegallery.git
synced 2025-02-13 09:43:14 +03:00
fix pin
This commit is contained in:
parent
82888d6e06
commit
558a5cb4c0
4 changed files with 21 additions and 24 deletions
|
@ -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 {
|
||||||
|
|
|
@ -79,7 +79,8 @@ 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({
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,8 @@ $(document).ready(function()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var placeElement = document.getElementById('place');
|
||||||
|
if (placeElement) {
|
||||||
$('#place').autocompleteHL({
|
$('#place').autocompleteHL({
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
source: function(request, response)
|
source: function(request, response)
|
||||||
|
@ -176,6 +177,8 @@ $(document).ready(function()
|
||||||
else response(null);
|
else response(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#image').click(function()
|
$('#image').click(function()
|
||||||
|
|
|
@ -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') {
|
||||||
|
|
Loading…
Reference in a new issue