nativegallery-weryskok/app/Models/Comment.php

66 lines
3.9 KiB
PHP
Raw Permalink Normal View History

2024-07-05 11:51:14 +03:00
<?php
namespace App\Models;
use \App\Services\{DB, Date};
2024-07-06 09:57:51 +03:00
use \App\Models\{User, Photo, Vote};
2024-07-05 11:51:14 +03:00
class Comment {
public $commentid;
public $c;
2024-07-21 16:58:26 +03:00
public $class;
2024-07-05 11:51:14 +03:00
function __construct($user_id) {
$this->c = $user_id;
}
2024-07-21 16:58:26 +03:00
public function class($class) {
$this->class = $class;
}
2024-07-05 11:51:14 +03:00
public function i() {
$user = new User($this->c['user_id']);
2024-07-21 16:58:26 +03:00
echo '<div class="'.$this->class.' comment" wid="'.$this->c['id'].'">
2024-07-05 11:51:14 +03:00
<div style="float:right; text-align:right" class="sm">
<span class="message_date">'.Date::zmdate($this->c['posted_at']).'</span><br>
2024-07-21 16:58:26 +03:00
<a href="#" class="quoteLink dot">Цитировать</a>
·
<a href="#'.$this->c['id'].'" class="cmLink dot">Ссылка</a>
2024-07-05 11:51:14 +03:00
</div>
<a name="2681468"></a><a name="last"></a>
2024-07-10 13:23:05 +03:00
<div><img src="'.$user->i('photourl').'" width="32" style="border-radius: 3px; margin-right: 5px;"><b><a href="/author/'.$this->c['user_id'].'/" class="message_author">'.htmlspecialchars($user->i('username')).'</a></b> &middot;
2024-07-05 15:03:35 +03:00
<span class="flag">';
if (json_decode($user->i('content'), true)['aboutrid']['value'] != null) {
echo '<img src="https://kamenphoto.ru/img/r/'.json_decode($user->i('content'), true)['aboutrid']['value'].'.gif">';
}
if (json_decode($user->i('content'), true)['aboutlive']['value'] != null) {
2024-07-10 13:23:05 +03:00
echo ' '.htmlspecialchars(json_decode($user->i('content'), true)['aboutlive']['value']);
2024-07-05 15:03:35 +03:00
}
2024-07-19 01:04:05 +03:00
if ($user->i('admin') === 1) {
$admintype = ' · Администратор сервера';
} else if ($user->i('admin') === 2) {
$admintype = ' · Фотомодератор';
}
2024-07-06 09:57:51 +03:00
if ((int)Vote::countcommrates($this->c['id'], -1) >= 1) {
$commclass = 'pro';
$symb = '+';
} else if ((int)Vote::countcommrates($this->c['id'], -1) < 0) {
$commclass = 'con';
2024-07-12 00:26:43 +03:00
$symb = '';
2024-07-06 09:57:51 +03:00
} else if ((int)Vote::countcommrates($this->c['id'], -1) === 0) {
$commclass = '';
}
2024-07-05 15:03:35 +03:00
echo '</span></div>
2024-07-19 01:04:05 +03:00
<div class="rank">Фото: '.Photo::fetchAll($this->c['user_id']).' '.$admintype.'</div>
2024-07-10 13:23:05 +03:00
<div class="message-text">'.htmlspecialchars($this->c['body']).'</div>
2024-07-05 11:51:14 +03:00
<div class="comment-votes-block">
<div class="wvote" wid="'.$this->c['id'].'">
2024-07-06 09:57:51 +03:00
<a href="#" vote="1" class="w-btn s2"><span>+</span></a>
2024-07-09 00:00:18 +03:00
<div class="w-rating '.$commclass.' active">'.$symb.Vote::countcommrates($this->c['id'], -1).'</div>
2024-07-05 11:51:14 +03:00
<div class="w-rating-ext">
2024-07-06 09:57:51 +03:00
<div><span class="pro">+'.Vote::countcommrates($this->c['id'], 1).'</span> / <span class="con">'.Vote::countcommrates($this->c['id'], 0).'</span></div>
2024-07-05 11:51:14 +03:00
</div>
2024-07-06 09:57:51 +03:00
<a href="#" vote="0" class="w-btn s5"><span></span></a>
2024-07-05 11:51:14 +03:00
</div>
</div>
</div>';
}
}