tiki-theme_control.php 2.51 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
rjsmelo's avatar
rjsmelo committed
6
//
7 8
// 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.
9
// $Id$
changi67's avatar
changi67 committed
10

rjsmelo's avatar
rjsmelo committed
11
require_once('tiki-setup.php');
12 13
$themelib = TikiLib::lib('theme');
$themecontrollib = TikiLib::lib('themecontrol');
14
$categlib = TikiLib::lib('categ');
15 16
$access->check_feature('feature_theme_control');
$access->check_permission('tiki_p_admin');
17

rjsmelo's avatar
rjsmelo committed
18
$auto_query_args = ['find', 'sort_mode', 'offset', 'theme', 'categId'];
19

20 21 22
//consider preference feature_theme_control_parentcategory setting when displaying list of available categories
if ($prefs['feature_theme_control_parentcategory'] != "n" && $prefs['feature_theme_control_parentcategory'] != -1) {
	$parentCategoryId = $prefs['feature_theme_control_parentcategory'];
rjsmelo's avatar
rjsmelo committed
23
	$categoryFilter = [
24 25
		'type' => 'children',
		'identifier' => $parentCategoryId,
rjsmelo's avatar
rjsmelo committed
26 27 28
	];
} else {
	$categoryFilter = [
29
		'type' => 'all',
rjsmelo's avatar
rjsmelo committed
30
	];
31 32
}
$categories = $categlib->getCategories($categoryFilter, true, true, false);
33
$smarty->assign('categories', $categories);
34

35 36
$smarty->assign('categId', isset($_REQUEST['categId']) ? $_REQUEST['categId'] : 0);

37 38
$themes = $themelib->list_themes_and_options();
$smarty->assign('themes', $themes);
39

40 41
if (isset($_REQUEST['assign'])) {
	if (isset($_REQUEST['categoryId'])) {
42
		check_ticket('theme-control');
43
		$themecontrollib->tc_assign_category($_REQUEST['categoryId'], $_REQUEST['theme']);
44
	} else {
45
		$smarty->assign('msg', tra("Please create a category first"));
46
		$smarty->display("error.tpl");
47 48
		die;
	}
49
}
50 51 52 53
if (isset($_REQUEST['delete'])) {
	check_ticket('theme-control');
	foreach (array_keys($_REQUEST['categoryIds']) as $cat) {
		$themecontrollib->tc_remove_cat($cat);
54
	}
55
}
56

rjsmelo's avatar
rjsmelo committed
57
if (! isset($_REQUEST["sort_mode"])) {
58
	$sort_mode = 'name_asc';
59
} else {
60 61
	$sort_mode = $_REQUEST["sort_mode"];
}
rjsmelo's avatar
rjsmelo committed
62
if (! isset($_REQUEST["offset"])) {
63
	$offset = 0;
64
} else {
65
	$offset = $_REQUEST["offset"];
66
}
67 68 69
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
70
} else {
71
	$find = '';
72
}
73 74
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
75
$channels = $themecontrollib->tc_list_categories($offset, $maxRecords, $sort_mode, $find);
76
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
77
$smarty->assign_by_ref('channels', $channels["data"]);
78
ask_ticket('theme-control');
79
// Display the template
80
$smarty->assign('mid', 'tiki-theme_control.tpl');
81
$smarty->display("tiki.tpl");