Update : New Category System

This commit is contained in:
Arslan Hassan 2009-09-01 20:57:38 +00:00
parent 8ef54a1448
commit 33cfaca1de
10 changed files with 896 additions and 282 deletions

View file

@ -1,10 +1,10 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*******************************************
| Copyright (c) 2007-2009 Clip-Bucket.com & (Arslan Hassan). All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
*******************************************
*/
require_once '../includes/admin_config.php';
@ -13,30 +13,26 @@ $pages->page_redir();
//Form Processing
if(isset($_POST['add_cateogry'])){
$cbvid->add_category($_POST);
}
//Making Categoyr as Default
if(isset($_GET['make_default']))
{
$cid = mysql_clean($_GET['make_default']);
$cbvid->make_default_category($cid);
}
//Edit Categoty
if(isset($_GET['category'])){
$category = clean($_GET['category']);
if($myquery->CategoryExists($category)){
if(isset($_POST['update_category'])){
if($myquery->UpdateCategory($_GET['category'])){
$msg[] = "Category Has Been Updated";
}
}
$sql = "SELECT * from category WHERE categoryid = '".$category."'";
$rs = $db->Execute($sql);
$category_data = $rs->getrows();;
Assign('category_data',$category_data);
Assign('edit_category','show');
}else{
$msg[] = $LANG['cat_exist_error'];
}
assign("edit_category","show");
if(isset($_POST['update_category']))
{
$cbvid->update_category($_POST);
}
assign('cat_details',$cbvid->get_category($_GET['category']));
}
//Delete Category
if(isset($_GET['delete_category'])){
@ -48,13 +44,6 @@ assign('category',$cbvid->get_categories());
assign('total',$cbvid->total_categories());
Assign('msg',@$msg);
/*Template('header.html');
Template('leftmenu.html');
Template('message.html');
Template('category.html');
Template('footer.html');*/
$cbvid->get_default_category();
template_files('category.html');
display_it();

View file

@ -2,7 +2,7 @@
<span class="page_title">Video Categories</span>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<table width="98%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200" align="left" valign="middle" class="left_head" style="text-indent:10px">Manage Video Categories</td>
<td class="head">&nbsp;</td>
@ -42,10 +42,9 @@
</p></td>
</tr>
<tr>
<td valign="top" class="td_body">Category Thumb</td>
<td class="td_body"><label>
<input name="category_thumb" type="file" id="category_thumb" size="45">
</label></td>
<td class="td_body">Category Thumb</td>
<td align="left" class="td_body"><label for="cat_thumb"></label>
<input type="file" name="cat_thumb" id="cat_thumb" /></td>
</tr>
<tr>
<td class="td_body">&nbsp;</td>
@ -55,9 +54,10 @@
</form>
{/if}
{if $edit_category == "show"}
{section name=list loop=$category_data}
<form action="" method="post" enctype="multipart/form-data" name="edit_category" id="Edit Category">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="2" class="block">
<input name="cid" value="{$cat_details.category_id}" type="hidden" />
<input name="cur_name" value="{$cat_details.category_name}" type="hidden" />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="block">
<tr>
<td class="td_body">&nbsp;</td>
@ -66,24 +66,31 @@
<tr>
<td valign="top" class="td_body">Category Name*</td>
<td class="td_body"><label>
<input name="title" type="text" id="title" value="{$category_data[list].category_name}" size="45" />
<input name="name" type="text" id="name" value="{$cat_details.category_name}" size="45" />
</label></td>
</tr>
<tr>
<td valign="top" class="td_body">Category Description*</td>
<td class="td_body"><textarea name="description" id="description" cols="33" rows="5">{$category_data[list].category_description}</textarea></td>
<td class="td_body"><textarea name="desc" id="desc" cols="33" rows="5">{$cat_details.category_desc}</textarea></td>
</tr>
<tr>
<td valign="top" class="td_body">Make Default Category</td>
<td class="td_body"><p>
<label>
<input type="radio" name="default" value="yes" id="default_0" {if $cat_details.isdefault=='yes'} checked="checked"{/if} />
Yes</label>
<label>
<input name="default" type="radio" id="default_1" value="no" {if $cat_details.isdefault=='no'} checked="checked"{/if} />
No</label>
<br />
</p></td>
</tr>
<tr>
<td valign="top" class="td_body">Category Thumb</td>
<td class="td_body">Category Thumb</td>
<td class="td_body"><label>
<img src="{$category_thumbs}/{$category_data[list].category_thumb}" /> <br /><input name="category_thumb" type="file" id="category_thumb" size="45" />
<input type="hidden" name="thumb" id="thumb" value="{$category_data[list].category_thumb}" />
<input type="file" name="cat_thumb" id="cat_thumb" />
</label></td>
</tr>
<tr>
<td class="td_body">&nbsp;</td>
<td class="td_body"><label></label></td>
</tr>
<tr>
<td colspan="2" align="right" class="tr_head"><label>
<input type="submit" name="update_category" id="button" value="Update Category" onclick="return validate_category_form(edit_category)" class="button"/>
@ -91,7 +98,6 @@
</tr>
</table>
</form>
{/section}
{/if}
@ -100,25 +106,38 @@
</div>
{if $total != 0}
<table width="67%" border="0" align="left" cellpadding="0" cellspacing="0">
<table width="98%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" class="left_head">Category Name</td>
<td width="22%" class="left_head" style="text-indent:10px">Category Name</td>
<td width="9%" class="head_sep_left">Thumb</td>
<td width="34%" class="head_sep_left">Description</td>
<td width="28%" class="head_sep_left">Defaul</td>
<td width="7%" align="center" class="right_head">Action</td>
<td width="28%" class="head_sep_left">Default</td>
<td width="7%" class="head_sep_left">Action</td>
<td width="20" align="left" class="right_head">&nbsp;</td>
</tr>
{assign var = bgcolor value = ""}
{assign var = bgcolor value = ""}
{section name=list loop=$category}
<tr bgcolor="{$bgcolor}">
<script type="text/javascript">
cat_div = "#thumbs_{$category[list].category_id}";
{literal}
$(function() { {/literal}
$("#thumbs_{$category[list].category_id}").tooltip({literal}{showURL: false});
});
{/literal}
</script>
<tr bgcolor="{$bgcolor}" class="item_listing">
<td style="text-indent:10px">{$category[list].category_name}</td>
<td style="text-indent:10px"><a href="#" onMouseover="fixedtooltip('<img src={$category_thumbs}/{$category[list].category_thumb} border=1/>', this, event, '0px')" onMouseout="delayhidetip()">View Thumb</a></td>
<td style="text-indent:10px">{$category[list].category_desc}</td>
<td style="text-indent:10px"><a id="thumbs_{$category[list].category_id}" title="<img src='{$cbvid->get_category_thumb($category[list])}' />" href="javascript:void(0)">View Thumb</a>
</td>
<td style="text-indent:10px">{if $category[list].category_desc}{$category[list].category_desc}{else}<em>N/A</em>{/if}</td>
<td style="text-indent:10px">{$category[list].isdefault}</td>
<td style="text-indent:10px">
<li><a href="?category={$category[list].categoryid}">Edit</a></li>
<li><a href="?category={$category[list].category_id}">Edit</a></li>
<li><a href="javascript:Confirm_Delete('?delete_category={$category[list].category_id}')">Delete</a></li>
{if $category[list].isdefault!="yes"}<li><a href="?make_default={$category[list].category_id}">Make Default</a></li>{/if}
</td>
<td style="text-indent:10px">&nbsp;</td>
</tr>
{if $bgcolor == ""}
{assign var = bgcolor value = "#EEEEEE"}

View file

@ -61,11 +61,11 @@ var baseurl = "{$baseurl}";
tooltip : 'Click to edit...',
});
});
</script>
{/literal}
</head>

