Added : Cached pagination system
This commit is contained in:
parent
946f1f390f
commit
17c3b131ce
7 changed files with 109 additions and 13 deletions
|
@ -186,6 +186,8 @@ if(isset($_POST['update'])){
|
|||
'users_items_search_page',
|
||||
'users_items_group_page',
|
||||
'user_max_chr',
|
||||
'use_cached_pagin',
|
||||
'cached_pagin_time',
|
||||
|
||||
'vid_categories',
|
||||
'vid_cat_height',
|
||||
|
|
|
@ -788,6 +788,29 @@ $(document).ready(function(){
|
|||
<td valign="top"> </td>
|
||||
<td valign="top"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" valign="top">Main Settings</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Use cached pagination</td>
|
||||
<td valign="top"><select name="use_cached_pagin" id="use_cached_pagin">
|
||||
<option value="yes" {if $row.use_cached_pagin==yes}
|
||||
selected="selected"
|
||||
{/if}>Yes</option>
|
||||
<option value="no" {if $row.use_cached_pagin!=yes}
|
||||
selected="selected"
|
||||
{/if}>No</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Pagination chaching time</td>
|
||||
<td valign="top"><input name="cached_pagin_time" type="text" id="cached_pagin_time" value="{$row.cached_pagin_time}" size="45" />
|
||||
in minutes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"> </td>
|
||||
<td valign="top"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="settings_inner_title">Videos Listing</td>
|
||||
</tr>
|
||||
|
|
|
@ -244,4 +244,5 @@ INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`)VALUES
|
|||
-- Addition for 2.6
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'facebook_embed', 'yes');
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'seo_vido_url', '1');
|
||||
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'use_cached_pagin', 'yes'),
|
||||
(NULL, 'cached_pagin_time', '5');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
ALTER TABLE `{tbl_prefix}video` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `{tbl_prefix}collections` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'facebook_embed', 'yes');
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'seo_vido_url', '0');
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'seo_vido_url', '0');
|
||||
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'use_cached_pagin', 'yes'),
|
||||
(NULL, 'cached_pagin_time', '5');
|
||||
|
|
|
@ -50,19 +50,27 @@ switch($sort)
|
|||
//Getting User List
|
||||
$page = mysql_clean($_GET['page']);
|
||||
$get_limit = create_query_limit($page,CLISTPP);
|
||||
$ulist = $u_cond;
|
||||
$count_query = $ulist = $u_cond;
|
||||
$ulist['limit'] = $get_limit;
|
||||
$users = get_users($ulist);
|
||||
Assign('users', $users);
|
||||
|
||||
//Collecting Data for Pagination
|
||||
$ucount = $u_cond;
|
||||
$ucount['count_only'] = true;
|
||||
$total_rows = get_users($ucount);
|
||||
$total_pages = count_pages($total_rows,CLISTPP);
|
||||
|
||||
$counter = get_counter('channel',$count_query);
|
||||
|
||||
if(!$counter)
|
||||
{
|
||||
//Collecting Data for Pagination
|
||||
$ucount = $u_cond;
|
||||
$ucount['count_only'] = true;
|
||||
$total_rows = get_users($ucount);
|
||||
$total_pages = count_pages($total_rows,CLISTPP);
|
||||
$counter = $total_pages;
|
||||
update_counter('channel',$count_query,$counter);
|
||||
}
|
||||
|
||||
//Pagination
|
||||
$pages->paginate($total_pages,$page);
|
||||
$pages->paginate($counter,$page);
|
||||
|
||||
subtitle(lang('channels'));
|
||||
template_files('channels.html');
|
||||
|
|
|
@ -5807,4 +5807,54 @@
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function used to get counts from
|
||||
* cb_counter table
|
||||
*/
|
||||
function get_counter($section,$query)
|
||||
{
|
||||
if(!config('use_cached_pagin'))
|
||||
return false;
|
||||
|
||||
global $db;
|
||||
|
||||
$timeRefresh = config('cached_pagin_time');
|
||||
$timeRefresh = $timeRefresh*60;
|
||||
|
||||
$validTime = time()-$timeRefresh;
|
||||
|
||||
unset($query['order']);
|
||||
$je_query = json_encode($query);
|
||||
$query_md5 = md5($je_query);
|
||||
$select = $db->select(tbl('counters'),"*","section='$section' AND query_md5='$query_md5'
|
||||
AND '$validTime' < date_added");
|
||||
if($db->num_rows>0)
|
||||
{
|
||||
return $select[0]['counts'];
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* function used to insert or update counter
|
||||
*/
|
||||
function update_counter($section,$query,$counter)
|
||||
{
|
||||
global $db;
|
||||
unset($query['order']);
|
||||
$je_query = json_encode($query);
|
||||
$query_md5 = md5($je_query);
|
||||
$count = $db->count(tbl('counters'),"*","section='$section' AND query_md5='$query_md5'");
|
||||
if($count)
|
||||
{
|
||||
$db->update(tbl('counters'),array('counts','date_added'),array($counter,strtotime(now())),
|
||||
"section='$section' AND query_md5='$query_md5'");
|
||||
}else
|
||||
{
|
||||
$db->insert(tbl('counters'),array('section','query','query_md5','counts','date_added'),
|
||||
array($section,'|no_mc|'.$je_query,$query_md5,$counter,strtotime(now())));
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -74,6 +74,7 @@ switch($sort)
|
|||
$page = mysql_clean($_GET['page']);
|
||||
$get_limit = create_query_limit($page,VLISTPP);
|
||||
$vlist = $vid_cond;
|
||||
$count_query = $vid_cond;
|
||||
$vlist['limit'] = $get_limit;
|
||||
$videos = get_videos($vlist);
|
||||
Assign('videos', $videos);
|
||||
|
@ -81,11 +82,19 @@ Assign('videos', $videos);
|
|||
|
||||
//Collecting Data for Pagination
|
||||
$vcount = $vid_cond;
|
||||
$vcount['count_only'] = true;
|
||||
$total_rows = get_videos($vcount);
|
||||
$total_pages = count_pages($total_rows,VLISTPP);
|
||||
|
||||
$counter = get_counter('video',$count_query);
|
||||
|
||||
if(!$counter)
|
||||
{
|
||||
$vcount['count_only'] = true;
|
||||
$total_rows = get_videos($vcount);
|
||||
$total_pages = count_pages($total_rows,VLISTPP);
|
||||
$counter = $total_pages;
|
||||
update_counter('video',$count_query,$counter);
|
||||
}
|
||||
//Pagination
|
||||
$pages->paginate($total_pages,$page);
|
||||
$pages->paginate($counter,$page);
|
||||
|
||||
subtitle(lang('videos'));
|
||||
//Displaying The Template
|
||||
|
|
Loading…
Add table
Reference in a new issue