3 require_once("view/CiteView.php");
4 require_once("profiller.php");
5 Profiller
::speed("Začínáme");
6 require_once("CiteConfig.php");
7 require_once("CiteOutput.php");
9 require_once("CiteFields.php");
10 require_once("CiteData.php");
11 require_once("database.php");
12 require_once("model/Models.php");
13 require_once("model/DataCache.php");
14 require_once("model/CiteModel.php");
15 require_once("view/Template.php");
16 require_once("view/HtmlTemplate.php");
17 require_once("view/LatexTemplate.php");
18 Profiller
::speed("Načtení vkládaných souborů");
19 //CiteConfig::setValue("output_filter","latex");
21 private $data=array();
22 public function add($key,$data){
23 if(array_key_exists($key,$this->data
)){
24 if(is_array($this->data
[$key])){
25 //CiteOutput::factory("Je pole")->lineBreak()->out();
26 $this->data
[$key][]=$data;
28 //CiteOutput::factory("Neni pole")->lineBreak()->out();
29 $old=$this->data
[$key];
30 $this->data
[$key]=array($old,$data);
33 $data=is_array($data)?
array($data):$data;
34 $this->data
[$key]=$data;
37 public function fetch(){
41 class pokus
extends CiteModel
{
42 private $authors=null;
43 private $publikace=array();
44 public function bibliography(){
49 ->field("names")->variable("author")->suffix(".")->limit(3)->limitUse(3)
50 ->name()->delimiter("; ")->delimiterAnd("; ")
51 ->namePart("family")->textCase("uppercase")->end()
56 ->field("names")->variable("editor")->suffix(".")->limit(3)->limitUse(3)
57 ->name()->delimiter("; ")->delimiterAnd("; ")
58 ->namePart("family")->textCase("uppercase")->end()
64 ->cslIf()->variable("editor")
65 ->field("text")->macro("editor")->end()
67 ->field("text")->macro("author")->end()
78 ->field("text")->macro("primary")->end()
79 ->field("text")->macro("document_name")->end()
83 /*->field("names")->variable("author")->suffix(".")->limit(3)->limitUse(3)
84 ->name()->delimiter("; ")->delimiterAnd("; ")
85 ->namePart("family")->textCase("uppercase")->end()
88 ->field("base")->variable("title")
89 ->fontStyle("italic")->fontWeight("bold")->textCase("title")
91 ->field("base")->macro("publisher")->end()
92 ->field("base")->variable("date")->end()
94 ->field("base")->term("pokus")->prefix(":")->suffix(";")->end()
95 ->field("base")->variable("titlle")->end()
96 ->field("number")->variable("ohoo")->end()
99 ->cslIf()->variable("pokusíík title")->match("any")->field(text)->value("První podmínka")->end()
100 ->cslElseIf()->variable("title")
101 ->field("text")->value("druhá podmínka")->end()
103 ->cslElse()->field("text")->value("nic z toho")->end()
116 ->textCase("uppercase")
122 ->fontStyle("italic")
127 ->variable("publisher")
133 CSL
::printBibliography();
135 public function __construct(){
136 $this->db
=DatabaseConnector
::database("krokobib")
140 Profiller
::speed("Připojení k databázi");
142 $name=ModelFactory
::get("Name");
143 $publication=ModelFactory
::get("Publication");
144 $authors=ModelFactory
::get("Author");
145 $role=ModelFactory
::get("AuthorRole");
146 $publication_type=ModelFactory
::get("PublicationType");
147 //$res=$this->query("autori")->rawQuery("SELECT name.* FROM publication inner join author on publication_id=publication inner join name on author_name=name_id ")->result();
148 Profiller
::speed("Nahrání modelů");
149 $res=$this->query("autori")
150 ->select("name.name_id, family,given, part, von_part, date, description, publication, author_id, author_name,role")
151 ->link($authors,$publication)
152 ->link($authors,$role)
153 ->link($authors,$name)
154 ->where("author_name is not null order by family")
156 //Profiller::speed("Build query");
157 ->prepare()->execute()->result();
158 //->buildQuery()->rawQuery()->result();
159 Profiller
::speed("Query autoři");
160 $this->authors
=new DataCache($authors);
161 $this->names
=new DataCache($name);
162 while($row=$res->fetch(PDO
::FETCH_ASSOC
)){
163 $this->authors
->load($row,"publication");
164 $this->names
->load($row);
166 //$this->authors->load($res);
167 Profiller
::speed("Nahrání autorů");
168 //$this->show($this->authors->fetch(1));
169 //$this->show($this->authors->fetch(2));
170 //$this->show($this->authors->fetch(1));
171 //Profiller::speed("Dotazy na autory");
172 //$this->show($this->authors->fetch(5));
173 $publikace=$this->query("publikace")
174 ->select("publication_id, type")
175 ->link($publication,$publication_type)
176 ->buildQuery()->prepare()->execute()->result();
177 Profiller
::speed("Query publikace");
178 while($row=$publikace->fetch(PDO
::FETCH_ASSOC
)){
179 $id=$row["publication_id"];
181 CiteOutput
::factory("Publikace: $id typ: $type")->lineBreak()->out();
182 $authors=$this->authors
->get($id);
183 $publ=new Publication();
184 if(is_array($authors)){
185 foreach($authors as $author){
186 $role=$author["role"];
187 $publ->add($role,$author);
188 $publ->add("type",$type);
189 //CiteOutput::factory("autor")->lineBreak()->out();
190 //CiteOutput::factory(implode(" / ",$author))->lineBreak()->out();
191 //$this->show($author);
194 //CiteOutput::factory("Autoři nejsou pole")->lineBreak()->out();
196 $publ->add("publisher","Nakladatel");
197 $publ->add("date","2009");
198 $publ->add("title","titulek");
199 $publ->add("author",array("family"=>"Obecný","given"=>"Autor"));
200 //print_r($publ->fetch());
201 $this->publikace
[]=$publ->fetch();
204 Profiller
::speed("Nahrání publikací");
205 }catch(Exception
$e){
206 CiteOutput
::factory($e->getMessage())->lineBreak()->out();
208 CiteData
::loadData($this->publikace
);
209 Profiller
::speed("Nahrání do CiteData");
210 //ModelFactory::get("name")->retrieve(2);
214 $pokus->bibliography();
215 Profiller
::speed("Konec");
217 $content=ob_get_contents();
218 $content.=CiteView
::get();
221 $tpl=new HtmlTemplate();
222 $tpl->assert("page_contents",$content);
223 $tpl->assert("page_title",CiteOutput
::factory(CiteConfig
::getValue("page_title"))->get());
224 echo $tpl->get("index.php");