Merge branch 'development' of https://github.com/arslancb/clipbucket
This commit is contained in:
commit
d292fcbadf
31 changed files with 3292 additions and 20 deletions
|
@ -86,6 +86,7 @@ if(isset($_POST['update'])){
|
|||
'debug_level',
|
||||
'default_country_iso2',
|
||||
'default_time_zone',
|
||||
'pick_geo_country',
|
||||
'disallowed_usernames',
|
||||
'use_subs',
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div id="navbar" class="navbar-container container">
|
||||
<div class="navbar-header pull-left">
|
||||
<div class="logoContainer clearfix">
|
||||
<a class="navbar-brand" href="{$baseurl}/admin_area">
|
||||
<a class="navbar-brand" href="{$admin_baseurl}">
|
||||
<img class="pull-left" src="{$imageurl}/login_logo.png" height="30">
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -231,6 +231,13 @@
|
|||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="pick_geo_country">Pick signup country geologically(if yes default country won't work)</label>
|
||||
<select name="pick_geo_country" id="pick_geo_country" class="form-control">
|
||||
<option value="yes" {if $row.pick_geo_country!='no'} selected="selected"{/if}>Yes</option>
|
||||
<option value="no" {if $row.pick_geo_country=='no'} selected="selected"{/if}>No</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<div class="" style="display:none">
|
||||
{foreach from=$requiredFields item=field}
|
||||
{$field.class='form-control'}
|
||||
{if $field.title=='Title'}
|
||||
{if $field.id=='title'}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label for="{$field.id}"><b style="color: #000000">{$field.name}</b></label>
|
||||
|
@ -53,7 +53,7 @@
|
|||
{/foreach}
|
||||
{foreach from=$requiredFields item=field}
|
||||
{$field.class='form-control'}
|
||||
{if $field.title=='Description'}
|
||||
{if $field.id=='desc'}
|
||||
<div class="col-md-6">
|
||||
<label for="{$field.id}"><b style="color: #000000">{$field.name}</b></label>
|
||||
{$formObj->createField($field, true)}
|
||||
|
@ -64,7 +64,7 @@
|
|||
<div class="row">
|
||||
{foreach from=$requiredFields item=field}
|
||||
{$field.class='form-control'}
|
||||
{if $field.title=='Video Category'}
|
||||
{if $field.id=='category'}
|
||||
<div class="col-md-6">
|
||||
<label for="{$field.id}"><b style="color: #000000">{$field.name}</b></label>
|
||||
<div class="scroll categories">
|
||||
|
@ -75,7 +75,7 @@
|
|||
{/foreach}
|
||||
{foreach from=$requiredFields item=field}
|
||||
{$field.class='form-control'}
|
||||
{if $field.title=='Tags'}
|
||||
{if $field.id=='tags'}
|
||||
<div class="col-md-6">
|
||||
<label for="{$field.id}"><b style="color: #000000">{$field.name}</b></label>
|
||||
{$formObj->createField($field, true)}
|
||||
|
|
|
@ -310,3 +310,6 @@ INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES ('', 'cb_l
|
|||
|
||||
-- Addition for Cooporate cb allowing collection and playlist page
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES ('', 'playlistsSection', 'yes');
|
||||
|
||||
-- Addition for Cooporate pick default sign up country geologically
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES ('', 'pick_geo_country', 'yes');
|
|
@ -1221,6 +1221,8 @@ ALTER TABLE `{tbl_prefix}video` ADD `conv_progress` TEXT NOT NULL;
|
|||
ALTER TABLE `{tbl_prefix}video` ADD `file_type` INT( 10 ) NOT NULL DEFAULT '0' AFTER `file_name`;
|
||||
ALTER TABLE `{tbl_prefix}video` ADD `blocked_countries` TEXT( 255 ) NOT NULL AFTER `country`;
|
||||
ALTER TABLE `{tbl_prefix}video` ADD `sprite_count` INT(11) NOT NULL DEFAULT '0' AFTER `blocked_countries`;
|
||||
ALTER TABLE `{tbl_prefix}video` ADD FULLTEXT INDEX (`title`,`tags`);
|
||||
ALTER TABLE `{tbl_prefix}photos` ADD FULLTEXT INDEX (`photo_title`,`photo_tags`);
|
||||
/*Cb_user_profile_info*/
|
||||
ALTER TABLE `{tbl_prefix}user_profile` ADD `fb_url` VARCHAR(200) NOT NULL AFTER `web_url`, ADD `twitter_url` VARCHAR(200) NOT NULL AFTER `fb_url`, ADD `insta_url` VARCHAR(200) NOT NULL AFTER `twitter_url`;
|
||||
|
||||
|
|
1
upload/cb_install/sql/upgrade_4.1.sql
Normal file
1
upload/cb_install/sql/upgrade_4.1.sql
Normal file
|
@ -0,0 +1 @@
|
|||
-- No db changes made
|
8
upload/cb_install/sql/upgrade_4.2.sql
Normal file
8
upload/cb_install/sql/upgrade_4.2.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- enabling Fulltext search with InnoDB as mysql engine
|
||||
ALTER TABLE `{tbl_prefix}video` ADD FULLTEXT INDEX (`title`,`tags`);
|
||||
|
||||
-- Addition for Cooporate pick default sign up country geologically
|
||||
INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES ('', 'pick_geo_country', 'yes');
|
||||
|
||||
-- enabling Fulltext search with InnoDB as mysql engine
|
||||
ALTER TABLE `{tbl_prefix}photos` ADD FULLTEXT INDEX (`photo_title`,`photo_tags`);
|
3
upload/includes/.gitignore
vendored
Normal file
3
upload/includes/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/dbconnect.php
|
||||
/clipbucket.php
|
||||
/development.dev
|
23
upload/includes/classes/category.class.php
Normal file → Executable file
23
upload/includes/classes/category.class.php
Normal file → Executable file
|
@ -874,6 +874,29 @@ abstract class CBCategory
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to get multiple category names
|
||||
*/
|
||||
function get_category_names($cid_array)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$cat_name = array();
|
||||
$cid = explode(' ', $cid_array);
|
||||
$cid = array_slice($cid,0,-1);
|
||||
$test = '';
|
||||
foreach ($cid as $key => $value)
|
||||
{
|
||||
$cat_id = str_replace('#','', $value);
|
||||
$results = $this->get_category($cat_id);
|
||||
|
||||
$cat_name[]= $results;
|
||||
|
||||
}
|
||||
return $cat_name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -585,7 +585,7 @@ class CBPhotos
|
|||
$query = $main_query;
|
||||
|
||||
$cond = "MATCH(".('photos.photo_title,photos.photo_tags').")";
|
||||
$cond .= " AGAINST ('".$cbsearch->set_the_key($p['title'])."' IN BOOLEAN MODE)";
|
||||
$cond .= " AGAINST ('".$cbsearch->set_the_key($p['title'])."' IN NATURAL LANGUAGE MODE)";
|
||||
if($p['exclude'])
|
||||
{
|
||||
if($cond != "")
|
||||
|
@ -624,7 +624,7 @@ class CBPhotos
|
|||
$tags = str_replace('+','',$tags);
|
||||
|
||||
$cond = "MATCH(".('photos.photo_title,photos.photo_tags').")";
|
||||
$cond .= " AGAINST ('".$tags."' IN BOOLEAN MODE)";
|
||||
$cond .= " AGAINST ('".$tags."' IN NATURAL LANGUAGE MODE)";
|
||||
|
||||
if($p['exclude'])
|
||||
{
|
||||
|
|
|
@ -3412,6 +3412,9 @@ class userquery extends CBCategory{
|
|||
$dob = $dob ? date(config("date_format"),strtotime($dob)) : date(config("date_format"),strtotime('14-10-1989'));
|
||||
|
||||
$countries = $Cbucket->get_countries(iso2);
|
||||
|
||||
$pick_geo_country = config('pick_geo_country');
|
||||
if($pick_geo_country=='yes'){
|
||||
$user_ip = $_SERVER['REMOTE_ADDR']; // getting user's ip
|
||||
$user_country = ip_info($user_ip, 'country'); // get country using IP
|
||||
foreach ($countries as $code => $name) {
|
||||
|
@ -3421,6 +3424,9 @@ class userquery extends CBCategory{
|
|||
$selected_cont = $code;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$selected_cont = config('default_country_iso2');
|
||||
}
|
||||
|
||||
if (strlen($selected_cont) != 2) {
|
||||
$selected_cont = "PK";
|
||||
|
|
|
@ -1119,7 +1119,7 @@ class CBvideo extends CBCategory
|
|||
$cond = $superCond." AND ";
|
||||
|
||||
$cond .= "MATCH(".("video.title,video.tags").")
|
||||
AGAINST ('".$params['title']."' IN BOOLEAN MODE) ";
|
||||
AGAINST ('".$params['title']."' IN NATURAL LANGUAGE MODE) ";
|
||||
|
||||
if($params['exclude'])
|
||||
{
|
||||
|
@ -1151,7 +1151,7 @@ class CBvideo extends CBCategory
|
|||
$cond = $superCond." AND ";
|
||||
//Try Finding videos via tags
|
||||
$cond .= "MATCH(".("video.title,video.tags").")
|
||||
AGAINST ('".($params['tags'])."' IN BOOLEAN MODE) ";
|
||||
AGAINST ('".($params['tags'])."' IN NATURAL LANGUAGE MODE) ";
|
||||
if($params['exclude'])
|
||||
{
|
||||
if($cond!='')
|
||||
|
|
|
@ -30,7 +30,7 @@ Assign('template_dir',TEMPLATEDIR);
|
|||
Assign('style_dir',LAYOUT);
|
||||
Assign('covers_dir', COVERS_DIR);
|
||||
|
||||
assign('admin_baseurl',BASEURL.'/'.ADMINDIR);
|
||||
assign('admin_baseurl',BASEURL.'/'.ADMINDIR.'/');
|
||||
|
||||
//Assigning JS Files
|
||||
Assign('jsArray',$Cbucket->JSArray);
|
||||
|
|
135
upload/includes/functions.php
Normal file → Executable file
135
upload/includes/functions.php
Normal file → Executable file
|
@ -5909,6 +5909,141 @@
|
|||
}
|
||||
|
||||
|
||||
function isset_check($input_arr=array(),$key_name,$mysql_clean=false)
|
||||
{
|
||||
|
||||
if(isset($input_arr[$key_name])&&!empty($input_arr[$key_name]))
|
||||
{
|
||||
|
||||
if(!is_array($input_arr[$key_name])&&!is_numeric($input_arr[$key_name])&&$mysql_clean)
|
||||
$input_arr[$key_name] = mysql_clean($input_arr[$key_name]);
|
||||
|
||||
return $input_arr[$key_name];
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [generic_curl use to send curl with post method]
|
||||
* @author Awais Tariq
|
||||
* @param [string] $call_bk [url where curl will be sent]
|
||||
* @param [array] $array [date to be send ]
|
||||
* @param [string] $follow_redirect [ redirect follow option for 301 status ]
|
||||
* @param [array] $header_arr [ header's parameters are sent through this array ]
|
||||
* @param [bool] $read_response_headers [ parse/fetch the response headers ]
|
||||
* @return [array] [return code and result of curl]
|
||||
*/
|
||||
function generic_curl($input_arr = array())
|
||||
{
|
||||
$call_bk = isset_check($input_arr,'url');
|
||||
|
||||
$array = isset_check($input_arr,'post_arr');
|
||||
$file = isset_check($input_arr,'file');
|
||||
$follow_redirect = isset_check($input_arr,'redirect');
|
||||
$full_return_info = isset_check($input_arr,'full_return_info');
|
||||
$header_arr = isset_check($input_arr,'headers');
|
||||
$curl_timeout = isset_check($input_arr,'curl_timeout');
|
||||
$methods = strtoupper(isset_check($input_arr,'method'));
|
||||
$curl_connect_timeout = isset_check($input_arr,'curl_connect_timeout');
|
||||
$curl_connect_timeout = (int)trim($curl_connect_timeout);
|
||||
$curl_timeout = (int)trim($curl_timeout);
|
||||
$read_response_headers = isset_check($input_arr,'response_headers');
|
||||
$return_arr = array();
|
||||
if(!empty($call_bk))
|
||||
{
|
||||
$ch = curl_init($call_bk);
|
||||
|
||||
if(!empty($file))
|
||||
{
|
||||
foreach ($file as $key => $value)
|
||||
{
|
||||
if(file_exists($value))
|
||||
$array[$key] = curl_file_create( $value, mime_content_type($value), basename($value));
|
||||
}
|
||||
}
|
||||
|
||||
if($methods)
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "{$methods}");
|
||||
|
||||
if(!empty($array))
|
||||
{
|
||||
|
||||
curl_setopt($ch,CURLOPT_POST,true);
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS,$array);
|
||||
}
|
||||
|
||||
if($read_response_headers===true)
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
}
|
||||
|
||||
if(empty($header_arr))
|
||||
$header_arr = array("Expect:");
|
||||
|
||||
if(empty($curl_timeout)||$curl_timeout==0)
|
||||
$curl_timeout = 3;
|
||||
|
||||
if($curl_timeout>0)
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $curl_timeout);
|
||||
|
||||
if(empty($curl_connect_timeout)||$curl_connect_timeout==0)
|
||||
$curl_connect_timeout = 2;
|
||||
|
||||
if($curl_connect_timeout>0)
|
||||
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $curl_connect_timeout);
|
||||
|
||||
curl_setopt($ch,CURLOPT_HTTPHEADER,$header_arr);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
if($follow_redirect)
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
|
||||
$result = curl_exec($ch);
|
||||
$error_msg = curl_error($ch);
|
||||
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if($full_return_info)
|
||||
$return_arr['full_info'] = curl_getinfo($ch);
|
||||
|
||||
$return_arr['code'] = $returnCode;
|
||||
$errorNO = curl_errno($ch);
|
||||
if($errorNO)
|
||||
{
|
||||
$return_arr['curl_error_no'] = $errorNO;
|
||||
}
|
||||
if(!empty($error_msg))
|
||||
{
|
||||
$return_arr['error_curl'] = $error_msg;
|
||||
}
|
||||
$return_arr['result'] = $result;
|
||||
curl_close($ch);
|
||||
}
|
||||
else{
|
||||
$return_arr['error'] = "False no callback url present! {$call_bk}";
|
||||
}
|
||||
|
||||
return $return_arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is used to clean a string removing all special chars
|
||||
* @author Mohammad Shoaib
|
||||
* @param string
|
||||
* @return cleaned string
|
||||
*/
|
||||
function cleanString($string) {
|
||||
$string = str_replace("’", "'", $string);
|
||||
return preg_replace('/[^A-Za-z0-9 !@#$%^&*()_?<>|{}\[\].,+-;\/:"\'\-]/', "'", $string);
|
||||
}
|
||||
|
||||
|
||||
include( 'functions_db.php' );
|
||||
include( 'functions_filter.php' );
|
||||
|
|
279
upload/plugins/cb_elastic_search/ElasticScript.php
Executable file
279
upload/plugins/cb_elastic_search/ElasticScript.php
Executable file
|
@ -0,0 +1,279 @@
|
|||
<?php
|
||||
|
||||
require 'includes/config.inc.php';
|
||||
|
||||
//require_once("includes/classes/elasticSearch.php");
|
||||
|
||||
|
||||
$request = $_REQUEST;
|
||||
$mode = $request["mode"];
|
||||
$type = $request["type"];
|
||||
if (!isset($request["method"])){
|
||||
$method = "get";
|
||||
}else{
|
||||
$method = $request["method"];
|
||||
}
|
||||
#$method = $request['method'] ? "GET" : "GET";
|
||||
$offset = 0;
|
||||
$count = 0;
|
||||
|
||||
if (isset($request["offset"])){
|
||||
$offset = $request["offset"];
|
||||
}
|
||||
if (isset($request["count"])){
|
||||
$count = $request["count"];
|
||||
}
|
||||
|
||||
|
||||
$response = array();
|
||||
$response["data"] = null;
|
||||
$results = array();
|
||||
try{
|
||||
|
||||
if (!$mode){
|
||||
throw new Exception("Please provide mode to map or index");
|
||||
}
|
||||
|
||||
|
||||
switch ($mode) {
|
||||
default:
|
||||
case 'videos':{
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
$mappingData = $es->videoMappingData;
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$videoRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$videoRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
|
||||
// get a specific video
|
||||
if ( isset($request["id"]) ){
|
||||
$videoRequest["videoid"] = $request["id"];
|
||||
}
|
||||
|
||||
//Fetching Videos to process
|
||||
$videos = $cbvid->get_videos($videoRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($videos){
|
||||
|
||||
foreach ($videos as $key => $video) {
|
||||
|
||||
$formattedVideo = $es->FormatVideo($video);
|
||||
$extras["id"] = $video["videoid"];
|
||||
$response["data"] = $es->EsIndex($formattedVideo,$extras);
|
||||
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'users':{
|
||||
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
$mappingData = $es->userMappingData;
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$userRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$userRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
|
||||
// get a specific user
|
||||
if ( isset($request["id"]) ){
|
||||
$userRequest["userid"] = $request["id"];
|
||||
}
|
||||
|
||||
//Fetching users to process
|
||||
$users = $userquery->get_users($userRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($users){
|
||||
foreach ($users as $key => $user) {
|
||||
$formatteduser = $es->FormatUser($user);
|
||||
$extras["id"] = $user["userid"];
|
||||
$response["data"] = $es->EsIndex($formatteduser,$extras);
|
||||
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'collections':
|
||||
case 'groups':{
|
||||
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
if ($index == 'groups'){
|
||||
$mappingData = $es->groupMappingData;
|
||||
}else{
|
||||
$mappingData = $es->collectionMappingData;
|
||||
}
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$groupRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$groupRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
// get a specific group
|
||||
if ( isset($request["id"]) ){
|
||||
$groupRequest["group_id"] = $request["id"];
|
||||
}
|
||||
|
||||
if ($index == 'collections'){
|
||||
$groupRequest["is_collection"] = "yes";
|
||||
}else{
|
||||
$groupRequest["is_collection"] = "no";
|
||||
}
|
||||
|
||||
//Fetching groups to process
|
||||
$groups = $cbgroup->get_groups($groupRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($groups){
|
||||
foreach ($groups as $key => $group) {
|
||||
$formattedgroup = $es->FormatGroupCollection($group);
|
||||
$extras["id"] = $group["group_id"];
|
||||
$response["data"] = $es->EsIndex($formattedgroup,$extras);
|
||||
#pr($response,1);
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
exit(json_encode(array("err"=>$e->getMessage(),"data"=>$response)));
|
||||
}
|
||||
|
||||
?>
|
110
upload/plugins/cb_elastic_search/admin/configure.html
Executable file
110
upload/plugins/cb_elastic_search/admin/configure.html
Executable file
|
@ -0,0 +1,110 @@
|
|||
<span class="page_title">ElasticSearch </span>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 mrgnt15">
|
||||
<span class="mandtory"><h3>Configurations</h3></span>
|
||||
</div>
|
||||
<div class="col-lg-11">
|
||||
<div class="row">
|
||||
<form id="index" method="post">
|
||||
<div class="col-md-4">
|
||||
<label for="elastic_server_ip">Elastic Server IP</label>
|
||||
<input type="text" name="elastic_server_ip" class="form-control" value="{config('elastic_server_ip')}">
|
||||
<p>e.g the URL on which elastic server is listening</p>
|
||||
</div>
|
||||
<!-- <div class="col-md-4">
|
||||
<label for="elastic_server_port">Elastic Server Port</label>
|
||||
<input type="text" name="elastic_server_port" class="form-control" value="{config('elastic_server_port')}">
|
||||
<p>e.g the port on which elastic server is listening</p>
|
||||
</div> -->
|
||||
<div class="col-md-2" style="margin-top: 25px;">
|
||||
<input type="submit" name="submit" id="submit" class="btn btn-md btn-success" value="Update">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{if is_es_server_running()}
|
||||
<span class="alert alert-success"> Elastic Server is running Up !
|
||||
<i class="glyphicon glyphicon-ok"></i>
|
||||
</span>
|
||||
{else}
|
||||
<span class="alert alert-warning"> Elastic Server not running or configured !
|
||||
<i class="glyphicon glyphicon-warning-sign"></i>
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 25px;margin-left: 15px;" >
|
||||
<div class="col-lg-12 results" style="background: #f8f8f8;border: 1px solid #d4d4d4"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 mrgnt15">
|
||||
<section class="clearfix form-elements cb-uikit">
|
||||
<header class="clearfix">
|
||||
<h2 class="">Documentation</h2>
|
||||
</header>
|
||||
<div class="clearfix">
|
||||
<h3 class="greycolor text_cent">Information About Plugin</h3>
|
||||
<ul>
|
||||
<li><strong>Last update:</strong> Jan, 2019</li>
|
||||
<li><strong>Authors:</strong>Fahad abbas</li>
|
||||
<li><strong>Author Website:</strong> http://clipbucket.com</li>
|
||||
<li><strong>Version:</strong> 1.0</li>
|
||||
<li><strong>ClipBucket Version:</strong> 4.2.x</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="clearfix" style="margin-bottom: 20px;">
|
||||
<h3 class="greycolor text_cent">Why You Need Elastic Search module?</h3>
|
||||
<p>To simply make website search more efficient for users. A full text search Engine which will make clipbucket's Search Experience a way better ! </p>
|
||||
</div>
|
||||
<div class="clearfix" style="margin-bottom: 20px;">
|
||||
<span class="alert alert-info" style="margin-top: 50px;"><strong>Note : </strong> To Run this plugin make sure your elastic server is running up ! </span>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
<div class="clearfix">
|
||||
<h3>Indexer</h3>
|
||||
<pre>Elastic Search Indexer helps you Index your Videos,Channels and Photos with Elastic Search Server.</pre>
|
||||
<h4>Request</h4>
|
||||
<pre>Update,Select,Delete,Add This menu lets you select the request type for Mapping and Indexing. <strong>`Update` </strong>is used to add and update both.</pre>
|
||||
<h4>Type</h4>
|
||||
<pre>This menu lets you decide wheather Map or Index, <strong>Note : Indexing is always done after Mapping.</strong> </pre>
|
||||
<h4>Offset</h4>
|
||||
<pre >It is used to specify the offset of the first row to be returned.</pre>
|
||||
<h4>Count</h4>
|
||||
<pre >It is used to specify the maximum number of rows to be returned. </pre>
|
||||
<h4>Id</h4>
|
||||
<pre>To Index Specific Id , it will ignore Offset and Count Parameter and it is only used while indexing.</pre>
|
||||
<h4>Mode</h4>
|
||||
<pre >This lets you decide between Videos,Channels and Photos.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<style>
|
||||
pre {
|
||||
word-wrap: break-word;
|
||||
padding: 6px 10px;
|
||||
line-height: 4px;
|
||||
margin-bottom: 20px;
|
||||
width: 100%
|
||||
}
|
||||
.code{
|
||||
font-family: Consolas,'Liberation Mono',Courier,monospace;
|
||||
border: 1px solid #ccc;
|
||||
color: #333;
|
||||
background: #e4e4e4;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #ccc;
|
||||
/*border: 1px solid #001;
|
||||
width: auto*/
|
||||
}
|
||||
</style>
|
||||
|
||||
|
29
upload/plugins/cb_elastic_search/admin/configure.php
Executable file
29
upload/plugins/cb_elastic_search/admin/configure.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/*
|
||||
***************************************************************
|
||||
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
|
||||
| @ Author : ArslanHassan
|
||||
| @ Software : ClipBucket , © PHPBucket.com
|
||||
****************************************************************
|
||||
*/
|
||||
|
||||
if(!defined('IN_CLIPBUCKET'))
|
||||
exit('Invalid access');
|
||||
|
||||
$rows = array("elastic_server_ip");
|
||||
if (isset($_POST['submit'])){
|
||||
foreach($rows as $field){
|
||||
$value = ($_POST[$field]);
|
||||
if(in_array($field,$num_array)){
|
||||
if($value <= 0 || !is_numeric($value)){
|
||||
$value = 1;
|
||||
}
|
||||
}
|
||||
$myquery->Set_Website_Details($field,$value);
|
||||
}
|
||||
}
|
||||
|
||||
$template = 'configure.html';
|
||||
template_files($template,CB_ES_ADMIN_DIR);
|
||||
|
||||
?>
|
126
upload/plugins/cb_elastic_search/admin/index_data.html
Executable file
126
upload/plugins/cb_elastic_search/admin/index_data.html
Executable file
|
@ -0,0 +1,126 @@
|
|||
|
||||
|
||||
|
||||
<span class="page_title">ElasticSearch Indexer</span>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12 mrgnt15">
|
||||
<span class="mandtory"><h1></h1></span>
|
||||
</div>
|
||||
<div class="col-lg-11">
|
||||
<div class="row">
|
||||
<form id="index" method="post">
|
||||
<!-- <input type="hidden" name="type" value="index"> -->
|
||||
<!-- <input type="hidden" name="method" value="put"> -->
|
||||
<div class="col-md-2">
|
||||
<label for="offset">Request</label>
|
||||
<select class="form-control" name="method">
|
||||
<option value="put" selected>Update</option>
|
||||
<option value="get">List</option>
|
||||
<option value="delete">Delete</option>
|
||||
<option value="post">Add</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="offset">Type</label>
|
||||
<select class="form-control" name="type">
|
||||
<option value="map">MAP</option>
|
||||
<option value="index" selected>INDEX</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="offset">Offset</label>
|
||||
<input type="text" name="offset" class="form-control" value="0">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="count">Count</label>
|
||||
<input type="text" name="count" class="form-control" value="1">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="count">Id</label>
|
||||
<input type="text" name="id" class="form-control" value="0">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="offset">Mode</label>
|
||||
<select class="form-control" name="mode">
|
||||
<option value="videos" selected>Videos</option>
|
||||
<option value="users">Users</option>
|
||||
<option value="photos">Photos</option>
|
||||
<!-- <option value="collections">Collections</option> -->
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="col-md-2" style="margin-top: 25px;">
|
||||
<input type="submit" name="submit" id="submit" class="btn btn-md btn-success" value="Index">
|
||||
</div>
|
||||
<!-- <div class="col-md-4" style="margin-top: 25px;">
|
||||
<span class="alert alert-info load-msg hide">
|
||||
This may take few minutes....
|
||||
</span>
|
||||
</div> -->
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-top: 25px;margin-left: 15px;" >
|
||||
<div class="col-lg-12 results" style="background: #f8f8f8;border: 1px solid #d4d4d4"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var ElasticScript = '{$cb_es_ajax_url}';
|
||||
$(document).ready(function(){
|
||||
$("#index").on("submit",function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var formData_ = new FormData(this);
|
||||
|
||||
$.ajax({
|
||||
url: ElasticScript,
|
||||
data: formData_,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
|
||||
beforeSend : function(data){
|
||||
$(".load-msg").removeClass("hide");
|
||||
$("#submit").attr("disabled",true);
|
||||
$("#submit").val("..Indexing");
|
||||
$(".results").html("");
|
||||
},
|
||||
success: function(data){
|
||||
|
||||
var results = $.parseJSON(data);
|
||||
var dataResults = results.data;
|
||||
console.log(dataResults);
|
||||
var html = "<ul style='margin-top:20px'>";
|
||||
if (typeof dataResults.length !== 'undefined'){
|
||||
for (var i = 0; i < dataResults.length ; i ++){
|
||||
if (dataResults[i].code == '400'){
|
||||
html += "<li style='color:red'>";
|
||||
}else{
|
||||
html += "<li style='color:green'>";
|
||||
}
|
||||
html += "<strong>Status Code : </strong>"+dataResults[i].code
|
||||
html += " <strong>Result : </strong>"+dataResults[i].result
|
||||
html += "</li>"
|
||||
}
|
||||
}else{
|
||||
html += dataResults.data.result;
|
||||
}
|
||||
|
||||
html += "</ul>";
|
||||
|
||||
$(".results").html(html);
|
||||
|
||||
$(".load-msg").addClass("hide");
|
||||
$("#submit").attr("disabled",false);
|
||||
$("#submit").val("Index");
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
20
upload/plugins/cb_elastic_search/admin/index_data.php
Executable file
20
upload/plugins/cb_elastic_search/admin/index_data.php
Executable file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/*
|
||||
***************************************************************
|
||||
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
|
||||
| @ Author : ArslanHassan
|
||||
| @ Software : ClipBucket , © PHPBucket.com
|
||||
****************************************************************
|
||||
*/
|
||||
|
||||
if(!defined('IN_CLIPBUCKET'))
|
||||
exit('Invalid access');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$template = 'index_data.html';
|
||||
template_files($template,CB_ES_ADMIN_DIR);
|
||||
|
||||
?>
|
1129
upload/plugins/cb_elastic_search/elasticSearch.php
Executable file
1129
upload/plugins/cb_elastic_search/elasticSearch.php
Executable file
File diff suppressed because it is too large
Load diff
68
upload/plugins/cb_elastic_search/elastic_search.php
Executable file
68
upload/plugins/cb_elastic_search/elastic_search.php
Executable file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: Clipbucket Elastic Search Module
|
||||
Description: This Plugins provides a new experience for efficient search
|
||||
Author: Fahad Abbas
|
||||
Author Website: http://clip-bucket.com/
|
||||
Version: 2.0
|
||||
ClipBucket Version: 4.2
|
||||
*/
|
||||
|
||||
|
||||
|
||||
define('CB_ES', this_plugin( __FILE__ ) );
|
||||
assign('cb_es',CB_ES_MANAGER);
|
||||
|
||||
define('CB_ES','installed');
|
||||
assign('cb_es',CB_ES);
|
||||
/* PATHS */
|
||||
define( 'CB_ES_DIR', PLUG_DIR.'/'.CB_ES);
|
||||
define( 'CB_ES_URL', PLUG_URL.'/'.CB_ES );
|
||||
|
||||
define( 'CB_ES_ADMIN_DIR', CB_ES_DIR.'/admin');
|
||||
define( 'CB_ES_ADMIN_URL', CB_ES_URL.'/admin');
|
||||
|
||||
assign('cb_es_dir',CB_ES_DIR);
|
||||
assign('cb_es_url',CB_ES_URL);
|
||||
|
||||
assign('cb_es_admin_dir',CB_ES_ADMIN_DIR);
|
||||
assign('cb_es_admin_url',CB_ES_ADMIN_URL);
|
||||
|
||||
assign('cb_es_ajax_url',CB_ES_URL.'/es_ajax.php');
|
||||
|
||||
define('CB_ES_INSTALLED', 'yes' );
|
||||
assign('cb_es_installed',CB_ES_INSTALLED);
|
||||
|
||||
|
||||
|
||||
$Cbucket->links['search_result'] = array('module.php','module.php');
|
||||
|
||||
//fields required for search form
|
||||
function elastic_mode_search() {
|
||||
echo '<input type="hidden" name="s" value="elastic">';
|
||||
echo '<input type="hidden" name="p" value="search">';
|
||||
}
|
||||
|
||||
|
||||
/*ini_set('display_errors', '-1');
|
||||
error_reporting(E_ALL);*/
|
||||
function is_es_server_running(){
|
||||
return checkRemoteFile(config('elastic_server_ip'));
|
||||
}
|
||||
|
||||
/*if (is_es_server_running()){
|
||||
exit("YES");
|
||||
}else{
|
||||
exit("NO");
|
||||
}*/
|
||||
|
||||
//Elastic Search Class
|
||||
include "elasticSearch.php";
|
||||
|
||||
register_anchor_function("elastic_mode_search","elastic_mode_search");
|
||||
|
||||
register_module('elastic_search',CB_ES_DIR.'/search.php');
|
||||
|
||||
add_admin_menu("Elastic Search","ES Indexer",'index_data.php',CB_ES.'/admin');
|
||||
add_admin_menu("Elastic Search","Configure",'configure.php',CB_ES.'/admin');
|
360
upload/plugins/cb_elastic_search/es_ajax.php
Executable file
360
upload/plugins/cb_elastic_search/es_ajax.php
Executable file
|
@ -0,0 +1,360 @@
|
|||
<?php
|
||||
|
||||
include("../../includes/config.inc.php");
|
||||
|
||||
//require_once("includes/classes/elasticSearch.php");
|
||||
|
||||
#ini_set('display_errors', -1);
|
||||
#error_reporting(E_ALL);
|
||||
|
||||
$request = $_REQUEST;
|
||||
$mode = $request["mode"];
|
||||
$type = $request["type"];
|
||||
if (!isset($request["method"])){
|
||||
$method = "get";
|
||||
}else{
|
||||
$method = $request["method"];
|
||||
}
|
||||
#$method = $request['method'] ? "GET" : "GET";
|
||||
$offset = 0;
|
||||
$count = 0;
|
||||
|
||||
if (isset($request["offset"])){
|
||||
$offset = $request["offset"];
|
||||
}
|
||||
if (isset($request["count"])){
|
||||
$count = $request["count"];
|
||||
}
|
||||
|
||||
|
||||
$response = array();
|
||||
$response["data"] = null;
|
||||
$results = array();
|
||||
try{
|
||||
|
||||
if (!$mode){
|
||||
throw new Exception("Please provide mode to map or index");
|
||||
}
|
||||
|
||||
|
||||
switch ($mode) {
|
||||
default:
|
||||
case 'videos':{
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
$mappingData = $es->videoMappingData;
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$videoRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$videoRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
|
||||
// get a specific video
|
||||
if ( isset($request["id"]) ){
|
||||
$videoRequest["videoid"] = $request["id"];
|
||||
}
|
||||
|
||||
//Fetching Videos to process
|
||||
$videos = $cbvid->get_videos($videoRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($videos){
|
||||
|
||||
foreach ($videos as $key => $video) {
|
||||
|
||||
$formattedVideo = $es->FormatVideo($video);
|
||||
$extras["id"] = $video["videoid"];
|
||||
$response["data"] = $es->EsIndex($formattedVideo,$extras);
|
||||
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'photos':{
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
$mappingData = $es->photoMappingData;
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$photoRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$photoRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
|
||||
// get a specific photo
|
||||
if ( isset($request["id"]) ){
|
||||
$photoRequest["photoid"] = $request["id"];
|
||||
}
|
||||
|
||||
//Fetching photos to process
|
||||
$photos = $cbphoto->get_photos($photoRequest);
|
||||
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($photos){
|
||||
|
||||
foreach ($photos as $key => $photo) {
|
||||
|
||||
$formattedPhoto = $es->FormatPhoto($photo);
|
||||
$extras["id"] = $photo["photo_id"];
|
||||
$response["data"] = $es->EsIndex($formattedPhoto,$extras);
|
||||
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No photo Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'users':{
|
||||
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
$mappingData = $es->userMappingData;
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$userRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$userRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
|
||||
// get a specific user
|
||||
if ( isset($request["id"]) ){
|
||||
$userRequest["userid"] = $request["id"];
|
||||
}
|
||||
|
||||
//Fetching users to process
|
||||
$users = $userquery->get_users($userRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($users){
|
||||
foreach ($users as $key => $user) {
|
||||
$formatteduser = $es->FormatUser($user);
|
||||
$extras["id"] = $user["userid"];
|
||||
$response["data"] = $es->EsIndex($formatteduser,$extras);
|
||||
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'collections':
|
||||
case 'groups':{
|
||||
|
||||
|
||||
$index = $mode;
|
||||
$es = new ElasticSearch($index);
|
||||
|
||||
if ($type == 'map'){
|
||||
|
||||
//mapping the database with ES server for videos
|
||||
if ($index == 'groups'){
|
||||
$mappingData = $es->groupMappingData;
|
||||
}else{
|
||||
$mappingData = $es->collectionMappingData;
|
||||
}
|
||||
//Finally Calling the Function
|
||||
$extras["method"] = $method;
|
||||
$response["data"] = $es->EsMap($mappingData,$extras);
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
exit(json_encode(array("err"=>$response["data"]["curl_error"],"data"=>$response)));
|
||||
}else{
|
||||
exit(json_encode(array("msg"=>"success","data"=>$response)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}elseif ($type == 'index'){
|
||||
|
||||
$groupRequest = array();
|
||||
|
||||
//applying dynamic limit
|
||||
if ($count){
|
||||
$groupRequest["limit"] = $offset.','.$count;
|
||||
}
|
||||
// get a specific group
|
||||
if ( isset($request["id"]) ){
|
||||
$groupRequest["group_id"] = $request["id"];
|
||||
}
|
||||
|
||||
if ($index == 'collections'){
|
||||
$groupRequest["is_collection"] = "yes";
|
||||
}else{
|
||||
$groupRequest["is_collection"] = "no";
|
||||
}
|
||||
|
||||
//Fetching groups to process
|
||||
$groups = $cbgroup->get_groups($groupRequest);
|
||||
$extras["method"] = $method;
|
||||
|
||||
if ($groups){
|
||||
foreach ($groups as $key => $group) {
|
||||
$formattedgroup = $es->FormatGroupCollection($group);
|
||||
$extras["id"] = $group["group_id"];
|
||||
$response["data"] = $es->EsIndex($formattedgroup,$extras);
|
||||
#pr($response,1);
|
||||
//checking for Curl Error
|
||||
if ($response["data"]["curl_error_no"]){
|
||||
throw new Exception($response["data"]["curl_error"]);
|
||||
|
||||
}
|
||||
#pre($response,1);
|
||||
//checking for bad request or error
|
||||
/*if ($response["data"]["code"] == '400' ){
|
||||
throw new Exception($response["data"]["result"]);
|
||||
}*/
|
||||
|
||||
$results[] = $response["data"];
|
||||
}
|
||||
}else{
|
||||
throw new Exception("No Video Found for this request");
|
||||
}
|
||||
|
||||
//Creating Response
|
||||
exit(json_encode(array("msg"=>"success","data"=>$results)));
|
||||
|
||||
}else{
|
||||
throw new Exception("Invalid Request, please select proper type");
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
exit(json_encode(array("err"=>$e->getMessage(),"data"=>$response)));
|
||||
}
|
||||
|
||||
?>
|
7
upload/plugins/cb_elastic_search/install_elastic_search.php
Executable file
7
upload/plugins/cb_elastic_search/install_elastic_search.php
Executable file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
|
||||
$db->Execute("INSERT INTO ".tbl('config')." (`configid`, `name`, `value`) VALUES
|
||||
(NULL, 'elastic_server_ip', 'localhost');");
|
||||
|
||||
?>
|
304
upload/plugins/cb_elastic_search/search.html
Executable file
304
upload/plugins/cb_elastic_search/search.html
Executable file
|
@ -0,0 +1,304 @@
|
|||
<div class="container clearfix" style="padding-top: 50px;">
|
||||
<div class="row cb-box">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="{if $mode == 'all'}active{/if}">
|
||||
<a href="?type=all&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}&s=elastic&p=search" >
|
||||
All
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'videos'}active{/if}" >
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}&s=elastic&p=search" >
|
||||
Videos
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'photos'}active{/if}" >
|
||||
<a href="?type=photos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}&s=elastic&p=search">
|
||||
Photos
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'channels'}active{/if}" >
|
||||
<a href="?type=channels&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}&s=elastic&p=search" >
|
||||
Channels</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="row cb-box">
|
||||
<div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'all'}active{/if}" id="all-tab">
|
||||
{if $videos}
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
Videos
|
||||
<span class="pull-right"><a href="{link name='videos'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="all-search-holder clearfix">
|
||||
{foreach $videos as $video}
|
||||
{include file="$style_dir/blocks/video.html" display_type='normal'}
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- videos -->
|
||||
{/if}
|
||||
{if $photos}
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
Photos
|
||||
<span class="pull-right"><a href="{link name='photos'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="all-search-holder clearfix">
|
||||
{foreach $photos as $photo}
|
||||
{include file="$style_dir/blocks/photo.html" }
|
||||
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- videos -->
|
||||
{/if}
|
||||
{if $users}
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
Users
|
||||
<span class="pull-right"><a href="{link name='channels'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="row">
|
||||
|
||||
{foreach $users as $user}
|
||||
{$user_details = $userquery->get_user_details($user.userid)}
|
||||
{include file="$style_dir/blocks/user.html" display_type='normal'}
|
||||
{/foreach}
|
||||
</div><!-- users list -->
|
||||
</div><!-- users -->
|
||||
{/if}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{if !$videos && !$photos && !$users }
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
|
||||
</div><!-- all users -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'videos'}active{/if}" id="videos-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
Videos
|
||||
<span class="pull-right"><a href="{link name='videos'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="all-search-holder clearfix">
|
||||
{if $videos}
|
||||
{foreach $videos as $video}
|
||||
{include file="$style_dir/blocks/video.html" display_type='normal'}
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!-- videos -->
|
||||
</div><!-- all videos -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'photos'}active{/if}" id="photos-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
photos
|
||||
<span class="pull-right"><a href="{link name='photos'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="all-search-holder clearfix">
|
||||
{if $photos}
|
||||
{foreach $photos as $photo}
|
||||
{include file="$style_dir/blocks/photo.html"}
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!-- photos -->
|
||||
</div><!-- all photos -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'channels'}active{/if}" id="users-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h4>
|
||||
Users
|
||||
<span class="pull-right"><a href="{link name='channels'}">See All</a></span>
|
||||
</h4>
|
||||
<div class="row">
|
||||
{if $users}
|
||||
{foreach $users as $user}
|
||||
{$user_details = $userquery->get_user_details($user.userid)}
|
||||
{include file="$style_dir/blocks/user.html" display_type='normal'}
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div><!-- users list -->
|
||||
</div>
|
||||
</div><!-- users -->
|
||||
</div><!-- tab content -->
|
||||
</div><!-- left column -->
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 hidden-xs">
|
||||
<div class="search-sort-by clearfix">
|
||||
<div class="sortby-holder">
|
||||
<span>Sort by:</span>
|
||||
<div class="dropdown">
|
||||
<button aria-expanded="true" data-toggle="dropdown" id="dropdownMenu1" type="button" class="btn btn-default dropdown-toggle">
|
||||
{if $smarty.get.search_by=='rel'}
|
||||
Relevance
|
||||
{elseif $smarty.get.search_by=='date'}
|
||||
Date
|
||||
{elseif $smarty.get.search_by=='views'}
|
||||
Popularity
|
||||
{else}
|
||||
Relevance
|
||||
{/if}
|
||||
<span class="caret-arrow"></span>
|
||||
</button>
|
||||
<ul aria-labelledby="dropdownMenu1" role="menu" class="dropdown-menu">
|
||||
<li role="presentation">
|
||||
<a href="?type={$smarty.get.type|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=rel&s=elastic&p=search">Relevance</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="?type={$smarty.get.type|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=date&s=elastic&p=search">Date</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="?type={$smarty.get.type|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=views&s=elastic&p=search">Popularity</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-filter clearfix">
|
||||
{foreach $filter_results as $key => $filter}
|
||||
<div class="filter-col clearfix">
|
||||
{if $filter.0 != ''}
|
||||
|
||||
|
||||
<h4>{$key}</h4>
|
||||
<ul>
|
||||
{foreach $filter as $final}
|
||||
{if $final@iteration < 5}
|
||||
<li class="display">
|
||||
{if $key == 'CATEGORY' }
|
||||
{$category = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&category={$category.id}&author={$smarty.get.author|form_val}&s=elastic&p=search">
|
||||
|
||||
{cleanString($final.source)} ( {$final.counts} )
|
||||
</a>
|
||||
{elseif $key == 'AUTHOR'}
|
||||
{$author = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$author.id}&s=elastic&p=search">{cleanString(name($final.source))} ( {$final.counts} )</a>
|
||||
{elseif $key == 'VIDEO' }
|
||||
{$video_name = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&object={$video_name}&object_type=video&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{elseif $key == 'GROUP' }
|
||||
{$group_name = $final}
|
||||
<a href="?type=groups&query={$smarty.get.query|form_val}&object={$group_name.id}&object_type=group&s=elastic&p=search">{cleanString($group_name.source)}</a>
|
||||
{elseif $key =='COLLECTION' }
|
||||
{$collection_name = $final}
|
||||
<a href="?type=collections&query={$smarty.get.query|form_val}&object={$collection_name.id}&object_type=collection&s=elastic&p=search">{cleanString($collection_name.source)}</a>
|
||||
{elseif $key == 'USER' }
|
||||
{$user_name = $final}
|
||||
<a href="?type=channels&query={$smarty.get.query|form_val}&object={$user_name}&object_type=user&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{elseif $key == 'SOURCE' }
|
||||
<a href="?type={$final.key}&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&s=elastic&p=search">{cleanString($final.key)} ( {$final.doc_count} )</a>
|
||||
{else}
|
||||
<a href="javascript:void(0)">{cleanString($final)}</a>
|
||||
{/if}
|
||||
|
||||
</li>
|
||||
{else}
|
||||
{$flag = true}
|
||||
<li class="no-display hide" >
|
||||
{if $key == 'CATEGORY' }
|
||||
{$category = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&category={$category.id}&author={$smarty.get.author|form_val}&s=elastic&p=search">{cleanString($final.source)} ( {$final.counts} )
|
||||
{elseif $key == 'AUTHOR'}
|
||||
{$author = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$author}&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{elseif $key == 'VIDEO' }
|
||||
{$video_name = $final}
|
||||
<a href="?type=videos&query={$smarty.get.query|form_val}&object={$video_name}&object_type=video&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{elseif $key == 'GROUP' }
|
||||
{$group_name = $final}
|
||||
<a href="?type=groups&query={$smarty.get.query|form_val}&object={$group_name.id}&object_type=group&s=elastic&p=search">{cleanString($final.source)} ( {$final.counts} )</a>
|
||||
{elseif $key =='COLLECTION' }
|
||||
{$collection_name = $final}
|
||||
<a href="?type=collections&query={$smarty.get.query|form_val}&object={$collection_name.id}&object_type=collection&s=elastic&p=search">{cleanString($final.source)} ( {$final.counts} )</a>
|
||||
{elseif $key == 'USER' }
|
||||
{$user_name = $final}
|
||||
<a href="?type=channels&query={$smarty.get.query|form_val}&object={$user_name}&object_type=user&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{elseif $key == 'SOURCE' }
|
||||
{$source = explode(' ',$final)}
|
||||
{$source = $source.1}
|
||||
|
||||
<a href="?type={$source}&query={$smarty.get.query|form_val}&category={$smarty.get.author|form_val}&author={$smarty.get.author|form_val}&s=elastic&p=search">{cleanString($final)}</a>
|
||||
{else}
|
||||
<a href="javascript:void(0)">{cleanString($final)}</a>
|
||||
{/if}
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
{if $flag}
|
||||
<a href="javascript:void(0)" class="more" >More...</a>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- right column -->
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
var more = true;
|
||||
$('.more').on("click",function(){
|
||||
if (more)
|
||||
{
|
||||
$(this).parent().find('.no-display').removeClass('hide');
|
||||
$(this).html("Less");
|
||||
|
||||
more = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).parent().find('.no-display').addClass('hide');
|
||||
$(this).html("More...");
|
||||
|
||||
more = true;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
208
upload/plugins/cb_elastic_search/search.php
Executable file
208
upload/plugins/cb_elastic_search/search.php
Executable file
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
|
||||
|
||||
if(!defined('IN_CLIPBUCKET'))
|
||||
exit('Invalid access');
|
||||
|
||||
|
||||
$section = get('s');
|
||||
$file = get('p');
|
||||
|
||||
|
||||
if(defined('IN_MODULE') && $section=='elastic')
|
||||
{
|
||||
|
||||
|
||||
//Elastic Search Page
|
||||
if($file=='search')
|
||||
{
|
||||
|
||||
|
||||
$search_mode = mysql_clean($_GET['type']) ? mysql_clean($_GET['type']) : 'all';
|
||||
$page = mysql_clean($_GET['page']);
|
||||
$sort = mysql_clean($_GET['search_by']);
|
||||
$search = mysql_clean($_GET['query']);
|
||||
$page = $_GET['page'] ? $_GET['page'] : 1;
|
||||
|
||||
#pex($search_mode,1);
|
||||
|
||||
//pre($sort,1);
|
||||
|
||||
|
||||
switch ($search_mode) {
|
||||
case 'videos':{
|
||||
|
||||
$query = array();
|
||||
$es = new ElasticSearch($search_mode);
|
||||
if (isset($_GET['category']) && !empty($_GET['category'])){
|
||||
$es->filters["category"] = mysql_clean($_GET['category']);
|
||||
}
|
||||
if (isset($_GET['author']) && !empty($_GET['author'])){
|
||||
$es->filters["author"] = mysql_clean($_GET['author']);
|
||||
}
|
||||
$es->publicQuery = $search;
|
||||
if ($sort){
|
||||
$es->sort = $sort;
|
||||
}
|
||||
if ($page > 1){
|
||||
$from = $page - 1;
|
||||
$es->from = $from * $es->size;
|
||||
}
|
||||
$es->buildQuery();
|
||||
$es->ElasticSearch();
|
||||
$results = json_decode($es->results['result'],1);
|
||||
#pre($results,1);
|
||||
if ($results["hits"]["hits"]){
|
||||
$es->resultsHits = $results["hits"]["hits"];
|
||||
foreach ($es->resultsHits as $key => $video) {
|
||||
$newVideos[] = $video["_source"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'photos':{
|
||||
|
||||
$query = array();
|
||||
$es = new ElasticSearch($search_mode);
|
||||
if (isset($_GET['category']) && !empty($_GET['category'])){
|
||||
$es->filters["category"] = mysql_clean($_GET['category']);
|
||||
}
|
||||
if (isset($_GET['author']) && !empty($_GET['author'])){
|
||||
$es->filters["author"] = mysql_clean($_GET['author']);
|
||||
}
|
||||
$es->publicQuery = $search;
|
||||
if ($sort){
|
||||
$es->sort = $sort;
|
||||
}
|
||||
if ($page > 1){
|
||||
$from = $page - 1;
|
||||
$es->from = $from * $es->size;
|
||||
}
|
||||
$es->buildQuery();
|
||||
$es->ElasticSearch();
|
||||
$results = json_decode($es->results['result'],1);
|
||||
#pex($results,1);
|
||||
if ($results["hits"]["hits"]){
|
||||
$es->resultsHits = $results["hits"]["hits"];
|
||||
foreach ($es->resultsHits as $key => $photo) {
|
||||
$newPhotos[] = $photo["_source"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'channels':{
|
||||
|
||||
$query = array();
|
||||
$es = new ElasticSearch('users');
|
||||
if (isset($_GET['category']) && !empty($_GET['category'])){
|
||||
$es->filters["category"] = $_GET['category'];
|
||||
}
|
||||
if (isset($_GET['author']) && !empty($_GET['author'])){
|
||||
$es->filters["author"] = $_GET['author'];
|
||||
}
|
||||
$es->publicQuery = $search;
|
||||
if ($sort){
|
||||
$es->sort = $sort;
|
||||
}
|
||||
if ($page > 1){
|
||||
$from = $page - 1;
|
||||
$es->from = $from * $es->size;
|
||||
}
|
||||
$es->buildQuery();
|
||||
$es->ElasticSearch();
|
||||
$results = json_decode($es->results['result'],1);
|
||||
#pex($results,1);
|
||||
if ($results["hits"]["hits"]){
|
||||
$es->resultsHits = $results["hits"]["hits"];
|
||||
foreach ($es->resultsHits as $key => $user) {
|
||||
$newUsers[] = $user["_source"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'all':
|
||||
default:{
|
||||
|
||||
$query = array();
|
||||
$es = new ElasticSearch(false);
|
||||
if (isset($_GET['category']) && !empty($_GET['category'])){
|
||||
$es->filters["category"] = $_GET['category'];
|
||||
}
|
||||
if (isset($_GET['author']) && !empty($_GET['author'])){
|
||||
$es->filters["author"] = $_GET['author'];
|
||||
}
|
||||
$es->publicQuery = $search;
|
||||
if ($sort){
|
||||
$es->sort = $sort;
|
||||
}
|
||||
if ($page > 1){
|
||||
$from = $page - 1;
|
||||
$es->from = $from * $es->size;
|
||||
}
|
||||
$es->buildQuery();
|
||||
$es->ElasticSearch();
|
||||
$results = json_decode($es->results['result'],1);
|
||||
#pex($results,1);
|
||||
if ($results["hits"]["hits"]){
|
||||
$es->resultsHits = $results["hits"]["hits"];
|
||||
foreach ($es->resultsHits as $key => $item) {
|
||||
if ($item["_index"] == 'videos'){
|
||||
$newVideos[] = $item["_source"];
|
||||
}
|
||||
if ($item["_index"] == 'users'){
|
||||
$newUsers[] = $item["_source"];
|
||||
}
|
||||
if ($item["_index"] == 'photos'){
|
||||
$newPhotos[] = $item["_source"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$filters = $es->makeFilters();
|
||||
assign("filter_results",$filters);
|
||||
|
||||
#pre($results,1);
|
||||
|
||||
|
||||
$get_limit = create_query_limit($page,10);
|
||||
$total_rows = $results["hits"]['total'];
|
||||
$total_pages = count_pages($total_rows,10);
|
||||
$pages->paginate($total_pages,$page);
|
||||
|
||||
|
||||
|
||||
|
||||
if (DEVELOPMENT_MODE)
|
||||
assign("time_took",$results["took"] / 1000);
|
||||
#pre($es->results['result'],1);
|
||||
assign("mode",$search_mode);
|
||||
assign("videos",$newVideos);
|
||||
assign("users",$newUsers);
|
||||
assign("photos",$newPhotos);
|
||||
|
||||
|
||||
template_files('search.html',CB_ES_DIR.'/');
|
||||
display_it();
|
||||
exit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
442
upload/plugins/cb_elastic_search/test.html
Executable file
442
upload/plugins/cb_elastic_search/test.html
Executable file
|
@ -0,0 +1,442 @@
|
|||
|
||||
|
||||
|
||||
<div class="content-holder clearfix">
|
||||
<div class="right-section padding-left">
|
||||
<div class="content clearfix">
|
||||
<div class="main-container">
|
||||
<div class="search-nav-holder groups-nav clearfix">
|
||||
<ul class="search-nav nav nav-tabs" role="tablist">
|
||||
<li class="{if $mode == 'all'}active{/if}">
|
||||
<a href="?search_mode=all&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}" >
|
||||
All
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'videos'}active{/if}" >
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}" >
|
||||
Videos
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'groups'}active{/if}" >
|
||||
<a href="?search_mode=groups&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}">
|
||||
Groups
|
||||
</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'collections'}active{/if}" >
|
||||
<a href="?search_mode=collections&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}" >
|
||||
Collections</a>
|
||||
</li>
|
||||
<li class="{if $mode == 'users'}active{/if}" >
|
||||
<a href="?search_mode=users&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}&search_by={$smarty.get.search_by|form_val}" >
|
||||
Users</a>
|
||||
</li>
|
||||
</ul>
|
||||
{if $time_took}
|
||||
<span class="pull-right label label label-info">
|
||||
{$time_took} seconds
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
</div><!-- search Nav -->
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'all'}active{/if}" id="all-tab">
|
||||
{if $videos}
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Videos
|
||||
<span class="pull-right"><a href="{link name='videos'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{foreach $videos as $video}
|
||||
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$video.video_link}">
|
||||
<!-- <img src="{get_thumb vdetails=$video size='320x200'}" alt="" class="img-responsive"> -->
|
||||
<img src="{get_thumb vdetails=$video.videoid size='320x200'}" alt="" class="img-responsive">
|
||||
<div class="like-comments">
|
||||
<span><i class="like"></i>{$video.likes}</span>
|
||||
<span><i class="comments"></i>{$video.comments_count}</span>
|
||||
</div>
|
||||
</a>
|
||||
<a href="{$video.video_link}" class="mask-icon">
|
||||
<span class="video-icon"></span>
|
||||
</a>
|
||||
</div>
|
||||
<h4>{$video.title}</h4>
|
||||
<p>{name($video)}</p>
|
||||
<div class="view-date clearfix">
|
||||
<span><i class="view"></i>{$video.views} views</span>
|
||||
<span><i class="date"></i>{$video.date_added|date_format} </span>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- videos -->
|
||||
{/if}
|
||||
{if $groups}
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Groups
|
||||
<span class="pull-right"><a href="{link name='groups'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{foreach $groups as $group}
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$group.group_url}">
|
||||
<img src="{$cbgroup->get_group_thumb($group,'110')}" alt="" class="img-responsive">
|
||||
<div class="search-group-circle">{$group.total_videos}<span>Videos</span></div>
|
||||
</a>
|
||||
</div>
|
||||
<h4 class="search-heading">{$group.group_name} </h4>
|
||||
<p class="search-para">{$group.ATCategory}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- Groups -->
|
||||
{/if}
|
||||
{if $collections}
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Collection
|
||||
<span class="pull-right"><a href="{link name='collections'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{foreach $collections as $collection}
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$collection.U}">
|
||||
<img src="{$cbgroup->get_group_thumb($collection,'110')}" alt="" class="img-responsive">
|
||||
<div class="search-group-circle">{$collection.total_videos}<span>Videos</span></div>
|
||||
</a>
|
||||
</div>
|
||||
<h4 class="search-heading">{$collection.group_name}</h4>
|
||||
<p class="search-para">{$collection.ATCategory}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- Collections -->
|
||||
{/if}
|
||||
{if $users}
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Users
|
||||
<span class="pull-right"><a href="{link name='channels'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="row">
|
||||
|
||||
{foreach $users as $user}
|
||||
{$user_details = $userquery->get_user_details($user.userid)}
|
||||
<div class="user-col">
|
||||
<a href="{$userquery->profile_link($user_details)}" {ANCHOR place='lync_info' data=$user_details} >
|
||||
<img src="{avatar details=$user_details}" alt="" class="img-responsive">
|
||||
</a>
|
||||
<div class="popper-content clearfix hide">
|
||||
<div class="img-holder">
|
||||
<img src="{avatar details=$user_details}" alt="" class="img-responsive">
|
||||
</div>
|
||||
<div class="content-user">
|
||||
<h4>{name($user_details)}</h4>
|
||||
<p><span>{$user.total_videos} {if $user.total_videos > 1}videos {else} video {/if}</span> | <span>{$user.views} Views</span>
|
||||
</p>
|
||||
</div>
|
||||
</div><!-- popper-content -->
|
||||
<h4>{name($user_details)}</h4>
|
||||
<p><span>{$user.total_videos} {if $user.total_videos > 1}videos {else}
|
||||
video {/if}</span> | <span>{$user.views} Views</span></p>
|
||||
</div><!-- user-col -->
|
||||
{/foreach}
|
||||
</div><!-- users list -->
|
||||
</div><!-- users -->
|
||||
{/if}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if !$videos && !$groups && !$collections && !$users }
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
|
||||
</div><!-- all users -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'videos'}active{/if}" id="videos-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Videos
|
||||
<span class="pull-right"><a href="{link name='videos'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{if $videos}
|
||||
{foreach $videos as $video}
|
||||
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$video.video_link}">
|
||||
<!-- <img src="{get_thumb vdetails=$video size='320x200'}" alt="" class="img-responsive"> -->
|
||||
<img src="{get_thumb vdetails=$video.videoid size='320x200'}" alt="" class="img-responsive">
|
||||
<div class="like-comments">
|
||||
<span><i class="like"></i>{$video.likes}</span>
|
||||
<span><i class="comments"></i>{$video.comments_count}</span>
|
||||
</div>
|
||||
</a>
|
||||
<a href="{$video.video_link}" class="mask-icon">
|
||||
<span class="video-icon"></span>
|
||||
</a>
|
||||
</div>
|
||||
<h4>{$video.title}</h4>
|
||||
<p>{name($video)}</p>
|
||||
<div class="view-date clearfix">
|
||||
<span><i class="view"></i>{$video.views} views</span>
|
||||
<span><i class="date"></i>{$video.date_added|date_format} </span>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!-- videos -->
|
||||
</div><!-- all videos -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'groups'}active{/if}" id="groups-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Groups
|
||||
<span class="pull-right"><a href="{link name='groups'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{if $groups}
|
||||
{foreach $groups as $group}
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$group.group_url}">
|
||||
<img src="{$cbgroup->get_group_thumb($group,'110')}" alt="" class="img-responsive">
|
||||
<div class="search-group-circle">{$group.total_videos}<span>Videos</span></div>
|
||||
</a>
|
||||
</div>
|
||||
<h4 class="search-heading">{$group.group_name} </h4>
|
||||
<p class="search-para">{$group.ATCategory}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Groups -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'collections'}active{/if}" id="collections-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Collections
|
||||
<span class="pull-right"><a href="{link name='collections'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="all-search-holder clearfix">
|
||||
{if $collections}
|
||||
{foreach $collections as $collection}
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 category-col">
|
||||
<div class="category-box">
|
||||
<a href="{$collection.U}">
|
||||
<img src="{$cbgroup->get_group_thumb($collection,'110')}" alt="" class="img-responsive">
|
||||
<div class="search-group-circle">{$collection.total_videos}<span>Videos</span></div>
|
||||
</a>
|
||||
</div>
|
||||
<h4 class="search-heading">{$collection.group_name}</h4>
|
||||
<p class="search-para">{$collection.ATCategory}</p>
|
||||
</div>
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Collections -->
|
||||
<div role="tabpanel" class="tab-pane {if $mode == 'users'}active{/if}" id="users-tab">
|
||||
<div class="search-sec clearfix visible-xs">
|
||||
<button type="button" class="btn btn-info btn-sm pull-right" data-toggle="modal" data-target="#filters-modal">Filters</button>
|
||||
</div>
|
||||
<div class="search-sec clearfix">
|
||||
<h3>
|
||||
Users
|
||||
<span class="pull-right"><a href="{link name='channels'}">See All</a></span>
|
||||
</h3>
|
||||
<div class="row">
|
||||
{if $users}
|
||||
{foreach $users as $user}
|
||||
{$user_details = $userquery->get_user_details($user.userid)}
|
||||
<div class="user-col">
|
||||
<a href="{$userquery->profile_link($user_details)}" {ANCHOR place='lync_info' data=$user_details} >
|
||||
<img src="{avatar details=$user_details}" alt="" class="img-responsive">
|
||||
</a>
|
||||
<div class="popper-content clearfix hide">
|
||||
<div class="img-holder">
|
||||
<img src="{avatar details=$user_details}" alt="" class="img-responsive">
|
||||
</div>
|
||||
<div class="content-user">
|
||||
<h4>{name($user_details)}</h4>
|
||||
<p><span>{$user.total_videos} {if $user.total_videos > 1}videos {else} video {/if}</span> | <span>{$user.views} Views</span>
|
||||
</p>
|
||||
</div>
|
||||
</div><!-- popper-content -->
|
||||
<h4>{name($user_details)}</h4>
|
||||
<p><span>{$user.total_videos} {if $user.total_videos > 1}videos {else}
|
||||
video {/if}</span> | <span>{$user.views} Views</span></p>
|
||||
</div><!-- user-col -->
|
||||
{/foreach}
|
||||
<div class="pagination-holder clearfix">
|
||||
<div class="pagination-holder clearfix">
|
||||
{include file="$style_dir/blocks/pagination.html"}
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<span class="well well-info btn-block">{lang code="no_search_results"}</span>
|
||||
{/if}
|
||||
</div><!-- users list -->
|
||||
</div>
|
||||
</div><!-- users -->
|
||||
</div><!-- tab content -->
|
||||
</div><!-- left column -->
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 hidden-xs">
|
||||
<div class="search-sort-by clearfix">
|
||||
<div class="sortby-holder">
|
||||
<span>Sort by:</span>
|
||||
<div class="dropdown">
|
||||
<button aria-expanded="true" data-toggle="dropdown" id="dropdownMenu1" type="button" class="btn btn-default dropdown-toggle">
|
||||
{if $smarty.get.search_by=='rel'}
|
||||
Relevance
|
||||
{elseif $smarty.get.search_by=='date'}
|
||||
Date
|
||||
{elseif $smarty.get.search_by=='views'}
|
||||
Popularity
|
||||
{else}
|
||||
Relevance
|
||||
{/if}
|
||||
<span class="caret-arrow"></span>
|
||||
</button>
|
||||
<ul aria-labelledby="dropdownMenu1" role="menu" class="dropdown-menu">
|
||||
<li role="presentation">
|
||||
<a href="?search_mode={$smarty.get.search_mode|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=rel">Relevance</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="?search_mode={$smarty.get.search_mode|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=date">Date</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="?search_mode={$smarty.get.search_mode|form_val}&query={$smarty.get.query|form_val}&category={$category}&author={$smarty.get.author|form_val}&search_by=views">Popularity</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-filter clearfix">
|
||||
{foreach $filter_results as $key => $filter}
|
||||
<div class="filter-col clearfix">
|
||||
{if $filter.0 != ''}
|
||||
|
||||
|
||||
<h4>{$key}</h4>
|
||||
<ul>
|
||||
{foreach $filter as $final}
|
||||
{if $final@iteration < 5}
|
||||
<li class="display">
|
||||
{if $key == 'CATEGORY' }
|
||||
{$category = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&category={$category.id}&author={$smarty.get.author|form_val}">
|
||||
|
||||
{cleanString($final.source)} ( {$final.counts} )
|
||||
</a>
|
||||
{elseif $key == 'AUTHOR'}
|
||||
{$author = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$author.id}">{cleanString(name($final.source))} ( {$final.counts} )</a>
|
||||
{elseif $key == 'VIDEO' }
|
||||
{$video_name = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&object={$video_name}&object_type=video">{cleanString($final)}</a>
|
||||
{elseif $key == 'GROUP' }
|
||||
{$group_name = $final}
|
||||
<a href="?search_mode=groups&query={$smarty.get.query|form_val}&object={$group_name.id}&object_type=group">{cleanString($group_name.source)}</a>
|
||||
{elseif $key =='COLLECTION' }
|
||||
{$collection_name = $final}
|
||||
<a href="?search_mode=collections&query={$smarty.get.query|form_val}&object={$collection_name.id}&object_type=collection">{cleanString($collection_name.source)}</a>
|
||||
{elseif $key == 'USER' }
|
||||
{$user_name = $final}
|
||||
<a href="?search_mode=users&query={$smarty.get.query|form_val}&object={$user_name}&object_type=user">{cleanString($final)}</a>
|
||||
{elseif $key == 'SOURCE' }
|
||||
<a href="?search_mode={$final.key}&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$smarty.get.author|form_val}">{cleanString($final.key)} ( {$final.doc_count} )</a>
|
||||
{else}
|
||||
<a href="javascript:void(0)">{cleanString($final)}</a>
|
||||
{/if}
|
||||
|
||||
</li>
|
||||
{else}
|
||||
{$flag = true}
|
||||
<li class="no-display hide" >
|
||||
{if $key == 'CATEGORY' }
|
||||
{$category = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&category={$category.id}&author={$smarty.get.author|form_val}">{cleanString($final.source)} ( {$final.counts} )
|
||||
{elseif $key == 'AUTHOR'}
|
||||
{$author = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&category={$smarty.get.category|form_val}&author={$author}">{cleanString($final)}</a>
|
||||
{elseif $key == 'VIDEO' }
|
||||
{$video_name = $final}
|
||||
<a href="?search_mode=videos&query={$smarty.get.query|form_val}&object={$video_name}&object_type=video">{cleanString($final)}</a>
|
||||
{elseif $key == 'GROUP' }
|
||||
{$group_name = $final}
|
||||
<a href="?search_mode=groups&query={$smarty.get.query|form_val}&object={$group_name.id}&object_type=group">{cleanString($final.source)} ( {$final.counts} )</a>
|
||||
{elseif $key =='COLLECTION' }
|
||||
{$collection_name = $final}
|
||||
<a href="?search_mode=collections&query={$smarty.get.query|form_val}&object={$collection_name.id}&object_type=collection">{cleanString($final.source)} ( {$final.counts} )</a>
|
||||
{elseif $key == 'USER' }
|
||||
{$user_name = $final}
|
||||
<a href="?search_mode=users&query={$smarty.get.query|form_val}&object={$user_name}&object_type=user">{cleanString($final)}</a>
|
||||
{elseif $key == 'SOURCE' }
|
||||
{$source = explode(' ',$final)}
|
||||
{$source = $source.1}
|
||||
|
||||
<a href="?search_mode={$source}&query={$smarty.get.query|form_val}&category={$smarty.get.author|form_val}&author={$smarty.get.author|form_val}">{cleanString($final)}</a>
|
||||
{else}
|
||||
<a href="javascript:void(0)">{cleanString($final)}</a>
|
||||
{/if}
|
||||
</li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
{if $flag}
|
||||
<a href="javascript:void(0)" class="more" >More...</a>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div><!-- right column -->
|
||||
</div>
|
||||
</div><!-- content -->
|
||||
</div><!-- content -->
|
||||
</div>
|
||||
</div><!-- content -->
|
0
upload/plugins/cb_elastic_search/uninstall_elastic_search.php
Executable file
0
upload/plugins/cb_elastic_search/uninstall_elastic_search.php
Executable file
2
upload/styles/cb_28/layout/blocks/category_list.html
Normal file → Executable file
2
upload/styles/cb_28/layout/blocks/category_list.html
Normal file → Executable file
|
@ -68,7 +68,7 @@
|
|||
{foreach from=$sub3.children item=sub4}
|
||||
<li>
|
||||
<div>
|
||||
<a class="">{$sub4.category_name}</a>
|
||||
<a href="{cblink(['name'=>'category','data'=>$sub4,'type'=>$type])}">{display_clean($sub4.category_name)}</a>
|
||||
{if $sub4.children}<i class="icon-right-arrow trigger" data-level="5" ></i>{/if}
|
||||
</div>
|
||||
</li>
|
||||
|
|
1
upload/styles/cb_28/layout/header.html
Normal file → Executable file
1
upload/styles/cb_28/layout/header.html
Normal file → Executable file
|
@ -107,6 +107,7 @@
|
|||
<input type="text" class="form-control" name="query" placeholder="{lang code="search_keyword_feed"}" value="{'query'|get_form_val:true}" id="query">
|
||||
<input type="hidden" name="type" class="type" value="{if isset($smarty.get.type)}{$smarty.get.type}{elseif $toSearch}{$toSearch}{else}videos{/if}" id="type">
|
||||
<button tabindex="-1" type="submit" name="cbsearch" id="cbsearch" class="btn btn-default btn-search icon-search"></button>
|
||||
{ANCHOR place="elastic_mode_search"}
|
||||
</div>
|
||||
</form><!-- form Ends -->
|
||||
</div>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
$tags = $vdo['tags'];
|
||||
$videoid = $vdo['videoid'];
|
||||
$related_videos = get_videos(array('title'=>$title,'tags'=>$tags,
|
||||
'exclude'=>$videoid,'show_related'=>'yes','limit'=>12,'order'=>'date_added DESC'));
|
||||
'exclude'=>$videoid,'show_related'=>'yes','limit'=>12,'order'=>'RAND()'));
|
||||
if(!$related_videos){
|
||||
$relMode = "ono";
|
||||
$related_videos = get_videos(array('exclude'=>$videoid,'limit'=>12,'order'=>'date_added DESC'));
|
||||
|
|
Loading…
Add table
Reference in a new issue