-
Notifications
You must be signed in to change notification settings - Fork 28
/
addons.php
89 lines (79 loc) · 2.5 KB
/
addons.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Copyright 2009 Lucas Baudin <[email protected]>
* 2011-2014 Stephen Just <[email protected]>
* 2014-2015 Daniel Butum <danibutum at gmail dot com>
* This file is part of stk-addons.
*
* stk-addons is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* stk-addons is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with stk-addons. If not, see <http://www.gnu.org/licenses/>.
*/
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
// Validate addon-id parameter
$_GET['type'] = (isset($_GET['type'])) ? $_GET['type'] : null;
$_GET['name'] = (isset($_GET['name'])) ? Addon::cleanId($_GET['name']) : null; // name is actually the id
$_GET['rev'] = (isset($_GET['rev'])) ? (int)$_GET['rev'] : null;
$addon_exists = Addon::exists($_GET["name"]);
$status = "";
// addon type is optional
if (!$_GET['type'])
{
$_GET['type'] = Addon::getTypeByID($_GET['name']);
}
// check type
switch (Addon::stringToType($_GET['type']))
{
case Addon::TRACK:
$type_label = _h('Tracks');
break;
case Addon::KART:
$type_label = _h('Karts');
break;
case Addon::ARENA:
$type_label = _h('Arenas');
break;
default:
exit(_h('Invalid addon type.')); // TODO redirect with error
break;
}
// build title
$title = $type_label . ' - ' . _h('SuperTuxKart Add-ons');
if ($addon_exists)
{
$addonName = Addon::getNameByID($_GET['name']);
if ($addonName)
{
$title = $addonName . ' - ' . $title;
}
}
// build template
$tpl = StkTemplate::get("addons/index.tpl")
->assign("title", $title)
->assign("is_name", $_GET['name'])
->addUtilLibrary()
->addBootstrapMultiSelectLibrary()
->addScriptInclude("addon.js");
$tpl_data = [
'menu' => Util::ob_get_require_once(ROOT_PATH . "addons-menu.php"),
'body' => '',
'type' => $_GET['type'],
'status' => $status
];
// right panel
if ($addon_exists)
{
$tpl_data['body'] = Util::ob_get_require_once(ROOT_PATH . 'addons-panel.php');
}
// output the view
$tpl->assign('addon', $tpl_data);
echo $tpl;