-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathadd-link-category.php
73 lines (46 loc) · 2.2 KB
/
add-link-category.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require 'class.base.php';
require 'class.html.php';
require 'class.misc.php';
$base_instance=new base();
$html_instance=new html();
$misc_instance=new misc();
$userid=$base_instance->get_userid();
$category_id=isset($_REQUEST['category_id']) ? (int)$_REQUEST['category_id'] : '';
if (isset($_POST['save'])) {
$error='';
$title=$_POST['title'];
if (!$title) { $error.='<li> Category cannot be left blank'; }
else {
$title=trim($title);
if (strlen($title)>50) { $error.='<li> Title is too long (Max. 50 Characters)'; }
$title=str_replace('"','"',$title);
}
if (!$error) {
$base_instance->query('INSERT INTO '.$base_instance->entity['LINK']['CATEGORY'].' (title,user,parent_id) VALUES ("'.sql_safe($title).'",'.$userid.','.$category_id.')');
$cat_id=mysqli_insert_id($base_instance->db_link);
$base_instance->show_message('Link Category saved','<a href="add-link.php?category_id='.$cat_id.'">[Add Link]</a> <a href="add-link-category.php">[Add Category]</a> <a href="edit-link-category.php?category_id='.$cat_id.'">[Edit]</a> <a href="javascript:void(window.open(\'delete-link-category.php?category_id='.$cat_id.'\',\'\',\'width=450,height=200,top=100,left=100\'))">[Delete]</a><p><a href="show-link-categories.php">[Show Link Categories]</a>');
}
else {
$html_instance->error_message=$error;
$title=stripslashes($title);
}
}
$select_box=' <select name="category_id">';
if (empty($category_id)) { $select_box.="<option selected value=0>-- MAIN CATEGORY --"; }
else { $select_box.='<option value=0>-- MAIN CATEGORY --'; }
$select_box.=$misc_instance->build_category_select_box(0,$userid,0,$category_id);
$select_box.='</select>';
$html_instance->add_parameter(
array('ACTION'=>'show_form',
'HEADER'=>'New Link Category',
'FORM_ACTION'=>$_SERVER['PHP_SELF'],
'BODY'=>'onLoad="javascript:document.form1.title.focus()"',
'INNER_TABLE_WIDTH'=>'400',
'TD_WIDTH'=>'30%',
'BUTTON_TEXT'=>'Save Category'
));
$html_instance->add_form_field(array('TYPE'=>'text','NAME'=>'title','VALUE'=>'','SIZE'=>35,'TEXT'=>'Title'));
$html_instance->add_form_field(array('TYPE'=>'label','TEXT1'=>'Subcategory of','TEXT2'=>"$select_box",'SECTIONS'=>2));
$html_instance->process();
?>