forked from marcelosoaressouza/estudiolivre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategorize.php
73 lines (56 loc) · 2.14 KB
/
categorize.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
// $Header: /cvsroot/tikiwiki/tiki/categorize.php,v 1.14.2.5 2007/03/02 12:23:17 luciash Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
if(strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== FALSE) {
//smarty is not there - we need setup
require_once('tiki-setup.php');
$smarty->assign('msg',tra("This script cannot be called directly"));
$smarty->display("error.tpl");
die;
}
global $feature_categories;
if($feature_categories == 'y') {
global $categlib;
if(!is_object($categlib)) {
include_once('lib/categories/categlib.php');
}
$smarty->assign('cat_categorize', 'n');
if(isset($_REQUEST['import']) and isset($_REQUEST['categories'])) {
$_REQUEST["cat_categories"] = preg_split('/,/',$_REQUEST['categories']);
$_REQUEST["cat_categorize"] = 'on';
}
if(isset($_REQUEST["cat_categorize"]) && $_REQUEST["cat_categorize"] == 'on') {
$smarty->assign('cat_categorize', 'y');
$categlib->uncategorize_object($cat_type, $cat_objid);
if(isset($_REQUEST["cat_categories"])) {
foreach($_REQUEST["cat_categories"] as $cat_acat) {
if($cat_acat) {
$catObjectId = $categlib->is_categorized($cat_type, $cat_objid);
if(!$catObjectId) {
// The object is not cateorized
$catObjectId = $categlib->add_categorized_object($cat_type, $cat_objid, $cat_desc, $cat_name, $cat_href);
}
$categlib->categorize($catObjectId, $cat_acat);
}
}
}
}
else {
$categlib->uncategorize_object($cat_type, $cat_objid);
}
$cats = $categlib->get_object_categories($cat_type, $cat_objid);
$categories = $categlib->list_categs();
$num_categories = count($categories);
for($i = 0; $i < $num_categories; $i++) {
if(in_array($categories[$i]["categId"], $cats)) {
$categories[$i]["incat"] = 'y';
}
else {
$categories[$i]["incat"] = 'n';
}
}
$smarty->assign_by_ref('categories', $categories["data"]);
}
?>