Projekt

Obecné

Profil

Stáhnout (9.85 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2
require_once("./functions/dictionary.php");
3

    
4
function authorize_article($ID) {
5
  require_once("./classes/db.php");
6
  $spojeni = new DB_Sql();
7
  $dotaz = "UPDATE article SET autorized = true
8
                        WHERE \"IDarticle\" = '$ID'";
9
  $spojeni->query($dotaz);
10
  if ($spojeni->Errno != 0) {
11
    return false;
12
  }
13
  return true;
14
}
15

    
16
//NOVE2504
17
function get_header_of_table() {
18
  return "\n  <tr class=\"nadpis_sekce\">
19
    <td>&nbsp;</td>
20
    <td>nadpis<br />text článku</td>
21
    <td>poznámka</td>
22
    <td>lekce</td>
23
    <td>zvuk</td>
24
  </tr>
25
";
26
}
27

    
28
function get_row_of_table($Record) {
29
  global $language;
30
  global $order;
31
  global $od;
32
  global $limit;
33
  global $contrains_source;
34
  global $contrains_lection;
35

    
36
  $nav_str = "language=$language&contrains_source=$contrains_source&contrains_lection=$contrains_lection";
37

    
38
  //pr($Record);
39
  
40
  $navrat .= "  <tr>\n";
41
  $navrat .= '    <td>
42
                <a href="?nav_id=list_article&action=delete_article&article_id='.$Record[0].'&'.$nav_str.'">smaž</a>
43
                  <!--input type="checkbox" name="smaz['.$Record[0].']" /-->';
44

    
45
  $navrat .= "\n".' <br /> ';
46

    
47
  $navrat .= '<a href="?nav_id=edit_article&article_id='.$Record[0].'&'.$nav_str;
48
  $navrat .= '">uprav</a>';
49

    
50
  $navrat .= "\n".' <br /> ';
51

    
52
  $navrat .= '<a href="?nav_id=autorize_article&article_id='.$Record[0].'&'.$nav_str;
53
  $navrat .= '">autorizuj</a>';
54
  
55
  $navrat .= "\n".' <br /> ';
56

    
57
  $navrat .= '<a href="?nav_id=add_test&language='.$Record['language'].'&source='.$Record['source'];
58
  $navrat .= '&lection='.urlencode( $Record['lection'] );
59
  $navrat .= '&title='.urlencode( $Record['title'] );
60
  $navrat .= '&body='.urlencode( $Record['body'] );
61
  $navrat .= '">vytvoř&nbsp;test</a></td>';
62
  
63

    
64
 /* $navrat .= "    <td class=\"arabic\" style=\"font-size: 180%\">";
65
  $navrat .= $Record["title"];
66
  $navrat .= "&nbsp;</td>\n";*/
67

    
68
  $navrat .= "    <td class=\"arabic\" style=\"font-size: 180%\" >";
69
  $navrat .= "<u>".$Record["title"]."</u><br />";
70
  $navrat .= nl2br($Record["body"]);
71
  $navrat .= "&nbsp;</td>\n";
72

    
73
  $navrat .= "    <td>";
74
  $navrat .= $Record["note"];
75
  $navrat .= "&nbsp;</td>\n";
76

    
77
  $navrat .= "    <td>";
78
  $navrat .= $Record["lection"];
79
  $navrat .= "&nbsp;</td>\n";
80

    
81
  if (Empty($Record["article_voice"])) {
82
    $navrat .= "\n    ".'<td> <a href="?nav_id=add_article_voice&article_id='.
83
               $Record[0].'&'.$nav_str.'"> přidat </a></td>';
84
  }
85
  else {
86
    $navrat .= "\n    ".'<td> <a href="?nav_id=add_article_voice&article_id='.
87
               $Record[0].'&'.$nav_str.'"> změnit </a>'."<br />\n".'      <a href="'.CESTA_CLANKU.$Record[0].PRIPONA.'"> přehrát </a></td>';
88
  }
89

    
90
  $navrat .= "\n  </tr> \n";
91
  return $navrat;
92
}
93

    
94
function get_razeni($l_order = "IDarticle",
95
                    $l_od = 0,
96
                    $l_limit = 30,
97
                    $contrains_source = "all",
98
                    $contrains_lection = "all",
99
                    $nonauthorized = false) {
100

    
101
  global $language;
102

    
103
  global $order;
104
  global $od;
105
  global $limit;
106

    
107
  $order = $l_order;
108
  $od    = $l_od;
109
  $limit = $l_limit;
110

    
111

    
112
  $nav = ($nonauthorized)? "list_nonauthorized_article" : "list_article";
113
  $nav_str = "language=$language&contrains_source=$contrains_source&contrains_lection=$contrains_lection";
114

    
115
  $pocet_slov = get_pocet_clanku($contrains_source, $contrains_lection, $nonauthorized);
116
  $navrat = "<p class=\"akt\"></p>";
117
  $navrat .= "\n<table>
118
  <tr class=\"nadpis_sekce\">
119
    <td>
120
      <form action=\"\" method=\"post\" name=\"razeni\">
121
        Filtr: $language - $contrains_source - $contrains_lection";
122

    
123
  $navrat .=  " (Ve výběru celkem $pocet_slov)<br />
124
         Řadit podle
125
         <select name=\"order\">
126
           <option value=\"IDarticle\">Identofikátor</option>
127
           <option value=\"title\">nadpis</option>
128
           <option value=\"body\">obsah</option>
129
           <option value=\"note\">poznámka</option>
130
         </select>
131
         od: <input type=\"text\" name=\"od\" value=\"$od\" size=\"5\" />
132
         počet: <input type=\"text\" name=\"limit\" value=\"$limit\" size=\"5\" />
133
         <input type=\"hidden\" name=\"contrains_source\" value=\"$contrains_source\" />
134
         <input type=\"hidden\" name=\"contrains_lection\" value=\"$contrains_lection\" />
135
         <input type=\"submit\" name=\"serad\" value=\"Zobraz\" />
136
         </form>
137
    </td>
138
  </tr>
139
  <tr class=\"nadpis_sekce\"><td align=\"center\">
140
    <a href=\"?nav_id=$nav&serad=true&order=$order&od=0&limit=$limit&$nav_str\">
141
            Na začátek </a> |       ";
142
  if ($od-$limit >= 0)
143
    $navrat .="\n    <a href=\"?nav_id=$nav&serad=true&order=$order&od=".
144
              ($od-$limit)."&limit=$limit&$nav_str\">
145
              Předchozích $limit </a> |       ";
146
  if ($od+$limit < $pocet_slov)
147
    $navrat .="\n    <a href=\"?nav_id=$nav&serad=true&order=$order&od=".
148
              ($od+$limit)."&limit=$limit&$nav_str\">
149
              Dalších $limit </a> |   ";
150
  $navrat .="\n    <a href=\"?nav_id=$nav&serad=true&order=$order&od=".
151
             ($pocet_slov-$limit)."&limit=$limit&$nav_str\">
152
             Na konec </a>
153
  ";
154
  $navrat .= "</td></tr></table>\n";
155
  $odkaz = "list_article_print.php?nav_id=$nav&serad=true&order=$order&od=$od&limit=$limit&$nav_str";
156
    $navrat .= "<a href=\"$odkaz\" onclick=\"OpenPopUp('$odkaz', 800, 750); return false\"
157
                              target=\"_blank\">verze pro tisk</a>";
158
  return $navrat;
159
}
160

    
161
function get_pocet_clanku($contrains_source, $contrains_lection, $nonauthorized) {
162
  global $language;
163
  require_once("./classes/db.php");
164
  $spojeni = new DB_Sql();
165
  //$spojeni->debug = true;
166
  $dotaz = "SELECT \"IDarticle\" FROM article";
167
   if ($nonauthorized == true) {
168
    $dotaz .= " WHERE autorized = false";
169
	}
170
	else {
171
		$dotaz .= " WHERE autorized = true";
172
	}
173
  if ($language != "all")
174
    $dotaz .= " AND language = '$language'";
175
  if ($contrains_source != "all")
176
    $dotaz .= " AND source = $contrains_source";
177
  if ($contrains_lection != "all")
178
    $dotaz .= " AND lection = '$contrains_lection'";
179

    
180
	//pr($dotaz);
181
  $spojeni->query($dotaz);
182
  return $spojeni->num_rows();
183

    
184
}
185

    
186

    
187
//NOVE2504
188
function get_foot_of_table() {
189
  return '<tr class="nadpis_sekce">
190

    
191
            <td></td>
192
            <td></td>
193
            <td></td>
194
            <td></td>
195
            <td></td>
196
          </tr>';
197
}
198

    
199
/**
200
 *  Funkce vypise z db vsechny slovnikove polozky
201
 *
202
 *  TODO: DODELAT VYPIS OSTATNICH DAT Z DB (DATA, USER, ATD...)
203
 *
204
 *
205
 */
206
function print_table_of_article($language = "all", $contrains_source = "all", $contrains_lection = "all",
207
							$nonauthorized = false,
208
                          $order = "IDarticle", $od = 0, $limit = 30) {
209

    
210
  require_once("./classes/db.php");
211
  $spojeni = new DB_Sql();
212
  $navrat = "<h3 class=\"nadpis2\">Výpis článků";
213

    
214
 if ($nonauthorized)
215
      $navrat .= " - neautorizováno";
216
  if ($language == "all")
217
    $navrat .= " - vše</h3>";
218
  else if($language == 1)
219
    $navrat .= " - arabské</h3>";
220
  else if($language == 2)
221
    $navrat .= " - hebrejské</h3>";
222
  else if($language == 3)
223
    $navrat .= " - akkadské</h3>";
224

    
225
  $navrat .= get_razeni($order, $od, $limit, $contrains_source, $contrains_lection, $nonauthorized);
226
  $navrat .= "<table>";
227
  $navrat .= get_header_of_table();
228

    
229
  $dotaz = "SELECT * FROM article ";
230

    
231
	if ($nonauthorized) $pomocna = " autorized = false ";
232
  else $pomocna = " autorized = true";
233

    
234
  if ($language != "all")
235
    $dotaz .= " WHERE language = '$language' AND $pomocna ";
236
  else
237
    $dotaz .= " WHERE $pomocna ";
238

    
239
  if ($contrains_source != "all")
240
    $dotaz .= "AND source = $contrains_source";
241
  if ($contrains_lection != "all")
242
    $dotaz .= "AND lection = '$contrains_lection'";
243

    
244

    
245
  $dotaz .= " ORDER BY \"$order\" OFFSET $od LIMIT $limit";
246

    
247
  $radky = $spojeni->query($dotaz);
248

    
249
  while ($spojeni->next_record()) {
250
    $navrat .= get_row_of_table($spojeni->Record);
251
  }
252
  $navrat .= get_foot_of_table();
253
  $navrat .= "</table>";
254
  echo $navrat;
255
}
256

    
257
function get_article($id) {
258
  require_once("./classes/db.php");
259
  $spojeni = new DB_Sql();
260
  $dotaz = "SELECT * FROM article WHERE \"IDarticle\" = '$id'";
261
  $radky = $spojeni->query($dotaz);
262
  $spojeni->next_record();
263

    
264
  if ($spojeni->Errno != 0) {
265
    print_hlasku("Clanek se nepodařilo načíst.");
266
  }
267

    
268
  return $spojeni->Record;
269
}
270

    
271
function delete_article($ID) {
272
  require_once("./classes/db.php");
273
  $spojeni = new DB_Sql();
274
  $dotaz = "DELETE FROM article WHERE \"IDarticle\" = '$ID'";
275
  $spojeni->query($dotaz);
276
  if ($spojeni->Errno != 0) {
277
    return false;
278
  }
279
  return true;
280
}
281

    
282
function update_article($id, $title, $body, $note, $lection) {
283
  require_once("./classes/db.php");
284
  $spojeni = new DB_Sql();
285

    
286
  $dotaz = "UPDATE article SET title = '".AddSlashes($title)."',
287
                            body = '".AddSlashes($body)."',
288
                            note = '".AddSlashes($note)."',
289
                            lection = '".AddSlashes($lection)."'
290
                            WHERE \"IDarticle\" = '".AddSlashes($id)."'";
291
  $spojeni->query($dotaz);
292
  if ($spojeni->Errno != 0) {
293
    print_hlasku("Slovo se nepodařilo upravit.");
294
  }
295
  print_hlasku("Slovo změněno.");
296
}
297

    
298

    
299

    
300

    
301
function insert_article($language,$source,$lection,$title,$body,$note,$user){
302
  require_once("./classes/db.php");
303
  $spojeni = new DB_Sql();
304
  //$NOW = Date("YmdHis");
305

    
306
  $dotaz = "INSERT INTO article (\"language\",
307
                              \"source\",
308
                              \"lection\",
309
                              \"inserted_by\",
310
                              \"title\",
311
                              \"body\",
312
                              \"note\",
313
                              \"article_voice\")
314
                    VALUES ('$language',
315
                            '$source',
316
                            '$lection',
317
                            '$user',
318
                            '$title',
319
                            '$body',
320
                            '$note',
321
                            '0')";
322
  $spojeni->query($dotaz);
323
  if ($spojeni->Errno != 0) {
324
    return false;
325
  }
326
  return true;
327
}
328

    
329
?>
(14-14/62)