ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBibItemGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Modules/LearningModule/classes/class.ilBibItem.php");
25 
37 {
38  var $ilias;
39  var $tpl;
40  var $lng;
41  var $obj;
42  var $bib_obj;
43 
44 
49  function ilBibItemGUI()
50  {
51  global $ilias, $tpl, $lng;
52  $lng->loadLanguageModule("bibitem");
53 
54  $this->ilias =& $ilias;
55  $this->tpl =& $tpl;
56  $this->lng =& $lng;
57  }
58 
59  function setObject($a_obj)
60  {
61  $this->obj = $a_obj;
62  $this->obj->initBibItemObject();
63  $this->bib_obj = $this->obj->bib_obj;
64 # echo $this->bib_obj->getXML();
65  }
66 
70  function curValue($a_val_name)
71  {
72  if(is_object($this->meta_obj))
73  {
74  $method = "get".$a_val_name;
75  return $this->meta_obj->$method();
76  }
77  else
78  {
79  return "";
80  }
81  }
82 
86  function showLangSel($a_name, $a_value = "")
87  {
88  $tpl = new ilTemplate("tpl.lang_selection.html", true, true);
89  $languages = ilMDLanguageItem::_getLanguages();
90  foreach($languages as $code => $text)
91  {
92  $tpl->setCurrentBlock("lg_option");
93  $tpl->setVariable("VAL_LG", $code);
94  $tpl->setVariable("TXT_LG", $text);
95  if ($a_value != "" &&
96  $a_value == $code)
97  {
98  $tpl->setVariable("SELECTED", "selected");
99  }
100  $tpl->parseCurrentBlock();
101  }
102  $tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
103  $tpl->setVariable("SEL_NAME", $a_name);
104  $return = $tpl->get();
105  unset($tpl);
106 
107  return $return;
108  }
109 
110  function fill($a_formaction, $a_index = 0, $a_language = "")
111  {
112  $this->tpl->setVariable("TXT_BIBITEM", $this->lng->txt("bibitem_bibitem"));
113  $this->tpl->setVariable("BIBITEM_TXT_DELETE", $this->lng->txt("bibitem_delete"));
114  $this->tpl->setVariable("BIBITEM_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "&bibItemName=BibItem");
115  $this->tpl->setVariable("BIBITEM_TXT_ADD", $this->lng->txt("bibitem_add"));
116  $this->tpl->setVariable("BIBITEM_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=BibItem");
117  $this->tpl->setVariable("TXT_NEW_ELEMENT", $this->lng->txt("bibitem_new_element"));
118  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("bibitem_language"));
119  $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("bibitem_author"));
120  $this->tpl->setVariable("TXT_CROSSREF", $this->lng->txt("bibitem_cross_reference"));
121  $this->tpl->setVariable("TXT_EDITOR", $this->lng->txt("bibitem_editor"));
122  $this->tpl->setVariable("TXT_WHERE_PUBLISHED", $this->lng->txt("bibitem_where_published"));
123  $this->tpl->setVariable("TXT_INSTITUTION", $this->lng->txt("bibitem_institution"));
124  $this->tpl->setVariable("TXT_KEYWORD", $this->lng->txt("bibitem_keyword"));
125  $this->tpl->setVariable("TXT_SCHOOL", $this->lng->txt("bibitem_school"));
126  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("bibitem_add"));
127 
128  $bibitem = $this->bib_obj->getElement("BibItem");
129  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("bibitem_type"));
130  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("bibitem_please_select"));
131  $this->tpl->setVariable("TXT_BOOK", $this->lng->txt("bibitem_book"));
132  $this->tpl->setVariable("TXT_INBOOK", $this->lng->txt("bibitem_inbook"));
133  $this->tpl->setVariable("TXT_JOURNALARTICLE", $this->lng->txt("bibitem_journal_article"));
134  $this->tpl->setVariable("TXT_PROCEEDINGS", $this->lng->txt("bibitem_proceedings"));
135  $this->tpl->setVariable("TXT_INPROCEEDINGS", $this->lng->txt("bibitem_inproceedings"));
136  $this->tpl->setVariable("TXT_DISSERTATION", $this->lng->txt("bibitem_dissertation"));
137  $this->tpl->setVariable("TXT_PHDTHESIS", $this->lng->txt("bibitem_phd_thesis"));
138  $this->tpl->setVariable("TXT_MASTERSTHESIS", $this->lng->txt("bibitem_master_thesis"));
139  $this->tpl->setVariable("TXT_TECHREPORT", $this->lng->txt("bibitem_technical_report"));
140  $this->tpl->setVariable("TXT_MANUAL", $this->lng->txt("bibitem_manual"));
141  $this->tpl->setVariable("TXT_NEWSPAPERARTICLE", $this->lng->txt("bibitem_newspaper_article"));
142  $this->tpl->setVariable("TXT_AV", $this->lng->txt("bibitem_av"));
143  $this->tpl->setVariable("TXT_INTERNET", $this->lng->txt("bibitem_internet"));
144  $this->tpl->setVariable("TXT_UNPUBLISHED", $this->lng->txt("bibitem_unpublished"));
145  $this->tpl->setVariable("TYPE_VAL_" . strtoupper(ilUtil::prepareFormOutput($bibitem[$a_index]["Type"])), " selected");
146 
147  $this->tpl->setVariable("TXT_LABEL", $this->lng->txt("bibitem_label"));
148  $this->tpl->setVariable("VAL_LABEL", ilUtil::prepareFormOutput($bibitem[$a_index]["Label"]));
149 
150  $identifier = $this->bib_obj->getElement("Identifier", "BibItem[" . ($a_index+1) . "]");
151  $this->tpl->setVariable("TXT_IDENTIFIER", $this->lng->txt("bibitem_identifier"));
152  $this->tpl->setVariable("TXT_CATALOG", $this->lng->txt("bibitem_catalog"));
153  $this->tpl->setVariable("VAL_IDENTIFIER_CATALOG", ilUtil::prepareFormOutput($identifier[0]["Catalog"]));
154  $this->tpl->setVariable("TXT_ENTRY", $this->lng->txt("bibitem_entry"));
155  $this->tpl->setVariable("VAL_IDENTIFIER_ENTRY", ilUtil::prepareFormOutput($identifier[0]["Entry"]));
156 
157  /* Language Loop */
158  if (is_array($language = $this->bib_obj->getElement("Language", "BibItem[" . ($a_index+1) . "]")) &&
159  count($language) > 0)
160  {
161  for ($i = 0; $i < count($language); $i++)
162  {
163  if (count($language) > 1)
164  {
165  $this->tpl->setCurrentBlock("language_delete");
166  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=Language");
167  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
168  $this->tpl->parseCurrentBlock();
169  }
170  $this->tpl->setCurrentBlock("language_loop");
171  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_LANGUAGE", $this->lng->txt("bibitem_language"));
172  $this->tpl->setVariable("LANGUAGE_LOOP_VAL_LANGUAGE", $this->showLangSel("meta[Language][" . $i . "][Language]", $language[$i]["Language"]));
173  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=Language&bibItemPath=BibItem&bibItemIndex=" . $a_index);
174  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
175  $this->tpl->parseCurrentBlock();
176  }
177  }
178 
179  /* Author Loop */
180  if (is_array($author = $this->bib_obj->getElement("Author", "BibItem[" . ($a_index+1) . "]")) &&
181  count($author) > 0)
182  {
183  for ($i = 0; $i < count($author); $i++)
184  {
185  $this->tpl->setCurrentBlock("author_loop");
186  $this->tpl->setVariable("AUTHOR_LOOP_TXT_AUTHOR", $this->lng->txt("bibitem_author"));
187  $this->tpl->setVariable("AUTHOR_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
188  $this->tpl->setVariable("AUTHOR_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=Author");
189  $this->tpl->setVariable("AUTHOR_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
190  $this->tpl->setVariable("AUTHOR_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=Author&bibItemPath=BibItem&bibItemIndex=" . $a_index);
191  $this->tpl->setVariable("AUTHOR_LOOP_NO", $i);
192  $this->tpl->setVariable("AUTHOR_LOOP_TXT_FIRSTNAME", $this->lng->txt("bibitem_first_name"));
193  if (is_array($firstname = $this->bib_obj->getElement("FirstName", "BibItem[" . ($a_index+1) . "]/Author[" . ($i+1) . "]")))
194  {
195  $this->tpl->setVariable("AUTHOR_LOOP_VAL_FIRSTNAME", ilUtil::prepareFormOutput($firstname[0]["value"]));
196  }
197  $this->tpl->setVariable("AUTHOR_LOOP_TXT_MIDDLENAME", $this->lng->txt("bibitem_middle_name"));
198  if (is_array($middlename = $this->bib_obj->getElement("MiddleName", "BibItem[" . ($a_index+1) . "]/Author[" . ($i+1) . "]")))
199  {
200  $this->tpl->setVariable("AUTHOR_LOOP_VAL_MIDDLENAME", ilUtil::prepareFormOutput($middlename[0]["value"]));
201  }
202  $this->tpl->setVariable("AUTHOR_LOOP_TXT_LASTNAME", $this->lng->txt("bibitem_last_name"));
203  if (is_array($lastname = $this->bib_obj->getElement("LastName", "BibItem[" . ($a_index+1) . "]/Author[" . ($i+1) . "]")))
204  {
205  $this->tpl->setVariable("AUTHOR_LOOP_VAL_LASTNAME", ilUtil::prepareFormOutput($lastname[0]["value"]));
206  }
207  $this->tpl->parseCurrentBlock("author_loop");
208  }
209  }
210 
211  $booktitle = $this->bib_obj->getElement("Booktitle", "BibItem[" . ($a_index+1) . "]");
212  $this->tpl->setVariable("TXT_BOOKTITLE", $this->lng->txt("bibitem_booktitle"));
213  $this->tpl->setVariable("BOOKTITLE_VAL", ilUtil::prepareFormOutput($booktitle[0]["value"]));
214  $this->tpl->setVariable("BOOKTITLE_VAL_LANGUAGE", $this->showLangSel("meta[Booktitle][Language]", $booktitle[0]["Language"]));
215 
216  /* CrossRef Loop */
217  if (is_array($crossref = $this->bib_obj->getElement("CrossRef", "BibItem[" . ($a_index+1) . "]")) &&
218  count($crossref) > 0)
219  {
220  for ($i = 0; $i < count($crossref); $i++)
221  {
222  $this->tpl->setCurrentBlock("crossref_loop");
223  $this->tpl->setVariable("CROSSREF_LOOP_TXT_CROSSREF", $this->lng->txt("bibitem_cross_reference"));
224  $this->tpl->setVariable("CROSSREF_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
225  $this->tpl->setVariable("CROSSREF_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=CrossRef");
226  $this->tpl->setVariable("CROSSREF_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
227  $this->tpl->setVariable("CROSSREF_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=CrossRef&bibItemPath=BibItem&bibItemIndex=" . $a_index);
228  $this->tpl->setVariable("CROSSREF_LOOP_NO", $i);
229  $this->tpl->setVariable("CROSSREF_LOOP_VAL", ilUtil::prepareFormOutput($crossref[$i]["value"]));
230  $this->tpl->parseCurrentBlock("crossref_loop");
231  }
232  }
233 
234  $edition = $this->bib_obj->getElement("Edition", "BibItem[" . ($a_index+1) . "]");
235  $this->tpl->setVariable("TXT_EDITION", $this->lng->txt("bibitem_edition"));
236  $this->tpl->setVariable("VAL_EDITION", ilUtil::prepareFormOutput($edition[0]["value"]));
237 
238  /* Editor Loop */
239  if (is_array($editor = $this->bib_obj->getElement("Editor", "BibItem[" . ($a_index+1) . "]")) &&
240  count($editor) > 0)
241  {
242  for ($i = 0; $i < count($editor); $i++)
243  {
244  $this->tpl->setCurrentBlock("editor_loop");
245  $this->tpl->setVariable("EDITOR_LOOP_TXT_EDITOR", $this->lng->txt("bibitem_editor"));
246  $this->tpl->setVariable("EDITOR_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
247  $this->tpl->setVariable("EDITOR_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=Editor");
248  $this->tpl->setVariable("EDITOR_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
249  $this->tpl->setVariable("EDITOR_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=Editor&bibItemPath=BibItem&bibItemIndex=" . $a_index);
250  $this->tpl->setVariable("EDITOR_LOOP_NO", $i);
251  $this->tpl->setVariable("EDITOR_LOOP_VAL", ilUtil::prepareFormOutput($editor[$i]["value"]));
252  $this->tpl->parseCurrentBlock("editor_loop");
253  }
254  }
255 
256  $howPublished = $this->bib_obj->getElement("HowPublished", "BibItem[" . ($a_index+1) . "]");
257  $this->tpl->setVariable("TXT_HOWPUBLISHED", $this->lng->txt("bibitem_how_published"));
258  $this->tpl->setVariable("TXT_GREYLITERATURE", $this->lng->txt("bibitem_grey_literature"));
259  $this->tpl->setVariable("TXT_PRINT", $this->lng->txt("bibitem_print"));
260  $this->tpl->setVariable("HOWPUBLISHED_TYPE_VAL_" . strtoupper(ilUtil::prepareFormOutput($howPublished[0]["Type"])), " selected");
261 
262  /* WherePublished Loop */
263  if (is_array($wherepublished = $this->bib_obj->getElement("WherePublished", "BibItem[" . ($a_index+1) . "]")) &&
264  count($wherepublished) > 0)
265  {
266  for ($i = 0; $i < count($wherepublished); $i++)
267  {
268  $this->tpl->setCurrentBlock("wherepublished_loop");
269  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_TXT_WHEREPUBLISHED", $this->lng->txt("bibitem_where_published"));
270  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
271  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=WherePublished");
272  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
273  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=WherePublished&bibItemPath=BibItem&bibItemIndex=" . $a_index);
274  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_NO", $i);
275  $this->tpl->setVariable("WHEREPUBLISHED_LOOP_VAL", ilUtil::prepareFormOutput($wherepublished[$i]["value"]));
276  $this->tpl->parseCurrentBlock("wherepublished_loop");
277  }
278  }
279 
280  /* Institution Loop */
281  if (is_array($institution = $this->bib_obj->getElement("Institution", "BibItem[" . ($a_index+1) . "]")) &&
282  count($institution) > 0)
283  {
284  for ($i = 0; $i < count($institution); $i++)
285  {
286  $this->tpl->setCurrentBlock("institution_loop");
287  $this->tpl->setVariable("INSTITUTION_LOOP_TXT_INSTITUTION", $this->lng->txt("bibitem_institution"));
288  $this->tpl->setVariable("INSTITUTION_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
289  $this->tpl->setVariable("INSTITUTION_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=Institution");
290  $this->tpl->setVariable("INSTITUTION_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
291  $this->tpl->setVariable("INSTITUTION_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=Institution&bibItemPath=BibItem&bibItemIndex=" . $a_index);
292  $this->tpl->setVariable("INSTITUTION_LOOP_NO", $i);
293  $this->tpl->setVariable("INSTITUTION_LOOP_VAL", ilUtil::prepareFormOutput($institution[$i]["value"]));
294  $this->tpl->parseCurrentBlock("institution_loop");
295  }
296  }
297 
298  /* Journal */
299  if (is_array($journal = $this->bib_obj->getElement("Journal", "BibItem[" . ($a_index+1) . "]")) &&
300  count($journal) > 0)
301  {
302  $this->tpl->setCurrentBlock("journal");
303  $this->tpl->setVariable("JOURNAL_TXT_JOURNAL", $this->lng->txt("bibitem_journal"));
304  $this->tpl->setVariable("JOURNAL_TXT_DELETE", $this->lng->txt("bibitem_delete"));
305  $this->tpl->setVariable("JOURNAL_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "&bibItemPath=BibItem&bibItemName=Journal");
306  $this->tpl->setVariable("VAL_JOURNAL", ilUtil::prepareFormOutput($journal[0]["value"]));
307  $this->tpl->setVariable("VAL_JOURNAL_NOTE", ilUtil::prepareFormOutput($journal[0]["Note"]));
308  $this->tpl->setVariable("VAL_JOURNAL_NUMBER", ilUtil::prepareFormOutput($journal[0]["Number"]));
309  $this->tpl->setVariable("VAL_JOURNAL_ORGANIZATION", ilUtil::prepareFormOutput($journal[0]["Organization"]));
310  $this->tpl->parseCurrentBlock("journal");
311 
312  }
313  else
314  {
315  $this->tpl->setVariable("TXT_JOURNAL", $this->lng->txt("bibitem_journal"));
316  }
317 
318  /* Keyword Loop */
319  if (is_array($keyword = $this->bib_obj->getElement("Keyword", "BibItem[" . ($a_index+1) . "]")) &&
320  count($keyword) > 0)
321  {
322  for ($i = 0; $i < count($keyword); $i++)
323  {
324  $this->tpl->setCurrentBlock("keyword_loop");
325  $this->tpl->setVariable("KEYWORD_LOOP_TXT_KEYWORD", $this->lng->txt("bibitem_keyword"));
326  $this->tpl->setVariable("KEYWORD_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
327  $this->tpl->setVariable("KEYWORD_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=Keyword");
328  $this->tpl->setVariable("KEYWORD_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
329  $this->tpl->setVariable("KEYWORD_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=Keyword&bibItemPath=BibItem&bibItemIndex=" . $a_index);
330  $this->tpl->setVariable("KEYWORD_LOOP_NO", $i);
331  $this->tpl->setVariable("KEYWORD_LOOP_VAL", ilUtil::prepareFormOutput($keyword[$i]["value"]));
332  $this->tpl->setVariable("KEYWORD_LOOP_TXT_LANGUAGE", $this->lng->txt("bibitem_language"));
333  $this->tpl->setVariable("KEYWORD_LOOP_VAL_LANGUAGE", $this->showLangSel("meta[Language][" . $i . "][Language]", $keyword[$i]["Language"]));
334  $this->tpl->parseCurrentBlock("keyword_loop");
335  }
336  }
337 
338  /* Month */
339  if (is_array($month = $this->bib_obj->getElement("Month", "BibItem[" . ($a_index+1) . "]")) &&
340  count($month) > 0)
341  {
342  $this->tpl->setCurrentBlock("month");
343  $this->tpl->setVariable("MONTH_TXT_MONTH", $this->lng->txt("bibitem_month"));
344  $this->tpl->setVariable("MONTH_TXT_DELETE", $this->lng->txt("bibitem_delete"));
345  $this->tpl->setVariable("MONTH_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "&bibItemPath=BibItem&bibItemName=Month");
346  $this->tpl->setVariable("VAL_MONTH", ilUtil::prepareFormOutput($month[0]["value"]));
347  $this->tpl->parseCurrentBlock("journal");
348  }
349  else
350  {
351  $this->tpl->setVariable("TXT_MONTH", $this->lng->txt("bibitem_month"));
352  }
353 
354  /* Pages */
355  if (is_array($pages = $this->bib_obj->getElement("Pages", "BibItem[" . ($a_index+1) . "]")) &&
356  count($pages) > 0)
357  {
358  $this->tpl->setCurrentBlock("pages");
359  $this->tpl->setVariable("PAGES_TXT_PAGES", $this->lng->txt("bibitem_pages"));
360  $this->tpl->setVariable("PAGES_TXT_DELETE", $this->lng->txt("bibitem_delete"));
361  $this->tpl->setVariable("PAGES_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "&bibItemPath=BibItem&bibItemName=Pages");
362  $this->tpl->setVariable("VAL_PAGES", ilUtil::prepareFormOutput($pages[0]["value"]));
363  $this->tpl->parseCurrentBlock("pages");
364  }
365  else
366  {
367  $this->tpl->setVariable("TXT_PAGES", $this->lng->txt("bibitem_pages"));
368  }
369 
370  $publisher = $this->bib_obj->getElement("Publisher", "BibItem[" . ($a_index+1) . "]");
371  $this->tpl->setVariable("TXT_PUBLISHER", $this->lng->txt("bibitem_publisher"));
372  $this->tpl->setVariable("VAL_PUBLISHER", ilUtil::prepareFormOutput($publisher[0]["value"]));
373 
374  /* School Loop */
375  if (is_array($school = $this->bib_obj->getElement("School", "BibItem[" . ($a_index+1) . "]")) &&
376  count($school) > 0)
377  {
378  for ($i = 0; $i < count($school); $i++)
379  {
380  $this->tpl->setCurrentBlock("school_loop");
381  $this->tpl->setVariable("SCHOOL_LOOP_TXT_SCHOOL", $this->lng->txt("bibitem_school"));
382  $this->tpl->setVariable("SCHOOL_LOOP_TXT_DELETE", $this->lng->txt("bibitem_delete"));
383  $this->tpl->setVariable("SCHOOL_LOOP_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&bibItemIndex=" . $a_index . "," . $i . "&bibItemPath=BibItem&bibItemName=School");
384  $this->tpl->setVariable("SCHOOL_LOOP_TXT_ADD", $this->lng->txt("bibitem_add"));
385  $this->tpl->setVariable("SCHOOL_LOOP_ACTION_ADD", $a_formaction . "&cmd=addBibItem&bibItemName=School&bibItemPath=BibItem&bibItemIndex=" . $a_index);
386  $this->tpl->setVariable("SCHOOL_LOOP_NO", $i);
387  $this->tpl->setVariable("SCHOOL_LOOP_VAL", ilUtil::prepareFormOutput($school[$i]["value"]));
388  $this->tpl->parseCurrentBlock("school_loop");
389  }
390  }
391 
392  /* Series */
393  if (is_array($series = $this->bib_obj->getElement("Series", "BibItem[" . ($a_index+1) . "]")) &&
394  count($series) > 0)
395  {
396  $this->tpl->setCurrentBlock("series");
397  $this->tpl->setVariable("SERIES_TXT_SERIES", $this->lng->txt("bibitem_series"));
398  $this->tpl->setVariable("SERIES_TXT_DELETE", $this->lng->txt("bibitem_delete"));
399  $this->tpl->setVariable("SERIES_ACTION_DELETE", $a_formaction . "&cmd=deleteBibItem&&bibItemPath=BibItem[" . ($a_index+1) ."]&bibItemName=Series");
400  $this->tpl->setVariable("SERIES_TXT_SERIESTITLE", $this->lng->txt("bibitem_series_title"));
401  if (is_array($title = $this->bib_obj->getElement("SeriesTitle", "BibItem[" . ($a_index+1) . "]/Series")))
402  {
403  $this->tpl->setVariable("SERIES_VAL_SERIESTITLE", ilUtil::prepareFormOutput($title[0]["value"]));
404  }
405  $this->tpl->setVariable("SERIES_TXT_SERIESEDITOR", $this->lng->txt("bibitem_series_editor"));
406  if (is_array($editor = $this->bib_obj->getElement("SeriesEditor", "BibItem[" . ($a_index+1) . "]/Series")))
407  {
408  $this->tpl->setVariable("SERIES_VAL_SERIESEDITOR", ilUtil::prepareFormOutput($editor[0]["value"]));
409  }
410  $this->tpl->setVariable("SERIES_TXT_SERIESVOLUME", $this->lng->txt("bibitem_series_volume"));
411  if (is_array($volume = $this->bib_obj->getElement("SeriesVolume", "BibItem[" . ($a_index+1) . "]/Series")))
412  {
413  $this->tpl->setVariable("SERIES_VAL_SERIESVOLUME", ilUtil::prepareFormOutput($volume[0]["value"]));
414  }
415  $this->tpl->parseCurrentBlock("series");
416  }
417  else
418  {
419  $this->tpl->setVariable("TXT_SERIES", $this->lng->txt("bibitem_series"));
420  }
421 
422  $year = $this->bib_obj->getElement("Year", "BibItem[" . ($a_index+1) . "]");
423  $this->tpl->setVariable("TXT_YEAR", $this->lng->txt("bibitem_year"));
424  $this->tpl->setVariable("VAL_YEAR", ilUtil::prepareFormOutput($year[0]["value"]));
425 
426  /* URL || ISBN || ISSN */
427  if (is_array($url = $this->bib_obj->getElement("URL", "BibItem[" . ($a_index+1) . "]")) &&
428  count($url) > 0)
429  {
430  $url_isbn_issn["type"] = "URL";
431  $url_isbn_issn["value"] = $url[0]["value"];
432  }
433  else if (is_array($isbn = $this->bib_obj->getElement("ISBN", "BibItem[" . ($a_index+1) . "]")) &&
434  count($isbn) > 0)
435  {
436  $url_isbn_issn["type"] = "ISBN";
437  $url_isbn_issn["value"] = $isbn[0]["value"];
438  }
439  else if (is_array($issn = $this->bib_obj->getElement("ISSN", "BibItem[" . ($a_index+1) . "]")) &&
440  count($issn) > 0)
441  {
442  $url_isbn_issn["type"] = "ISSN";
443  $url_isbn_issn["value"] = $issn[0]["value"];
444  }
445  $this->tpl->setVariable($url_isbn_issn["type"], " selected");
446  $this->tpl->setVariable("VAL_URL_ISBN_ISSN", ilUtil::prepareFormOutput($url_isbn_issn["value"]));
447 
448  $this->tpl->setVariable("EDIT_ACTION", $a_formaction . "&cmd=post");
449  $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
450  $this->tpl->setVariable("VAL_INDEX", $a_index);
451  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("bibitem_save"));
452 
453  return true;
454  }
455 
456  function edit($a_temp_var, $a_temp_block, $a_formaction, $a_index = 0, $a_language = "")
457  {
458  if ($a_language == "")
459  {
460  $a_language = $this->ilias->account->getLanguage();
461  }
462  $this->tpl->addBlockFile($a_temp_var, $a_temp_block, "tpl.bib_data_editor.html", "Modules/LearningModule");
463 
464 #echo "Pr�fen, ob BibItems vorhanden sind:<br>\n";
465  if (!is_array($data = $this->bib_obj->getElement("BibItem")))
466  {
467 #echo "Nein!<br>\n";
468  $this->tpl->setCurrentBlock("not_found");
469  $this->tpl->setVariable("NOT_FOUND_ACTION", $a_formaction . "&cmd=addBibItem&bibItemName=BibItem");
470  $this->tpl->setVariable("NOT_FOUND_TXT" , $this->lng->txt("bibitem_not_found"));
471  $this->tpl->setVariable("NOT_FOUND_TXT_ADD" , $this->lng->txt("bibitem_add"));
472  $this->tpl->parseCurrentBlock();
473  }
474  else
475  {
476 #echo "OK!<br>\n";
477 #vd($data);
478  for ($i = 0; $i < count($data); $i++)
479  {
480  $edition = $this->bib_obj->getElement("Edition", "BibItem", $i);
481  $year = $this->bib_obj->getElement("Year", "BibItem", $i);
482  $this->tpl->setCurrentBlock("index_loop");
483  $this->tpl->setVariable("INDEX_LOOP_VALUE", $i);
484  if ($a_index == $i)
485  {
486  $this->tpl->setVariable("INDEX_LOOP_SELECTED", " selected");
487  }
488  $this->tpl->setVariable("INDEX_LOOP_TEXT", $edition[0]["value"] . ", " . $year[0]["value"]);
489  $this->tpl->parseCurrentBlock("index_loop");
490  }
491  $this->tpl->setCurrentBlock("found");
492  $this->tpl->setVariable("FOUND_ACTION", $a_formaction . "&cmd=editBibItem");
493  $this->tpl->setVariable("FOUND_TXT" , $this->lng->txt("bibitem_choose_index"));
494 #echo "Einlesen des BibItems:<br>\n";
495  $this->fill($a_formaction, $a_index, $a_language);
496  $this->tpl->parseCurrentBlock();
497  }
498  }
499 
500  function save($a_index)
501  {
502  $p = "//Bibliography";
503  $this->bib_obj->nested_obj->updateDomNode($p, $_POST["meta"], $a_index);
504  $this->bib_obj->nested_obj->updateFromDom();
505  $data = $this->bib_obj->getElement("BibItem");
506  return (count($data) - 1);
507  }
508 
509 
517  function getTargetFrame($a_cmd, $a_target_frame = "")
518  {
519  if ($this->target_frame[$a_cmd] != "")
520  {
521  return $this->target_frame[$a_cmd];
522  }
523  elseif (!empty($a_target_frame))
524  {
525  return $a_target_frame;
526  }
527  else
528  {
529  return;
530  }
531  }
532 
540  function setTargetFrame($a_cmd, $a_target_frame)
541  {
542  $this->target_frame[$a_cmd] = $a_target_frame;
543  }
544 }
545 ?>