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'"; } 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'; break; } $videos = $wpdb->get_results($query); $custid = ( $profile->custom_gallery_id ) ? $profile->custom_gallery_id : 'avs_gallery'; $limit = $profile->rows * $profile->cols; $total = ceil( count($videos) / $limit ); $start = max(1, $_GET['start']); $limitstart = ($start - 1) * $limit; $limitend = $start * $limit; if(count($videos) < $limitend) $limitend = count($videos); $output = ''; $output .= '
'; for ($i=$limitstart, $n=$limitend; $i < $n; $i++) { $clear = ''; if($column >= $profile->cols) { $clear = '
'; $column = 0; $row++; } $column++; $output .= $clear; $output .= '
'; $output .= 'slug) . '">'; $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; } } ?>