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