clipbucket/upload/ajax/home.php

88 lines
2 KiB
PHP
Raw Normal View History

2016-03-14 05:27:34 -07:00
<?php
/**
* File: Home Ajax
* Description: ClipBucket home page will now be Ajax based to imporve page loading
* and to enhance user experience. This file will handle all ajax requests
* for ClipBucket's home page
* @since: 14th March, 2016, ClipBucket 2.8.1
* @author: Saqib Razzaq
* @modified: 14th March, 2016
*/
require '../includes/config.inc.php';
2016-03-17 17:20:58 +05:00
$params = array();
2016-03-14 05:27:34 -07:00
if (isset($_POST['load_type'])) {
$load_type = $_POST['load_type'];
2016-03-18 18:17:10 +05:00
if ($load_type == 'recent') {
$params['order'] = 'DESC';
}
2016-03-14 05:27:34 -07:00
if (isset($_POST['load_mode'])) {
$load_mode = $_POST['load_mode'];
if ($load_mode == 'featured') {
$params['featured'] = "yes";
}
}
if (isset($_POST['load_limit'])) {
$load_limit = $_POST['load_limit'];
} else {
$load_limit = "8";
}
if (isset($_POST['load_hit'])) {
$cur_load_hit = $_POST['load_hit'];
$start = $load_limit * $cur_load_hit - $load_limit;
} else {
2016-03-18 18:17:10 +05:00
$start = "0";
2016-03-14 05:27:34 -07:00
}
$params['limit'] = "$start,$load_limit";
switch ($load_type) {
case 'video':
$data = get_videos($params);
break;
case 'users':
$data = get_users($params);
break;
case 'photos':
$data = get_photos($params);
break;
case 'collections':
$data = get_collections($params);
break;
default:
$data = get_videos($params);
break;
}
2016-03-17 17:20:58 +05:00
#pr($params,true);
2016-03-14 05:27:34 -07:00
if (is_array($data)) {
2016-03-17 17:20:58 +05:00
if (count($data) < 1) {
$msg = array();
$msg['notice'] = "You've reached end of list";
#echo json_encode($msg);
return false;
}
2016-03-14 05:27:34 -07:00
$json_string['loadhit'] = $cur_load_hit + 1;
$json_string['array_meta'] = $data;
2016-03-17 17:20:58 +05:00
if ($load_mode == 'recent') {
$display_type = 'ajaxHome';
} else {
$display_type = 'featuredHome';
}
foreach ($data as $key => $video) {
assign("video",$video);
2016-03-17 17:20:58 +05:00
assign("display_type",$display_type);
Template('blocks/videos/video.html');
}
2016-03-14 05:27:34 -07:00
}
} else {
$msg = array();
$msg['error'] = "Invalid request made";
echo json_encode($msg);
}
?>