Projekt

Obecné

Profil

Stáhnout (7.88 KB) Statistiky
| Větev: | Tag: | Revize:
1 6daefa8c Petr Lukašík
<?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&nbsp;</td>
8
    <td>zdroj&nbsp;</td>
9
    <td>lekce</td>
10
    <td>nadpis</td>
11
    <td>&nbsp;</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 .= "&nbsp;</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 ON (ar.\"IDarticle\")
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 OFFSET $od LIMIT $limit";
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
  while ($spojeni->next_record()) {
174
    //print_r($spojeni->Record);
175
    if (!empty($spojeni->Record['title'])) {
176
	    $navrat .= "<a href=\"?language=".$_REQUEST['language']."&amp;view_article=".$spojeni->Record['IDarticle']."\">".$spojeni->Record['title']."</a><br />";
177
	}
178
  }
179
	return $navrat;
180
} // END function get_short_table_of_article
181
182
183
/**
184
 *  Funkce vypise z db vsechny slovnikove polozky
185
 *
186
 *
187
 */
188
function print_table_of_article($language = "all", $contrains_source = "all", $contrains_lection = "all",
189
                          $order = "IDarticle", $od = 0, $limit = 30) {
190
191
  require_once("./classes/db.php");
192
  $spojeni = new DB_Sql();
193
  $navrat = "<h3 class=\"nadpis2\">Výpis článků";
194
195
  if ($language == "all")
196
    $navrat .= " - vše</h3>";
197
  else if($language == 1)
198
    $navrat .= " - arabské</h3>";
199
  else if($language == 2)
200
    $navrat .= " - hebrejské</h3>";
201
  else if($language == 3)
202
    $navrat .= " - akkadské</h3>";
203
204
  $navrat .= get_razeni($order, $od, $limit, $contrains_source, $contrains_lection);
205
  $navrat .= "<table>";
206
  $navrat .= get_header_of_table();
207
208
  $dotaz = build_query_article($language, $contrains_source, $contrains_lection,$order, $od, $limit);
209
    //echo "dotaz: ".$dotaz;
210
  $radky = $spojeni->query($dotaz);
211
212
  while ($spojeni->next_record()) {
213
    $navrat .= get_row_of_table($spojeni->Record);
214
  }
215
  $navrat .= get_foot_of_table();
216
  $navrat .= "</table>";
217
  echo $navrat;
218
}
219
220
function get_article($id) {
221
  require_once("./classes/db.php");
222
  $spojeni = new DB_Sql();
223
  $dotaz = "SELECT DISTINCT ON (ar.\"IDarticle\")
224
                         ar.\"IDarticle\"  as \"IDarticle\",
225
                         ar.title          as title,
226
                         ar.body           as body,
227
                         ar.note           as note,
228
                         ar.article_voice  as article_voice,
229
                         lan.language      as language,
230
                         so.title          as source,
231
                         ar.lection        as lection,
232
                         ar.source         as \"IDsource\"
233
             FROM article ar, language lan, source so
234
             WHERE \"IDarticle\" = '$id'
235
              AND ar.language = lan.\"IDlanguage\"
236
              AND ar.source   = so.\"IDsource\" ";
237
  $radky = $spojeni->query($dotaz);
238
  $spojeni->next_record();
239
240
  if ($spojeni->Errno != 0) {
241
    print_hlasku("Slovo se nepodařilo načíst.");
242
  }
243
244
  return $spojeni->Record;
245
}
246
247
248
249
?>