Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/views.php
Строк: 39
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_video_views extends VModule_Admin_video
{
protected $db;
private $voption;
public function __construct()
{
$this->db = &VF::factory('database');
$this->voption = array(
'username' => '', 'ip' => '',
'sort' => 'vh.view_date', 'order' => 'DESC', 'display' => 20
);
}
public function render()
{
$tpl = VF::factory('template');
$views = array();
$video_id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? (int) $_GET['id'] : 0;
$page = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 0;
$categories = $this->get_video_categories();
$this->db->query("SELECT total_views FROM #__video WHERE video_id = ".$video_id." LIMIT 1");
if ($this->db->affected_rows()) {
$views_total = $this->db->fetch_field('total_views');
$pagination = VPagination::get($page, $views_total, 20);
$views = $this->db->get_rows("SELECT vh.*, u.username
FROM #__video_history AS vh
LEFT JOIN #__user AS u ON (u.user_id = vh.user_id)
WHERE vh.video_id = ".$video_id."
ORDER BY vh.view_date DESC
LIMIT ".$pagination['limit']);
$tpl->pagination = $pagination;
}
$tpl->menu = 'video';
$tpl->submenu = 'video_views';
$tpl->meta_title = 'Admin::Video::View::Views';
$tpl->vcfg = VF::cfg('module.video');
$tpl->video_id = $video_id;
$tpl->views = $views;
$tpl->load(array('header', 'video_views', 'footer'));
$tpl->display();
}
private function get_video_categories()
{
return $this->db->get_rows("SELECT cat_id, name FROM #__video_categories ORDER BY name ASC");
}
}
?>