View file

@ -1,3 +1,7 @@
/*
Link Color : #0c4469
*/
@import url("slidemenu.css");
@import url("pagination.css");
@import url("cbtab.css");
@ -110,4 +114,10 @@ padding-left:5px; font-size:16px; font-weight:bold; font-family:Arial, Helvetica
.search_box{margin:5px; padding:5px; border:1px solid #146194; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; background:#eff9ff}
.video_search .input{border:1px solid #666}
.video_search .input{border:1px solid #666}
.item_listing td{border-bottom:1px solid #ccc}
.item_listing li{list-style:none}
.item_listing a{color:#0c4469; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-style:italic}

View file

@ -0,0 +1,337 @@
<?php
/**
* @Author : Arslan Hassan <arslan@clip-bucket.com>
* This class is used to create
* and manage categories
* its an abstract class
* it will be used in plugins or built-in
* sections to use category system like videos, groups , channels etc
*
* this abstract class has some rules
* each section's category column should be named as "category"
* each section's category table must have same columns as video_categories
*/
abstract class CBCategory
{
var $cat_tbl = ''; //Name of category Table
var $section_tbl = ''; //Name of table that related to $cat_tbl
var $cat_thumb_height = '125';
var $cat_thumb_width = '125';
var $default_thumb = 'no_thumb.jpg';
/**
* Function used to check weather category exists or not
*/
function category_exists($cid)
{
global $db;
return $this->get_category($cid);
}
/**
* Function used to get category details
*/
function get_category($cid)
{
global $db;
$results = $db->select($this->cat_tbl,"*"," category_id='$cid' ");
if($db->num_rows>0)
{
return $results[0];
}else{
return false;
}
}
/**
* Function used to get category by name
*/
function get_cat_by_name($name)
{
global $db;
$results = $db->select($this->cat_tbl,"*"," category_name='$name' ");
if($db->num_rows>0)
{
return $results[0];
}else{
return false;
}
}
/**
* Function used to add new category
*/
function add_category($array)
{
global $db;
$name = mysql_clean($array['name']);
$desc = mysql_clean($array['desc']);
$default = mysql_clean($array['default']);
if($this->get_cat_by_name($name))
{
e(lang("add_cat_erro"));
}elseif(empty($name))
{
e(lang("add_cat_no_name_err"));
}else{
$cid = $db->insert($this->cat_tbl,
array("category_name","category_desc","date_added"),
array($name,$desc,now())
);
$cid = $db->insert_id();
if($default=='yes' || !$this->get_default_category())
$this->make_default_category($cid);
e(lang("cat_add_msg"),m);
//Uploading thumb
if(!empty($_FILES['cat_thumb']['tmp_name']))
$this->add_category_thumb($cid,$_FILES['cat_thumb']);
}
}
/**
* Function used to make category as default
*/
function make_default_category($cid)
{
global $db;
if($this->category_exists($cid))
{
$db->update($this->cat_tbl,array("isdefault"),array("no")," isdefault='yes' ");
$db->update($this->cat_tbl,array("isdefault"),array("yes")," category_id='$cid' ");
e(lang("cat_set_default_ok"),m);
}else
e(lang("cat_exist_error"));
}
/**
* Function used to get list of categories
*/
function get_categories()
{
global $db;
$select = $db->select($this->cat_tbl,"*");
return $select;
}
/**
* Function used to count total number of categoies
*/
function total_categories()
{
global $db;
return $db->count($this->cat_tbl,"*");
}
/**
* Function used to delete category
*/
function delete_category($cid)
{
global $db;
$cat_details = $this->category_exists($cid);
if(!$cat_details)
e(lang("cat_exist_error"));
//CHecking if category is default or not
elseif($cat_details['isdefault'] == 'yes')
e(lang("cat_default_err"));
else{
//Moving all contents to default category
$this->change_category($cid);
//Removing Category
$db->execute("DELETE FROM ".$this->cat_tbl." WHERE category_id='$cid'");
e(lang("class_cat_del_msg"),m);
}
}
/**
* Functon used to get dafault categry
*/
function get_default_category()
{
global $db;
$results = $db->select($this->cat_tbl,"*"," isdefault='yes' ");
if($db->num_rows>0)
return $results[0];
else
return false;
}
/**
* Function used to get default category ID
*/
function get_default_cid()
{
$default = $this->get_default_category();
return $default['category_id'];
}
/**
* Function used to move contents from one section to other
*/
function change_category($from,$to=NULL,$check_multiple=false)
{
global $db;
if(!$this->category_exists($to))
$to = $this->get_default_cid();
$db->execute("UPDATE ".$this->section_tbl." SET category = replace(category,'#".$from."#','#".$to."#') WHERE category LIKE '%#".$from."#%'");
$db->execute("UPDATE ".$this->section_tbl." SET category = replace(category,'#".$to."# #".$to."#','#".$to."#') WHERE category LIKE '%#".$to."#%'");
}
/**
* Function used to edit category
* submit values and it will update category
*/
function update_category($array)
{
global $db;
$name = mysql_clean($array['name']);
$desc = mysql_clean($array['desc']);
$default = mysql_clean($array['default']);
$cur_name = mysql_clean($array['cur_name']);
$cid = mysql_clean($array['cid']);
if($this->get_cat_by_name($name) && $cur_name !=$name )
{
e(lang("add_cat_erro"));
}elseif(empty($name))
{
e(lang("add_cat_no_name_err"));
}else{
$db->update($this->cat_tbl,
array("category_name","category_desc"),
array($name,$desc),
" category_id='$cid' "
);
if($default=='yes' || !$this->get_default_category())
$this->make_default_category($cid);
e(lang("cat_update_msg"),m);
//Uploading thumb
if(!empty($_FILES['cat_thumb']['tmp_name']))
$this->add_category_thumb($cid,$_FILES['cat_thumb']);
}
}
/**
* Function used to add category thumbnail
* @param $Cid and Array
*/
function add_category_thumb($cid,$file)
{
global $imgObj;
if($this->category_exists($cid))
{
//Checking for category thumbs direcotry
if(isset($this->thumb_dir))
$dir = $this->thumb_dir;
else
$dir = $this->section_tbl;
//Checking File Extension
$ext = strtolower(getext($file['name']));
if($ext=='jpg' || $ext =='png' || $ext=='gif')
{
$dir_path = CAT_THUMB_DIR.'/'.$dir;
if(!is_dir($dir_path))
@mkdir($dir_path,0777);
if(is_dir($dir_path))
{
$path = $dir_path.'/'.$cid.'.'.$ext;
//Removing File if already exists
if(file_exists($path))
unlink($path);
move_uploaded_file($file['tmp_name'],$path);
//Now checking if file is really an image
if(!@$imgObj->ValidateImage($path,$ext))
e(lang("pic_upload_vali_err"));
else
{
$imgObj->CreateThumb($path,$path,$this->cat_thumb_width,$ext,$this->cat_thumb_height,true);
}
}else{
e(lang("cat_dir_make_err"));
}
}else{
e(lang("cat_img_error"));
}
}
}
/**
* Function used to get category thumb
*/
function get_cat_thumb($cat_details)
{
//Checking for category thumbs direcotry
if(isset($this->thumb_dir))
$dir = $this->thumb_dir;
else
$dir = $this->section_tbl;
$cid = $cat_details['category_id'];
$path = CAT_THUMB_DIR.'/'.$dir.'/'.$cid.'.';
$exts = array('jpg','png','gif');
$file_exists = false;
foreach($exts as $ext)
{
$cur_ext = $ext;
if(file_exists($path.$ext))
{
$file_exists = true;
break;
}
}
if($file_exists)
return CAT_THUMB_URL.'/'.$dir.'/'.$cid.'.'.$ext;
else
return $this->default_thumb();
}
function get_category_thumb($i)
{
return $this->get_cat_thumb($i);
}
/**
* function used to return default thumb
*/
function default_thumb()
{
if(empty($this->default_thumb))
$this->default_thumb = 'no_thumb.jpg';
return CAT_THUMB_URL.'/'.$this->default_thumb;
}
}
?>

View file

@ -32,6 +32,13 @@
--- in_header
You can additionally add admin area options
such as if you want to add new option in admin panel
you can add links at following places
-- in_video_manage_links
-- in_video_manage_buttons
function
-- get_plugin_details
reads the file and parse plugin details

View file

@ -0,0 +1,212 @@
<?php
/**
* Author : Arslan Hassan
* Script : ClipBucket v2
* LIcense : CBLA
*
*
* Class : Video
* Used to perform function swith videos
* -- history
* all function that were in my_query
* has been transfered here
* however thhey will still work from there
* too
*/
class CBvideo extends CBCategory
{
/**
* __Constructor of CBVideo
*/
function CBvideo()
{
$this->cat_tbl = 'video_categories';
$this->section_tbl = 'video';
}
/**
* Function used to check weather video exists or not
* @param VID or VKEY
*/
function video_exists($vid)
{
return $this->get_video($vid);
}
function exists($vid){return $this->video_exists($vid);}
function videoexists($vid){return $this->video_exists($vid);}
/**
* Function used to get video data
*/
function get_video($vid)
{
global $db;
$results = $db->select("video","*"," videoid='$vid' OR videokey='$vid'");
if($db->num_rows>0)
{
return $results[0];
}else{
return false;
}
}
function getvideo($vid){return $this->get_video($vid);}
function get_video_data($vid){return $this->get_video($vid);}
function getvideodata($vid){return $this->get_video($vid);}
function get_video_details($vid){return $this->get_video($vid);}
function getvideodetails($vid){return $this->get_video($vid);}
/**
* Function used to perform several actions with a video
*/
function action($case,$vid)
{
global $db;
if(!$this->exists($vid))
return false;
//Lets just check weathter video exists or not
switch($case)
{
//Activating a video
case 'activate':
case 'av':
case 'a':
{
$db->update("video",array('active'),array('yes')," videoid='$vid' OR videokey = '$vid' ");
e(lang("class_vdo_act_msg"),m);
}
break;
//Deactivating a video
case "deactivate":
case "dav":
case "d":
{
$db->update("video",array('active'),array('no')," videoid='$vid' OR videokey = '$vid' ");
e(lang("class_vdo_act_msg1"),m);
}
break;
//Featuring Video
case "feature":
case "featured":
case "f":
{
$db->update("video",array('featured'),array('yes')," videoid='$vid' OR videokey = '$vid' ");
e(lang("class_vdo_fr_msg"),m);
}
break;
//Unfeatured video
case "unfeature":
case "unfeatured":
case "uf":
{
$db->update("video",array('featured'),array('no')," videoid='$vid' OR videokey = '$vid' ");
e(lang("class_fr_msg1"),m);
}
break;
}
}
/**
* Function used to update video
*/
function update_video()
{
global $eh,$Cbucket,$db,$Upload;
$Upload->validate_video_upload_form(NULL,TRUE);
if(empty($eh->error_list))
{
$required_fields = $Upload->loadRequiredFields($array);
$location_fields = $Upload->loadLocationFields($array);
$option_fields = $Upload->loadOptionFields($array);
$upload_fields = array_merge($required_fields,$location_fields,$option_fields);
//Adding Custom Upload Fields
if(count($Upload->custom_upload_fields)>0)
$upload_fields = array_merge($upload_fields,$Upload->custom_upload_fields);
//Adding Custom Form Fields
if(count($Upload->custom_form_fields)>0)
$upload_fields = array_merge($upload_fields,$Upload->custom_form_fields);
$array = $_POST;
$vid = $array['videoid'];
if(is_array($_FILES))
$array = array_merge($array,$_FILES);
foreach($upload_fields as $field)
{
$name = formObj::rmBrackets($field['name']);
$val = $array[$name];
if($field['use_func_val'])
$val = $field['validate_function']($val);
if(!empty($field['db_field']))
$query_field[] = $field['db_field'];
if(is_array($val))
{
$new_val = '';
foreach($val as $v)
{
$new_val .= "#".$v."# ";
}
$val = $new_val;
}
if(!$field['clean_func'] || (!apply_func($field['clean_func'],$val) && !is_array($field['clean_func'])))
$val = mysql_clean($val);
else
$val = apply_func($field['clean_func'],$val);
if(!empty($field['db_field']))
$query_val[] = $val;
}
#$query = "INSERT INTO video (";
$total_fields = count($query_field);
//Adding Fields to query
$i = 0;
/*for($key=0;$key<$total_fields;$key++)
{
$query .= query_field[$key]." = '".$query_val[$key]."'" ;
if($key<$total_fields-1)
$query .= ',';
}*/
if(!userid())
{
e("You are not logged in");
}elseif(!$this->video_exists($vid)){
e("Video deos not exist");
}else{
$db->update('video',$query_field,$query_val," videoid='$vid'");
e("Video details have been updated",m);
}
}
}
}
?>

View file

@ -257,8 +257,14 @@ error_reporting(E_ALL ^ E_NOTICE);
define('MAX_COMMENT_CHR',$Cbucket->configs['max_comment_chr']);
define('USER_COMMENT_OWN',$Cbucket->configs['user_comment_own']);
//Defining Category Thumbs directory
define('CAT_THUMB_DIR',BASEDIR.'/images/category_thumbs');
define('CAT_THUMB_URL',BASEURL.'/images/category_thumbs');
//Assigning Smarty Tags & Values
include 'functions.php';
include 'plugin.functions.php';
include 'plugins_functions.php';
require BASEDIR.'/includes/templatelib/Template.class.php';
require BASEDIR.'/includes/classes/template.class.php';
@ -288,7 +294,7 @@ error_reporting(E_ALL ^ E_NOTICE);
Assign('flvplayer',FLVPLAYER);
Assign('avatardir',BASEURL.'/images/avatars');
Assign('whatis',$row['whatis']);
Assign('category_thumbs',BASEURL.'/images/category_thumbs');
Assign('category_thumbs',CAT_THUMB_URL);
Assign('video_thumbs',THUMBS_URL);
//Assign('ads',$ads);
Assign('meta_keywords',$row['keywords']);
@ -377,7 +383,7 @@ $Smarty->assign_by_ref('formObj', $formObj);
$Smarty->assign_by_ref('Cbucket', $Cbucket);$Smarty->assign_by_ref('ClipBucket', $Cbucket);
$Smarty->assign_by_ref('eh', $eh);
$Smarty->assign_by_ref('lang_obj', $lang_obj);
$Smarty->assign_by_ref('cbvid', $cbvid);
/*
REGISERTING FUNCTION FOR SMARTY TEMPLATES

View file

@ -793,30 +793,7 @@ function SetTime($sec, $padHours = true) {
}
/**
* FUNCTION USED TO REGISTER ACTIONS THAT ARE TO APPLIED
* ON COMMENTS , TITLE, DESCRIPTIONS etc
*/
function register_action($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->actionList[$name][] = $key;
}
}else{
$Cbucket->actionList[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->actionList[$type][] = $name;
}
}
//Function used to register function as multiple modifiers
@ -934,104 +911,6 @@ function SetTime($sec, $padHours = true) {
}
/**
* FUNCTION USED TO CREATE ANCHOR PLACEMENT
* these are the placement where we can add plugin's or widget's code,
* e.g if we want to display a new WYSIWYG box before comment text area
* we will create anchor before text area as {ANCHOR place='before_compose_box'}
* code will be written in plugin file and its place will point 'before_compose_box'
* then our function will get all the code for this placement and will display it
* @param : array(Ad Code, LIMIT);
*/
function ANCHOR($params,&$Smarty)
{
global $Cbucket;
//Getting List of codes to display at this anchor
$codes = $Cbucket->get_anchor_codes($params['place']);
if(!empty($codes))
{
if(is_array($codes))
{
foreach($codes as $code)
{
echo $code;
}
}else{
echo $codes;
}
}
//Getting list of function that will be performed while calling achor
$funcs = $Cbucket->get_anchor_function_list($params['place']);
if(!empty($funcs))
{
if(is_array($funcs))
{
foreach($funcs as $func)
{
if(function_exists($func))
$func();
}
}else{
$funcs();
}
}
}
/**
* FUNCTION USED TO REGISTER ANCHORS
* before_comments etc.. see complete list on http://docs.clip-bucket.com
*/
function register_anchor($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->anchorList[$name][] = $key;
}
}else{
$Cbucket->anchorList[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->anchorList[$type][] = $name;
}
}
/**
* FUNCTION USED TO REGISTER FUNCTION
* If you want to perform some function on
* some place, you can simple register function that will be execute where anchor points are
* placed
*/
function register_anchor_function($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->anchor_function_list[$name][] = $key;
}
}else{
$Cbucket->anchor_function_list[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->anchor_function_list[$type][] = $name;
}
}
/**
* Insert Id
@ -1053,28 +932,6 @@ function SetTime($sec, $padHours = true) {
return $Cbucket->ids[$code]=$id;
}
/**
* 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)
* @param STRING $header - Could be Plugin , Videos, Users , please check
* http://docs.clip-bucket.com. for reference
* @param STRING name
* @param STRING link
* That will add new item in admin menu
*/
function add_admin_menu($header='Tool Box',$name,$link)
{
global $Cbucket;
//Gett Menu
$menu = $Cbucket->AdminMenu;
//Add New Meny
$menu[$header][$name] = $link;
$Cbucket->AdminMenu = $menu;
}
/**
* Function used to select data from database
@ -1553,60 +1410,6 @@ function SetTime($sec, $padHours = true) {
/**
* Function used to add custom upload fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom upload field"
*/
function register_custom_upload_field($array)
{
global $Upload;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$Upload->custom_upload_fields[$key] = $arr;
}
}
/**
* Function used to add custom form fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom form field"
*/
function register_custom_form_field($array)
{
global $Upload;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$Upload->custom_form_fields[$key] = $arr;
}
}
/**
* Function used to add custom signup form fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom signup field"
*/
function register_signup_field($array)
{
global $signup;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$signup->custom_signup_fields[$key] = $arr;
}
}
/**
* Function used to get PHP Path
*/
@ -1617,28 +1420,6 @@ function SetTime($sec, $padHours = true) {
/**
* Function used to add actions that will be performed
* when video is uploaded
* @param Function name
*/
function register_after_video_upload_action($func)
{
global $Upload;
$Upload->actions_after_video_upload[] = $func;
}
/**
* Function used to add actions that will be performed
* when video is going to play, it will check which player to use
* what type to use and what to do
* @param Function name
*/
function register_actions_play_video($func)
{
global $Cbucket;
$Cbucket->actions_play_video[] = $func;
}

View file

@ -0,0 +1,253 @@
<?php
/**
* this sperate file
* has all functions that are used
* to create plugins
*/
/**
* FUNCTION USED TO REGISTER ACTIONS THAT ARE TO APPLIED
* ON COMMENTS , TITLE, DESCRIPTIONS etc
*/
function register_action($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->actionList[$name][] = $key;
}
}else{
$Cbucket->actionList[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->actionList[$type][] = $name;
}
}
/**
* FUNCTION USED TO CREATE ANCHOR PLACEMENT
* these are the placement where we can add plugin's or widget's code,
* e.g if we want to display a new WYSIWYG box before comment text area
* we will create anchor before text area as {ANCHOR place='before_compose_box'}
* code will be written in plugin file and its place will point 'before_compose_box'
* then our function will get all the code for this placement and will display it
* @param : array(Ad Code, LIMIT);
*/
function ANCHOR($params,&$Smarty)
{
global $Cbucket;
//Getting List of codes to display at this anchor
$codes = $Cbucket->get_anchor_codes($params['place']);
if(!empty($codes))
{
if(is_array($codes))
{
foreach($codes as $code)
{
echo $code;
}
}else{
echo $codes;
}
}
//Getting list of function that will be performed while calling achor
$funcs = $Cbucket->get_anchor_function_list($params['place']);
if(!empty($funcs))
{
if(is_array($funcs))
{
foreach($funcs as $func)
{
if(function_exists($func))
$func();
}
}else{
$funcs();
}
}
}
/**
* FUNCTION USED TO REGISTER ANCHORS
* before_comments etc.. see complete list on http://docs.clip-bucket.com
*/
function register_anchor($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->anchorList[$name][] = $key;
}
}else{
$Cbucket->anchorList[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->anchorList[$type][] = $name;
}
}
/**
* FUNCTION USED TO REGISTER FUNCTION
* If you want to perform some function on
* some place, you can simple register function that will be execute where anchor points are
* placed
*/
function register_anchor_function($name,$type=NULL)
{
global $Cbucket;
if(is_array($name))
{
foreach($name as $key => $naam)
if(is_array($naam))
{
foreach($naam as $name)
{
$Cbucket->anchor_function_list[$name][] = $key;
}
}else{
$Cbucket->anchor_function_list[$naam][] = $key;
}
}elseif($type!=NULL){
$Cbucket->anchor_function_list[$type][] = $name;
}
}
/**
* 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)
* @param STRING $header - Could be Plugin , Videos, Users , please check
* http://docs.clip-bucket.com. for reference
* @param STRING name
* @param STRING link
* That will add new item in admin menu
*/
function add_admin_menu($header='Tool Box',$name,$link)
{
global $Cbucket;
//Gett Menu
$menu = $Cbucket->AdminMenu;
//Add New Meny
$menu[$header][$name] = $link;
$Cbucket->AdminMenu = $menu;
}
/**
* Function used to add custom upload fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom upload field"
*/
function register_custom_upload_field($array)
{
global $Upload;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$Upload->custom_upload_fields[$key] = $arr;
}
}
/**
* Function used to add custom form fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom form field"
*/
function register_custom_form_field($array)
{
global $Upload;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$Upload->custom_form_fields[$key] = $arr;
}
}
/**
* Function used to add custom signup form fields
* In this you will provide an array that has a complete
* details of the field such as 'name',validate_func etc
* please check docs.clip-bucket.com for "how to add custom signup field"
*/
function register_signup_field($array)
{
global $signup;
$name = key($array);
if(is_array($array) && !empty($array[$name]['name']))
{
foreach($array as $key => $arr)
$signup->custom_signup_fields[$key] = $arr;
}
}
/**
* Function used to add actions that will be performed
* when video is uploaded
* @param Function name
*/
function register_after_video_upload_action($func)
{
global $Upload;
$Upload->actions_after_video_upload[] = $func;
}
/**
* Function used to add actions that will be performed
* when video is going to play, it will check which player to use
* what type to use and what to do
* @param Function name
*/
function register_actions_play_video($func)
{
global $Cbucket;
$Cbucket->actions_play_video[] = $func;
}
/**
* Function used to add links in admin area
*/
function add_admin_link($array)
{
$area = $array['area'];
$title = $array['title'];
$link = $array['link'];
}
?>