Revize 2eab68b9
Přidáno uživatelem Tomáš Pašek před téměř 4 roky(ů)
application/controller/TableController.php | ||
---|---|---|
2 | 2 |
require "../model/DB.php"; |
3 | 3 |
require "../model/Tag.php"; |
4 | 4 |
require "../model/Word.php"; |
5 |
require "../model/Lemma.php"; |
|
5 | 6 |
$DB = new DB(); |
6 | 7 |
|
7 |
// (B) SEARCH FOR USERS |
|
8 |
$results = $DB->select( |
|
9 |
"SELECT w.id, w.context, w.date, w.description, w.description2, w.description3, w.ending, w.finished, |
|
10 |
w.namedentity, w.position1, w.position2, w.positiondetail, w.word, w.tag_id, w.lemma_id, t.tag, l.lemma, l.pos FROM dd_wordform as w left join dd_tag as t on w.tag_id = t.id left join dd_lemma as l on w.lemma_id = l.id order by w.id LIMIT 100" |
|
11 |
); |
|
8 |
$parArray = Array(); |
|
9 |
$whereQuery = createWhereQuery($parArray); |
|
12 | 10 |
|
13 |
var_dump($results); |
|
11 |
if (array_key_exists("manuscript", $_POST) && $_POST['manuscript'] != "") { |
|
12 |
$results = $DB->select( |
|
13 |
"SELECT w.id, w.context, w.date, w.description, w.description2, w.description3, w.ending, w.finished, |
|
14 |
w.namedentity, w.position1, w.position2, w.positiondetail, w.word, w.tag_id, w.lemma_id, t.tag, l.lemma, m.manuscript, |
|
15 |
l.pos FROM dd_manuscript as m left join dd_wordform as w on m.wordform_id = w.id left join dd_tag as t on w.tag_id = t.id left join dd_lemma as l on w.lemma_id = l.id ".$whereQuery." order by w.id", $parArray); |
|
16 |
} else { |
|
17 |
$results = $DB->select( |
|
18 |
"SELECT w.id, w.context, w.date, w.description, w.description2, w.description3, w.ending, w.finished, |
|
19 |
w.namedentity, w.position1, w.position2, w.positiondetail, w.word, w.tag_id, w.lemma_id, t.tag, l.lemma, |
|
20 |
l.pos FROM dd_wordform as w left join dd_tag as t on w.tag_id = t.id left join dd_lemma as l on w.lemma_id = l.id ".$whereQuery." order by w.id", $parArray); |
|
21 |
} |
|
14 | 22 |
|
15 | 23 |
$output = Array(); |
24 |
$temp_value = null; |
|
16 | 25 |
foreach ($results as $res) { |
17 |
$tag = new Tag($res["tag_id"], $res["tag"]); |
|
18 |
$lemma = new Lemma($res["lemma_id"], $res["lemma"], $res["pos"]); |
|
19 |
$word = new Word($res["id"], $res["context"], $res["date"], $res["description"], $res["description2"], $res["description3"], $res["ending"], |
|
20 |
$res["finished"], $res["namedentity"], $res["position1"], $res["position2"], $res["positiondetail"], $res["word"], $lemma, $tag); |
|
21 |
array_push($output, $word); |
|
26 |
if ($temp_value != null && $res["id"] != $temp_value->id) { |
|
27 |
array_push($output, $temp_value); |
|
28 |
$temp_value = null; |
|
29 |
} |
|
30 |
if ($temp_value == null) { |
|
31 |
$tag = new Tag($res["tag_id"], $res["tag"]); |
|
32 |
$lemma = new Lemma($res["lemma_id"], $res["lemma"], $res["pos"]); |
|
33 |
$word = new Word($res["id"], $res["context"], $res["date"], $res["description"], $res["description2"], $res["description3"], $res["ending"], |
|
34 |
$res["finished"], $res["namedentity"], $res["position1"], $res["position2"], $res["positiondetail"], $res["word"], $lemma, $tag); |
|
35 |
if (array_key_exists("manuscript", $res)) { |
|
36 |
array_push($word->manuscript, $res["manuscript"]); |
|
37 |
} |
|
38 |
$temp_value = $word; |
|
39 |
} else { |
|
40 |
array_push($temp_value->manuscript, $res["manuscript"]); |
|
41 |
} |
|
22 | 42 |
} |
43 |
echo json_encode(count($output)==0 ? null : $output); |
|
44 |
|
|
23 | 45 |
|
24 |
$result = json_encode(count($output)==0 ? null : $output); |
|
25 |
echo $result; |
|
46 |
function createWhereQuery(&$array) { |
|
47 |
$whereQuery = "WHERE"; |
|
48 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
49 |
$array['lemma'] = $_POST['lemma']."%"; |
|
50 |
$whereQuery .= " l.lemma LIKE :lemma AND"; |
|
51 |
} |
|
52 |
if (array_key_exists("word", $_POST) && $_POST['word'] != "") { |
|
53 |
$array['word'] = $_POST['word']; |
|
54 |
$whereQuery .= " w.word = :word AND"; |
|
55 |
} |
|
56 |
if (array_key_exists("position1", $_POST) && $_POST['position1'] != "") { |
|
57 |
$array['position1'] = $_POST['position1']; |
|
58 |
$whereQuery .= " w.position1 = :position1 AND"; |
|
59 |
} |
|
60 |
if (array_key_exists("position2", $_POST) && $_POST['position2'] != "") { |
|
61 |
$array['position2'] = $_POST['position2']; |
|
62 |
$whereQuery .= " w.position2 = :position2 AND"; |
|
63 |
} |
|
64 |
if (array_key_exists("positiondetail", $_POST) && $_POST['positiondetail'] != "") { |
|
65 |
$array['positiondetail'] = $_POST['positiondetail']; |
|
66 |
$whereQuery .= " w.positiondetail = :positiondetail AND"; |
|
67 |
} |
|
68 |
if (array_key_exists("manuscript", $_POST) && $_POST['manuscript'] != "") { |
|
69 |
$array['manuscript'] = Array(); |
|
70 |
$nums = explode(",", $_POST['manuscript']); |
|
71 |
$whereQuery .= " m.manuscript in ("; |
|
72 |
for ($x = 0; $x < count($nums); $x += 1) { |
|
73 |
$array['manuscript'][$x] = $nums[$x]; |
|
74 |
$whereQuery .= ":manuscript".$x.","; |
|
75 |
} |
|
76 |
$whereQuery = substr_replace($whereQuery, "", -1, 1); |
|
77 |
$whereQuery .= ") AND"; |
|
78 |
} |
|
79 |
$tag = "____________%"; |
|
80 |
if (array_key_exists("tag_pos", $_POST) && $_POST['tag_pos'] != "") { |
|
81 |
$tag = substr_replace($tag, $_POST['tag_pos'], 0, 1); |
|
82 |
} |
|
83 |
if (array_key_exists("tag_case", $_POST) && $_POST['tag_case'] != "") { |
|
84 |
$tag = substr_replace($tag, $_POST['tag_case'], 1, 1); |
|
85 |
} |
|
86 |
if (array_key_exists("tag_number", $_POST) && $_POST['tag_number'] != "") { |
|
87 |
$tag = substr_replace($tag, $_POST['tag_number'], 2, 1); |
|
88 |
} |
|
89 |
if (array_key_exists("tag_gender", $_POST) && $_POST['tag_gender'] != "") { |
|
90 |
$tag = substr_replace($tag, $_POST['tag_gender'], 3, 1); |
|
91 |
} |
|
92 |
if (array_key_exists("tag_degree", $_POST) && $_POST['tag_degree'] != "") { |
|
93 |
$tag = substr_replace($tag, $_POST['tag_degree'], 4, 1); |
|
94 |
} |
|
95 |
if (array_key_exists("tag_shape", $_POST) && $_POST['tag_shape'] != "") { |
|
96 |
$tag = substr_replace($tag, $_POST['tag_shape'], 5, 1); |
|
97 |
} |
|
98 |
if (array_key_exists("tag_num", $_POST) && $_POST['tag_num'] != "") { |
|
99 |
$tag = substr_replace($tag, $_POST['tag_num'], 6, 1); |
|
100 |
} |
|
101 |
if (array_key_exists("tag_sentence", $_POST) && $_POST['tag_sentence'] != "") { |
|
102 |
$tag = substr_replace($tag, $_POST['tag_sentence'], 7, 1); |
|
103 |
} |
|
104 |
if (array_key_exists("tag_verb_person", $_POST) && $_POST['tag_verb_person'] != "") { |
|
105 |
$tag = substr_replace($tag, $_POST['tag_verb_person'], 8, 1); |
|
106 |
} |
|
107 |
if (array_key_exists("tag_verb_time", $_POST) && $_POST['tag_verb_time'] != "") { |
|
108 |
$tag = substr_replace($tag, $_POST['tag_verb_time'], 9, 1); |
|
109 |
} |
|
110 |
if (array_key_exists("tag_verb_degree", $_POST) && $_POST['tag_verb_degree'] != "") { |
|
111 |
$tag = substr_replace($tag, $_POST['tag_verb_degree'], 10, 1); |
|
112 |
} |
|
113 |
if (array_key_exists("tag_verb_aspect", $_POST) && $_POST['tag_verb_aspect'] != "") { |
|
114 |
$tag = substr_replace($tag, $_POST['tag_verb_aspect'], 11, 1); |
|
115 |
} |
|
116 |
$array['tag'] = $tag; |
|
117 |
$whereQuery .= " t.tag LIKE :tag"; |
|
118 |
return $whereQuery; |
|
119 |
} |
Také k dispozici: Unified diff
Feature #8345 Implementce filterů dat - Server
vytvoření filtrů