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

  ViewVC Help
Powered by ViewVC 1.1.26