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_search_page',
|
||||||
'users_items_group_page',
|
'users_items_group_page',
|
||||||
'user_max_chr',
|
'user_max_chr',
|
||||||
|
'use_cached_pagin',
|
||||||
|
'cached_pagin_time',
|
||||||
|
|
||||||
'vid_categories',
|
'vid_categories',
|
||||||
'vid_cat_height',
|
'vid_cat_height',
|
||||||
|
|
|
@ -788,6 +788,29 @@ $(document).ready(function(){
|
||||||
<td valign="top"> </td>
|
<td valign="top"> </td>
|
||||||
<td valign="top"> </td>
|
<td valign="top"> </td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td colspan="2" class="settings_inner_title">Videos Listing</td>
|
<td colspan="2" class="settings_inner_title">Videos Listing</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -244,4 +244,5 @@ INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`)VALUES
|
||||||
-- Addition for 2.6
|
-- 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, '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, '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}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 ;
|
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, '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
|
//Getting User List
|
||||||
$page = mysql_clean($_GET['page']);
|
$page = mysql_clean($_GET['page']);
|
||||||
$get_limit = create_query_limit($page,CLISTPP);
|
$get_limit = create_query_limit($page,CLISTPP);
|
||||||
$ulist = $u_cond;
|
$count_query = $ulist = $u_cond;
|
||||||
$ulist['limit'] = $get_limit;
|
$ulist['limit'] = $get_limit;
|
||||||
$users = get_users($ulist);
|
$users = get_users($ulist);
|
||||||
Assign('users', $users);
|
Assign('users', $users);
|
||||||
|
|
||||||
//Collecting Data for Pagination
|
|
||||||
$ucount = $u_cond;
|
$counter = get_counter('channel',$count_query);
|
||||||
$ucount['count_only'] = true;
|
|
||||||
$total_rows = get_users($ucount);
|
if(!$counter)
|
||||||
$total_pages = count_pages($total_rows,CLISTPP);
|
{
|
||||||
|
//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
|
//Pagination
|
||||||
$pages->paginate($total_pages,$page);
|
$pages->paginate($counter,$page);
|
||||||
|
|
||||||
subtitle(lang('channels'));
|
subtitle(lang('channels'));
|
||||||
template_files('channels.html');
|
template_files('channels.html');
|
||||||
|
|
|
@ -5807,4 +5807,54 @@
|
||||||
return false;
|
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']);
|
$page = mysql_clean($_GET['page']);
|
||||||
$get_limit = create_query_limit($page,VLISTPP);
|
$get_limit = create_query_limit($page,VLISTPP);
|
||||||
$vlist = $vid_cond;
|
$vlist = $vid_cond;
|
||||||
|
$count_query = $vid_cond;
|
||||||
$vlist['limit'] = $get_limit;
|
$vlist['limit'] = $get_limit;
|
||||||
$videos = get_videos($vlist);
|
$videos = get_videos($vlist);
|
||||||
Assign('videos', $videos);
|
Assign('videos', $videos);
|
||||||
|
@ -81,11 +82,19 @@ Assign('videos', $videos);
|
||||||
|
|
||||||
//Collecting Data for Pagination
|
//Collecting Data for Pagination
|
||||||
$vcount = $vid_cond;
|
$vcount = $vid_cond;
|
||||||
$vcount['count_only'] = true;
|
|
||||||
$total_rows = get_videos($vcount);
|
$counter = get_counter('video',$count_query);
|
||||||
$total_pages = count_pages($total_rows,VLISTPP);
|
|
||||||
|
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
|
//Pagination
|
||||||
$pages->paginate($total_pages,$page);
|
$pages->paginate($counter,$page);
|
||||||
|
|
||||||
subtitle(lang('videos'));
|
subtitle(lang('videos'));
|
||||||
//Displaying The Template
|
//Displaying The Template
|
||||||
|
|
Loading…
Add table
Reference in a new issue