Added templates
[bibliodb.git] / reserse.php
blob359c5323374a1037728f22d730a260b1f5ada98e
1 <pre>
2 <?php
3 error_reporting(E_ERROR | E_WARNING | E_PARSE);
4 require_once("view/CiteView.php");
5 require_once("profiller.php");
6 Profiller::speed("Začínáme");
7 require_once("CiteConfig.php");
8 require_once("CiteOutput.php");
9 //
10 require_once("CiteFields.php");
11 require_once("CiteData.php");
12 require_once("database.php");
13 require_once("model/Models.php");
14 require_once("model/DataCache.php");
15 require_once("model/CiteModel.php");
16 require_once("view/Template.php");
17 require_once("view/HtmlTemplate.php");
18 require_once("view/LatexTemplate.php");
19 Profiller::speed("Načtení vkládaných souborů");
21 class Publication{
22 private $data=array();
23 public function add($key,$data){
24 if(array_key_exists($key,$this->data)){
25 if(is_array($this->data[$key])){
26 //CiteOutput::factory("Je pole")->lineBreak()->out();
27 $this->data[$key][]=$data;
28 }else{
29 //CiteOutput::factory("Neni pole")->lineBreak()->out();
30 $old=$this->data[$key];
31 $this->data[$key]=array($old,$data);
33 }else{
34 $data=is_array($data)?array($data):$data;
35 $this->data[$key]=$data;
38 public function fetch(){
39 return $this->data;
43 class Reserse{
44 private $sources=array();
45 private $counter=0;
46 public function head(){
47 $number_of_records=$this->counter;
48 setlocale(LC_COLLATE, 'czech');
49 usort($this->sources, 'strcoll');
50 CiteOutput::factory()->lineBreak()
51 ->bold("Rešerše:")->text("č.j. 4 / 2010")->lineBreak()
52 ->bold("Téma rešerše:")->text("Systém CDS/ISIS pro využití v knihovní praxi")->lineBreak()
53 ->bold("Zadavatel:")->text("Národní technická knihovna pro účely RKK")->lineBreak()
54 ->bold("Zpracovatel:")->text("Michal Hoftich")->lineBreak()
55 ->bold("Datum zadání:")->text("1. 4. 2010")->lineBreak()
56 ->bold("Datum zpracování:")->text("29. 4. 2010")->lineBreak()
57 ->bold("Klíčová slova:")->text("CDS/ISIS")->lineBreak()
58 ->bold("Jazykové vymezení:")->text("Angličtina, Čeština, Slovenština")->lineBreak()
59 ->bold("Časové rozmezí:")->text("1998 -- 2010")->lineBreak()
60 ->bold("Uspořádání záznamů:")->text("abecedně dle zdroje a následně chronologicky (dle data vydání)")->lineBreak()
61 ->bold("Zdroje:")->text(implode(", ",$this->sources))->lineBreak()
62 ->bold("Celkový počet záznamů: ")->text($number_of_records)->lineBreak()
63 ->bold("Typ záznamů:")->text("citace dle normy ČSN ISO 690 a ČSN ISO 690/2 s anotací")->lineBreak()
64 ->out();
65 return $this;
67 public function addSource($name){
68 $this->printSource(0);
69 $this->sources[]=$name;
70 $this->actual=$name;
71 return $this;
73 public function load($file_name){
74 $contents=file_get_contents($file_name);
75 $records=explode("\zalomit",$contents);
76 $this->printSource(count($records));
77 foreach($records as $record) {
78 if(strlen(trim($record))>0)
79 CiteOutput::factory()->text("\item")->text($record)->out();
81 //$this->sources[$this->actual]=$records;
82 return $this;
84 public function loadEbsco(){
85 $this->ebsco=new Ebsco();
86 include("ebsco.php");
87 $count = $this->ebsco->load($ebsco);
88 $this->printSource($count);
89 $this->ebsco->bibliography();
90 return $this;
93 public function printSource($counter){
94 if($this->actual){
95 $this->counter+=$counter;
96 CiteOutput::factory()->lineBreak()->bold("Název zdroje")->text($this->actual)->lineBreak()
97 ->bold("Počet záznamů")->text($counter)->lineBreak()->out();
98 $this->actual=false;
102 function ebscocmp($a,$b){return strcmp($a["year"],$b["year"]);}
103 class Ebsco{
104 private $publ=array();
105 function load($ebsco){
106 $i=0;
107 $data=array();
109 foreach($ebsco as $zaznam){
110 $publ=new Publication();
111 $mala=array();
112 $i++;
113 if(array_key_exists("Author",$zaznam)){
114 $autori=explode("; ",$zaznam["Author"]);
115 $n=array();
116 foreach($autori as $autor){
117 $parts=explode(", ",$autor);
118 $p=array("family"=>$parts[0],"given"=>$parts[1]);
119 $n[]=$p;
121 $zaznam["Author"]=$n;
123 if(array_key_exists("ISSN",$zaznam)){
124 $issn=implode("-",str_split($zaznam["ISSN"],4));
125 $zaznam["ISSN"]=$issn;
128 foreach($zaznam as $key=>$value){
129 $klic=strtolower($key);
130 $mala[$klic]=$value;
132 $data[]=$mala;
133 //$data[]=$publ->fetch();
134 echo "<pre>";
135 //print_r($data);
136 echo "</pre>";
137 //CiteOutput::factory($i.": ".$zaznam["Author"])->lineBreak()->out();
139 usort($data,"ebscocmp");
140 //echo "<pre>";
141 //print_r($data);
142 //echo "</pre>";
143 CiteData::loadData($data);
144 return count($data);
146 public function bibliography(){
147 CSL::style("iso-690")
148 ->bibliography()
149 ->sort()->end()
150 ->layout()
151 ->field("group")
152 ->field("names")->variable("author")->suffix(".")->limit(3)->limitUse(3)
153 ->name()->delimiter("; ")->delimiterAnd("; ")
154 ->namePart("family")->textCase("uppercase")->end()
155 ->end()
156 ->end()
157 ->end()
158 ->field("text")->variable("title")->suffix("")->end()
159 ->field("text")->variable("journal")->fontStyle("italic")->suffix(".")->end()
160 ->field("text")->variable("year")->suffix(",")->end()
161 ->field("group")
162 ->field("text")->value("vol.")->end()
163 ->field("text")->variable("volume")->suffix(",")->end()
164 ->end()
165 ->field("group")
166 ->field("text")->value("no.")->end()
167 ->field("text")->variable("number")->suffix(",")->end()
168 ->end()
169 ->field("group")
170 ->field("text")->value("p.")->end()
171 ->field("text")->variable("pages")->suffix(".")->end()
172 ->end()
173 ->field("text")->value("Dostupné také komerčně na WWW: <\url{http://search.ebscohost.com/}>.")->end()
174 ->field("group")
175 ->field("text")->value("ISSN")->end()
176 ->field("text")->variable("issn")->suffix(".")->end()
177 ->end()
178 ->field("group")
179 ->field("text")->value("//dělit anotaci//")->end()
180 ->field("text")->variable("abstract")->end()
181 ->end()
182 ->end()
183 ->end();
184 CSL::printBibliography();
187 CiteConfig::setValue("output_filter","html");
188 $reserse=new Reserse();
189 $reserse
190 ->addSource("ANL -- Článková bibliografie")
191 ->load("./reserse-kurz/anl.txt")
192 ->addSource("Česká národní bibliografie")
193 ->addSource("EBSCO")
194 ->loadEbsco()
195 ->addSource("KKL -- Katalog Knihovnické Literatury")
196 ->load("./reserse-kurz/kkl.txt")
197 ->addSource("Souborný katalog ČR -- Monografie")
198 ->addSource("Souborný katalog ČR -- Seriály")
199 ->addSource("Centrální katalog Univerzity Karlovy")
200 ->addSource("Volný internet")
201 ->head(3);
202 //$ebscoClass=new Ebsco();
203 //include("ebsco.php");
204 //$ebscoClass->load($ebsco)
205 //->bibliography();
206 $content=CiteView::get();
207 //$tpl=new LatexTemplate();
208 //$content.=print_r(dba_handlers(true),true);
209 $tpl=new HtmlTemplate();
210 $tpl->assert("page_contents",$content);
211 $tpl->assert("page_title","rešerše");
212 echo $tpl->get("index.php");