/[health_html]/inc/pgKnjiznica2-vjesnik.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-vjesnik.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Mon Oct 29 14:43:21 2001 UTC (17 years, 10 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -1 lines
Added a new page (Farmaceutski glasnik) to plivamed. Other improvements/fixes.

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

  ViewVC Help
Powered by ViewVC 1.1.26