Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/photo_search.php
Строк: 78
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_photo_search extends VComponent_mobile_photo
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$query  = (isset($_GET['query'])) ? trim($_GET['query']) : null;
        if (!
$query) {
            
$this->notfound();
        }

        
$timelines  = array(
            
'all' => 1,
            
'today' => 1,
            
'yesterday' => 1,
            
'week' => 1,
            
'month' => 1,
            
'year' => 1
        
);

        
$timeline   = (isset($_GET['time'])) ? trim($_GET['time']) : 'all';
        if (!isset(
$timelines[$timeline])) {
            
$this->notfound();
        }

        
$sorts  = array(
            
'relevance' => 1,
            
'added' => 1,
            
'views' => 1,
            
'rating' => 1
        
);

        
$sort   = (isset($_GET['sort'])) ? trim($_GET['sort']) : 'relevance';
        if (!isset(
$sorts[$sort])) {
            
$this->notfound();
        }
        
        
$page       = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;
        
$page_add    = ($page 1) ? ' - '.__('page').' '.$page '';
    
        
$this->search_albums($query$page$sort$timeline);

        
$this->tpl->menu        'photo';
        
$this->tpl->title        __('photo-search-title', array($query)).$page_add;
        
$this->tpl->meta_title    __('photo-search-meta-title', array($query.$page_add$this->mcfg['site_name']));
        
$this->tpl->meta_desc    __('photo-search-meta-desc', array($query.$page_add$this->mcfg['meta_desc']));
        
$this->tpl->meta_keys    __('photo-search-meta-keys', array($this->mcfg['meta_keys']));
        
        
$this->tpl->query        $query;
        
$this->tpl->page        $page;
        
$this->tpl->order        $sort;
        
$this->tpl->timeline    $timeline;
        
$this->tpl->slug        null;
        
        
$this->tpl->canonical   BASE_URL.'/search/photo/'.str_replace(' ''-'$query).'/';
        if (
$page 1) {
            
$this->tpl->canonical   .= $page.'/';
        }
        
        
$this->tpl->load(array('header''photo_search''footer'));
        
$this->tpl->display();
    }
    
    private function 
search_albums($query$page$sort$timeline)
    {
        
$sql_add        null;
        
$today          strtotime('12:00:00');
        if (
$timeline == 'today') {
            
$sql_add    ' AND a.add_time > '.$today;
        } elseif (
$timeline == 'yesterday') {
            
$sql_add    ' AND a.add_time > '.strtotime('-1 day'$today).' AND a.add_time < '.$today;
        } elseif (
$timeline == 'week') {
            
$sql_add    ' AND a.add_time > '.strtotime('this week'time());
        } elseif (
$timeline == 'month') {
            
$sql_add    ' AND a.add_time > '.strtotime('first day of this month'time());
        } elseif (
$timeline == 'year') {
            
$sql_add    ' AND a.add_time > '.strtotime('first day of January'time());
        }

        
$orders            = array(
            
'relevance'    => 'relevance',
            
'added'        => 'a.add_time',
            
'views'        => 'a.total_views',
            
'rating'    => 'a.rating'
        
);    

        
$sql_count  "SELECT COUNT(*) AS total_albums
                       FROM #__photo_albums AS a
                       WHERE MATCH (a.title) AGAINST ('"
.$this->db->escape($query)."')
                       AND a.status = '1'
                       AND a.mobile = '1'"
.$sql_add;
        
$total       $this->db->get_field($sql_count'total_videos');
        
$pagination VPagination::get($page$total$this->mcfg['albums_per_page']);    
        
$sql        "SELECT a.album_id, a.title, a.slug, a.rating, a.rated_by, a.total_views,
                              a.total_photos, a.add_time, a.type, u.username,
                              MATCH (a.title) AGAINST ('"
.$this->db->escape($query)."') AS relevance
                       FROM #__photo_albums AS a
                       LEFT JOIN #__user AS u ON (u.user_id = a.user_id)
                       WHERE MATCH (a.title) AGAINST ('"
.$this->db->escape($query)."')
                       AND a.status = '1'
                       AND a.mobile = '1'"
.$sql_add."
                       ORDER BY "
.$orders[$sort]." DESC
                       LIMIT "
.$pagination['limit'];

        
$this->tpl->pagination  $pagination;
        
$this->tpl->albums      $this->db->get_rows($sql);
        
$this->db->debug();
    }
}

function 
build_search_url($query$page$sort$timeline)
{
    
$url    MOBILE_REL.'/search/photo/?query='.$query;
    if (
$page 1) {
        
$url    .= '&page='.$page;
    }

    if (
$sort != 'all') {
        
$url    .= '&sort='.$sort;
    }

    if (
$timeline != 'all') {
        
$url    .= '&time='.$timeline;
    }

    return 
$url;
}
Онлайн: 1
Реклама