/[health_html]/inc/pgKnjiznica2-inf_glasnik.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/pgKnjiznica2-inf_glasnik.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Wed Oct 10 12:40:58 2001 UTC (17 years, 6 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +3 -1 lines
Improved Arhiva, Alergijski semafor and Home. Added a second Q&A page (test version). Other improvements & bugfixes.

1 <?php
2 include("inc/conn.php");
3 include_once("inc/search.php");
4 function MyCmp1($a, $b) { return MyCompare($a["naslov"], $b["naslov"]); }
5 function MyCmp2($a, $b) { return MyCompare($a["l"], $b["l"]); }
6 $fields = array(
7 "broj" => array("dbname" => "broj", "caption" => "Broj èasopisa"),
8 "godina" => array("dbname" => "godina", "caption" => "Godina izdanja"),
9 "naslov" => array("dbname" => "naslov", "caption" => "Naslov èlanka"),
10 "autor" => array("dbname" => "autor_ime", "caption" => "Ime autora"),
11 "adresa" => array("dbname" => "autor_adresa", "caption" => "Adresa autora"),
12 "rijeci" => array("dbname" => "keywords", "caption" => "Kljuène rijeèi")
13 );
14 if (!$id) {
15 list($srch, $qry_1, $qry_2) = Search($fields, array("broj", "godina", "naslov", "rijeci", "autor", "adresa"), array(), "naslov");
16 # Win1250 -> ISO8859-2
17 if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
18 if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
19 $tpl->assign("index", $index);
20 $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
21 $tpl->assign("SEARCH", $srch);
22 }
23 if (!$index && !$srch) $index = 1;
24 $letters = Slova();
25 if (!$id && ($index || ($qry_1 || $qry_2))) {
26 $prvo_slovo = "UPPER(SUBSTRING(autor_ime || ': ' || clanak FROM 1 FOR 1))";
27 $sql = "SELECT ig_id, $prvo_slovo AS prvo_slovo, autor_ime, clanak FROM inf_glasnik";
28 $uvjet = array();
29 if ($index && $index != 1) {
30 if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
31 else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
32 }
33 if ($qry_1) array_push($uvjet, "($qry_1)");
34 $uvjet = implode(" AND ", $uvjet);
35 if ($uvjet) $sql .= " WHERE $uvjet";
36 $sql .= " ORDER BY prvo_slovo, autor_ime, clanak";
37 $sth = $dbh->prepare($sql);
38 if (!$sth) error("Cannot prepare query: \"$sql\"");
39 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
40 $slova = array();
41 $clanci = array();
42 unset($staro_slovo);
43 while ($row = $sth->fetchrow_array()) {
44 list($id2, $fl, $autor, $naslov) = $row;
45 if (!isset($staro_slovo)) $staro_slovo = $fl;
46 if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
47 usort($clanci, "MyCmp1");
48 array_push($slova, array("l" => $staro_slovo, "clanci" => $clanci));
49 $staro_slovo = $fl;
50 $clanci = array();
51 }
52 array_push($clanci, array("id" => $id2, "naslov" => MyEscape($naslov), "autor" => MyEscape($autor)));
53 }
54 $sth->finish();
55 if (count($clanci) > 0) {
56 usort($clanci, "MyCmp1");
57 array_push($slova, array("l" => $staro_slovo, "clanci" => $clanci));
58 }
59 usort($slova, "MyCmp2");
60 $records = 0;
61 for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["clanci"]);
62 $tpl->assign("records", $records);
63 $tpl->assign("slova", $slova);
64 $tpl->assign("stype", $stype);
65 }
66 if ($id) {
67 $sql = "SELECT broj, godina, clanak, keywords, autor_ime, autor_adresa, pdf FROM inf_glasnik WHERE (ig_id = $id)";
68 $sth = $dbh->prepare($sql);
69 if (!$sth) error("Cannot prepare query: \"$sql\"");
70 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
71 $row = $sth->fetchrow_array();
72 $sth->finish();
73 list($broj, $godina, $naslov, $keywords, $autor, $adresa, $pdf) = $row;
74 $tpl->assign("broj", MyEscape($broj));
75 $tpl->assign("godina", MyEscape($godina));
76 $tpl->assign("naslov", MyEscape($naslov));
77 $tpl->assign("keywords", MyEscape($keywords));
78 $tpl->assign("autor", MyEscape($autor));
79 $tpl->assign("adresa", MyEscape($adresa));
80 $tpl->assign("pdf", MyEscape($pdf));
81 }
82 $tpl->assign("letters", $letters);
83 $tpl->assign("ID", $id);
84 $dbh->disconnect();
85 array_push($PATH, "INFEKTOLO©KI GLASNIK");
86 ?>

  ViewVC Help
Powered by ViewVC 1.1.26