'; */
return $ratingTemplate;
}
/**
* Function used to display
* Blank Screen
* if there is nothing to play or to show
* then show a blank screen
*/
function blank_screen($data) {
global $swfobj;
$code = '
No Player or Video File Found - Unable to Play Any Video
';
$swfobj->EmbedCode(unhtmlentities($code), $data['player_div']);
return $swfobj->code;
}
/**
* Adds js files in ClipBucket template.
*
* @link http://docs.clip-bucket.com/user-manual/developers-guide/functions/functions_templates/add_js
* @global type $Cbucket
* @param type $files
* @return type
* @since 2.6
*/
function add_js($files, $scope = 'global') {
global $Cbucket;
if ($files) {
if (is_array($scope)) {
foreach ($scope as $sc) {
if (is_array($files))
foreach ($files as $file)
$Cbucket->JSArray[$sc][] = $file;
else
$Cbucket->JSArray[$sc][] = $files;
}
}else {
if (is_array($files))
foreach ($files as $file)
$Cbucket->JSArray[$scope][] = $file;
else
$Cbucket->JSArray[$scope][] = $files;
}
}
return;
}
/**
* Adds CSS Files in ClipBucket template
*
* @link http://docs.clip-bucket.com/user-manual/developers-guide/functions/functions_templates/add_css
* @since 2.6
* @param STRING $file CSS FILE
* @param STRING $scope File Scope, read more about scope on http://docs.clip-bucket.com/
*/
function add_css($files, $scope) {
global $Cbucket;
if ($files) {
if (is_array($scope)) {
foreach ($scope as $sc) {
if (is_array($files)) {
foreach ($files as $file) {
$Cbucket->CSSArray[$sc][] = $file;
}
} else {
$Cbucket->CSSArray[$sc][] = $files;
}
}
} else {
if (is_array($files)) {
foreach ($files as $file) {
$Cbucket->CSSArray[$scope][] = $file;
}
} else {
$Cbucket->CSSArray[$scope][] = $files;
}
}
}
return;
}
/**
* Function add_header()
* this will be used to add new files in header array
* this is basically for plugins
* for specific page array('page'=>'file')
* ie array('uploadactive'=>'datepicker.js')
*/
function add_header($files) {
global $Cbucket;
return $Cbucket->add_header($files);
}
function add_admin_header($files) {
global $Cbucket;
return $Cbucket->add_admin_header($files);
}
/**
* Function used to show sharing form
*/
function show_share_form($array) {
assign('params', $array);
Template('blocks/share_form.html');
}
/**
* Function used to show flag form
*/
function show_flag_form($array) {
assign('params', $array);
Template('blocks/flag_form.html');
}
/**
* Function used to show flag form
*/
function show_playlist_form($array) {
global $cbvid;
assign('params', $array);
$playlists = $cbvid->action->get_playlists();
assign('playlists', $playlists);
Template('blocks/playlist_form.html');
}
/**
* Function used to show collection form
*/
function show_collection_form($params) {
global $db, $cbcollection;
if (!userid())
$loggedIn = "not";
else {
$collectArray = array("order" => " collection_name ASC", "type" => "videos", "user" => userid());
$collections = $cbcollection->get_collections($collectArray);
assign("collections", $collections);
}
Template("/blocks/collection_form.html");
}
/**
* Function used to check weather tempalte file exists or not
* input path to file
*/
function template_file_exists($file, $dir) {
if (!file_exists($dir . '/' . $file) && !empty($file) && !file_exists($file)) {
echo sprintf(lang("temp_file_load_err"), $file, $dir);
return false;
}else
return true;
}
/**
* Category Link is used to return
* Category based link
*/
function category_link($data, $type) {
switch ($type) {
case 'video':case 'videos':case 'v': {
if (SEO == 'yes')
return BASEURL . '/videos/' . $data['category_id'] . '/' . SEO($data['category_name']) . '/' . $_GET['sort'] . '/' . $_GET['time'] . '/';
else
return BASEURL . '/videos.php?cat=' . $data['category_id'] . '&sort=' . $_GET['sort'] . '&time=' . $_GET['time'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
case 'channels':case 'channel':case'c':case'user': {
if (SEO == 'yes')
return BASEURL . '/channels/' . $data['category_id'] . '/' . SEO($data['category_name']) . '/' . $_GET['sort'] . '/' . $_GET['time'] . '/';
else
return BASEURL . '/channels.php?cat=' . $data['category_id'] . '&sort=' . $_GET['sort'] . '&time=' . $_GET['time'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
default: {
if (THIS_PAGE == 'photos')
$type = 'photos';
if (defined("IN_MODULE")) {
$url = 'cat=' . $data['category_id'] . '&sort=' . $_GET['sort'] . '&time=' . $_GET['time'] . '&page=' . $_GET['page'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
global $prefix_catlink;
$url = $prefix_catlink . $url;
$rm_array = array("cat", "sort", "time", "page", "seo_cat_name");
$p = "";
if ($prefix_catlink)
$rm_array[] = 'p';
$plugURL = queryString($url, $rm_array);
return $plugURL;
}
if (SEO == 'yes')
return BASEURL . '/' . $type . '/' . $data['category_id'] . '/' . SEO($data['category_name']) . '/' . $_GET['sort'] . '/' . $_GET['time'] . '/';
else
return BASEURL . '/' . $type . '.php?cat=' . $data['category_id'] . '&sort=' . $_GET['sort'] . '&time=' . $_GET['time'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
}
}
/**
* Sorting Links is used to return
* Sorting based link
*/
function sort_link($sort, $mode = 'sort', $type) {
switch ($type) {
case 'video':
case 'videos':
case 'v': {
if (!isset($_GET['cat']))
$_GET['cat'] = 'all';
if (!isset($_GET['time']))
$_GET['time'] = 'all_time';
if (!isset($_GET['sort']))
$_GET['sort'] = 'most_recent';
if (!isset($_GET['page']))
$_GET['page'] = 1;
if (!isset($_GET['seo_cat_name']))
$_GET['seo_cat_name'] = 'All';
if ($mode == 'sort')
$sorting = $sort;
else
$sorting = $_GET['sort'];
if ($mode == 'time')
$time = $sort;
else
$time = $_GET['time'];
if (SEO == 'yes')
return BASEURL . '/videos/' . $_GET['cat'] . '/' . $_GET['seo_cat_name'] . '/' . $sorting . '/' . $time . '/' . $_GET['page'];
else
return BASEURL . '/videos.php?cat=' . $_GET['cat'] . '&sort=' . $sorting . '&time=' . $time . '&page=' . $_GET['page'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
case 'channels':
case 'channel': {
if (!isset($_GET['cat']))
$_GET['cat'] = 'all';
if (!isset($_GET['time']))
$_GET['time'] = 'all_time';
if (!isset($_GET['sort']))
$_GET['sort'] = 'most_recent';
if (!isset($_GET['page']))
$_GET['page'] = 1;
if (!isset($_GET['seo_cat_name']))
$_GET['seo_cat_name'] = 'All';
if ($mode == 'sort')
$sorting = $sort;
else
$sorting = $_GET['sort'];
if ($mode == 'time')
$time = $sort;
else
$time = $_GET['time'];
if (SEO == 'yes')
return BASEURL . '/channels/' . $_GET['cat'] . '/' . $_GET['seo_cat_name'] . '/' . $sorting . '/' . $time . '/' . $_GET['page'];
else
return BASEURL . '/channels.php?cat=' . $_GET['cat'] . '&sort=' . $sorting . '&time=' . $time . '&page=' . $_GET['page'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
default: {
if (!isset($_GET['cat']))
$_GET['cat'] = 'all';
if (!isset($_GET['time']))
$_GET['time'] = 'all_time';
if (!isset($_GET['sort']))
$_GET['sort'] = 'most_recent';
if (!isset($_GET['page']))
$_GET['page'] = 1;
if (!isset($_GET['seo_cat_name']))
$_GET['seo_cat_name'] = 'All';
if ($mode == 'sort')
$sorting = $sort;
else
$sorting = $_GET['sort'];
if ($mode == 'time')
$time = $sort;
else
$time = $_GET['time'];
if (THIS_PAGE == 'photos')
$type = 'photos';
if (defined("IN_MODULE")) {
$url = 'cat=' . $_GET['cat'] . '&sort=' . $sorting . '&time=' . $time . '&page=' . $_GET['page'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
$plugURL = queryString($url, array("cat", "sort", "time", "page", "seo_cat_name"));
return $plugURL;
}
if (SEO == 'yes')
return BASEURL . '/' . $type . '/' . $_GET['cat'] . '/' . $_GET['seo_cat_name'] . '/' . $sorting . '/' . $time . '/' . $_GET['page'];
else
return BASEURL . '/' . $type . '.php?cat=' . $_GET['cat'] . '&sort=' . $sorting . '&time=' . $time . '&page=' . $_GET['page'] . '&seo_cat_name=' . $_GET['seo_cat_name'];
}
break;
}
}
/**
* function used to call clipbucket footers
*/
function footer() {
$funcs = get_functions('clipbucket_footer');
if (is_array($funcs) && count($funcs) > 0) {
foreach ($funcs as $func) {
if (function_exists($func)) {
$func();
}
}
}
}
/**
* FUnction used to get head menu
*/
function head_menu($params = NULL) {
global $Cbucket;
return $Cbucket->head_menu($params);
}
/**
* This function returns the provided menu. If no name is passed
* navigation menu will load automatically.
*
* @global object $Cbucket
* @param array $params
* @return string
*/
function cbMenu($params = NULL) {
global $Cbucket;
$name = $params['name'];
if (!$name) {
$name = 'navigation';
}
$menu = get_menu($name);
$params['show_icons'] = $params['show_icons'] ? $params['show_icons'] : 'yes';
if ($menu) {
foreach ($menu as $item) {
$continue = true;
if ($item['section'] && !isSectionEnabled($item['section'])) {
$continue = false;
}
if ($continue == true) {
$selected = current_page(array('page' => $item['section']));
$icon = '';
$output .= '
";
}
}
if ($params['assign']) {
assign($params['assign'], $output);
} else {
return $output;
}
}
//pr( $menu , true );
//return $Cbucket->cbMenu($params);
}
/**
* FUnction used to get foot menu
*/
function foot_menu($params = NULL) {
global $Cbucket;
return $Cbucket->foot_menu($params);
}
/**
* This function used to include headers in tag
* it will check weather to include the file or not
* it will take file and its type as an array
* then compare its type with THIS_PAGE constant
* if header has TYPE of THIS_PAGE then it will be inlucded
*/
function include_header($params) {
$file = $params['file'];
$type = $params['type'];
if ($file == 'global_header') {
Template(BASEDIR . '/styles/global/head.html', false);
return false;
}
if ($file == 'admin_bar') {
if (has_access('admin_access', TRUE))
Template(BASEDIR . '/styles/global/admin_bar.html', false);
return false;
}
if (!$type)
$type = "global";
if (is_includeable($type))
Template($file, false);
return false;
}
/**
* Function used to check weather to include
* given file or not
* it will take array of pages
* if array has ACTIVE PAGE or has GLOBAL value
* it will return true
* otherwise FALSE
*/
function is_includeable($array) {
if (!is_array($array))
$array = array($array);
if (in_array(THIS_PAGE, $array) || in_array('global', $array)) {
return true;
}else
return false;
}
/**
* This function works the same way as include_header
* but the only difference is , it is used to include
* JS files only
* @deprecated v3.0
*/
$the_js_files = array();
function include_js($params) {
global $the_js_files;
$file = $params['file'];
$type = $params['type'];
if (!in_array($file, $the_js_files)) {
$the_js_files[] = $file;
if ($type == 'global')
return '';
elseif (is_array($type)) {
foreach ($type as $t) {
if ($t == THIS_PAGE)
return '';
}
}elseif ($type == THIS_PAGE)
return '';
}
return false;
}
/**
* function used to get theme options
* @todo Write documentation
*/
function theme_config($name) {
global $Cbucket;
if ($Cbucket->theme_configs)
$theme_configs = $Cbucket->theme_configs;
else
$theme_configs = theme_configs();
$value = $value[$name];
}
/**
* Get them configurations
* @global type $Cbucket
* @return type
*/
function theme_configs() {
global $Cbucket;
$value = config($Cbucket->template . '-options');
$value = json_decode($value, true);
$value = $value['options'];
return $value;
}
/**
* add link in admin area left menu
*
* Function used to add items in admin menu
* This function will insert new item in admin menu
* under given header, if the header is not available
* it will create one, ( Header means titles ie 'Plugins' 'Videos' etc)
* http://docs.clip-bucket.com/add_admin_menu-function for reference
*
* @todo Write documentation
*/
function add_admin_menu($params, $name = false, $link = false, $plug_folder = false, $is_player_file = false) {
global $Cbucket;
if (!is_array($params)) {
$params = _add_admin_menu($params, $name, $link, $plug_folder, $is_player_file);
add_admin_sub_menu($params);
return true;
}
$defaults = array(
'title' => lang('Settings'),
'id' => 'settings',
'icon' => 'icon-gauge',
'access' => 'admin-access'
);
$params = array_merge($defaults, $params);
return $Cbucket->AdminMenu[$params['id']] = $params;
}
/**
* add multiple admin menus
*/
function add_admin_menus($menus) {
if (is_array($menus)) {
foreach ($menus as $menu)
add_admin_menu($menu);
}
}
/**
* @todo write documentation
*/
function add_admin_sub_menu($params) {
global $Cbucket;
$defaults = array(
'parent_id' => 'tool-box',
'access' => 'admin_access',
);
$params = array_merge($defaults, $params);
if ($params['title']) {
$id = $params['id'];
if (!$id)
$id = SEO($params['title']);
$menu = array(
'id' => $id,
'parent_id' => $params['parent_id'],
'access' => $params['access'],
'title' => $params['title'],
'link' => $params['link'],
'icon' => $params['icon'],
);
if ($Cbucket->AdminMenu[$params['parent_id']]) {
$Cbucket->AdminMenu[$params['parent_id']]['sub_menu'][] = $menu;
} else {
//Add menu to misc menu
$Cbucket->AdminMenu['miscellaneous']['sub_menu'][] = $menu;
}
}
}
function add_admin_sub_menus($params) {
if (is_array($params)) {
foreach ($params as $parent => $child) {
foreach ($child as $ch) {
$ch['parent_id'] = $parent;
add_admin_sub_menu($ch);
}
}
}
}
function _add_admin_menu($header = 'Tool Box', $name = false, $link = false, $plug_folder = false, $is_player_file = false) {
global $Cbucket;
//Get Menu
$menu = $Cbucket->AdminMenu;
if ($plug_folder)
$link = 'plugin.php?folder=' . $plug_folder . '&file=' . $link;
if ($is_player_file)
$link .= '&player=true';
//Add New Menu
$menu[$header][$name] = $link;
//Add sub menu function here...
$params = array(
'title' => $name,
'parent_id' => SEO($header),
'id' => SEO('title'),
'link' => $link
);
return $params;
}
/**
* get admin menu
*
* @todo Write documentation
*/
function get_admin_menu() {
global $Cbucket;
$array = $Cbucket->AdminMenu;
//Apply Filters
$array = apply_filters($array, 'admin_menu');
return $array;
}
/**
* get list of icons in category-icons folder
*/
function get_category_icons() {
//Check if there is a folder
//template for category icons
if (file_exists(FRONT_TEMPLATEDIR . '/category-icons')) {
$dir = FRONT_TEMPLATEDIR . '/category-icons';
$dir_url = FRONT_TEMPLATEURL . '/category-icons';
} else {
$dir = BASEDIR . '/images/category-icons';
$dir_url = BASEURL . '/images/category-icons';
}
//Blank list of images
$images = array();
if (file_exists($dir)) {
//Only get PNGs
$imgList = glob($dir . '/*.png');
if ($imgList) {
foreach ($imgList as $img) {
list($width, $height, $type, $attr) = getimagesize($img);
if ($width && $height)
$images[] = $img;
}
}
}
$final_images = array();
if ($images) {
foreach ($images as $image) {
$imagearr = explode('/', $image);
$imageName = $imagearr[count($imagearr) - 1];
$final_images[$imageName] = array('url' => $dir_url . '/' . $imageName,
'path' => $dir . '/' . $imageName);
}
}
return $final_images;
}
/**
* Loading Pointer
*
* Displays a loading image with the given ID
* we need this pointer on many places to let user know if the
* process is finised or not to improve UI
*
* @param ID String
* @return Image wraped in img tag with ID and hidden by default
*/
function loading_pointer($params) {
$id = $params['place'] ? $params['place'] : $params['id'];
$img = TEMPLATEURL . '/images/loaders/1.gif';
return '';
}
/**
* Shortify Numbers
*
* display large numbers in short forms by adding K
* and triming the rest
* 100,000 => 100K 105,2345 => 105.2K
*
* @param INT $numbers
* @return STRING $shortened
*/
function shortify($numbers) {
if (is_numeric($numbers)) {
if ($numbers > 1000) {
$new = round($numbers / 1000, 1);
return $new . 'K';
}
}
}
/**
* Displays the rating in the template in an ajax request
* @todo Write Documentation
*
* filters isliye lagay hain take array main radobadal ki ja skay
* cb_call_functions baad main issy array ko istemal kr k rating
* show krwa dega, is k liye pehle cb_register_function krwana
* parre ga.
*
* return isliye kuch nhin krwaya kion k cb_call_funcion b kuch return
* nhin kr ra hai wo ilsye k ye content ko format nhin krta
* balke jitne registered functions hote hain unko call krta aur bich
* me hi echo hota
*/
function showRating($rating) {
$rating = apply_filters($rating, 'show-rating');
cb_call_functions('show_rating', $rating);
}
function get_menu($name) {
global $Cbucket;
$menu = $Cbucket->menus[$name];
if ($menu) {
$menu = apply_filters($menu, 'filter_menu');
return $menu;
} else {
return false;
}
}
function add_menu($name, $items = null) {
global $Cbucket;
if (!get_menu($name) && !is_null($items) && is_array($items)) {
$Cbucket->menus[$name] = array();
add_menu_items($name, $items);
}
}
function add_menu_items($name, $items) {
if (is_array($items)) {
foreach ($items as $item) {
add_menu_item($name, $item);
}
}
}
/**
* This adds a new item in provided menu.
* @param $name STRING, Name of the menu in which item will be added
* @param $item STRING|ARRAY, If a string is provided it will be considered as item title
* it should be an array
* @param $link STRING, HTTP URL for provided title
* @param $section STRING, Name of the section
* @param $icon STRING, Add class name for icon. http://twitter.github.com/bootstrap/base-css.html#icon
* contains list of all icons that you can use
* @param $id STRING, Unique id for this item
* @param $target STRING, Set a target for current item
*/
function add_menu_item($name, $item, $link = false, $section = false, $icon = false, $id = false, $target = '_self') {
global $Cbucket;
if (!is_array($item)) {
$item = array('title' => $item, 'link' => $link, 'icon' => $icon, 'target' => $target, 'id' => $id, 'section' => $section);
}
$item['id'] = $item['id'] ? $item['id'] : SEO(strtolower($item['title']));
$Cbucket->menus[$name][$item['id']] = $item;
}
/* * *
* fetch template files as defined int he template config
* @param file
* @param type , display | fetch
*/
function get_template($file, $type = 'fetch',$layout=true) {
$defaults = array(
'single_comment' => 'blocks/comments/comment.html',
'comments' => 'blocks/comments/comments.html',
'pagination' => 'blocks/pagination.html',
'topics' => 'blocks/groups/topics.html',
'single_topic' => 'blocks/groups/topic.html',
'group_topic' => 'blocks/groups/group_topic.html',
'group_video' => 'blocks/groups/video.html'
);
$files = config('template_files');
if ($files[$file]) {
$the_file = $files[$file];
} else {
$the_file = $defaults[$file];
}
if ($the_file) {
if ($type == 'fetch')
return fetch($the_file);
if ($type=='path')
{
$path = $the_file;
if($layout)
$path = LAYOUT.'/'.$the_file;
return $path;
}else
template($the_file);
}
}
/**
* Loads all javascript files, previous function include_js is now
* deprecated, all js files that are added using add_js function will be
* loadded this simple function
*
* @return js files wrappded in script tag
*/
function cb_load_js() {
global $Cbucket;
$js_array = $Cbucket->JSArray;
$js_array = apply_filters($js_array, 'js_array');
if (is_array($js_array)) {
foreach ($js_array as $scope => $js_files) {
if ((defined('THIS_PAGE') && $scope == THIS_PAGE) OR
$scope == 'global' || !defined('THIS_PAGE')) {
foreach ($js_files as $file) {
if (!strstr($file, 'http')) {
$file = JS_URL . '/' . $file;
}
echo '';
echo "\n";
}
}
}
}
}
/**
* Function loads ClipBucket CSS Files that are added using add_css function
* either in a plugin or a template file.
*
* @return CSS files...
*/
function cb_load_css() {
global $Cbucket;
$css_array = $Cbucket->CSSArray;
$css_array = apply_filters($css_array, '$css_array');
if (is_array($css_array)) {
foreach ($css_array as $scope => $css_files) {
if ((defined('THIS_PAGE') && $scope == THIS_PAGE) OR
$scope == 'global' || !defined('THIS_PAGE')) {
foreach ($css_files as $file) {
echo ' ';
echo "\n";
}
}
}
}
}
/**
* Source: http://www.barattalo.it/2010/02/02/recursive-remove-directory-rmdir-in-php/
* @param string $path
*/
function rmdir_recurse($path) {
$path = rtrim($path, '/') . '/';
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if ($file != '.' and $file != '..') {
$fullpath = $path . $file;
if (is_dir($fullpath))
rmdir_recurse($fullpath); else
unlink($fullpath);
}
}
closedir($handle);
rmdir($path);
}
/**
* Get manager order for provided $type
*
* @todo Add alias function for different objects
* @global OBJECT $Cbucket
* @param STRING $type
* @return MIX
*/
function object_manager_orders ( $type='video' ) {
global $Cbucket;
$orders = $Cbucket->manager_orders[ $type ];
if ( $orders ) {
$orders = apply_filters( $orders, 'manager_orders' );
return $orders;
}
return false;
}
/**
* Adds a new order for object
*
* @todo Add alias function for different objects
* @global OBJECT $Cbucket
* @param STRING $title
* @param STRING $order
* @param STRING $type
* @param STRING $id
* @return MIX
*/
function add_object_manager_order ( $title, $order, $type = 'video' ) {
global $Cbucket;
if ( !$title || !$order || !$type ) {
return false;
}
$order_array = array(
'title' => $title,
'order' => $order,
'id' => $type.'-'.SEO( strtolower($title) ).'-'.time()
);
$Cbucket->manager_orders[ trim($type) ][] = $order_array;
return $Cbucket->manager_orders;
}
/**
* Displays the current order title
*
* @todo Add alias function for different objects
* @param STRING $type
* @return MIX
*/
function current_object_order( $type = 'video' ) {
$current = $_GET['omo'] ? mysql_clean( $_GET['omo'] ) : (int)0;
$orders = object_manager_orders( $type );
if ( !$orders[$current] ) {
$current = 0;
}
if ( $orders[$current] ) {
return $orders[$current]['title'];
}
return false;
}
/**
* Displays the list of orders for current object. You have option to only
* display unselected orders excluding the current order. Set $display to
* 'all' to add all orders, adding CSS .active class to current one
*
* @todo Add alias function for different objects
* @param STRING $type
* @param STRING $display
* @return MIX
*/
function display_manager_orders( $type = 'video', $display = 'unselected' ) {
$orders = object_manager_orders( $type );
$current_order = $_GET['omo'] ? mysql_clean( $_GET['omo'] ) : (int)0;
if ( !$orders[$current_order] ) {
$current_order = 0;
}
$total_order = count( $orders );
if ( $_SERVER['QUERY_STRING'] ) {
$query_string = queryString(null,'omo');
}
if ( $orders ) {
foreach ( $orders as $key => $order ) {
if ( $key == $current_order && $display == 'unselected' && $total_order >= 2 ) {
continue; // skip the selected one
}
$active = '';
if ( $key == $current_order ) {
$active = ' class="active"';
}
$output .= '