mirror of
https://github.com/claradex/nativegallery.git
synced 2025-07-02 22:09:42 +03:00
ghjghj
This commit is contained in:
parent
efbfdb6226
commit
ee10fe5c21
23 changed files with 93 additions and 206 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -1,29 +1,6 @@
|
|||
<?php
|
||||
|
||||
use \App\Services\{Auth, DB, Date};
|
||||
use \App\Models\{User, Photo, Vote};
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="backgr"></div>
|
||||
<table class="tmain">
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
|
||||
<tr>
|
||||
<td class="main">
|
||||
{layout '..\@layout.latte'}
|
||||
{block content}
|
||||
<h1>Лента комментариев</h1>
|
||||
<script src="/js/jquery-ui.js?1633005526"></script>
|
||||
<script src="/js/selector.js?1730197663"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#cname').citySelector('cid', {
|
||||
|
@ -52,58 +29,57 @@ use \App\Models\{User, Photo, Vote};
|
|||
});
|
||||
</script>
|
||||
<div id="upd_anchor"></div>
|
||||
<?php
|
||||
$comments = DB::query('SELECT * FROM photos_comments ORDER BY id DESC LIMIT 30');
|
||||
foreach ($comments as $c) {
|
||||
$user = new User($c['user_id']);
|
||||
$content = json_decode($c['content'], true);
|
||||
$photo = new Photo($c['photo_id']);
|
||||
if ($user->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 '<div class="p-comment p20p">
|
||||
<div class="pc-photo"><a href="/photo/'.$c['photo_id'].'/?top=1" target="_blank" class="prw"><img src="/api/photo/compress?url='.$photo->i('photourl').'" class="f"></a></div>
|
||||
{var $comments = \App\Services\DB::query('SELECT * FROM photos_comments ORDER BY id DESC LIMIT 30')}
|
||||
{foreach $comments as $c}
|
||||
{var $user = new \App\Models\User($c[user_id])}
|
||||
{var $content = json_decode($c[content], true)}
|
||||
{var $photo = new \App\Models\Photo($c[photo_id])}
|
||||
{if $user->i(admin) === 1}
|
||||
{var $admintype = ' · Администратор сервера'}
|
||||
{else}
|
||||
{if $user->i(admin) === 2}
|
||||
{var $admintype = ' · Фотомодератор'}
|
||||
{/if}
|
||||
{/if}
|
||||
{if (int) \App\Models\Vote::countcommrates($c[id], -1) >= 1}
|
||||
{var $commclass = pro}
|
||||
{var $symb = '+'}
|
||||
{else}
|
||||
{if (int) \App\Models\Vote::countcommrates($c[id], -1) < 0}
|
||||
{var $commclass = con}
|
||||
{var $symb = ''}
|
||||
{else}
|
||||
{if (int) \App\Models\Vote::countcommrates($c[id], -1) === 0}
|
||||
{var $commclass = ''}
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="p-comment p20p">
|
||||
<div class="pc-photo"><a href="/photo/{$c[photo_id]}/?top=1" target="_blank" class="prw"><img src="/api/photo/compress?url={$photo->i(photourl)}" class="f"></a></div>
|
||||
<div class="pc-content">
|
||||
<a class="pc-topost" href="/photo/'.$c['photo_id'].'/?top=1#' . $c['id'] . '" target="_blank">Ссылка</a>
|
||||
<a class="pc-topost" href="/photo/{$c[photo_id]}/?top=1#{$c[id]}" target="_blank">Ссылка</a>
|
||||
<div class="pc-text">
|
||||
<div><span class="cmt-aname">
|
||||
<b><a href="/author/'.$c['user_id'].'/">'.$user->i('username').'</a></b></span> · <span class="sm nw">'.Date::zmdate($c['posted_at']).'</span>
|
||||
<div class="rank">Фото: '.Photo::fetchAll($c['user_id']).''.$admintype.'</div>
|
||||
<div class="message-text feed">'.$c['body'].'</div>
|
||||
<b><a href="/author/{$c[user_id]}/">{$user->i(username)}</a></b></span> · <span class="sm nw">{\App\Services\Date::zmdate($c[posted_at])}</span>
|
||||
<div class="rank">Фото: {\App\Models\Photo::fetchAll($c[user_id])}{$admintype}</div>
|
||||
<div class="message-text feed">{$c[body]}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pc-compl">
|
||||
<div class="comment-votes-block">
|
||||
|
||||
<div class="wvote" wid="' . $c['id'] . '">
|
||||
<div class="wvote" wid="{$c[id]}">
|
||||
<a href="#" vote="1" class="w-btn s2"><span>+</span></a>
|
||||
<div class="w-rating '.$commclass.' active">' . $symb . Vote::countcommrates($c['id'], -1) . '</div>
|
||||
<div class="w-rating {$commclass} active">{$symb}{\App\Models\Vote::countcommrates($c[id], -1)}</div>
|
||||
<div class="w-rating-ext">
|
||||
<div><span class="pro">+' . Vote::countcommrates($c['id'], 1) . '</span> / <span class="con">' . Vote::countcommrates($c['id'], 0) . '</span></div>
|
||||
<div><span class="pro">+{\App\Models\Vote::countcommrates($c[id], 1)}</span> / <span class="con">{\App\Models\Vote::countcommrates($c[id], 0)}</span></div>
|
||||
</div>
|
||||
<a href="#" vote="0" class="w-btn s5"><span>–</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
{/foreach}
|
||||
<div id="scroll_anchor"></div>
|
||||
<script src="/js/endless.js?031021"></script>
|
||||
<script>
|
||||
|
@ -158,10 +134,4 @@ use \App\Models\{User, Photo, Vote};
|
|||
</script>
|
||||
<div id="loader-anchor"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
{/block}
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
header("HTTP/1.1 503 Service Unavailable");
|
||||
?>
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
use App\Core\Page;
|
||||
?>
|
||||
|
||||
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></audio></button></canvas></datalist></details></dialog></iframe></listing></meter></noembed></noframes></noscript></optgroup></option></progress></rp></select></table></template></title></video>
|
||||
<meta charset="utf-8">
|
||||
<meta name=robots content=noindex>
|
||||
<title>Server Error</title>
|
||||
|
||||
<style>
|
||||
#tracy-error { all: initial; position: absolute; top: 0; left: 0; right: 0; height: 70vh; min-height: 400px; display: flex; align-items: center; justify-content: center; z-index: 1000 }
|
||||
#tracy-error div { all: initial; max-width: 550px; background: white; color: #333; display: block }
|
||||
#tracy-error h1 { all: initial; font: bold 50px/1.1 sans-serif; display: block; margin: 40px }
|
||||
#tracy-error p { all: initial; font: 20px/1.4 sans-serif; margin: 40px; display: block }
|
||||
#tracy-error small { color: gray }
|
||||
#tracy-error small span { color: silver }
|
||||
</style>
|
||||
|
||||
<div id=tracy-error>
|
||||
<div>
|
||||
<h1>Server Error</h1>
|
||||
|
||||
<p>Method <?=Page::method()?> not allowed for this page. Sorry!</p>
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,4 @@
|
|||
{layout '..\@layout.latte'}
|
||||
{var $photo = new \App\Models\Photo($photo_id)}
|
||||
{block content}
|
||||
<h1>Произошла ошибка</h1>
|
||||
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
|
||||
use App\Services\{DB, Auth, Date, Json};
|
||||
use App\Models\{User, Vote, Comment, Photo};
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<style>
|
||||
.ix-country {
|
||||
padding-top: 3px;
|
||||
white-space: nowrap;
|
||||
font-family: var(--narrow-font);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.ix-country>a>b {
|
||||
border-bottom: dotted 1px;
|
||||
}
|
||||
|
||||
.ix-cities {
|
||||
padding: 5px 0 15px 15px;
|
||||
}
|
||||
|
||||
.ix-arrow {
|
||||
display: inline-block;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
background: url("/img/arrow_blue.png") no-repeat;
|
||||
transition: transform .1s ease-out;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.ix-arrow.ix-arrow-expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="backgr"></div>
|
||||
<table class="tmain">
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
|
||||
<tr>
|
||||
<td class="main">
|
||||
<h1>Избранные фотографии</h1>
|
||||
|
||||
|
||||
<?php
|
||||
$photos = DB::query('SELECT * FROM photos_favorite WHERE user_id=:uid ORDER BY id DESC LIMIT 100', array(':uid'=>Auth::userid()));
|
||||
foreach ($photos as $p) {
|
||||
$photo = new Photo($p['photo_id']);
|
||||
$user = new User($p['user_id']);
|
||||
echo ' <div class="p20p" style="padding:0 5px">
|
||||
<table>
|
||||
<tr>
|
||||
|
||||
<td class="pb_photo" id="p2017137"><a href="/photo/'.$photo->i('id').'" target="_blank" class="prw"><img class="f" src="/api/photo/compress?url=' . $photo->i('photourl') . '" alt="598 КБ">
|
||||
<div class="hpshade">
|
||||
<div class="eye-icon">'.DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$photo->i('id')))[0]['COUNT(*)'].'</div>
|
||||
</div>
|
||||
</a></td>
|
||||
<td class="pb_descr">
|
||||
<p>'.htmlspecialchars($photo->i('postbody')).'</p>
|
||||
<p><b class="pw-place">'.htmlspecialchars($photo->i('place')).'</b></p>
|
||||
<p class="sm"><b>'.Date::zmdate($photo->i('posted_at')).'</b><br>Автор: <a href="/author/'.$photo->i('user_id').'/">'.$user->i('username').'</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><br>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<div id="scroll_anchor"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
32
views/pages/System/Fav.latte
Normal file
32
views/pages/System/Fav.latte
Normal file
|
@ -0,0 +1,32 @@
|
|||
{layout '..\@layout.latte'}
|
||||
|
||||
{block content}
|
||||
<h1>Избранные фотографии</h1>
|
||||
{dump $photos}
|
||||
{foreach $photos as $p}
|
||||
{dump $p['photo']->photo['photourl']}
|
||||
<div class="p20p" style="padding:0 5px">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="pb_photo" id="p{$p['photo']->photo['id']}">
|
||||
<a href="/photo/{$p['photo']->photo['id']}" target="_blank" class="prw">
|
||||
<img class="f" src="/api/photo/compress?url={$p['photo']->photo['photourl']}" alt="598 КБ">
|
||||
<div class="hpshade">
|
||||
<div class="eye-icon">{$p['photo']->photo['views']}</div>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
<td class="pb_descr">
|
||||
<p>{$p['photo']->photo['postbody']|noescape}</p>
|
||||
<p><b class="pw-place">{$p['photo']->photo['place']|noescape}</b></p>
|
||||
<p class="sm">
|
||||
<b>{$p->date}</b><br>
|
||||
Автор: <a href="/author/{$p['user']->user['id']}/">{$p['user']->user['username']}</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
{/foreach}
|
||||
{/block}
|
Loading…
Reference in a new issue