Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/photo_ratings.php
Строк: 62
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_photo_photo_ratings extends VModule_admin_photo
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$tpl = VF::factory('template');
$errors = array();
$messages = array();
$comments = array();
$photo_id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? (int) $_GET['id'] : 0;
$page = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 0;
if (isset($_POST['submit_reset'])) {
if (isset($_SESSION['search_pratings_options'])) {
unset($_SESSION['search_pratings_options']);
}
}
if (isset($_SESSION['search_pratings_options'])) {
$this->coption = $_SESSION['search_pratings_options'];
}
$this->db->query("SELECT rating FROM #__photo WHERE photo_id = ".$photo_id." LIMIT 1");
if ($this->db->affected_rows()) {
$sql_count = "SELECT COUNT(*) AS total_ratings
FROM #__photo_rating AS r
WHERE r.photo_id = ".$photo_id;
$ratings_total = $this->db->get_field($sql_count, 'total_ratings');
$pagination = VPagination::get($page, $ratings_total, 10);
$sql = "SELECT r.*, u.username
FROM #__photo_rating AS r
LEFT JOIN #__user AS u ON u.user_id = r.voter_id
WHERE r.photo_id = ".$photo_id."
ORDER BY r.add_date DESC
LIMIT ".$pagination['limit'];
$ratings = $this->db->get_rows($sql);
$tpl->pagination = $pagination;
}
$tpl->menu = 'photo';
$tpl->submenu = 'photo_manage';
$tpl->amenu = 'photo_ratings';
$tpl->meta_title = 'Admin::Photo::Ratings';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->photo_id = $photo_id;
$tpl->ratings = $ratings;
$tpl->load(array('header', 'photo_ratings', 'footer'));
$tpl->display();
}
}
?>