forked from OpenCorpora/opencorpora
-
Notifications
You must be signed in to change notification settings - Fork 1
/
books.php
132 lines (122 loc) · 5.04 KB
/
books.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
<?php
require('lib/header.php');
require('lib/lib_books.php');
require('lib/lib_syntax.php');
require('lib/lib_ne.php');
$action = isset($_GET['act']) ? $_GET['act'] : '';
if (!$action) {
if (isset($_GET['book_id']) && $book_id = $_GET['book_id']) {
$smarty->assign('book', get_book_page($book_id, isset($_GET['full'])));
$smarty->display('book.tpl');
} else {
$smarty->assign('books', get_books_list());
$smarty->display('books.tpl');
}
}
elseif (is_admin() && $action == 'del_sentence') {
delete_sentence($_GET['sid']);
header("Location:books.php?book_id=".$_GET['book_id'].'&full');
}
elseif (user_has_permission('perm_syntax') && $action == 'anaphora') {
if (isset($_GET['book_id']) && $book_id = $_GET['book_id']) {
$book = get_book_page($book_id, TRUE);
$groups = array();
$smarty->assign('group_types', get_syntax_group_types());
foreach ($book['paragraphs'] as &$paragraph) {
foreach ($paragraph['sentences'] as &$sentence) {
$sentence['props'] = get_pronouns_by_sentence($sentence['id']);
foreach ($sentence['tokens'] as &$token) {
$groups[$token['id']] = $token['groups']
= get_moderated_groups_by_token($token['id']);
}
}
}
$smarty->assign('anaphora', get_anaphora_by_book($book_id));
$smarty->assign('book', $book);
$smarty->assign('token_groups', $groups);
$smarty->display('syntax/book.tpl');
} else {
throw new UnexpectedValueException();
}
}
elseif (/*user_has_permission('perm_syntax') && */is_logged() && $action == 'ner') {
if (isset($_GET['book_id']) && $book_id = $_GET['book_id']) {
$book = get_book_page($book_id, TRUE);
$paragraphs_status = get_ne_paragraph_status($book_id, $_SESSION['user_id']);
foreach ($book['paragraphs'] as &$paragraph) {
$ne = get_ne_by_paragraph($paragraph['id'], $_SESSION['user_id']);
$paragraph['named_entities'] = $ne['entities'];
$paragraph['annotation_id'] = $ne['annot_id'];
$paragraph['ne_by_token'] = get_ne_tokens_by_paragraph($paragraph['id'], $_SESSION['user_id']);
$paragraph['comments'] = get_comments_by_paragraph($paragraph['id'], $_SESSION['user_id']);
if (in_array($paragraph['id'], $paragraphs_status['unavailable']) or
in_array($paragraph['id'], $paragraphs_status['done_by_user']))
$paragraph['disabled'] = true;
elseif (in_array($paragraph['id'], $paragraphs_status['started_by_user']))
$paragraph['mine'] = true;
}
$smarty->assign('book', $book);
$smarty->assign('types', get_ne_types());
$smarty->assign('use_fast_mode', $_SESSION['options'][5]);
$smarty->display('ner/book.tpl');
} else {
throw new UnexpectedValueException();
}
}
elseif (user_has_permission('perm_adder')) {
switch ($action) {
case 'add':
$book_name = trim($_POST['book_name']);
$book_parent = $_POST['book_parent'];
$book_id = books_add($book_name, $book_parent);
if (isset($_POST['goto']))
header("Location:books.php?book_id=$book_id");
else
header("Location:books.php?book_id=$book_parent");
case 'rename':
$name = trim($_POST['new_name']);
$book_id = $_POST['book_id'];
books_rename($book_id, $name);
header("Location:books.php?book_id=$book_id");
break;
case 'move':
books_move($_POST['book_id'], $_POST['book_to']);
header("Location:books.php?book_id=$book_to");
break;
case 'add_tag':
$book_id = $_POST['book_id'];
$tag_name = $_POST['tag_name'];
books_add_tag($book_id, $tag_name);
header("Location:books.php?book_id=$book_id");
break;
case 'del_tag':
$book_id = $_GET['book_id'];
$tag_name = $_GET['tag_name'];
books_del_tag($book_id, $tag_name);
header("Location:books.php?book_id=$book_id");
break;
case 'merge_sentences':
$sent1 = $_POST['id1'];
$sent2 = $_POST['id2'];
merge_sentences($sent1, $sent2);
header("Location:sentence.php?id=$sent1");
break;
case 'split_token':
$val = split_token($_POST['tid'], $_POST['nc']);
header("Location:books.php?book_id=".$val[0]."&full#sen".$val[1]);
break;
case 'split_sentence':
$a = split_sentence($_POST['tid']);
header("Location:books.php?book_id=".$a[0]."&full#sen".$a[1]);
break;
case 'split_paragraph':
$sent_id = $_GET['sid'];
$book_id = split_paragraph($sent_id);
header("Location:books.php?book_id=$book_id&full#sen$sent_id");
break;
}
} else {
show_error($config['msg']['notadmin']);
}
log_timing();
?>