1
|
<?php
|
2
|
require_once("./functions/dictionary.php");
|
3
|
|
4
|
//NOVE2504
|
5
|
function get_header_of_table() {
|
6
|
return "\n <tr class=\"nadpis_sekce\">
|
7
|
<td>jazyk </td>
|
8
|
<td>zdroj </td>
|
9
|
<td>lekce</td>
|
10
|
<td>nadpis</td>
|
11
|
<td> </td>
|
12
|
</tr>
|
13
|
";
|
14
|
}
|
15
|
|
16
|
function get_row_of_table($Record) {
|
17
|
global $language;
|
18
|
global $order;
|
19
|
global $od;
|
20
|
global $limit;
|
21
|
global $contrains_source;
|
22
|
global $contrains_lection;
|
23
|
|
24
|
$nav_str = "language=$language&contrains_source=$contrains_source&contrains_lection=$contrains_lection";
|
25
|
|
26
|
$navrat .= " <tr class=\"akt\">";
|
27
|
$navrat .= "\n <td> ".$Record['language']." </td>";
|
28
|
$navrat .= "\n <td> ".$Record['source']."</td>";
|
29
|
$navrat .= "\n <td> ".$Record['lection']."</td>";
|
30
|
|
31
|
$navrat .= "\n <td class=\"arabic\">";
|
32
|
$navrat .= $Record["title"];
|
33
|
$navrat .= " </td>\n";
|
34
|
$navrat .= "\n <td><a href=\"?nav_id=detail_article&article_id=".$Record['IDarticle']."&".$nav_str."\">detail</a></td>";
|
35
|
$navrat .= "\n </tr> \n";
|
36
|
return $navrat;
|
37
|
}
|
38
|
|
39
|
|
40
|
//NOVE2504
|
41
|
function get_foot_of_table() {
|
42
|
return '<tr class="nadpis_sekce">
|
43
|
<td></td>
|
44
|
<td></td>
|
45
|
<td></td>
|
46
|
<td></td>
|
47
|
<td></td>
|
48
|
</tr>';
|
49
|
}
|
50
|
|
51
|
function get_razeni($l_order = "IDarticle",
|
52
|
$l_od = 0,
|
53
|
$l_limit = 30,
|
54
|
$contrains_source = "all",
|
55
|
$contrains_lection = "all") {
|
56
|
|
57
|
global $language;
|
58
|
|
59
|
global $order;
|
60
|
global $od;
|
61
|
global $limit;
|
62
|
|
63
|
$order = $l_order;
|
64
|
$od = $l_od;
|
65
|
$limit = $l_limit;
|
66
|
|
67
|
|
68
|
|
69
|
$nav_str = "language=$language&contrains_source=$contrains_source&contrains_lection=$contrains_lection";
|
70
|
|
71
|
$pocet_slov = get_pocet_clanku($contrains_source, $contrains_lection);
|
72
|
$navrat = "<p class=\"akt\"></p>";
|
73
|
$navrat .= "\n<table>
|
74
|
<tr class=\"nadpis_sekce\">
|
75
|
<td>
|
76
|
<form action=\"\" method=\"post\" name=\"razeni\">
|
77
|
Filtr: $language - $contrains_source - $contrains_lection";
|
78
|
|
79
|
$navrat .= " (Ve výběru celkem $pocet_slov)<br />
|
80
|
Řadit podle
|
81
|
<select name=\"order\">
|
82
|
<option value=\"IDarticle\">Identofikátor</option>
|
83
|
<option value=\"title\">nadpis</option>
|
84
|
<option value=\"body\">obsah</option>
|
85
|
<option value=\"note\">poznámka</option>
|
86
|
</select>
|
87
|
od: <input type=\"text\" name=\"od\" value=\"$od\" size=\"5\" />
|
88
|
počet: <input type=\"text\" name=\"limit\" value=\"$limit\" size=\"5\" />
|
89
|
<input type=\"hidden\" name=\"contrains_source\" value=\"$contrains_source\" />
|
90
|
<input type=\"hidden\" name=\"contrains_lection\" value=\"$contrains_lection\" />
|
91
|
<input type=\"submit\" name=\"serad\" value=\"Zobraz\" />
|
92
|
</form>
|
93
|
</td>
|
94
|
</tr>
|
95
|
<tr class=\"nadpis_sekce\"><td align=\"center\">
|
96
|
<a href=\"?nav_id=list_article&serad=true&order=$order&od=0&limit=$limit&$nav_str\">
|
97
|
Na začátek </a> | ";
|
98
|
if ($od-$limit >= 0)
|
99
|
$navrat .="\n <a href=\"?nav_id=list_article&serad=true&order=$order&od=".
|
100
|
($od-$limit)."&limit=$limit&$nav_str\">
|
101
|
Předchozích $limit </a> | ";
|
102
|
if ($od+$limit < $pocet_slov)
|
103
|
$navrat .="\n <a href=\"?nav_id=list_article&serad=true&order=$order&od=".
|
104
|
($od+$limit)."&limit=$limit&$nav_str\">
|
105
|
Dalších $limit </a> | ";
|
106
|
$navrat .="\n <a href=\"?nav_id=list_article&serad=true&order=$order&od=".
|
107
|
($pocet_slov-$limit)."&limit=$limit&$nav_str\">
|
108
|
Na konec </a>
|
109
|
";
|
110
|
$navrat .= "</td></tr></table>\n";
|
111
|
return $navrat;
|
112
|
}
|
113
|
|
114
|
function get_pocet_clanku($contrains_source, $contrains_lection) {
|
115
|
global $language;
|
116
|
require_once("./classes/db.php");
|
117
|
$spojeni = new DB_Sql();
|
118
|
$dotaz = "SELECT \"IDarticle\" FROM article";
|
119
|
if ($language != "all")
|
120
|
$dotaz .= " WHERE language LIKE '$language'";
|
121
|
if ($contrains_source != "all")
|
122
|
$dotaz .= " AND source = $contrains_source";
|
123
|
if ($contrains_lection != "all")
|
124
|
$dotaz .= " AND lection = $contrains_lection";
|
125
|
|
126
|
$spojeni->query($dotaz);
|
127
|
return $spojeni->num_rows();
|
128
|
|
129
|
}
|
130
|
|
131
|
function build_query_article($language, $contrains_source, $contrains_lection,$order, $od, $limit) {
|
132
|
$dotaz = "SELECT DISTINCT
|
133
|
ar.IDarticle as IDarticle,
|
134
|
ar.title as title,
|
135
|
lan.language as language,
|
136
|
so.title as source,
|
137
|
ar.lection as lection
|
138
|
|
139
|
|
140
|
FROM article ar, language lan, source so";
|
141
|
|
142
|
if ($language != "all")
|
143
|
$dotaz .= " WHERE ar.language LIKE '$language' ";
|
144
|
else
|
145
|
$dotaz .= " WHERE TRUE ";
|
146
|
|
147
|
if ($contrains_source != "all")
|
148
|
$dotaz .= "AND ar.source = $contrains_source";
|
149
|
if ($contrains_lection != "all")
|
150
|
$dotaz .= "AND ar.lection = $contrains_lection";
|
151
|
|
152
|
$dotaz .= " AND ar.language = lan.IDlanguage
|
153
|
AND ar.source = so.IDsource ";
|
154
|
if (!empty($order)) {
|
155
|
$orderClause = "ar.IDarticle, $order";
|
156
|
}
|
157
|
else {
|
158
|
$orderClause = "IDarticle";
|
159
|
}
|
160
|
|
161
|
$dotaz .= " ORDER BY $orderClause LIMIT $limit OFFSET $od";
|
162
|
|
163
|
return $dotaz;
|
164
|
} // END function build_query_article
|
165
|
|
166
|
|
167
|
function get_short_table_of_article($language = "all", $contrains_source = "all", $contrains_lection = "all",
|
168
|
$order = "IDarticle", $od = 0, $limit = 30) {
|
169
|
require_once("./classes/db.php");
|
170
|
$spojeni = new DB_Sql();
|
171
|
$dotaz = build_query_article($language, $contrains_source, $contrains_lection,$order, $od, $limit);
|
172
|
$radky = $spojeni->query($dotaz);
|
173
|
foreach ($radky as $radka){
|
174
|
if (!empty($radka['title'])) {
|
175
|
$navrat .= "<a href=\"?language=".$_REQUEST['language']."&view_article=".$radka['IDarticle']."\">".$radka['title']."</a><br />";
|
176
|
}
|
177
|
}
|
178
|
return $navrat;
|
179
|
} // END function get_short_table_of_article
|
180
|
|
181
|
|
182
|
/**
|
183
|
* Funkce vypise z db vsechny slovnikove polozky
|
184
|
*
|
185
|
*
|
186
|
*/
|
187
|
function print_table_of_article($language = "all", $contrains_source = "all", $contrains_lection = "all",
|
188
|
$order = "IDarticle", $od = 0, $limit = 30) {
|
189
|
|
190
|
require_once("./classes/db.php");
|
191
|
$spojeni = new DB_Sql();
|
192
|
$navrat = "<h3 class=\"nadpis2\">Výpis článků";
|
193
|
|
194
|
if ($language == "all")
|
195
|
$navrat .= " - vše</h3>";
|
196
|
else if($language == 1)
|
197
|
$navrat .= " - arabské</h3>";
|
198
|
else if($language == 2)
|
199
|
$navrat .= " - hebrejské</h3>";
|
200
|
else if($language == 3)
|
201
|
$navrat .= " - akkadské</h3>";
|
202
|
|
203
|
$navrat .= get_razeni($order, $od, $limit, $contrains_source, $contrains_lection);
|
204
|
$navrat .= "<table>";
|
205
|
$navrat .= get_header_of_table();
|
206
|
|
207
|
$dotaz = build_query_article($language, $contrains_source, $contrains_lection,$order, $od, $limit);
|
208
|
//echo "dotaz: ".$dotaz;
|
209
|
$radky = $spojeni->query($dotaz);
|
210
|
|
211
|
while ($spojeni->next_record()) {
|
212
|
$navrat .= get_row_of_table($spojeni->Record);
|
213
|
}
|
214
|
$navrat .= get_foot_of_table();
|
215
|
$navrat .= "</table>";
|
216
|
echo $navrat;
|
217
|
}
|
218
|
|
219
|
function get_article($id) {
|
220
|
require_once("./classes/db.php");
|
221
|
$spojeni = new DB_Sql();
|
222
|
$dotaz = "SELECT DISTINCT ON (ar.\"IDarticle\")
|
223
|
ar.\"IDarticle\" as \"IDarticle\",
|
224
|
ar.title as title,
|
225
|
ar.body as body,
|
226
|
ar.note as note,
|
227
|
ar.article_voice as article_voice,
|
228
|
lan.language as language,
|
229
|
so.title as source,
|
230
|
ar.lection as lection,
|
231
|
ar.source as \"IDsource\"
|
232
|
FROM article ar, language lan, source so
|
233
|
WHERE \"IDarticle\" = '$id'
|
234
|
AND ar.language = lan.\"IDlanguage\"
|
235
|
AND ar.source = so.\"IDsource\" ";
|
236
|
$radky = $spojeni->query($dotaz);
|
237
|
$spojeni->next_record();
|
238
|
|
239
|
if ($spojeni->Errno != 0) {
|
240
|
print_hlasku("Slovo se nepodařilo načíst.");
|
241
|
}
|
242
|
|
243
|
return $spojeni->Record;
|
244
|
}
|
245
|
|
246
|
|
247
|
|
248
|
?>
|