Файл: modules/blog/tag.php
Строк: 59
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_blogs';
$id = @input($_GET['id']);
$title = _t('blog_tags');
include_header($title);
Template::div('title', $title);
if(isset($_GET['id']))
{
if(isset($_GET['type']))
{
$type = ($_GET['type'] == 0 ? 'tags' : ($_GET['type'] == 1 ? 'text' : ($_GET['type'] == 2 ? 'name' : 'tags')));
}
else
{
$type = 'tags';
}
$tags_r = $db->query("SELECT * FROM `blogs` WHERE `".$type."` LIKE '%".$id."%'")->rowCount();
$pages = new Paginator($tags_r, $ames);
if($tags_r == 0)
{
Template::div('error', _t('not_found'));
}
else
{
$tags = $db->query("SELECT * FROM `blogs` WHERE `".$type."` LIKE '%".$id."%' ORDER BY time DESC LIMIT $start, $ames");
foreach($tags as $tag)
{
$tag['name'] = str_replace($id, '<i>'.$id.'</i>', $tag['name']);
echo '<div class="post">
<a href="/blog/note/'.$tag['id'].'"><b>'.$tag['name'].'</b></a> ('.rtime($tag['time']).')<br/>
'.mb_substr($tag['text'], 0, 300).'...<br/>
'._t('blog_tags').': ';
$_tags = explode(',', $tag['tags']);
foreach($_tags as $_tag)
{
$lastTag = $_tags[count($_tags)-1];
if($_tag == $lastTag)
{
echo '<a href="/blog/tag?id='.trim($_tag).'">'.trim($_tag).'</a>';
}
else
{
echo '<a href="/blog/tag?id='.trim($_tag).'">'.trim($_tag).'</a>, ';
}
}
echo '<br/>
<b>'._t('author').'</b>: '.nick($tag['user_id']).' ('.rtime($tag['time']).')
</div>';
}
$pages->view();
}
}
echo '<div class="menu">'. _t('search').':
<form action="/blog/tag" method="get">
<input type="text" name="id"'.(isset($_GET['id']) ? ' value="'.input($_GET['id']).'"' : null).' /><br/>
<select name="type">
<option value="2"'.(isset($_GET['type']) && $_GET['type'] == 2 ? ' selected="selected"' : null).'>'._t('search_by_name').'</option>
<option value="0"'.(isset($_GET['type']) && $_GET['type'] == 0 ? ' selected="selected"' : null).'>'._t('search_by_tags').'</option>
<option value="1"'.(isset($_GET['type']) && $_GET['type'] == 1 ? ' selected="selected"' : null).'>'._t('search_by_text').'</option>
</select>
<input type="submit" value="Go!" />
</form>
</div>';
echo '<div class="block">'.
NAV.' <a href="/blog/">'._t('blogs').'</a><br/>'
.HICO.' <a href="/">'._t('home').'</a>
</div>';
include_footer();