Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/photo_views.php
Строк: 42
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_photo_photo_views extends VModule_Admin_photo
{
private $poption;
public function __construct()
{
parent::__construct();
$this->poption = array(
'username' => '', 'ip' => '',
'sort' => 'pv.view_date', 'order' => 'DESC', 'display' => 20
);
}
public function render()
{
$views = array();
$pagination = 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'] : 1;
$sql_count = "SELECT COUNT(*) AS total_views
FROM #__photo_views
WHERE photo_id = ".$photo_id;
$views_total = $this->db->get_field($sql_count, 'total_views');
$pagination = VPagination::get($page, $views_total, 20);
$sql = "SELECT pv.*, u.username
FROM #__photo_views AS pv
LEFT JOIN #__user AS u ON (u.user_id = pv.user_id)
WHERE pv.photo_id = ".$photo_id."
ORDER BY pv.view_date DESC
LIMIT ".$pagination['limit'];
$views = $this->db->get_rows($sql);
$tpl = VF::factory('template');
$tpl->menu = 'photo';
$tpl->submenu = 'photo_manage';
$tpl->amenu = 'photo_views';
$tpl->meta_title = 'Admin::Photo::View::Views';
$tpl->photo_id = $photo_id;
$tpl->views = $views;
$tpl->pagination = $pagination;
$tpl->load(array('header', 'photo_views', 'footer'));
$tpl->display();
}
}
?>