| 1 |
<?php
|
| 2 |
// $Header: /cvsroot/tikiwiki/tiki/categorize.php,v 1.14.2.4 2005/01/22 20:34:27 mose Exp $
|
| 3 |
|
| 4 |
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
|
| 5 |
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
|
| 6 |
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
|
| 7 |
|
| 8 |
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== FALSE) {
|
| 9 |
//smarty is not there - we need setup
|
| 10 |
require_once('tiki-setup.php');
|
| 11 |
$smarty->assign('msg',tra("This script cannot be called directly"));
|
| 12 |
$smarty->display("error.tpl");
|
| 13 |
die;
|
| 14 |
}
|
| 15 |
|
| 16 |
global $feature_categories;
|
| 17 |
|
| 18 |
if ($feature_categories == 'y') {
|
| 19 |
global $categlib;
|
| 20 |
if (!is_object($categlib)) {
|
| 21 |
include_once('lib/categories/categlib.php');
|
| 22 |
}
|
| 23 |
$smarty->assign('cat_categorize', 'n');
|
| 24 |
|
| 25 |
if (isset($_REQUEST['import']) and isset($_REQUEST['categories'])) {
|
| 26 |
$_REQUEST["cat_categories"] = split(',',$_REQUEST['categories']);
|
| 27 |
$_REQUEST["cat_categorize"] = 'on';
|
| 28 |
}
|
| 29 |
|
| 30 |
if (isset($_REQUEST["cat_categorize"]) && $_REQUEST["cat_categorize"] == 'on') {
|
| 31 |
$smarty->assign('cat_categorize', 'y');
|
| 32 |
$categlib->uncategorize_object($cat_type, $cat_objid);
|
| 33 |
|
| 34 |
if (isset($_REQUEST["cat_categories"])) {
|
| 35 |
foreach ($_REQUEST["cat_categories"] as $cat_acat) {
|
| 36 |
if ($cat_acat) {
|
| 37 |
$catObjectId = $categlib->is_categorized($cat_type, $cat_objid);
|
| 38 |
|
| 39 |
if (!$catObjectId) {
|
| 40 |
// The object is not cateorized
|
| 41 |
$catObjectId = $categlib->add_categorized_object($cat_type, $cat_objid, $cat_desc, $cat_name, $cat_href);
|
| 42 |
}
|
| 43 |
|
| 44 |
$categlib->categorize($catObjectId, $cat_acat);
|
| 45 |
}
|
| 46 |
}
|
| 47 |
}
|
| 48 |
} else {
|
| 49 |
$categlib->uncategorize_object($cat_type, $cat_objid);
|
| 50 |
}
|
| 51 |
|
| 52 |
$cats = $categlib->get_object_categories($cat_type, $cat_objid);
|
| 53 |
$categories = $categlib->list_categs();
|
| 54 |
$num_categories = count($categories);
|
| 55 |
for ($i = 0; $i < $num_categories; $i++) {
|
| 56 |
if (in_array($categories[$i]["categId"], $cats)) {
|
| 57 |
$categories[$i]["incat"] = 'y';
|
| 58 |
} else {
|
| 59 |
$categories[$i]["incat"] = 'n';
|
| 60 |
}
|
| 61 |
}
|
| 62 |
$smarty->assign_by_ref('categories', $categories["data"]);
|
| 63 |
}
|
| 64 |
|
| 65 |
?>
|