get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_profiles WHERE id=".$profileid); $query = "SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE published=1"; if( isset($_GET['slg']) ) { $slug = $_GET['slg']; $query .= " AND slug!='$slug'"; } if($catid) { $gallery = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_categories WHERE id=".$catid); $query .= " AND category='$gallery->name'"; $arr_params['catid'] = $gallery->slug; } $arr_params['sort'] = $sort; switch($sort) { case 'latest' : $query .= ' ORDER BY id DESC'; break; case 'popular' : $query .= ' ORDER BY hits DESC'; break; case 'random' : $query .= ' ORDER BY RAND()'; break; case 'featured' : $query .= ' AND featured=1 ORDER BY ordering'; break; default : $query .= ' ORDER BY ordering'; unset( $arr_params['sort'] ); break; } $videos = $wpdb->get_results($query); $custid = ( $profile->custom_gallery_id ) ? $profile->custom_gallery_id : 'avs_gallery'; $custpage = ( $profile->custom_page_url ) ? $profile->custom_page_url : ''; $limit = $profile->rows * $profile->cols; $count = ( $count != 0 && $count < count($videos) ) ? $count : count($videos); $total = ceil( $count / $limit ); $start = isset( $_GET['start'] ) ? $_GET['start'] : 1; $limitstart = ($start - 1) * $limit; $limitend = $start * $limit; if($count < $limitend) $limitend = $count; $output = ''; $output .= '
'; $column = 0; $row = 0; for ($i=$limitstart, $n=$limitend; $i < $n; $i++) { $clear = ''; if($column >= $profile->cols) { $clear = '
'; $column = 0; $row++; } $column++; $output .= $clear; $output .= '
'; $arr_params['slg'] = $videos[$i]->slug; $custhref = $custpage ? @add_query_arg($arr_params, $custpage) : @add_query_arg($arr_params); $output .= ''; $output .= '
'; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= '' . $videos[$i]->title . ''; $output .= 'No. of Hits : ' . $videos[$i]->hits . ''; $output .= '
'; $output .= '
'; $output .= '
'; } $output .= '
'; $output .= '
'; $args = array( 'base' => $this->remove_qs_key(@add_query_arg('start', '%#%'), "slg"), 'format' => '', 'total' => $total, 'current' => $start, 'end_size' => 3, 'prev_text' => __('prev'), 'next_text' => __('next'), 'type' => 'list' ); $output .= paginate_links( $args ); return $output; } } ?>