forked from OpenCorpora/opencorpora
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dict.php
139 lines (134 loc) · 4.91 KB
/
dict.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
require('lib/header.php');
require('lib/lib_dict.php');
if (isset($_GET['act']))
$action = $_GET['act'];
else $action = '';
$smarty->assign('active_page', 'dict');
//check permissions
if (!in_array($action, array('', 'gram', 'gram_restr', 'lemmata', 'errata', 'edit', 'absent')) &&
!user_has_permission('perm_dict')) {
show_error($config['msg']['notadmin']);
return;
}
switch ($action) {
case 'add_gram':
add_grammem($_POST['g_name'], $_POST['parent_gram'], $_POST['outer_id'], $_POST['descr']);
header("Location:dict.php?act=gram");
break;
case 'move_gram':
move_grammem($_GET['id'], $_GET['dir']);
header('Location:dict.php?act=gram#g'.$grm_id);
break;
case 'del_gram':
del_grammem($_GET['id']);
header("Location:dict.php?act=gram");
break;
case 'edit_gram':
$id = $_POST['id'];
$inner_id = $_POST['inner_id'];
$outer_id = $_POST['outer_id'];
$descr = $_POST['descr'];
edit_grammem($id, $inner_id, $outer_id, $descr);
header('Location:dict.php?act=gram');
break;
case 'clear_errata':
clear_dict_errata(isset($_GET['old']));
header("Location:dict.php?act=errata");
break;
case 'not_error':
mark_dict_error_ok($_GET['error_id'], $_POST['comm']);
header("Location:dict.php?act=errata");
break;
case 'add_restr':
add_dict_restriction($_POST);
header("Location:dict.php?act=gram_restr");
break;
case 'del_restr':
del_dict_restriction($_GET['id']);
header("Location:dict.php?act=gram_restr");
break;
case 'update_restr':
calculate_gram_restrictions();
header("Location:dict.php?act=gram_restr");
break;
case 'save':
// update after selectpicker (lemma_edit.tpl)
// now we have to implode the arrays
if (!empty($_POST['form_gram']))
foreach ($_POST['form_gram'] as &$grams) {
$grams = implode(', ', $grams);
}
if (!empty($_POST['lemma_gram']))
$_POST['lemma_gram'] = implode(', ', $_POST['lemma_gram']);
$lemma_id = dict_save($_POST);
header("Location:dict.php?act=edit&saved&id=$lemma_id");
break;
case 'add_link':
add_link($_POST['from_id'], $_POST['lemma_id'], $_POST['link_type']);
header("Location:dict.php?act=edit&id=".$_POST['from_id']);
break;
case 'del_link':
del_link($_GET['id']);
header("Location:dict.php?act=edit&id=".$_GET['lemma_id']);
break;
case 'change_link_dir':
change_link_direction($_GET['id']);
header("Location:dict.php?act=edit&id=".$_GET['lemma_id']);
break;
case 'del_lemma':
del_lemma($_GET['lemma_id']);
header("Location:dict.php");
break;
case 'lemmata':
$smarty->assign('search', get_dict_search_results($_GET));
$smarty->display('dict/lemmata.tpl');
break;
case 'gram':
$order = isset($_GET['order']) ? $_GET['order'] : '';
$smarty->assign('grammems', get_grammem_editor($order));
$smarty->assign('order', $order);
$smarty->assign('select', dict_get_select_gram());
$smarty->display('dict/gram.tpl');
break;
case 'gram_restr':
$smarty->assign('restrictions', get_gram_restrictions(isset($_GET['hide_auto'])));
$smarty->display('dict/restrictions.tpl');
break;
case 'edit':
$smarty->assign('editor', get_lemma_editor($_GET['id']));
$smarty->assign('link_types', get_link_types());
$smarty->assign('possible_grammems', dict_get_select_gram());
$smarty->display('dict/lemma_edit.tpl');
break;
case 'errata':
$smarty->assign('errata', get_dict_errata(isset($_GET['all']), isset($_GET['rand'])));
$smarty->display('dict/errata.tpl');
break;
case 'pending':
$skip = isset($_GET['skip']) ? $_GET['skip'] : 0;
$smarty->assign('data', get_pending_updates($skip));
$smarty->display('dict/pending.tpl');
break;
case 'reannot':
update_pending_tokens($_POST['rev_id']);
header("Location:dict.php?act=pending");
break;
case 'absent':
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(3600);
if (!is_cached('dict/absent.tpl'))
$smarty->assign('words', get_top_absent_words());
$smarty->display('dict/absent.tpl');
break;
default:
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->setCacheLifetime(600);
if (!is_cached('dict/main.tpl', (int)user_has_permission('perm_dict'))) {
$smarty->assign('stats', get_dict_stats());
$smarty->assign('dl', get_downloads_info());
}
$smarty->display('dict/main.tpl', (int)user_has_permission('perm_dict'));
}
log_timing();
?>