ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMDEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 include_once 'Services/MetaData/classes/class.ilMD.php';
13 include_once 'Services/MetaData/classes/class.ilMDUtilSelect.php';
14 
15 define('IL_TLT_MAX_HOURS',99);
16 
17 
19 {
20  var $ctrl = null;
21  var $lng = null;
22  var $tpl = null;
23  var $md_obj = null;
24 
25  var $observers = array();
26 
27  var $rbac_id = null;
28  var $obj_id = null;
29  var $obj_type = null;
30 
31  function ilMDEditorGUI($a_rbac_id,$a_obj_id,$a_obj_type)
32  {
33  global $ilCtrl,$lng,$tpl,$ilTabs;
34 
35  $this->md_obj =& new ilMD($a_rbac_id,$a_obj_id,$a_obj_type);
36  $this->ctrl =& $ilCtrl;
37 
38  $this->lng =& $lng;
39  $this->lng->loadLanguageModule('meta');
40 
41  include_once('Services/MetaData/classes/class.ilMDSettings.php');
42  $this->md_settings = ilMDSettings::_getInstance();
43 
44  $this->tpl =& $tpl;
45 
46  $this->tabs_gui =& $ilTabs;
47 
48  }
49 
50  function &executeCommand()
51  {
52  global $rbacsystem;
53 
54  $next_class = $this->ctrl->getNextClass($this);
55 
56  $cmd = $this->ctrl->getCmd();
57  switch($next_class)
58  {
59  default:
60  if(!$cmd)
61  {
62  $cmd = "listSection";
63  }
64  $this->$cmd();
65  break;
66  }
67  return true;
68  }
69 
70 
71  function debug()
72  {
73  include_once 'Services/MetaData/classes/class.ilMD2XML.php';
74 
75 
76  $xml_writer =& new ilMD2XML($this->md_obj->getRBACId(),$this->md_obj->getObjId(),$this->md_obj->getObjType());
77  $xml_writer->startExport();
78 
79  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
80 
81  $this->__setTabs('meta_general');
82 
83  $this->tpl->setVariable("MD_CONTENT",htmlentities($xml_writer->getXML()));
84 
85  return true;
86  }
87 
88  /*
89  * list quick edit screen
90  */
92  {
93  global $lng;
94  if(!is_object($this->md_section = $this->md_obj->getGeneral()))
95  {
96  $this->md_section = $this->md_obj->addGeneral();
97  $this->md_section->save();
98  }
99 
100  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
101 
102  $this->__setTabs('meta_quickedit');
103 
104  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_quick_edit_scorm.html','Services/MetaData');
105 
106  $this->ctrl->setReturn($this,'listGeneral');
107  $this->ctrl->setParameter($this,'section','meta_general');
108  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
109 
110  $this->tpl->setVariable("TXT_QUICK_EDIT", $this->lng->txt("meta_quickedit"));
111  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("meta_language"));
112  $this->tpl->setVariable("TXT_KEYWORD", $this->lng->txt("meta_keyword"));
113  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("meta_description"));
114  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
115 
116  // Language
117  $first = true;
118  foreach($ids = $this->md_section->getLanguageIds() as $id)
119  {
120  $md_lan = $this->md_section->getLanguage($id);
121 
122  if ($first)
123  {
124  $this->tpl->setCurrentBlock("language_head");
125  $this->tpl->setVariable("ROWSPAN_LANG", count($ids));
126  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
127  $this->tpl->parseCurrentBlock();
128  $first = false;
129  }
130 
131  if (count($ids) > 1)
132  {
133  $this->ctrl->setParameter($this,'meta_index',$id);
134  $this->ctrl->setParameter($this,'meta_path','meta_language');
135 
136  $this->tpl->setCurrentBlock("language_delete");
137  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
138  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
139  $this->tpl->parseCurrentBlock();
140  }
141  $this->tpl->setCurrentBlock("language_loop");
142  $this->tpl->setVariable("LANGUAGE_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect('gen_language['.$id.'][language]',
143  $md_lan->getLanguageCode()));
144  $this->tpl->parseCurrentBlock();
145  }
146 
147  if ($first)
148  {
149  $this->tpl->setCurrentBlock("language_head");
150  $this->tpl->setVariable("ROWSPAN_LANG", 1);
151  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
152  $this->tpl->parseCurrentBlock();
153  $this->tpl->setCurrentBlock("language_loop");
154  $this->tpl->setVariable("LANGUAGE_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect('gen_language[][language]',
155  ""));
156  $this->tpl->parseCurrentBlock();
157  }
158 
159  // TITLE
160  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
161  $this->tpl->setVariable("VAL_TITLE",ilUtil::prepareFormOutput($this->md_section->getTitle()));
162  $this->tpl->setVariable("VAL_TITLE_LANGUAGE",$this->__showLanguageSelect('gen_title_language',
163  $this->md_section->getTitleLanguageCode()));
164 
165  // DESCRIPTION
166  foreach($ids = $this->md_section->getDescriptionIds() as $id)
167  {
168  $md_des = $this->md_section->getDescription($id);
169 
170  if (count($ids) > 1)
171  {
172  $this->ctrl->setParameter($this,'meta_index',$id);
173  $this->ctrl->setParameter($this,'meta_path','meta_description');
174 
175  $this->tpl->setCurrentBlock("description_delete");
176  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
177  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
178  $this->tpl->parseCurrentBlock();
179  }
180 
181  $this->tpl->setCurrentBlock("description_loop");
182  $this->tpl->setVariable("DESCRIPTION_LOOP_NO",$id);
183  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DESCRIPTION", $this->lng->txt("meta_description"));
184  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
185  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL",ilUtil::prepareFormOutput($md_des->getDescription()));
186  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
187  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect("gen_description[".$id.'][language]',
188  $md_des->getDescriptionLanguageCode()));
189  $this->tpl->parseCurrentBlock();
190  }
191 
192  // KEYWORD
193  $first = true;
194  $keywords = array();
195  foreach($ids = $this->md_section->getKeywordIds() as $id)
196  {
197  $md_key = $this->md_section->getKeyword($id);
198  $keywords[$md_key->getKeywordLanguageCode()][]
199  = $md_key->getKeyword();
200  }
201 
202  foreach($keywords as $lang => $keyword_set)
203  {
204  if ($first)
205  {
206  $this->tpl->setCurrentBlock("keyword_head");
207  $this->tpl->setVariable("ROWSPAN_KEYWORD", count($keywords));
208  $this->tpl->setVariable("TXT_COMMA_SEP2",$this->lng->txt('comma_separated'));
209  $this->tpl->setVariable("KEYWORD_LOOP_TXT_KEYWORD", $this->lng->txt("keywords"));
210  $this->tpl->parseCurrentBlock();
211  $first = false;
212  }
213 
214  $this->tpl->setCurrentBlock("keyword_loop");
215  $this->tpl->setVariable("KEYWORD_LOOP_VAL", ilUtil::prepareFormOutput(
216  implode($keyword_set, ", ")));
217  $this->tpl->setVariable("LANG", $lang);
218  $this->tpl->setVariable("KEYWORD_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect("keyword[language][$lang]",
219  $lang));
220  $this->tpl->parseCurrentBlock();
221  }
222 
223  if (count($keywords) == 0)
224  {
225  $this->tpl->setCurrentBlock("keyword_head");
226  $this->tpl->setVariable("ROWSPAN_KEYWORD", 1);
227  $this->tpl->setVariable("TXT_COMMA_SEP2",$this->lng->txt('comma_separated'));
228  $this->tpl->setVariable("KEYWORD_LOOP_TXT_KEYWORD", $this->lng->txt("keywords"));
229  $this->tpl->parseCurrentBlock();
230  $this->tpl->setCurrentBlock("keyword_loop");
231  $this->tpl->setVariable("KEYWORD_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect("keyword[language][$lang]",
232  $lang));
233  }
234 
235  // Lifecycle...
236  // experts
237  $this->tpl->setVariable("TXT_EXPERTS",$lng->txt('meta_subjectmatterexpert'));
238  $this->tpl->setVariable("TXT_COMMA_SEP",$this->lng->txt('comma_separated'));
239  $this->tpl->setVariable("TXT_SCOPROP_EXPERT",$this->lng->txt('sco_propagate'));
240  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
241  {
242  $sep = $ent_str = "";
243  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
244  {
245  $md_con = $this->md_section->getContribute($con_id);
246  if ($md_con->getRole() == "SubjectMatterExpert")
247  {
248  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
249  {
250  $md_ent = $md_con->getEntity($ent_id);
251  $ent_str = $ent_str.$sep.$md_ent->getEntity();
252  $sep = ", ";
253  }
254  }
255  }
256  $this->tpl->setVariable("EXPERTS_VAL", ilUtil::prepareFormOutput($ent_str));
257  }
258  // InstructionalDesigner
259  $this->tpl->setVariable("TXT_DESIGNERS",$lng->txt('meta_instructionaldesigner'));
260  $this->tpl->setVariable("TXT_SCOPROP_DESIGNERS",$this->lng->txt('sco_propagate'));
261  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
262  {
263  $sep = $ent_str = "";
264  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
265  {
266  $md_con = $this->md_section->getContribute($con_id);
267  if ($md_con->getRole() == "InstructionalDesigner")
268  {
269  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
270  {
271  $md_ent = $md_con->getEntity($ent_id);
272  $ent_str = $ent_str.$sep.$md_ent->getEntity();
273  $sep = ", ";
274  }
275  }
276  }
277  $this->tpl->setVariable("DESIGNERS_VAL", ilUtil::prepareFormOutput($ent_str));
278  }
279  // Point of Contact
280  $this->tpl->setVariable("TXT_POC",$lng->txt('meta_pointofcontact'));
281  $this->tpl->setVariable("TXT_SCOPROP_POC",$this->lng->txt('sco_propagate'));
282  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
283  {
284  $sep = $ent_str = "";
285  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
286  {
287  $md_con = $this->md_section->getContribute($con_id);
288  if ($md_con->getRole() == "PointOfContact")
289  {
290  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
291  {
292  $md_ent = $md_con->getEntity($ent_id);
293  $ent_str = $ent_str.$sep.$md_ent->getEntity();
294  $sep = ", ";
295  }
296  }
297  }
298  $this->tpl->setVariable("POC_VAL", ilUtil::prepareFormOutput($ent_str));
299  }
300 
301  $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('meta_status'));
302  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
303  {
304  $this->md_section = $this->md_obj->addLifecycle();
305  $this->md_section->save();
306  }
307  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
308  {
309  $this->tpl->setVariable("SEL_STATUS",ilMDUtilSelect::_getStatusSelect($this->md_section->getStatus(),
310  "lif_status",
311  array(0 => $this->lng->txt('meta_please_select'))));
312  }
313 
314  // Rights...
315  // Copyright
316 
317  include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionGUI.php');
318 
320  $this->md_obj->getRBACId(),
321  $this->md_obj->getObjId());
322  $copyright_gui->fillTemplate();
323 
324 
325  /*
326  if(is_object($this->md_section = $this->md_obj->getRights()))
327  {
328  $this->tpl->setVariable("COPYRIGHT_VAL", ilUtil::prepareFormOutput($this->md_section->getDescription()));
329  }
330  $this->tpl->setVariable("TXT_COPYRIGHT",$this->lng->txt('meta_copyright'));
331  */
332 
333  // Educational...
334  // Typical learning time
335  // creates entries like 2H59M12S. If entry is not parsable => warning.
336 
337  #if(is_object($this->md_section = $this->md_obj->getEducational()))
338  #{
339  # $this->tpl->setVariable("VAL_TYPICAL_LEARN_TIME", ilUtil::prepareFormOutput($this->md_section->getTypicalLearningTime()));
340  #}
341 
342  $tlt = array(0,0,0,0,0);
343  $valid = true;
344  if(is_object($this->md_section = $this->md_obj->getEducational()))
345  {
346  include_once 'Services/MetaData/classes/class.ilMDUtils.php';
347 
348  if(!$tlt = ilMDUtils::_LOMDurationToArray($this->md_section->getTypicalLearningTime()))
349  {
350  if(strlen($this->md_section->getTypicalLearningTime()))
351  {
352  $tlt = array(0,0,0,0,0);
353  $valid = false;
354  }
355  }
356  }
357  $this->tpl->setVariable("TXT_MONTH",$this->lng->txt('md_months'));
358  $this->tpl->setVariable("SEL_MONTHS",$this->__buildMonthsSelect($tlt[0]));
359  $this->tpl->setVariable("SEL_DAYS",$this->__buildDaysSelect($tlt[1]));
360 
361  $this->tpl->setVariable("TXT_DAYS",$this->lng->txt('md_days'));
362  $this->tpl->setVariable("TXT_TIME",$this->lng->txt('md_time'));
363 
364  $this->tpl->setVariable("TXT_TYPICAL_LEARN_TIME",$this->lng->txt('meta_typical_learning_time'));
365  $this->tpl->setVariable("SEL_TLT",ilUtil::makeTimeSelect('tlt',$tlt[4] ? false : true,
366  $tlt[2],$tlt[3],$tlt[4],
367  false));
368  $this->tpl->setVariable("TLT_HINT",$tlt[4] ? '(hh:mm:ss)' : '(hh:mm)');
369 
370  if(!$valid)
371  {
372  $this->tpl->setCurrentBlock("tlt_not_valid");
373  $this->tpl->setVariable("TXT_CURRENT_VAL",$this->lng->txt('meta_current_value'));
374  $this->tpl->setVariable("TLT",$this->md_section->getTypicalLearningTime());
375  $this->tpl->setVariable("INFO_TLT_NOT_VALID",$this->lng->txt('meta_info_tlt_not_valid'));
376  $this->tpl->parseCurrentBlock();
377  }
378 
379 
380  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
381  }
382 
383  function listQuickEdit()
384  {
385  global $tpl;
386 
387  if(!is_object($this->md_section = $this->md_obj->getGeneral()))
388  {
389  $this->md_section = $this->md_obj->addGeneral();
390  $this->md_section->save();
391  }
392 
393  $this->__setTabs('meta_quickedit');
394  $form = $this->initQuickEditForm();
395  $tpl->setContent($form->getHTML());
396  }
397 
401  public function initQuickEditForm()
402  {
403  global $lng, $ilCtrl;
404 
405  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
406  $this->form = new ilPropertyFormGUI();
407 
408  // title
409  $ti = new ilTextInputGUI($this->lng->txt("title"), "gen_title");
410  $ti->setMaxLength(200);
411  $ti->setSize(50);
412  $ti->setRequired(true);
413  $ti->setValue($this->md_section->getTitle());
414  $this->form->addItem($ti);
415 
416  // description(s)
417  foreach($ids = $this->md_section->getDescriptionIds() as $id)
418  {
419  $md_des = $this->md_section->getDescription($id);
420 
421  $ta = new ilTextAreaInputGUI($this->lng->txt("meta_description"), "gen_description[".$id."][description]");
422  $ta->setCols(50);
423  $ta->setRows(4);
424  $ta->setValue($md_des->getDescription());
425  if (count($ids) > 1)
426  {
427  $ta->setInfo($this->lng->txt("meta_l_".$md_des->getDescriptionLanguageCode()));
428  }
429 
430  $this->form->addItem($ta);
431  }
432 
433  // language(s)
434  $first = "";
435  $options = ilMDLanguageItem::_getLanguages();
436  foreach($ids = $this->md_section->getLanguageIds() as $id)
437  {
438  $md_lan = $this->md_section->getLanguage($id);
439  $first_lang = $md_lan->getLanguageCode();
440  $si = new ilSelectInputGUI($this->lng->txt("meta_language"), "gen_language[".$id."][language]");
441  $si->setOptions($options);
442  $si->setValue($md_lan->getLanguageCode());
443  $this->form->addItem($si);
444  $first = false;
445  }
446  if ($first)
447  {
448  $si = new ilSelectInputGUI($this->lng->txt("meta_language"), "gen_language[][language]");
449  $si->setOptions($options);
450  $this->form->addItem($si);
451  }
452 
453  // keyword(s)
454  $first = true;
455  $keywords = array();
456  foreach($ids = $this->md_section->getKeywordIds() as $id)
457  {
458  $md_key = $this->md_section->getKeyword($id);
459  if (trim($md_key->getKeyword()) != "")
460  {
461  $keywords[$md_key->getKeywordLanguageCode()][]
462  = $md_key->getKeyword();
463  }
464  }
465  foreach($keywords as $lang => $keyword_set)
466  {
467  $kw = new ilTextInputGUI($this->lng->txt("keywords"),
468  "keywords[value][".$lang."]");
469  $kw->setDataSource($this->ctrl->getLinkTarget($this, "keywordAutocomplete", "", true));
470  $kw->setMaxLength(200);
471  $kw->setSize(50);
472  $kw->setMulti(true);
473  if (count($keywords) > 1)
474  {
475  $kw->setInfo($this->lng->txt("meta_l_".$lang));
476  }
477  $this->form->addItem($kw);
478  asort($keyword_set);
479  $kw->setValue($keyword_set);
480  }
481  if (count($keywords) == 0)
482  {
483  $kw = new ilTextInputGUI($this->lng->txt("keywords"),
484  "keywords[value][".$first_lang."]");
485  $kw->setDataSource($this->ctrl->getLinkTarget($this, "keywordAutocomplete", "", true));
486  $kw->setMaxLength(200);
487  $kw->setSize(50);
488  $kw->setMulti(true);
489  $this->form->addItem($kw);
490  }
491 
492  // Lifecycle...
493  // Authors
494  $ta = new ilTextAreaInputGUI($this->lng->txt('authors')."<br />".
495  "(".sprintf($this->lng->txt('md_separated_by'), $this->md_settings->getDelimiter()).")",
496  "life_authors");
497  $ta->setCols(50);
498  $ta->setRows(2);
499  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
500  {
501  $sep = $ent_str = "";
502  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
503  {
504  $md_con = $this->md_section->getContribute($con_id);
505  if ($md_con->getRole() == "Author")
506  {
507  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
508  {
509  $md_ent = $md_con->getEntity($ent_id);
510  $ent_str = $ent_str.$sep.$md_ent->getEntity();
511  $sep = $this->md_settings->getDelimiter()." ";
512  }
513  }
514  }
515  $ta->setValue($ent_str);
516  }
517  $this->form->addItem($ta);
518 
519  // copyright
520  include_once("./Services/MetaData/classes/class.ilCopyrightInputGUI.php");
521  $cp = new ilCopyrightInputGUI($this->lng->txt("meta_copyright"), "copyright");
522  $cp->setCols(50);
523  $cp->setRows(3);
524  $desc = ilMDRights::_lookupDescription($this->md_obj->getRBACId(),
525  $this->md_obj->getObjId());
526  $val["ta"] = $desc;
527  $cp->setValue($val);
528  $this->form->addItem($cp);
529 
530  // typical learning time
531  include_once("./Services/MetaData/classes/class.ilTypicalLearningTimeInputGUI.php");
532  $tlt = new ilTypicalLearningTimeInputGUI($this->lng->txt("meta_typical_learning_time"), "tlt");
533  $edu = $this->md_obj->getEducational();
534  if (is_object($edu))
535  {
536  $tlt->setValueByLOMDuration($edu->getTypicalLearningTime());
537  }
538  $this->form->addItem($tlt);
539 
540  $this->form->addCommandButton("updateQuickEdit", $lng->txt("save"));
541  $this->form->setTitle($this->lng->txt("meta_quickedit"));
542  $this->form->setFormAction($ilCtrl->getFormAction($this));
543 
544  return $this->form;
545  }
546 
554  {
555 
556  include_once("./Services/MetaData/classes/class.ilMDKeyword.php");
558  $this->md_obj->getObjType(), $this->md_obj->getRBACId());
559 
560  $result = array();
561  $cnt = 0;
562  foreach ($res as $r)
563  {
564  if ($cnt++ > 19)
565  {
566  continue;
567  }
568  $entry = new stdClass();
569  $entry->value = $r;
570  $entry->label = $r;
571  $result[] = $entry;
572  }
573 
574  include_once './Services/JSON/classes/class.ilJsonUtil.php';
575  echo ilJsonUtil::encode($result);
576  exit;
577  }
578 
579 
583  function updateQuickEdit()
584  {
585  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
586 
587  if(!trim($_POST['gen_title']))
588  {
589  ilUtil::sendFailure($this->lng->txt('title_required'));
590  $this->listQuickEdit();
591  return false;
592  }
593 
594  // General values
595  $this->md_section = $this->md_obj->getGeneral();
596  $this->md_section->setTitle(ilUtil::stripSlashes($_POST['gen_title']));
597 // $this->md_section->setTitleLanguage(new ilMDLanguageItem($_POST['gen_title_language']));
598  $this->md_section->update();
599 
600  // Language
601  if(is_array($_POST['gen_language']))
602  {
603  foreach($_POST['gen_language'] as $id => $data)
604  {
605  if ($id > 0)
606  {
607  $md_lan = $this->md_section->getLanguage($id);
608  $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
609  $md_lan->update();
610  }
611  else
612  {
613  $md_lan = $this->md_section->addLanguage();
614  $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
615  $md_lan->save();
616  }
617  }
618  }
619  // Description
620  if(is_array($_POST['gen_description']))
621  {
622  foreach($_POST['gen_description'] as $id => $data)
623  {
624  $md_des = $this->md_section->getDescription($id);
625  $md_des->setDescription(ilUtil::stripSlashes($data['description']));
626 // $md_des->setDescriptionLanguage(new ilMDLanguageItem($data['language']));
627  $md_des->update();
628  }
629  }
630 
631  // Keyword
632  if(is_array($_POST["keywords"]["value"]))
633  {
634  include_once("./Services/MetaData/classes/class.ilMDKeyword.php");
635  ilMDKeyword::updateKeywords($this->md_section, $_POST["keywords"]["value"]);
636  }
637  $this->callListeners('General');
638 
639  // Copyright
640  //if($_POST['copyright_id'] or $_POST['rights_copyright'])
641  if($_POST['copyright']['sel'] || $_POST['copyright']['ta'])
642  {
643  if(!is_object($this->md_section = $this->md_obj->getRights()))
644  {
645  $this->md_section = $this->md_obj->addRights();
646  $this->md_section->save();
647  }
648  if($_POST['copyright']['sel'])
649  {
650  $this->md_section->setCopyrightAndOtherRestrictions("Yes");
651  $this->md_section->setDescription('il_copyright_entry__'.IL_INST_ID.'__'.(int) $_POST['copyright']['sel']);
652  }
653  else
654  {
655  $this->md_section->setCopyrightAndOtherRestrictions("Yes");
656  $this->md_section->setDescription(ilUtil::stripSlashes($_POST['copyright']['ta']));
657  }
658  $this->md_section->update();
659  }
660  else
661  {
662  if(is_object($this->md_section = $this->md_obj->getRights()))
663  {
664  $this->md_section->setCopyrightAndOtherRestrictions("No");
665  $this->md_section->setDescription("");
666  $this->md_section->update();
667  }
668  }
669  $this->callListeners('Rights');
670 
671  //Educational...
672  // Typical Learning Time
673  if($_POST['tlt']['mo'] or $_POST['tlt']['d'] or
674  $_POST["tlt"]['h'] or $_POST['tlt']['m'] or $_POST['tlt']['s'])
675  {
676  if(!is_object($this->md_section = $this->md_obj->getEducational()))
677  {
678  $this->md_section = $this->md_obj->addEducational();
679  $this->md_section->save();
680  }
681  $this->md_section->setPhysicalTypicalLearningTime((int)$_POST['tlt']['mo'],(int)$_POST['tlt']['d'],
682  (int)$_POST['tlt']['h'],(int)$_POST['tlt']['m'],(int)$_POST['tlt']['s']);
683  $this->md_section->update();
684  }
685  else
686  {
687  if(is_object($this->md_section = $this->md_obj->getEducational()))
688  {
689  $this->md_section->setPhysicalTypicalLearningTime(0,0,0,0,0);
690  $this->md_section->update();
691  }
692  }
693  $this->callListeners('Educational');
694  //Lifecycle...
695  // Authors
696  if ($_POST["life_authors"] != "")
697  {
698  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
699  {
700  $this->md_section = $this->md_obj->addLifecycle();
701  $this->md_section->save();
702  }
703 
704  // determine all entered authors
705  $auth_arr = explode($this->md_settings->getDelimiter(), $_POST["life_authors"]);
706  for($i = 0; $i < count($auth_arr); $i++)
707  {
708  $auth_arr[$i] = trim($auth_arr[$i]);
709  }
710 
711  $md_con_author = "";
712 
713  // update existing author entries (delete if not entered)
714  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
715  {
716  $md_con = $this->md_section->getContribute($con_id);
717  if ($md_con->getRole() == "Author")
718  {
719  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
720  {
721  $md_ent = $md_con->getEntity($ent_id);
722 
723  // entered author already exists
724  if (in_array($md_ent->getEntity(), $auth_arr))
725  {
726  unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
727  }
728  else // existing author has not been entered again -> delete
729  {
730  $md_ent->delete();
731  }
732  }
733  $md_con_author = $md_con;
734  }
735  }
736 
737  // insert enterd, but not existing authors
738  if (count($auth_arr) > 0)
739  {
740  if (!is_object($md_con_author))
741  {
742  $md_con_author = $this->md_section->addContribute();
743  $md_con_author->setRole("Author");
744  $md_con_author->save();
745  }
746  foreach ($auth_arr as $auth)
747  {
748  $md_ent = $md_con_author->addEntity();
749  $md_ent->setEntity(ilUtil::stripSlashes($auth));
750  $md_ent->save();
751  }
752  }
753  }
754  else // nothing has been entered: delete all author contribs
755  {
756  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
757  {
758  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
759  {
760  $md_con = $this->md_section->getContribute($con_id);
761  if ($md_con->getRole() == "Author")
762  {
763  $md_con->delete();
764  }
765  }
766  }
767  }
768  $this->callListeners('Lifecycle');
769 
770  // Redirect here to read new title and description
771  // Otherwise ('Lifecycle' 'technical' ...) simply call listSection()
772  ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
773  $this->ctrl->redirect($this,'listSection');
774 
775  }
776 
777  function updateQuickEdit_scorm_propagate($request, $type)
778  {
779  $module_id = $this->md_obj->obj_id;
780  if($this->md_obj->obj_type=='sco')
781  $module_id = $this->md_obj->rbac_id;
782  $tree = new ilTree($module_id);
783  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
784  $tree->setTreeTablePK("slm_id");
785  foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),true,'sco') as $sco)
786  {
787  $sco_md = new ilMD($module_id,$sco['obj_id'],'sco');
788  if ($_POST[$request] != "")
789  {
790  $sco_md_section;
791  if(!is_object($sco_md_section = $sco_md->getLifecycle()))
792  {
793  $sco_md_section = $sco_md->addLifecycle();
794  $sco_md_section->save();
795  }
796  // determine all entered authors
797  $auth_arr = explode(",", $_POST[$request]);
798  for($i = 0; $i < count($auth_arr); $i++)
799  {
800  $auth_arr[$i] = trim($auth_arr[$i]);
801  }
802 
803  $md_con_author = "";
804 
805  // update existing author entries (delete if not entered)
806  foreach(($ids = $sco_md_section->getContributeIds()) as $con_id)
807  {
808  $md_con = $sco_md_section->getContribute($con_id);
809  if ($md_con->getRole() == $type)
810  {
811  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
812  {
813  $md_ent = $md_con->getEntity($ent_id);
814 
815  // entered author already exists
816  if (in_array($md_ent->getEntity(), $auth_arr))
817  {
818  unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
819  }
820  else // existing author has not been entered again -> delete
821  {
822  $md_ent->delete();
823  }
824  }
825  $md_con_author = $md_con;
826  }
827  }
828 
829  // insert enterd, but not existing authors
830  if (count($auth_arr) > 0)
831  {
832  if (!is_object($md_con_author))
833  {
834  $md_con_author = $sco_md_section->addContribute();
835  $md_con_author->setRole($type);
836  $md_con_author->save();
837  }
838  foreach ($auth_arr as $auth)
839  {
840  $md_ent = $md_con_author->addEntity();
841  $md_ent->setEntity(ilUtil::stripSlashes($auth));
842  $md_ent->save();
843  }
844  }
845  }
846  else // nothing has been entered: delete all author contribs
847  {
848  if(is_object($sco_md_section = $sco_md->getLifecycle()))
849  {
850  foreach(($ids = $sco_md_section->getContributeIds()) as $con_id)
851  {
852  $md_con = $sco_md_section->getContribute($con_id);
853  if ($md_con->getRole() == $type)
854  {
855  $md_con->delete();
856  }
857  }
858  }
859 
860  }
861  $sco_md->update();
862  }
863  $this->updateQuickEdit_scorm();
864  }
865 
867  {
868  $this->updateQuickEdit_scorm_propagate("life_experts", "SubjectMatterExpert");
869  }
871  {
872  $this->updateQuickEdit_scorm_propagate("life_designers", "InstructionalDesigner");
873  }
875  {
876  $this->updateQuickEdit_scorm_propagate("life_poc", "PointOfContact");
877  }
882  {
883  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
884 
885  // General values
886  $this->md_section = $this->md_obj->getGeneral();
887  $this->md_section->setTitle(ilUtil::stripSlashes($_POST['gen_title']));
888  $this->md_section->setTitleLanguage(new ilMDLanguageItem($_POST['gen_title_language']));
889  $this->md_section->update();
890 
891  // Language
892  if(is_array($_POST['gen_language']))
893  {
894  foreach($_POST['gen_language'] as $id => $data)
895  {
896  if ($id > 0)
897  {
898  $md_lan = $this->md_section->getLanguage($id);
899  $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
900  $md_lan->update();
901  }
902  else
903  {
904  $md_lan = $this->md_section->addLanguage();
905  $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
906  $md_lan->save();
907  }
908  }
909  }
910  // Description
911  if(is_array($_POST['gen_description']))
912  {
913  foreach($_POST['gen_description'] as $id => $data)
914  {
915  $md_des = $this->md_section->getDescription($id);
916  $md_des->setDescription(ilUtil::stripSlashes($data['description']));
917  $md_des->setDescriptionLanguage(new ilMDLanguageItem($data['language']));
918  $md_des->update();
919  }
920  }
921 
922 
923  // Keyword
924  if(is_array($_POST["keywords"]["value"]))
925  {
926  $new_keywords = array();
927  foreach($_POST["keywords"]["value"] as $lang => $keywords)
928  {
929  $language = $_POST["keyword"]["language"][$lang];
930  $keywords = explode(",", $keywords);
931  foreach($keywords as $keyword)
932  {
933  $new_keywords[$language][] = trim($keyword);
934  }
935  }
936 
937  // update existing author entries (delete if not entered)
938  foreach($ids = $this->md_section->getKeywordIds() as $id)
939  {
940  $md_key = $this->md_section->getKeyword($id);
941 
942  $lang = $md_key->getKeywordLanguageCode();
943 
944  // entered keyword already exists
945  if (is_array($new_keywords[$lang]) &&
946  in_array($md_key->getKeyword(), $new_keywords[$lang]))
947  {
948  unset($new_keywords[$lang]
949  [array_search($md_key->getKeyword(), $new_keywords[$lang])]);
950  }
951  else // existing keyword has not been entered again -> delete
952  {
953  $md_key->delete();
954  }
955  }
956 
957  // insert entered, but not existing keywords
958  foreach ($new_keywords as $lang => $key_arr)
959  {
960  foreach($key_arr as $keyword)
961  {
962  if ($keyword != "")
963  {
964  $md_key = $this->md_section->addKeyword();
965  $md_key->setKeyword(ilUtil::stripSlashes($keyword));
966  $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
967  $md_key->save();
968  }
969  }
970  }
971 
972  }
973  $this->callListeners('General');
974 
975  // Copyright
976  if($_POST['copyright_id'] or $_POST['rights_copyright'])
977  {
978  if(!is_object($this->md_section = $this->md_obj->getRights()))
979  {
980  $this->md_section = $this->md_obj->addRights();
981  $this->md_section->save();
982  }
983  if($_POST['copyright_id'])
984  {
985  $this->md_section->setCopyrightAndOtherRestrictions("Yes");
986  $this->md_section->setDescription('il_copyright_entry__'.IL_INST_ID.'__'.(int) $_POST['copyright_id']);
987  }
988  else
989  {
990  $this->md_section->setCopyrightAndOtherRestrictions("Yes");
991  $this->md_section->setDescription(ilUtil::stripSlashes($_POST["rights_copyright"]));
992  }
993  $this->md_section->update();
994  }
995  else
996  {
997  if(is_object($this->md_section = $this->md_obj->getRights()))
998  {
999  $this->md_section->setCopyrightAndOtherRestrictions("No");
1000  $this->md_section->setDescription("");
1001  $this->md_section->update();
1002  }
1003  }
1004  $this->callListeners('Rights');
1005 
1006  //Educational...
1007  // Typical Learning Time
1008  if($_POST['tlt']['mo'] or $_POST['tlt']['d'] or
1009  $_POST["tlt"]['h'] or $_POST['tlt']['m'] or $_POST['tlt']['s'])
1010  {
1011  if(!is_object($this->md_section = $this->md_obj->getEducational()))
1012  {
1013  $this->md_section = $this->md_obj->addEducational();
1014  $this->md_section->save();
1015  }
1016  $this->md_section->setPhysicalTypicalLearningTime((int)$_POST['tlt']['mo'],(int)$_POST['tlt']['d'],
1017  (int)$_POST['tlt']['h'],(int)$_POST['tlt']['m'],(int)$_POST['tlt']['s']);
1018  $this->md_section->update();
1019  }
1020  else
1021  {
1022  if(is_object($this->md_section = $this->md_obj->getEducational()))
1023  {
1024  $this->md_section->setPhysicalTypicalLearningTime(0,0,0,0,0);
1025  $this->md_section->update();
1026  }
1027  }
1028  $this->callListeners('Educational');
1029  //Lifecycle...
1030  // experts
1031  if ($_POST["life_experts"] != "")
1032  {
1033  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
1034  {
1035  $this->md_section = $this->md_obj->addLifecycle();
1036  $this->md_section->save();
1037  }
1038 
1039  // determine all entered authors
1040  $auth_arr = explode(",", $_POST["life_experts"]);
1041  for($i = 0; $i < count($auth_arr); $i++)
1042  {
1043  $auth_arr[$i] = trim($auth_arr[$i]);
1044  }
1045 
1046  $md_con_author = "";
1047 
1048  // update existing author entries (delete if not entered)
1049  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1050  {
1051  $md_con = $this->md_section->getContribute($con_id);
1052  if ($md_con->getRole() == "SubjectMatterExpert")
1053  {
1054  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
1055  {
1056  $md_ent = $md_con->getEntity($ent_id);
1057 
1058  // entered author already exists
1059  if (in_array($md_ent->getEntity(), $auth_arr))
1060  {
1061  unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
1062  }
1063  else // existing author has not been entered again -> delete
1064  {
1065  $md_ent->delete();
1066  }
1067  }
1068  $md_con_author = $md_con;
1069  }
1070  }
1071 
1072  // insert enterd, but not existing authors
1073  if (count($auth_arr) > 0)
1074  {
1075  if (!is_object($md_con_author))
1076  {
1077  $md_con_author = $this->md_section->addContribute();
1078  $md_con_author->setRole("SubjectMatterExpert");
1079  $md_con_author->save();
1080  }
1081  foreach ($auth_arr as $auth)
1082  {
1083  $md_ent = $md_con_author->addEntity();
1084  $md_ent->setEntity(ilUtil::stripSlashes($auth));
1085  $md_ent->save();
1086  }
1087  }
1088  }
1089  else // nothing has been entered: delete all author contribs
1090  {
1091  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
1092  {
1093  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1094  {
1095  $md_con = $this->md_section->getContribute($con_id);
1096  if ($md_con->getRole() == "SubjectMatterExpert")
1097  {
1098  $md_con->delete();
1099  }
1100  }
1101  }
1102 
1103  }
1104 
1105  // InstructionalDesigner
1106  if ($_POST["life_designers"] != "")
1107  {
1108  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
1109  {
1110  $this->md_section = $this->md_obj->addLifecycle();
1111  $this->md_section->save();
1112  }
1113 
1114  // determine all entered authors
1115  $auth_arr = explode(",", $_POST["life_designers"]);
1116  for($i = 0; $i < count($auth_arr); $i++)
1117  {
1118  $auth_arr[$i] = trim($auth_arr[$i]);
1119  }
1120 
1121  $md_con_author = "";
1122 
1123  // update existing author entries (delete if not entered)
1124  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1125  {
1126  $md_con = $this->md_section->getContribute($con_id);
1127  if ($md_con->getRole() == "InstructionalDesigner")
1128  {
1129  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
1130  {
1131  $md_ent = $md_con->getEntity($ent_id);
1132 
1133  // entered author already exists
1134  if (in_array($md_ent->getEntity(), $auth_arr))
1135  {
1136  unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
1137  }
1138  else // existing author has not been entered again -> delete
1139  {
1140  $md_ent->delete();
1141  }
1142  }
1143  $md_con_author = $md_con;
1144  }
1145  }
1146 
1147  // insert enterd, but not existing authors
1148  if (count($auth_arr) > 0)
1149  {
1150  if (!is_object($md_con_author))
1151  {
1152  $md_con_author = $this->md_section->addContribute();
1153  $md_con_author->setRole("InstructionalDesigner");
1154  $md_con_author->save();
1155  }
1156  foreach ($auth_arr as $auth)
1157  {
1158  $md_ent = $md_con_author->addEntity();
1159  $md_ent->setEntity(ilUtil::stripSlashes($auth));
1160  $md_ent->save();
1161  }
1162  }
1163  }
1164  else // nothing has been entered: delete all author contribs
1165  {
1166  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
1167  {
1168  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1169  {
1170  $md_con = $this->md_section->getContribute($con_id);
1171  if ($md_con->getRole() == "InstructionalDesigner")
1172  {
1173  $md_con->delete();
1174 
1175  }
1176  }
1177  }
1178  }
1179 
1180  // Point of Contact
1181  if ($_POST["life_poc"] != "")
1182  {
1183  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
1184  {
1185  $this->md_section = $this->md_obj->addLifecycle();
1186  $this->md_section->save();
1187  }
1188 
1189  // determine all entered authors
1190  $auth_arr = explode(",", $_POST["life_poc"]);
1191  for($i = 0; $i < count($auth_arr); $i++)
1192  {
1193  $auth_arr[$i] = trim($auth_arr[$i]);
1194  }
1195 
1196  $md_con_author = "";
1197 
1198  // update existing author entries (delete if not entered)
1199  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1200  {
1201  $md_con = $this->md_section->getContribute($con_id);
1202  if ($md_con->getRole() == "PointOfContact")
1203  {
1204  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
1205  {
1206  $md_ent = $md_con->getEntity($ent_id);
1207 
1208  // entered author already exists
1209  if (in_array($md_ent->getEntity(), $auth_arr))
1210  {
1211  unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
1212  }
1213  else // existing author has not been entered again -> delete
1214  {
1215  $md_ent->delete();
1216  }
1217  }
1218  $md_con_author = $md_con;
1219  }
1220  }
1221 
1222  // insert enterd, but not existing authors
1223  if (count($auth_arr) > 0)
1224  {
1225  if (!is_object($md_con_author))
1226  {
1227  $md_con_author = $this->md_section->addContribute();
1228  $md_con_author->setRole("PointOfContact");
1229  $md_con_author->save();
1230  }
1231  foreach ($auth_arr as $auth)
1232  {
1233  $md_ent = $md_con_author->addEntity();
1234  $md_ent->setEntity(ilUtil::stripSlashes($auth));
1235  $md_ent->save();
1236  }
1237  }
1238  }
1239  else // nothing has been entered: delete all author contribs
1240  {
1241  if(is_object($this->md_section = $this->md_obj->getLifecycle()))
1242  {
1243  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1244  {
1245  $md_con = $this->md_section->getContribute($con_id);
1246  if ($md_con->getRole() == "PointOfContact")
1247  {
1248  $md_con->delete();
1249 
1250  }
1251  }
1252  }
1253  }
1254 
1255  $this->md_section = $this->md_obj->getLifecycle();
1256  $this->md_section->setVersionLanguage(new ilMDLanguageItem($_POST['lif_language']));
1257  $this->md_section->setVersion(ilUtil::stripSlashes($_POST['lif_version']));
1258  $this->md_section->setStatus($_POST['lif_status']);
1259  $this->md_section->update();
1260 
1261 
1262  $this->callListeners('Lifecycle');
1263 
1264  // Redirect here to read new title and description
1265  // Otherwise ('Lifecycle' 'technical' ...) simply call listSection()
1266  ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
1267  $this->ctrl->redirect($this,'listSection');
1268  }
1269 
1270  /*
1271  * list general sections
1272  */
1273  function listGeneral()
1274  {
1275  if(!is_object($this->md_section = $this->md_obj->getGeneral()))
1276  {
1277  $this->md_section = $this->md_obj->addGeneral();
1278  $this->md_section->save();
1279  }
1280 
1281  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
1282 
1283  $this->__setTabs('meta_general');
1284 
1285  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_general.html','Services/MetaData');
1286 
1287  $this->ctrl->setReturn($this,'listGeneral');
1288  $this->ctrl->setParameter($this,'section','meta_general');
1289  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
1290 
1291  $this->__fillSubelements();
1292 
1293  $this->tpl->setVariable("TXT_GENERAL", $this->lng->txt("meta_general"));
1294  $this->tpl->setVariable("TXT_IDENTIFIER", $this->lng->txt("meta_identifier"));
1295  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("meta_language"));
1296  $this->tpl->setVariable("TXT_KEYWORD", $this->lng->txt("meta_keyword"));
1297  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("meta_description"));
1298  $this->tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("meta_structure"));
1299  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
1300  $this->tpl->setVariable("TXT_ATOMIC", $this->lng->txt("meta_atomic"));
1301  $this->tpl->setVariable("TXT_COLLECTION", $this->lng->txt("meta_collection"));
1302  $this->tpl->setVariable("TXT_NETWORKED", $this->lng->txt("meta_networked"));
1303  $this->tpl->setVariable("TXT_HIERARCHICAL", $this->lng->txt("meta_hierarchical"));
1304  $this->tpl->setVariable("TXT_LINEAR", $this->lng->txt("meta_linear"));
1305 
1306  // Structure
1307  $this->tpl->setVariable("STRUCTURE_VAL_".strtoupper($this->md_section->getStructure())," selected=selected");
1308 
1309  // Identifier
1310  $first = true;
1311  foreach($ids = $this->md_section->getIdentifierIds() as $id)
1312  {
1313  $md_ide = $this->md_section->getIdentifier($id);
1314 
1315  //
1316  if ($first)
1317  {
1318  $this->tpl->setCurrentBlock("id_head");
1319  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_IDENTIFIER", $this->lng->txt("meta_identifier"));
1320  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_CATALOG", $this->lng->txt("meta_catalog"));
1321  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_ENTRY", $this->lng->txt("meta_entry"));
1322  $this->tpl->setVariable("ROWSPAN_ID", count($ids));
1323  $this->tpl->parseCurrentBlock();
1324  $first = false;
1325  }
1326 
1327  if(count($ids) > 1)
1328  {
1329  $this->ctrl->setParameter($this,'meta_index',$id);
1330  $this->ctrl->setParameter($this,'meta_path','meta_identifier');
1331 
1332  if ($md_ide->getCatalog() != "ILIAS")
1333  {
1334  $this->tpl->setCurrentBlock("identifier_delete");
1335  $this->tpl->setVariable("IDENTIFIER_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1336  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1337  $this->tpl->parseCurrentBlock();
1338  }
1339  }
1340 
1341  $this->tpl->setCurrentBlock("identifier_loop");
1342  if ($md_ide->getCatalog() == "ILIAS")
1343  {
1344  $this->tpl->setVariable("DISABLE_IDENT", ' disabled="disabled" ');
1345  }
1346  $this->tpl->setVariable("IDENTIFIER_LOOP_NO", $id);
1347  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_IDENTIFIER_CATALOG",
1348  ilUtil::prepareFormOutput($md_ide->getCatalog()));
1349  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_IDENTIFIER_ENTRY",
1350  ilUtil::prepareFormOutput($md_ide->getEntry()));
1351  $this->tpl->parseCurrentBlock();
1352  }
1353 
1354 
1355  // Language
1356  $first = true;
1357  foreach($ids = $this->md_section->getLanguageIds() as $id)
1358  {
1359  $md_lan = $this->md_section->getLanguage($id);
1360 
1361  if ($first)
1362  {
1363  $this->tpl->setCurrentBlock("language_head");
1364  $this->tpl->setVariable("ROWSPAN_LANG", count($ids));
1365  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
1366  $this->tpl->parseCurrentBlock();
1367  $first = false;
1368  }
1369 
1370  if (count($ids) > 1)
1371  {
1372  $this->ctrl->setParameter($this,'meta_index',$id);
1373  $this->ctrl->setParameter($this,'meta_path','meta_language');
1374 
1375  $this->tpl->setCurrentBlock("language_delete");
1376  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1377  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
1378  $this->tpl->parseCurrentBlock();
1379  }
1380  $this->tpl->setCurrentBlock("language_loop");
1381  $this->tpl->setVariable("LANGUAGE_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect('gen_language['.$id.'][language]',
1382  $md_lan->getLanguageCode()));
1383  $this->tpl->parseCurrentBlock();
1384  }
1385 
1386  // TITLE
1387  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
1388  $this->tpl->setVariable("VAL_TITLE",ilUtil::prepareFormOutput($this->md_section->getTitle()));
1389  $this->tpl->setVariable("VAL_TITLE_LANGUAGE",$this->__showLanguageSelect('gen_title_language',
1390  $this->md_section->getTitleLanguageCode()));
1391 
1392 
1393  // DESCRIPTION
1394  foreach($ids = $this->md_section->getDescriptionIds() as $id)
1395  {
1396  $md_des = $this->md_section->getDescription($id);
1397 
1398  if (count($ids) > 1)
1399  {
1400  $this->ctrl->setParameter($this,'meta_index',$id);
1401  $this->ctrl->setParameter($this,'meta_path','meta_description');
1402 
1403  $this->tpl->setCurrentBlock("description_delete");
1404  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1405  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
1406  $this->tpl->parseCurrentBlock();
1407  }
1408 
1409  $this->tpl->setCurrentBlock("description_loop");
1410  $this->tpl->setVariable("DESCRIPTION_LOOP_NO",$id);
1411  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DESCRIPTION", $this->lng->txt("meta_description"));
1412  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
1413  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL", ilUtil::prepareFormOutput($md_des->getDescription()));
1414  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
1415  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect("gen_description[".$id.'][language]',
1416  $md_des->getDescriptionLanguageCode()));
1417  $this->tpl->parseCurrentBlock();
1418  }
1419 
1420  // KEYWORD
1421  $first = true;
1422  foreach($ids = $this->md_section->getKeywordIds() as $id)
1423  {
1424  $md_key = $this->md_section->getKeyword($id);
1425 
1426  if ($first)
1427  {
1428  $this->tpl->setCurrentBlock("keyword_head");
1429  $this->tpl->setVariable("ROWSPAN_KEYWORD", count($ids));
1430  $this->tpl->setVariable("KEYWORD_LOOP_TXT_KEYWORD", $this->lng->txt("meta_keyword"));
1431  $this->tpl->parseCurrentBlock();
1432  $first = false;
1433  }
1434 
1435 
1436  if(count($ids) > 1)
1437  {
1438  $this->ctrl->setParameter($this,'meta_index',$id);
1439  $this->ctrl->setParameter($this,'meta_path','meta_keyword');
1440 
1441  $this->tpl->setCurrentBlock("keyword_delete");
1442  $this->tpl->setVariable("KEYWORD_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1443  $this->tpl->setVariable("KEYWORD_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
1444  $this->tpl->parseCurrentBlock();
1445  }
1446 
1447  $this->tpl->setCurrentBlock("keyword_loop");
1448  $this->tpl->setVariable("KEYWORD_LOOP_NO",$id);
1449  $this->tpl->setVariable("KEYWORD_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
1450  $this->tpl->setVariable("KEYWORD_LOOP_VAL", ilUtil::prepareFormOutput($md_key->getKeyword()));
1451  $this->tpl->setVariable("KEYWORD_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
1452  $this->tpl->setVariable("KEYWORD_LOOP_VAL_LANGUAGE", $this->__showLanguageSelect("gen_keyword[".$id.'][language]',
1453  $md_key->getKeywordLanguageCode()));
1454 
1455  $this->tpl->parseCurrentBlock();
1456  }
1457 
1458  // Coverage
1459  $this->tpl->setVariable("COVERAGE_LOOP_TXT_COVERAGE",$this->lng->txt('meta_coverage'));
1460  $this->tpl->setVariable("COVERAGE_LOOP_VAL",ilUtil::prepareFormOutput($this->md_section->getCoverage()));
1461  $this->tpl->setVariable("COVERAGE_LOOP_TXT_LANGUAGE",$this->lng->txt('meta_language'));
1462  $this->tpl->setVariable("COVERAGE_LOOP_VAL_LANGUAGE",$this->__showLanguageSelect('gen_coverage_language',
1463  $this->md_section->getCoverageLanguageCode()));
1464 
1465  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
1466  }
1467 
1471  function updateGeneral()
1472  {
1473  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
1474 
1475  if(!strlen(trim($_POST['gen_title'])))
1476  {
1477  ilUtil::sendFailure($this->lng->txt('title_required'));
1478  $this->listGeneral();
1479  return false;
1480  }
1481 
1482  // General values
1483  $this->md_section = $this->md_obj->getGeneral();
1484  $this->md_section->setStructure($_POST['gen_structure']);
1485  $this->md_section->setTitle(ilUtil::stripSlashes($_POST['gen_title']));
1486  $this->md_section->setTitleLanguage(new ilMDLanguageItem($_POST['gen_title_language']));
1487  $this->md_section->setCoverage(ilUtil::stripSlashes($_POST['gen_coverage']));
1488  $this->md_section->setCoverageLanguage(new ilMDLanguageItem($_POST['gen_coverage_language']));
1489  $this->md_section->update();
1490 
1491  // Identifier
1492  if(is_array($_POST['gen_identifier']))
1493  {
1494  foreach($_POST['gen_identifier'] as $id => $data)
1495  {
1496  $md_ide = $this->md_section->getIdentifier($id);
1497  $md_ide->setCatalog(ilUtil::stripSlashes($data['Catalog']));
1498  $md_ide->setEntry(ilUtil::stripSlashes($data['Entry']));
1499  $md_ide->update();
1500  }
1501  }
1502 
1503  // Language
1504  if(is_array($_POST['gen_language']))
1505  {
1506  foreach($_POST['gen_language'] as $id => $data)
1507  {
1508  $md_lan = $this->md_section->getLanguage($id);
1509  $md_lan->setLanguage(new ilMDLanguageItem($data['language']));
1510  $md_lan->update();
1511  }
1512  }
1513  // Description
1514  if(is_array($_POST['gen_description']))
1515  {
1516  foreach($_POST['gen_description'] as $id => $data)
1517  {
1518  $md_des = $this->md_section->getDescription($id);
1519  $md_des->setDescription(ilUtil::stripSlashes($data['description']));
1520  $md_des->setDescriptionLanguage(new ilMDLanguageItem($data['language']));
1521  $md_des->update();
1522  }
1523  }
1524  // Keyword
1525  if(is_array($_POST['gen_keyword']))
1526  {
1527  foreach($_POST['gen_keyword'] as $id => $data)
1528  {
1529  $md_key = $this->md_section->getKeyword($id);
1530 
1531  $md_key->setKeyword(ilUtil::stripSlashes($data['keyword']));
1532  $md_key->setKeywordLanguage(new ilMDLanguageItem($data['language']));
1533  $md_key->update();
1534  }
1535  }
1536  $this->callListeners('General');
1537 
1538  // Redirect here to read new title and description
1539  // Otherwise ('Lifecycle' 'technical' ...) simply call listSection()
1540  $this->ctrl->setParameter($this, "section", "meta_general");
1541  ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
1542  $this->ctrl->redirect($this,'listSection');
1543  }
1544 
1545  function updateTechnical()
1546  {
1547  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
1548 
1549  // update technical section
1550  $this->md_section = $this->md_obj->getTechnical();
1551  $this->md_section->setSize(ilUtil::stripSlashes($_POST['met_size']));
1552  $this->md_section->setInstallationRemarks(ilUtil::stripSlashes($_POST['met_inst']));
1553  $this->md_section->setInstallationRemarksLanguage(new ilMDLanguageItem($_POST['inst_language']));
1554  $this->md_section->setOtherPlatformRequirements(ilUtil::stripSlashes($_POST['met_opr']));
1555  $this->md_section->setOtherPlatformRequirementsLanguage(new ilMDLanguageItem($_POST['opr_language']));
1556  $this->md_section->setDuration(ilUtil::stripSlashes($_POST['duration']));
1557  $this->md_section->update();
1558 
1559  // Format
1560  if(is_array($_POST['met_format']))
1561  {
1562  foreach($_POST['met_format'] as $id => $data)
1563  {
1564  $md_for = $this->md_section->getFormat($id);
1565  $md_for->setFormat(ilUtil::stripSlashes($data['Format']));
1566  $md_for->update();
1567  }
1568  }
1569  // Location
1570  if(is_array($_POST['met_location']))
1571  {
1572  foreach($_POST['met_location'] as $id => $data)
1573  {
1574  $md_loc = $this->md_section->getLocation($id);
1575  $md_loc->setLocation(ilUtil::stripSlashes($data['Location']));
1576  $md_loc->setLocationType(ilUtil::stripSlashes($data['Type']));
1577  $md_loc->update();
1578  }
1579  }
1580  if(is_array($_POST['met_re']))
1581  {
1582  foreach($_POST['met_re'] as $id => $data)
1583  {
1584 
1585  $md_re = $this->md_section->getRequirement($id);
1586  $md_re->setOperatingSystemName(ilUtil::stripSlashes($data['os']['name']));
1587  $md_re->setOperatingSystemMinimumVersion(ilUtil::stripSlashes($data['os']['MinimumVersion']));
1588  $md_re->setOperatingSystemMaximumVersion(ilUtil::stripSlashes($data['os']['MaximumVersion']));
1589  $md_re->setBrowserName(ilUtil::stripSlashes($data['browser']['name']));
1590  $md_re->setBrowserMinimumVersion(ilUtil::stripSlashes($data['browser']['MinimumVersion']));
1591  $md_re->setBrowserMaximumVersion(ilUtil::stripSlashes($data['browser']['MaximumVersion']));
1592  $md_re->update();
1593  }
1594  }
1595  $this->callListeners('Technical');
1596 
1597  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
1598  $this->listSection();
1599  return true;
1600  }
1601 
1602 
1603 
1604  function listTechnical()
1605  {
1606  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
1607  $this->__setTabs('meta_technical');
1608  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_technical.html','Services/MetaData');
1609 
1610 
1611  $this->ctrl->setParameter($this, "section", "meta_technical");
1612  if(!is_object($this->md_section = $this->md_obj->getTechnical()))
1613  {
1614  $this->tpl->setCurrentBlock("no_technical");
1615  $this->tpl->setVariable("TXT_NO_TECHNICAL", $this->lng->txt("meta_no_technical"));
1616  $this->tpl->setVariable("TXT_ADD_TECHNICAL", $this->lng->txt("meta_add"));
1617  $this->tpl->setVariable("ACTION_ADD_TECHNICAL",$this->ctrl->getLinkTarget($this, "addSection"));
1618  $this->tpl->parseCurrentBlock();
1619 
1620  return true;
1621  }
1622  $this->ctrl->setReturn($this,'listTechnical');
1623  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
1624 
1625  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
1626  $this->tpl->setVariable("TXT_TECHNICAL",$this->lng->txt('meta_technical'));
1627 
1628  // Delete link
1629  $this->tpl->setVariable("ACTION_DELETE",
1630  $this->ctrl->getLinkTarget($this, "deleteSection"));
1631  $this->tpl->setVariable("TXT_DELETE",$this->lng->txt('delete'));
1632 
1633  // New element
1634  $this->__fillSubelements();
1635 
1636  // Format
1637  foreach($ids = $this->md_section->getFormatIds() as $id)
1638  {
1639  $md_for =& $this->md_section->getFormat($id);
1640 
1641  $this->tpl->setCurrentBlock("format_loop");
1642 
1643  $this->ctrl->setParameter($this,'meta_index',$id);
1644  $this->ctrl->setParameter($this,'meta_path','meta_format');
1645  $this->tpl->setVariable("FORMAT_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1646  $this->tpl->setVariable("FORMAT_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1647 
1648  $this->tpl->setVariable("FORMAT_LOOP_NO",$id);
1649  $this->tpl->setVariable("FORMAT_LOOP_TXT_FORMAT",$this->lng->txt('meta_format'));
1650  $this->tpl->setVariable("FORMAT_LOOP_VAL",ilUtil::prepareFormOutput($md_for->getFormat()));
1651 
1652  $this->tpl->parseCurrentBlock();
1653  }
1654  // Size
1655  $this->tpl->setVariable("SIZE_TXT_SIZE",$this->lng->txt('meta_size'));
1656  $this->tpl->setVariable("SIZE_VAL",ilUtil::prepareFormOutput($this->md_section->getSize()));
1657 
1658  // Location
1659  foreach($ids = $this->md_section->getLocationIds() as $id)
1660  {
1661  $md_loc =& $this->md_section->getLocation($id);
1662 
1663  $this->tpl->setCurrentBlock("location_loop");
1664 
1665  $this->ctrl->setParameter($this,'meta_index',$id);
1666  $this->ctrl->setParameter($this,'meta_path','meta_location');
1667  $this->tpl->setVariable("LOCATION_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1668  $this->tpl->setVariable("LOCATION_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1669 
1670  $this->tpl->setVariable("LOCATION_LOOP_TXT_LOCATION",$this->lng->txt('meta_location'));
1671  $this->tpl->setVariable("LOCATION_LOOP_NO",$id);
1672  $this->tpl->setVariable("LOCATION_LOOP_TXT_TYPE",$this->lng->txt('meta_type'));
1673  $this->tpl->setVariable("LOCATION_LOOP_VAL",ilUtil::prepareFormOutput($md_loc->getLocation()));
1674 
1675  $this->tpl->setVariable("SEL_LOCATION_TYPE",
1676  ilMDUtilSelect::_getLocationTypeSelect($md_loc->getLocationType(),
1677  "met_location[".$id."][Type]",
1678  array(0 => $this->lng->txt('meta_please_select'))));
1679  $this->tpl->parseCurrentBlock();
1680  }
1681  // Requirement
1682  foreach($ids = $this->md_section->getRequirementIds() as $id)
1683  {
1684  $md_re =& $this->md_section->getRequirement($id);
1685 
1686  $this->tpl->setCurrentBlock("requirement_loop");
1687 
1688  $this->ctrl->setParameter($this,'meta_index',$id);
1689  $this->ctrl->setParameter($this,'meta_path','meta_requirement');
1690  $this->tpl->setVariable("REQUIREMENT_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1691  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1692 
1693  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_REQUIREMENT",$this->lng->txt('meta_requirement'));
1694  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_TYPE",$this->lng->txt('meta_type'));
1695  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_OPERATINGSYSTEM",$this->lng->txt('meta_operating_system'));
1696  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_BROWSER",$this->lng->txt('meta_browser'));
1697  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_NAME",$this->lng->txt('meta_name'));
1698  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_MINIMUMVERSION",$this->lng->txt('meta_minimum_version'));
1699  $this->tpl->setVariable("REQUIREMENT_LOOP_TXT_MAXIMUMVERSION",$this->lng->txt('meta_maximum_version'));
1700 
1701  $this->tpl->setVariable("REQUIREMENT_LOOP_NO",$id);
1702  $this->tpl->setVariable("REQUIREMENT_SEL_OS_NAME",
1703  ilMDUtilSelect::_getOperatingSystemSelect($md_re->getOperatingSystemName(),
1704  "met_re[".$id."][os][name]",
1705  array(0 => $this->lng->txt('meta_please_select'))));
1706  $this->tpl->setVariable("REQUIREMENT_SEL_BROWSER_NAME",
1707  ilMDUtilSelect::_getBrowserSelect($md_re->getBrowserName(),
1708  "met_re[".$id."][browser][name]",
1709  array(0 => $this->lng->txt('meta_please_select'))));
1710 
1711  $this->tpl->setVariable("REQUIREMENT_LOOP_VAL_OPERATINGSYSTEM_MINIMUMVERSION",
1712  ilUtil::prepareFormOutput($md_re->getOperatingSystemMinimumVersion()));
1713 
1714  $this->tpl->setVariable("REQUIREMENT_LOOP_VAL_OPERATINGSYSTEM_MAXIMUMVERSION",
1715  ilUtil::prepareFormOutput($md_re->getOperatingSystemMaximumVersion()));
1716 
1717  $this->tpl->setVariable("REQUIREMENT_LOOP_VAL_BROWSER_MINIMUMVERSION",
1718  ilUtil::prepareFormOutput($md_re->getBrowserMinimumVersion()));
1719 
1720  $this->tpl->setVariable("REQUIREMENT_LOOP_VAL_BROWSER_MAXIMUMVERSION",
1721  ilUtil::prepareFormOutput($md_re->getBrowserMaximumVersion()));
1722  $this->tpl->parseCurrentBlock();
1723 
1724  }
1725  // OrComposite
1726  foreach($ids = $this->md_section->getOrCompositeIds() as $or_id)
1727  {
1728  $md_or =& $this->md_section->getOrComposite($or_id);
1729  foreach($ids = $md_or->getRequirementIds() as $id)
1730  {
1731  $md_re =& $this->md_section->getRequirement($id);
1732 
1733  $this->tpl->setCurrentBlock("orrequirement_loop");
1734 
1735  $this->ctrl->setParameter($this,'meta_index',$id);
1736  $this->ctrl->setParameter($this,'meta_path','meta_requirement');
1737  $this->tpl->setVariable("ORREQUIREMENT_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1738  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1739 
1740  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_REQUIREMENT",$this->lng->txt('meta_requirement'));
1741  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_TYPE",$this->lng->txt('meta_type'));
1742  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_OPERATINGSYSTEM",$this->lng->txt('meta_operating_system'));
1743  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_BROWSER",$this->lng->txt('meta_browser'));
1744  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_NAME",$this->lng->txt('meta_name'));
1745  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_MINIMUMVERSION",$this->lng->txt('meta_minimum_version'));
1746  $this->tpl->setVariable("ORREQUIREMENT_LOOP_TXT_MAXIMUMVERSION",$this->lng->txt('meta_maximum_version'));
1747 
1748  $this->tpl->setVariable("ORREQUIREMENT_LOOP_NO",$id);
1749  $this->tpl->setVariable("ORREQUIREMENT_SEL_OS_NAME",
1750  ilMDUtilSelect::_getOperatingSystemSelect($md_re->getOperatingSystemName(),
1751  "met_re[".$id."][os][name]",
1752  array(0 => $this->lng->txt('meta_please_select'))));
1753  $this->tpl->setVariable("ORREQUIREMENT_SEL_BROWSER_NAME",
1754  ilMDUtilSelect::_getBrowserSelect($md_re->getBrowserName(),
1755  "met_re[".$id."][browser][name]",
1756  array(0 => $this->lng->txt('meta_please_select'))));
1757 
1758  $this->tpl->setVariable("ORREQUIREMENT_LOOP_VAL_OPERATINGSYSTEM_MINIMUMVERSION",
1759  ilUtil::prepareFormOutput($md_re->getOperatingSystemMinimumVersion()));
1760 
1761  $this->tpl->setVariable("ORREQUIREMENT_LOOP_VAL_OPERATINGSYSTEM_MAXIMUMVERSION",
1762  ilUtil::prepareFormOutput($md_re->getOperatingSystemMaximumVersion()));
1763 
1764  $this->tpl->setVariable("ORREQUIREMENT_LOOP_VAL_BROWSER_MINIMUMVERSION",
1765  ilUtil::prepareFormOutput($md_re->getBrowserMinimumVersion()));
1766 
1767  $this->tpl->setVariable("ORREQUIREMENT_LOOP_VAL_BROWSER_MAXIMUMVERSION",
1768  ilUtil::prepareFormOutput($md_re->getBrowserMaximumVersion()));
1769  $this->tpl->parseCurrentBlock();
1770  }
1771  $this->tpl->setCurrentBlock("orcomposite_loop");
1772 
1773  $this->ctrl->setParameter($this,'meta_index',$or_id);
1774  $this->ctrl->setParameter($this,'meta_path','meta_or_composite');
1775  $this->ctrl->setParameter($this,'meta_technical',$this->md_section->getMetaId());
1776  $this->tpl->setVariable("ORCOMPOSITE_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1777  $this->tpl->setVariable("ORCOMPOSITE_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1778 
1779  $this->tpl->setVariable("ORCOMPOSITE_LOOP_TXT_ORCOMPOSITE",$this->lng->txt('meta_or_composite'));
1780  $this->tpl->parseCurrentBlock();
1781  }
1782 
1783  // InstallationRemarks
1784  $this->tpl->setVariable("INSTALLATIONREMARKS_TXT_INSTALLATIONREMARKS",$this->lng->txt('meta_installation_remarks'));
1785  $this->tpl->setVariable("INSTALLATIONREMARKS_TXT_LANGUAGE",$this->lng->txt('meta_language'));
1786 
1787  $this->tpl->setVariable("INSTALLATIONREMARKS_VAL",ilUtil::prepareFormOutput($this->md_section->getInstallationRemarks()));
1788  $this->tpl->setVariable("INSTALLATIONREMARKS_VAL_LANGUAGE",
1789  $this->__showLanguageSelect('inst_language',
1790  $this->md_section->getInstallationRemarksLanguageCode()));
1791 
1792  // Other platform requirement
1793  $this->tpl->setVariable("OTHERPLATTFORMREQUIREMENTS_TXT_OTHERPLATTFORMREQUIREMENTS",
1794  $this->lng->txt('meta_other_plattform_requirements'));
1795  $this->tpl->setVariable("OTHERPLATTFORMREQUIREMENTS_TXT_LANGUAGE",$this->lng->txt('meta_language'));
1796 
1797  $this->tpl->setVariable("OTHERPLATTFORMREQUIREMENTS_VAL",
1798  ilUtil::prepareFormOutput($this->md_section->getOtherPlatformRequirements()));
1799  $this->tpl->setVariable("OTHERPLATTFORMREQUIREMENTS_VAL_LANGUAGE",
1800  $this->__showLanguageSelect('opr_language',
1801  $this->md_section->getOtherPlatformRequirementsLanguageCode()));
1802 
1803  // Duration
1804  $this->tpl->setVariable("DURATION_TXT_DURATION",$this->lng->txt('meta_duration'));
1805  $this->tpl->setVariable("DURATION_VAL",ilUtil::prepareFormOutput($this->md_section->getDuration()));
1806 
1807  $this->tpl->setCurrentBlock("technical");
1808  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
1809  $this->tpl->parseCurrentBlock();
1810  }
1811 
1812 
1813 
1814  function listLifecycle()
1815  {
1816  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
1817  $this->__setTabs('meta_lifecycle');
1818  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_lifecycle.html','Services/MetaData');
1819 
1820 
1821  $this->ctrl->setParameter($this, "section", "meta_lifecycle");
1822  if(!is_object($this->md_section = $this->md_obj->getLifecycle()))
1823  {
1824  $this->tpl->setCurrentBlock("no_lifecycle");
1825  $this->tpl->setVariable("TXT_NO_LIFECYCLE", $this->lng->txt("meta_no_lifecycle"));
1826  $this->tpl->setVariable("TXT_ADD_LIFECYCLE", $this->lng->txt("meta_add"));
1827  $this->tpl->setVariable("ACTION_ADD_LIFECYCLE",$this->ctrl->getLinkTarget($this, "addSection"));
1828  $this->tpl->parseCurrentBlock();
1829 
1830  return true;
1831  }
1832  $this->ctrl->setReturn($this,'listLifecycle');
1833  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
1834 
1835  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
1836  $this->tpl->setVariable("TXT_LIFECYCLE",$this->lng->txt('meta_lifecycle'));
1837 
1838  // Delete link
1839  $this->tpl->setVariable("ACTION_DELETE",
1840  $this->ctrl->getLinkTarget($this, "deleteSection"));
1841  $this->tpl->setVariable("TXT_DELETE",$this->lng->txt('delete'));
1842 
1843  // New element
1844  $this->__fillSubelements();
1845 
1846  // Status
1847  $this->tpl->setVariable("TXT_STATUS",$this->lng->txt('meta_status'));
1848  $this->tpl->setVariable("SEL_STATUS",ilMDUtilSelect::_getStatusSelect($this->md_section->getStatus(),
1849  "lif_status",
1850  array(0 => $this->lng->txt('meta_please_select'))));
1851  // Version
1852  $this->tpl->setVariable("TXT_VERSION",$this->lng->txt('meta_version'));
1853  $this->tpl->setVariable("VAL_VERSION",ilUtil::prepareFormOutput($this->md_section->getVersion()));
1854 
1855  $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt('meta_language'));
1856  $this->tpl->setVariable("VAL_VERSION_LANGUAGE",$this->__showLanguageSelect('lif_language',
1857  $this->md_section->getVersionLanguageCode()));
1858 
1859  // Contributes
1860  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
1861  {
1862  $md_con = $this->md_section->getContribute($con_id);
1863 
1864  if(count($ids) > 1)
1865  {
1866  $this->ctrl->setParameter($this,'meta_index',$con_id);
1867  $this->ctrl->setParameter($this,'meta_path','meta_contribute');
1868 
1869  $this->tpl->setCurrentBlock("contribute_delete");
1870  $this->tpl->setVariable("CONTRIBUTE_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1871  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1872  $this->tpl->parseCurrentBlock();
1873  }
1874  // Entities
1875  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
1876  {
1877  $md_ent = $md_con->getEntity($ent_id);
1878 
1879  $this->ctrl->setParameter($this,'meta_path','meta_entity');
1880 
1881  if(count($ent_ids) > 1)
1882  {
1883  $this->tpl->setCurrentBlock("contribute_entity_delete");
1884 
1885  $this->ctrl->setParameter($this,'meta_index',$ent_id);
1886  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
1887  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_DELETE",$this->lng->txt('delete'));
1888  $this->tpl->parseCurrentBlock();
1889  }
1890 
1891  $this->tpl->setCurrentBlock("contribute_entity_loop");
1892 
1893  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_CONTRIBUTE_NO",$con_id);
1894  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_NO",$ent_id);
1895  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_VAL_ENTITY",ilUtil::prepareFormOutput($md_ent->getEntity()));
1896  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_ENTITY",$this->lng->txt('meta_entity'));
1897  $this->tpl->parseCurrentBlock();
1898  }
1899  $this->tpl->setCurrentBlock("contribute_loop");
1900 
1901  $this->ctrl->setParameter($this,'section_element','meta_entity');
1902  $this->ctrl->setParameter($this,'meta_index',$con_id);
1903  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_ACTION_ADD",$this->ctrl->getLinkTarget($this,'addSectionElement'));
1904  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_ADD",
1905  $this->lng->txt('add')." ".$this->lng->txt('meta_entity'));
1906 
1907  $this->tpl->setVariable("CONTRIBUTE_LOOP_ROWSPAN",2 + count($ent_ids));
1908  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_CONTRIBUTE",$this->lng->txt('meta_contribute'));
1909  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_ROLE",$this->lng->txt('meta_role'));
1910  $this->tpl->setVariable("SEL_CONTRIBUTE_ROLE",ilMDUtilSelect::_getRoleSelect($md_con->getRole(),
1911  "met_contribute[".$con_id."][Role]",
1912  array(0 => $this->lng->txt('meta_please_select'))));
1913  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_DATE",$this->lng->txt('meta_date'));
1914  $this->tpl->setVariable("CONTRIBUTE_LOOP_NO",$con_id);
1915  $this->tpl->setVariable("CONTRIBUTE_LOOP_VAL_DATE",ilUtil::prepareFormOutput($md_con->getDate()));
1916 
1917  $this->tpl->parseCurrentBlock();
1918  }
1919  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
1920 
1921  }
1922 
1923  function updateLifecycle()
1924  {
1925  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
1926 
1927  // update metametadata section
1928  $this->md_section = $this->md_obj->getLifecycle();
1929  $this->md_section->setVersionLanguage(new ilMDLanguageItem($_POST['lif_language']));
1930  $this->md_section->setVersion(ilUtil::stripSlashes($_POST['lif_version']));
1931  $this->md_section->setStatus($_POST['lif_status']);
1932  $this->md_section->update();
1933 
1934  // Identifier
1935  if(is_array($_POST['met_identifier']))
1936  {
1937  foreach($_POST['met_identifier'] as $id => $data)
1938  {
1939  $md_ide = $this->md_section->getIdentifier($id);
1940  $md_ide->setCatalog(ilUtil::stripSlashes($data['Catalog']));
1941  $md_ide->setEntry(ilUtil::stripSlashes($data['Entry']));
1942  $md_ide->update();
1943  }
1944  }
1945  // Contribute
1946  if(is_array($_POST['met_contribute']))
1947  {
1948  foreach($_POST['met_contribute'] as $id => $data)
1949  {
1950  $md_con =& $this->md_section->getContribute($id);
1951  $md_con->setRole(ilUtil::stripSlashes($data['Role']));
1952  $md_con->setDate(ilUtil::stripSlashes($data['Date']));
1953  $md_con->update();
1954 
1955  if(is_array($_POST['met_entity'][$id]))
1956  {
1957  foreach($_POST['met_entity'][$id] as $ent_id => $data)
1958  {
1959  $md_ent =& $md_con->getEntity($ent_id);
1960  $md_ent->setEntity(ilUtil::stripSlashes($data['Entity']));
1961  $md_ent->update();
1962  }
1963  }
1964  }
1965  }
1966  $this->callListeners('Lifecycle');
1967  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
1968  $this->listSection();
1969  return true;
1970  }
1971 
1972 
1973 
1974 
1975 
1976  function listMetaMetaData()
1977  {
1978  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
1979  $this->__setTabs('meta_meta_metadata');
1980  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_meta_metadata.html','Services/MetaData');
1981 
1982 
1983  $this->ctrl->setParameter($this, "section", "meta_meta_metadata");
1984  if(!is_object($this->md_section = $this->md_obj->getMetaMetadata()))
1985  {
1986  $this->tpl->setCurrentBlock("no_meta_meta");
1987  $this->tpl->setVariable("TXT_NO_META_META", $this->lng->txt("meta_no_meta_metadata"));
1988  $this->tpl->setVariable("TXT_ADD_META_META", $this->lng->txt("meta_add"));
1989  $this->tpl->setVariable("ACTION_ADD_META_META",$this->ctrl->getLinkTarget($this, "addSection"));
1990  $this->tpl->parseCurrentBlock();
1991 
1992  return true;
1993  }
1994  $this->ctrl->setReturn($this,'listMetaMetaData');
1995  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
1996 
1997  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
1998  $this->tpl->setVariable("TXT_META_METADATA",$this->lng->txt('meta_meta_metadata'));
1999 
2000  // Delete link
2001  $this->tpl->setVariable("ACTION_DELETE",
2002  $this->ctrl->getLinkTarget($this, "deleteSection"));
2003  $this->tpl->setVariable("TXT_DELETE",$this->lng->txt('delete'));
2004 
2005  // New element
2006  $this->__fillSubelements();
2007 
2008  $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt('meta_language'));
2009 
2010  $this->tpl->setVariable("VAL_LANGUAGE",$this->__showLanguageSelect('met_language',$this->md_section->getLanguageCode()));
2011  $this->tpl->setVariable("TXT_METADATASCHEME",$this->lng->txt('meta_metadatascheme'));
2012  $this->tpl->setVariable("VAL_METADATASCHEME",$this->md_section->getMetaDataScheme());
2013 
2014 
2015  // Identifier
2016  foreach($ids = $this->md_section->getIdentifierIds() as $id)
2017  {
2018  $md_ide = $this->md_section->getIdentifier($id);
2019 
2020  if(count($ids) > 1)
2021  {
2022  $this->ctrl->setParameter($this,'meta_index',$id);
2023  $this->ctrl->setParameter($this,'meta_path','meta_identifier');
2024 
2025  $this->tpl->setCurrentBlock("identifier_delete");
2026  $this->tpl->setVariable("IDENTIFIER_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
2027  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_DELETE",$this->lng->txt('delete'));
2028  $this->tpl->parseCurrentBlock();
2029  }
2030 
2031  $this->tpl->setCurrentBlock("identifier_loop");
2032  $this->tpl->setVariable("IDENTIFIER_LOOP_NO", $id);
2033  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_IDENTIFIER", $this->lng->txt("meta_identifier"));
2034  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_CATALOG", $this->lng->txt("meta_catalog"));
2035  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_IDENTIFIER_CATALOG",
2036  ilUtil::prepareFormOutput($md_ide->getCatalog()));
2037  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_ENTRY", $this->lng->txt("meta_entry"));
2038  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_IDENTIFIER_ENTRY",
2039  ilUtil::prepareFormOutput($md_ide->getEntry()));
2040  $this->tpl->parseCurrentBlock();
2041  }
2042 
2043  // Contributes
2044  foreach(($ids = $this->md_section->getContributeIds()) as $con_id)
2045  {
2046  $md_con = $this->md_section->getContribute($con_id);
2047 
2048  if(count($ids) > 1)
2049  {
2050  $this->ctrl->setParameter($this,'meta_index',$con_id);
2051  $this->ctrl->setParameter($this,'meta_path','meta_contribute');
2052 
2053  $this->tpl->setCurrentBlock("contribute_delete");
2054  $this->tpl->setVariable("CONTRIBUTE_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
2055  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_DELETE",$this->lng->txt('delete'));
2056  $this->tpl->parseCurrentBlock();
2057  }
2058  // Entities
2059  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
2060  {
2061  $md_ent = $md_con->getEntity($ent_id);
2062 
2063  $this->ctrl->setParameter($this,'meta_path','meta_entity');
2064 
2065  if(count($ent_ids) > 1)
2066  {
2067  $this->tpl->setCurrentBlock("contribute_entity_delete");
2068 
2069  $this->ctrl->setParameter($this,'meta_index',$ent_id);
2070  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_ACTION_DELETE",$this->ctrl->getLinkTarget($this,'deleteElement'));
2071  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_DELETE",$this->lng->txt('delete'));
2072  $this->tpl->parseCurrentBlock();
2073  }
2074 
2075  $this->tpl->setCurrentBlock("contribute_entity_loop");
2076 
2077  $this->ctrl->setParameter($this,'section_element','meta_entity');
2078  $this->ctrl->setParameter($this,'meta_index',$con_id);
2079  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_ACTION_ADD",$this->ctrl->getLinkTarget($this,'addSectionElement'));
2080  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_ADD",$this->lng->txt('add'));
2081 
2082 
2083  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_CONTRIBUTE_NO",$con_id);
2084  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_NO",$ent_id);
2085  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_VAL_ENTITY",ilUtil::prepareFormOutput($md_ent->getEntity()));
2086  $this->tpl->setVariable("CONTRIBUTE_ENTITY_LOOP_TXT_ENTITY",$this->lng->txt('meta_entity'));
2087  $this->tpl->parseCurrentBlock();
2088  }
2089  $this->tpl->setCurrentBlock("contribute_loop");
2090  $this->tpl->setVariable("CONTRIBUTE_LOOP_ROWSPAN",2 + count($ent_ids));
2091  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_CONTRIBUTE",$this->lng->txt('meta_contribute'));
2092  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_ROLE",$this->lng->txt('meta_role'));
2093  $this->tpl->setVariable("SEL_CONTRIBUTE_ROLE",ilMDUtilSelect::_getRoleSelect($md_con->getRole(),
2094  "met_contribute[".$con_id."][Role]",
2095  array(0 => $this->lng->txt('meta_please_select'))));
2096  $this->tpl->setVariable("CONTRIBUTE_LOOP_TXT_DATE",$this->lng->txt('meta_date'));
2097  $this->tpl->setVariable("CONTRIBUTE_LOOP_NO",$con_id);
2098  $this->tpl->setVariable("CONTRIBUTE_LOOP_VAL_DATE",ilUtil::prepareFormOutput($md_con->getDate()));
2099 
2100  $this->tpl->parseCurrentBlock();
2101  }
2102  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
2103  }
2104 
2105 
2107  {
2108  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
2109 
2110  // update metametadata section
2111  $this->md_section = $this->md_obj->getMetaMetadata();
2112  $this->md_section->setLanguage(new ilMDLanguageItem($_POST['met_language']));
2113  $this->md_section->update();
2114 
2115  // Identifier
2116  if(is_array($_POST['met_identifier']))
2117  {
2118  foreach($_POST['met_identifier'] as $id => $data)
2119  {
2120  $md_ide = $this->md_section->getIdentifier($id);
2121  $md_ide->setCatalog(ilUtil::stripSlashes($data['Catalog']));
2122  $md_ide->setEntry(ilUtil::stripSlashes($data['Entry']));
2123  $md_ide->update();
2124  }
2125  }
2126  // Contribute
2127  if(is_array($_POST['met_contribute']))
2128  {
2129  foreach($_POST['met_contribute'] as $id => $data)
2130  {
2131  $md_con =& $this->md_section->getContribute($id);
2132  $md_con->setRole(ilUtil::stripSlashes($data['Role']));
2133  $md_con->setDate(ilUtil::stripSlashes($data['Date']));
2134  $md_con->update();
2135 
2136  if(is_array($_POST['met_entity'][$id]))
2137  {
2138  foreach($_POST['met_entity'][$id] as $ent_id => $data)
2139  {
2140  $md_ent =& $md_con->getEntity($ent_id);
2141  $md_ent->setEntity(ilUtil::stripSlashes($data['Entity']));
2142  $md_ent->update();
2143  }
2144  }
2145  }
2146  }
2147  $this->callListeners('MetaMetaData');
2148  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2149  $this->listSection();
2150  return true;
2151  }
2152 
2153 
2154  /*
2155  * list rights section
2156  */
2157  function listRights()
2158  {
2159  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
2160  $this->__setTabs('meta_rights');
2161  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_rights.html','Services/MetaData');
2162 
2163  if(!is_object($this->md_section = $this->md_obj->getRights()))
2164  {
2165  $this->tpl->setCurrentBlock("no_rights");
2166  $this->tpl->setVariable("TXT_NO_RIGHTS", $this->lng->txt("meta_no_rights"));
2167  $this->tpl->setVariable("TXT_ADD_RIGHTS", $this->lng->txt("meta_add"));
2168  $this->ctrl->setParameter($this, "section", "meta_rights");
2169  $this->tpl->setVariable("ACTION_ADD_RIGHTS",
2170  $this->ctrl->getLinkTarget($this, "addSection"));
2171  $this->tpl->parseCurrentBlock();
2172  }
2173  else
2174  {
2175 
2176  $this->ctrl->setReturn($this,'listRights');
2177  $this->ctrl->setParameter($this,'section','meta_rights');
2178  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
2179 
2180  $this->tpl->setVariable("TXT_RIGHTS", $this->lng->txt("meta_rights"));
2181  $this->tpl->setVariable("TXT_COST", $this->lng->txt("meta_cost"));
2182  $this->tpl->setVariable("TXT_COPYRIGHTANDOTHERRESTRICTIONS", $this->lng->txt("meta_copyright_and_other_restrictions"));
2183  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
2184  $this->tpl->setVariable("TXT_YES", $this->lng->txt("meta_yes"));
2185  $this->tpl->setVariable("TXT_NO", $this->lng->txt("meta_no"));
2186 
2187  $this->ctrl->setParameter($this, "section", "meta_rights");
2188  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
2189  $this->tpl->setVariable("ACTION_DELETE",
2190  $this->ctrl->getLinkTarget($this, "deleteSection"));
2191 
2192  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("meta_delete"));
2193 
2194  $this->tpl->setVariable("VAL_COST_".strtoupper($this->md_section->getCosts()), " selected");
2195  $this->tpl->setVariable("VAL_COPYRIGHTANDOTHERRESTRICTIONS_".
2196  strtoupper($this->md_section->getCopyrightAndOtherRestrictions()), " selected");
2197 
2198  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2199  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2200  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL", ilUtil::prepareFormOutput($this->md_section->getDescription()));
2201  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2202  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL_LANGUAGE",
2203  $this->__showLanguageSelect('rights[DescriptionLanguage]',
2204  $this->md_section->getDescriptionLanguageCode()));
2205 
2206  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2207 
2208  $this->tpl->setCurrentBlock("rights");
2209  $this->tpl->parseCurrentBlock();
2210 
2211  }
2212  }
2213 
2214  function updateRights()
2215  {
2216  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
2217 
2218  // update rights section
2219  $this->md_section = $this->md_obj->getRights();
2220  $this->md_section->setCosts($_POST['rights']['Cost']);
2221  $this->md_section->setCopyrightAndOtherRestrictions($_POST['rights']['CopyrightAndOtherRestrictions']);
2222  $this->md_section->setDescriptionLanguage(new ilMDLanguageItem($_POST['rights']['DescriptionLanguage']));
2223  $this->md_section->setDescription(ilUtil::stripSlashes($_POST['rights']['Description']));
2224  $this->md_section->update();
2225 
2226  $this->callListeners('Rights');
2227  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2228  $this->listSection();
2229  }
2230 
2231  /*
2232  * list educational section
2233  */
2234  function listEducational()
2235  {
2236  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
2237  $this->__setTabs('meta_educational');
2238  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_educational.html','Services/MetaData');
2239 
2240  if(!is_object($this->md_section = $this->md_obj->getEducational()))
2241  {
2242  $this->tpl->setCurrentBlock("no_educational");
2243  $this->tpl->setVariable("TXT_NO_EDUCATIONAL", $this->lng->txt("meta_no_educational"));
2244  $this->tpl->setVariable("TXT_ADD_EDUCATIONAL", $this->lng->txt("meta_add"));
2245  $this->ctrl->setParameter($this, "section", "meta_educational");
2246  $this->tpl->setVariable("ACTION_ADD_EDUCATIONAL",
2247  $this->ctrl->getLinkTarget($this, "addSection"));
2248  $this->tpl->parseCurrentBlock();
2249  }
2250  else
2251  {
2252  $this->ctrl->setReturn($this,'listEducational');
2253  $this->ctrl->setParameter($this,'section','meta_educational');
2254  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
2255 
2256  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
2257  $this->tpl->setVariable("ACTION_DELETE",
2258  $this->ctrl->getLinkTarget($this, "deleteSection"));
2259 
2260  $this->tpl->setVariable("TXT_EDUCATIONAL", $this->lng->txt("meta_educational"));
2261  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("meta_delete"));
2262  $this->tpl->setVariable("TXT_NEW_ELEMENT", $this->lng->txt("meta_new_element"));
2263  $this->tpl->setVariable("TXT_TYPICALAGERANGE", $this->lng->txt("meta_typical_age_range"));
2264  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2265  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("meta_language"));
2266  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("meta_add"));
2267  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
2268 
2269  $this->tpl->setVariable("TXT_INTERACTIVITYTYPE", $this->lng->txt("meta_interactivity_type"));
2270  $this->tpl->setVariable("TXT_LEARNINGRESOURCETYPE", $this->lng->txt("meta_learning_resource_type"));
2271  $this->tpl->setVariable("TXT_INTERACTIVITYLEVEL", $this->lng->txt("meta_interactivity_level"));
2272  $this->tpl->setVariable("TXT_SEMANTICDENSITY", $this->lng->txt("meta_semantic_density"));
2273  $this->tpl->setVariable("TXT_INTENDEDENDUSERROLE", $this->lng->txt("meta_intended_end_user_role"));
2274  $this->tpl->setVariable("TXT_CONTEXT", $this->lng->txt("meta_context"));
2275  $this->tpl->setVariable("TXT_DIFFICULTY", $this->lng->txt("meta_difficulty"));
2276 
2277  $this->tpl->setVariable("VAL_INTERACTIVITYTYPE_" . strtoupper($this->md_section->getInteractivityType()), " selected");
2278  $this->tpl->setVariable("VAL_LEARNINGRESOURCETYPE_" . strtoupper($this->md_section->getLearningResourceType()), " selected");
2279  $this->tpl->setVariable("VAL_INTERACTIVITYLEVEL_" . strtoupper($this->md_section->getInteractivityLevel()), " selected");
2280  $this->tpl->setVariable("VAL_SEMANTICDENSITY_" . strtoupper($this->md_section->getSemanticDensity()), " selected");
2281  $this->tpl->setVariable("VAL_INTENDEDENDUSERROLE_" . strtoupper($this->md_section->getIntendedEndUserRole()), " selected");
2282  $this->tpl->setVariable("VAL_CONTEXT_" . strtoupper($this->md_section->getContext()), " selected");
2283  $this->tpl->setVariable("VAL_DIFFICULTY_" . strtoupper($this->md_section->getDifficulty()), " selected");
2284  #$this->tpl->setVariable("VAL_TYPICALLEARNINGTIME", ilUtil::prepareFormOutput($this->md_section->getTypicalLearningTime()));
2285 
2286  $this->tpl->setVariable("TXT_ACTIVE", $this->lng->txt("meta_active"));
2287  $this->tpl->setVariable("TXT_EXPOSITIVE", $this->lng->txt("meta_expositive"));
2288  $this->tpl->setVariable("TXT_MIXED", $this->lng->txt("meta_mixed"));
2289  $this->tpl->setVariable("TXT_EXERCISE", $this->lng->txt("meta_exercise"));
2290  $this->tpl->setVariable("TXT_SIMULATION", $this->lng->txt("meta_simulation"));
2291  $this->tpl->setVariable("TXT_QUESTIONNAIRE", $this->lng->txt("meta_questionnaire"));
2292  $this->tpl->setVariable("TXT_DIAGRAMM", $this->lng->txt("meta_diagramm"));
2293  $this->tpl->setVariable("TXT_FIGURE", $this->lng->txt("meta_figure"));
2294  $this->tpl->setVariable("TXT_GRAPH", $this->lng->txt("meta_graph"));
2295  $this->tpl->setVariable("TXT_INDEX", $this->lng->txt("meta_index"));
2296  $this->tpl->setVariable("TXT_SLIDE", $this->lng->txt("meta_slide"));
2297  $this->tpl->setVariable("TXT_TABLE", $this->lng->txt("meta_table"));
2298  $this->tpl->setVariable("TXT_NARRATIVETEXT", $this->lng->txt("meta_narrative_text"));
2299  $this->tpl->setVariable("TXT_EXAM", $this->lng->txt("meta_exam"));
2300  $this->tpl->setVariable("TXT_EXPERIMENT", $this->lng->txt("meta_experiment"));
2301  $this->tpl->setVariable("TXT_PROBLEMSTATEMENT", $this->lng->txt("meta_problem_statement"));
2302  $this->tpl->setVariable("TXT_SELFASSESSMENT", $this->lng->txt("meta_self_assessment"));
2303  $this->tpl->setVariable("TXT_LECTURE", $this->lng->txt("meta_lecture"));
2304  $this->tpl->setVariable("TXT_VERYLOW", $this->lng->txt("meta_very_low"));
2305  $this->tpl->setVariable("TXT_LOW", $this->lng->txt("meta_low"));
2306  $this->tpl->setVariable("TXT_MEDIUM", $this->lng->txt("meta_medium"));
2307  $this->tpl->setVariable("TXT_HIGH", $this->lng->txt("meta_high"));
2308  $this->tpl->setVariable("TXT_VERYHIGH", $this->lng->txt("meta_very_high"));
2309  $this->tpl->setVariable("TXT_TEACHER", $this->lng->txt("meta_teacher"));
2310  $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author"));
2311  $this->tpl->setVariable("TXT_LEARNER", $this->lng->txt("meta_learner"));
2312  $this->tpl->setVariable("TXT_MANAGER", $this->lng->txt("meta_manager"));
2313  $this->tpl->setVariable("TXT_SCHOOL", $this->lng->txt("meta_school"));
2314  $this->tpl->setVariable("TXT_HIGHEREDUCATION", $this->lng->txt("meta_higher_education"));
2315  $this->tpl->setVariable("TXT_TRAINING", $this->lng->txt("meta_training"));
2316  $this->tpl->setVariable("TXT_OTHER", $this->lng->txt("meta_other"));
2317  $this->tpl->setVariable("TXT_VERYEASY", $this->lng->txt("meta_very_easy"));
2318  $this->tpl->setVariable("TXT_EASY", $this->lng->txt("meta_easy"));
2319  $this->tpl->setVariable("TXT_DIFFICULT", $this->lng->txt("meta_difficult"));
2320  $this->tpl->setVariable("TXT_VERYDIFFICULT", $this->lng->txt("meta_very_difficult"));
2321  $this->tpl->setVariable("TXT_TYPICALLEARNINGTIME", $this->lng->txt("meta_typical_learning_time"));
2322 
2323 
2324  // Typical learning time
2325  $tlt = array(0,0,0,0,0);
2326  $valid = true;
2327 
2328  include_once 'Services/MetaData/classes/class.ilMDUtils.php';
2329 
2330  if(!$tlt = ilMDUtils::_LOMDurationToArray($this->md_section->getTypicalLearningTime()))
2331  {
2332  if(strlen($this->md_section->getTypicalLearningTime()))
2333  {
2334  $tlt = array(0,0,0,0,0);
2335  $valid = false;
2336  }
2337  }
2338 
2339  $this->tpl->setVariable("TXT_MONTH",$this->lng->txt('md_months'));
2340  $this->tpl->setVariable("SEL_MONTHS",$this->__buildMonthsSelect($tlt[0]));
2341  $this->tpl->setVariable("SEL_DAYS",$this->__buildDaysSelect($tlt[1]));
2342 
2343  $this->tpl->setVariable("TXT_DAYS",$this->lng->txt('md_days'));
2344  $this->tpl->setVariable("TXT_TIME",$this->lng->txt('md_time'));
2345 
2346  $this->tpl->setVariable("TXT_TYPICAL_LEARN_TIME",$this->lng->txt('meta_typical_learning_time'));
2347  $this->tpl->setVariable("SEL_TLT",ilUtil::makeTimeSelect('tlt',$tlt[4] ? false : true,
2348  $tlt[2],$tlt[3],$tlt[4],
2349  false));
2350  $this->tpl->setVariable("TLT_HINT",$tlt[4] ? '(hh:mm:ss)' : '(hh:mm)');
2351 
2352  if(!$valid)
2353  {
2354  $this->tpl->setCurrentBlock("tlt_not_valid");
2355  $this->tpl->setVariable("TXT_CURRENT_VAL",$this->lng->txt('meta_current_value'));
2356  $this->tpl->setVariable("TLT",$this->md_section->getTypicalLearningTime());
2357  $this->tpl->setVariable("INFO_TLT_NOT_VALID",$this->lng->txt('meta_info_tlt_not_valid'));
2358  $this->tpl->parseCurrentBlock();
2359  }
2360 
2361 
2362  /* TypicalAgeRange */
2363  $first = true;
2364  foreach($ids = $this->md_section->getTypicalAgeRangeIds() as $id)
2365  {
2366  $md_age = $this->md_section->getTypicalAgeRange($id);
2367 
2368  // extra test due to bug 5316 (may be due to eLaix import)
2369  if (is_object($md_age))
2370  {
2371 
2372  if ($first)
2373  {
2374  $this->tpl->setCurrentBlock("agerange_head");
2375  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_TXT_TYPICALAGERANGE",
2376  $this->lng->txt("meta_typical_age_range"));
2377  $this->tpl->setVariable("ROWSPAN_AGERANGE", count($ids));
2378  $this->tpl->parseCurrentBlock();
2379  $first = false;
2380  }
2381 
2382 
2383  $this->ctrl->setParameter($this, 'meta_index', $id);
2384  $this->ctrl->setParameter($this, 'meta_path', 'educational_typical_age_range');
2385 
2386  $this->tpl->setCurrentBlock("typicalagerange_delete");
2387  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_ACTION_DELETE",
2388  $this->ctrl->getLinkTarget($this, "deleteElement"));
2389  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2390  $this->tpl->parseCurrentBlock();
2391 
2392  $this->tpl->setCurrentBlock("typicalagerange_loop");
2393  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2394  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_VAL", ilUtil::prepareFormOutput($md_age->getTypicalAgeRange()));
2395  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_NO", $id);
2396  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2397  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_VAL_LANGUAGE",
2398  $this->__showLanguageSelect('educational[TypicalAgeRange]['.$id.'][Language]',
2399  $md_age->getTypicalAgeRangeLanguageCode()));
2400  $this->ctrl->setParameter($this, "section_element", "educational_typical_age_range");
2401  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_ACTION_ADD",
2402  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2403  $this->tpl->setVariable("TYPICALAGERANGE_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2404  $this->tpl->parseCurrentBlock();
2405  }
2406  }
2407 
2408  /* Description */
2409  $first = true;
2410  foreach($ids = $this->md_section->getDescriptionIds() as $id)
2411  {
2412  if ($first)
2413  {
2414  $this->tpl->setCurrentBlock("desc_head");
2415  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2416  $this->tpl->setVariable("ROWSPAN_DESC", count($ids));
2417  $this->tpl->parseCurrentBlock();
2418  $first = false;
2419  }
2420 
2421  $md_des = $this->md_section->getDescription($id);
2422 
2423  $this->ctrl->setParameter($this, 'meta_index', $id);
2424  $this->ctrl->setParameter($this, 'meta_path', 'educational_description');
2425 
2426  $this->tpl->setCurrentBlock("description_loop");
2427  $this->tpl->setVariable("DESCRIPTION_LOOP_NO", $id);
2428  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2429  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL", ilUtil::prepareFormOutput($md_des->getDescription()));
2430  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2431  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL_LANGUAGE",
2432  $this->__showLanguageSelect('educational[Description]['.$id.'][Language]',
2433  $md_des->getDescriptionLanguageCode()));
2434  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_DELETE",
2435  $this->ctrl->getLinkTarget($this, "deleteElement"));
2436  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2437  $this->ctrl->setParameter($this, "section_element", "educational_description");
2438  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_ADD",
2439  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2440  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2441  $this->tpl->parseCurrentBlock();
2442  }
2443 
2444 
2445  /* Language */
2446  $first = true;
2447  foreach($ids = $this->md_section->getLanguageIds() as $id)
2448  {
2449  if ($first)
2450  {
2451  $this->tpl->setCurrentBlock("language_head");
2452  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2453  $this->tpl->setVariable("ROWSPAN_LANG", count($ids));
2454  $this->tpl->parseCurrentBlock();
2455  $first = false;
2456  }
2457 
2458  $md_lang = $this->md_section->getLanguage($id);
2459 
2460  $this->ctrl->setParameter($this, 'meta_index', $id);
2461  $this->ctrl->setParameter($this, 'meta_path', 'educational_language');
2462 
2463  $this->tpl->setCurrentBlock("language_loop");
2464  $this->tpl->setVariable("LANGUAGE_LOOP_VAL_LANGUAGE",
2465  $this->__showLanguageSelect('educational[Language]['.$id.']',
2466  $md_lang->getLanguageCode()));
2467 
2468  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_DELETE",
2469  $this->ctrl->getLinkTarget($this, "deleteElement"));
2470  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2471  $this->ctrl->setParameter($this, "section_element", "educational_language");
2472  $this->tpl->setVariable("LANGUAGE_LOOP_ACTION_ADD",
2473  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2474  $this->tpl->setVariable("LANGUAGE_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2475  $this->tpl->parseCurrentBlock();
2476 
2477  }
2478 
2479  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2480 
2481  $this->tpl->setCurrentBlock("educational");
2482  $this->tpl->parseCurrentBlock();
2483  }
2484  }
2485 
2487  {
2488  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
2489 
2490  // update rights section
2491  $this->md_section = $this->md_obj->getEducational();
2492  $this->md_section->setInteractivityType($_POST['educational']['InteractivityType']);
2493  $this->md_section->setLearningResourceType($_POST['educational']['LearningResourceType']);
2494  $this->md_section->setInteractivityLevel($_POST['educational']['InteractivityLevel']);
2495  $this->md_section->setSemanticDensity($_POST['educational']['SemanticDensity']);
2496  $this->md_section->setIntendedEndUserRole($_POST['educational']['IntendedEndUserRole']);
2497  $this->md_section->setContext($_POST['educational']['Context']);
2498  $this->md_section->setDifficulty($_POST['educational']['Difficulty']);
2499 
2500 
2501  // TLT
2502 
2503  if($_POST['tlt']['mo'] or $_POST['tlt']['d'] or
2504  $_POST['tlt']['h'] or $_POST['tlt']['m'] or $_POST['tlt']['s'])
2505  {
2506  $this->md_section->setPhysicalTypicalLearningTime((int)$_POST['tlt']['mo'],(int)$_POST['tlt']['d'],
2507  (int)$_POST['tlt']['h'],(int)$_POST['tlt']['m'],(int)$_POST['tlt']['s']);
2508  }
2509  else
2510  {
2511  $this->md_section->setTypicalLearningTime('');
2512  }
2513  $this->callListeners('Educational');
2514 
2515 
2516  /* TypicalAgeRange */
2517  foreach($ids = $this->md_section->getTypicalAgeRangeIds() as $id)
2518  {
2519  $md_age = $this->md_section->getTypicalAgeRange($id);
2520  $md_age->setTypicalAgeRange(ilUtil::stripSlashes($_POST['educational']['TypicalAgeRange'][$id]['Value']));
2521  $md_age->setTypicalAgeRangeLanguage(
2522  new ilMDLanguageItem($_POST['educational']['TypicalAgeRange'][$id]['Language']));
2523  $md_age->update();
2524  }
2525 
2526  /* Description */
2527  foreach($ids = $this->md_section->getDescriptionIds() as $id)
2528  {
2529  $md_des = $this->md_section->getDescription($id);
2530  $md_des->setDescription(ilUtil::stripSlashes($_POST['educational']['Description'][$id]['Value']));
2531  $md_des->setDescriptionLanguage(
2532  new ilMDLanguageItem($_POST['educational']['Description'][$id]['Language']));
2533  $md_des->update();
2534  }
2535 
2536  /* Language */
2537  foreach($ids = $this->md_section->getLanguageIds() as $id)
2538  {
2539  $md_lang = $this->md_section->getLanguage($id);
2540  $md_lang->setLanguage(
2541  new ilMDLanguageItem($_POST['educational']['Language'][$id]));
2542  $md_lang->update();
2543  }
2544 
2545  $this->md_section->update();
2546 
2547  $this->callListeners('Educational');
2548  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2549  $this->listSection();
2550  }
2551 
2552  /*
2553  * list relation section
2554  */
2555  function listRelation()
2556  {
2557  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
2558  $this->__setTabs('meta_relation');
2559  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_relation.html','Services/MetaData');
2560 
2561  $rel_ids = $this->md_obj->getRelationIds();
2562  if (!is_array($rel_ids) || count($rel_ids) == 0)
2563  {
2564  $this->tpl->setCurrentBlock("no_relation");
2565  $this->tpl->setVariable("TXT_NO_RELATION", $this->lng->txt("meta_no_relation"));
2566  $this->tpl->setVariable("TXT_ADD_RELATION", $this->lng->txt("meta_add"));
2567  $this->ctrl->setParameter($this, "section", "meta_relation");
2568  $this->tpl->setVariable("ACTION_ADD_RELATION",
2569  $this->ctrl->getLinkTarget($this, "addSection"));
2570  $this->tpl->parseCurrentBlock();
2571  }
2572  else
2573  {
2574  foreach($rel_ids as $rel_id)
2575  {
2576  $this->md_section = $this->md_obj->getRelation($rel_id);
2577 
2578  $this->ctrl->setParameter($this, 'meta_index', $rel_id);
2579  $this->ctrl->setParameter($this, "section", "meta_relation");
2580 
2581  /* Identifier_ */
2582  $res_ids = $this->md_section->getIdentifier_Ids();
2583  foreach ($res_ids as $res_id)
2584  {
2585  $ident = $this->md_section->getIdentifier_($res_id);
2586  $this->ctrl->setParameter($this, "meta_index", $res_id);
2587 
2588  if (count($res_ids) > 1)
2589  {
2590  $this->tpl->setCurrentBlock("identifier_delete");
2591  $this->ctrl->setParameter($this, "meta_path", "relation_resource_identifier");
2592  $this->tpl->setVariable("IDENTIFIER_LOOP_ACTION_DELETE",
2593  $this->ctrl->getLinkTarget($this, "deleteElement"));
2594  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2595  $this->tpl->parseCurrentBlock();
2596  }
2597 
2598  $this->tpl->setCurrentBlock("identifier_loop");
2599 
2600  $this->tpl->setVariable("IDENTIFIER_LOOP_NO", $res_id);
2601  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_IDENTIFIER", $this->lng->txt("meta_identifier"));
2602  $this->ctrl->setParameter($this, 'meta_index', $rel_id);
2603  $this->ctrl->setParameter($this, "section_element", "relation_resource_identifier");
2604  $this->tpl->setVariable("IDENTIFIER_LOOP_ACTION_ADD",
2605  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2606  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2607  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_ENTRY", $this->lng->txt("meta_entry"));
2608  $this->tpl->setVariable("IDENTIFIER_LOOP_TXT_CATALOG", $this->lng->txt("meta_catalog"));
2609  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_CATALOG",
2610  ilUtil::prepareFormOutput($ident->getCatalog()));
2611  $this->tpl->setVariable("IDENTIFIER_LOOP_VAL_ENTRY",
2612  ilUtil::prepareFormOutput($ident->getEntry()));
2613  $this->tpl->parseCurrentBlock();
2614  }
2615 
2616  /* Description */
2617  $res_dess = $this->md_section->getDescriptionIds();
2618  foreach ($res_dess as $res_des)
2619  {
2620  $des = $this->md_section->getDescription($res_des);
2621  $this->ctrl->setParameter($this, "meta_index", $res_des);
2622 
2623  if (count($res_dess) > 1)
2624  {
2625  $this->tpl->setCurrentBlock("description_delete");
2626  $this->ctrl->setParameter($this, "meta_path", "relation_resource_description");
2627  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_DELETE",
2628  $this->ctrl->getLinkTarget($this, "deleteElement"));
2629  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2630  $this->tpl->parseCurrentBlock();
2631  }
2632 
2633  $this->tpl->setCurrentBlock("description_loop");
2634  $this->tpl->setVariable("DESCRIPTION_LOOP_NO", $res_des);
2635  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2636  $this->ctrl->setParameter($this, 'meta_index', $rel_id);
2637  $this->ctrl->setParameter($this, "section_element", "relation_resource_description");
2638  $this->tpl->setVariable("DESCRIPTION_LOOP_ACTION_ADD",
2639  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2640  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2641  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2642  $this->tpl->setVariable("DESCRIPTION_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2643  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL",
2644  ilUtil::prepareFormOutput($des->getDescription()));
2645  $this->tpl->setVariable("DESCRIPTION_LOOP_VAL_LANGUAGE",
2646  $this->__showLanguageSelect('relation[Resource][Description]['.$res_des.'][Language]',
2647  $des->getDescriptionLanguageCode()));
2648  $this->tpl->parseCurrentBlock();
2649  }
2650 
2651  $this->tpl->setCurrentBlock("relation_loop");
2652  $this->tpl->setVariable("REL_ID", $rel_id);
2653  $this->tpl->setVariable("TXT_RELATION", $this->lng->txt("meta_relation"));
2654  $this->ctrl->setParameter($this, "meta_index", $this->md_section->getMetaId());
2655  $this->tpl->setVariable("ACTION_DELETE",
2656  $this->ctrl->getLinkTarget($this, "deleteSection"));
2657  $this->ctrl->setParameter($this, "section", "meta_relation");
2658  $this->tpl->setVariable("ACTION_ADD",
2659  $this->ctrl->getLinkTarget($this, "addSection"));
2660  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("meta_delete"));
2661  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("meta_add"));
2662  $this->tpl->setVariable("TXT_NEW_ELEMENT", $this->lng->txt("meta_new_element"));
2663  $this->tpl->setVariable("TXT_KIND", $this->lng->txt("meta_kind"));
2664  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
2665  $this->tpl->setVariable("TXT_ISPARTOF", $this->lng->txt("meta_is_part_of"));
2666  $this->tpl->setVariable("TXT_HASPART", $this->lng->txt("meta_has_part"));
2667  $this->tpl->setVariable("TXT_ISVERSIONOF", $this->lng->txt("meta_is_version_of"));
2668  $this->tpl->setVariable("TXT_HASVERSION", $this->lng->txt("meta_has_version"));
2669  $this->tpl->setVariable("TXT_ISFORMATOF", $this->lng->txt("meta_is_format_of"));
2670  $this->tpl->setVariable("TXT_HASFORMAT", $this->lng->txt("meta_has_format"));
2671  $this->tpl->setVariable("TXT_REFERENCES", $this->lng->txt("meta_references"));
2672  $this->tpl->setVariable("TXT_ISREFERENCEDBY", $this->lng->txt("meta_is_referenced_by"));
2673  $this->tpl->setVariable("TXT_ISBASEDON", $this->lng->txt("meta_is_based_on"));
2674  $this->tpl->setVariable("TXT_ISBASISFOR", $this->lng->txt("meta_is_basis_for"));
2675  $this->tpl->setVariable("TXT_REQUIRES", $this->lng->txt("meta_requires"));
2676  $this->tpl->setVariable("TXT_ISREQUIREDBY", $this->lng->txt("meta_is_required_by"));
2677  $this->tpl->setVariable("TXT_RESOURCE", $this->lng->txt("meta_resource"));
2678  $this->tpl->setVariable("VAL_KIND_" . strtoupper($this->md_section->getKind()), " selected");
2679  $this->tpl->parseCurrentBlock();
2680  }
2681 
2682  $this->tpl->setCurrentBlock("relation");
2683  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
2684  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2685  $this->tpl->parseCurrentBlock();
2686  }
2687  }
2688 
2689  function updateRelation()
2690  {
2691  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
2692 
2693  // relation
2694  foreach($ids = $this->md_obj->getRelationIds() as $id)
2695  {
2696  // kind
2697  $relation = $this->md_obj->getRelation($id);
2698  $relation->setKind($_POST['relation'][$id]['Kind']);
2699 
2700  $relation->update();
2701 
2702  // identifiers
2703  $res_idents = $relation->getIdentifier_Ids();
2704  foreach ($res_idents as $res_id)
2705  {
2706  $ident = $relation->getIdentifier_($res_id);
2707  $ident->setCatalog(ilUtil::stripSlashes($_POST['relation']['Resource']['Identifier'][$res_id][Catalog]));
2708  $ident->setEntry(ilUtil::stripSlashes($_POST['relation']['Resource']['Identifier'][$res_id][Entry]));
2709  $ident->update();
2710  }
2711 
2712  // descriptions
2713  $res_dess = $relation->getDescriptionIds();
2714  foreach ($res_dess as $res_des)
2715  {
2716  $des = $relation->getDescription($res_des);
2717  $des->setDescription(ilUtil::stripSlashes($_POST['relation']['Resource']['Description'][$res_des][Value]));
2718  $des->setDescriptionLanguage(
2719  new ilMDLanguageItem($_POST['relation']['Resource']['Description'][$res_des]['Language']));
2720  $des->update();
2721  }
2722  }
2723 
2724  $this->callListeners('Relation');
2725  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2726  $this->listSection();
2727  }
2728 
2729  /*
2730  * list annotation section
2731  */
2732  function listAnnotation()
2733  {
2734  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
2735  $this->__setTabs('meta_annotation');
2736  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_annotation.html','Services/MetaData');
2737 
2738  $anno_ids = $this->md_obj->getAnnotationIds();
2739  if (!is_array($anno_ids) || count($anno_ids) == 0)
2740  {
2741  $this->tpl->setCurrentBlock("no_annotation");
2742  $this->tpl->setVariable("TXT_NO_ANNOTATION", $this->lng->txt("meta_no_annotation"));
2743  $this->tpl->setVariable("TXT_ADD_ANNOTATION", $this->lng->txt("meta_add"));
2744  $this->ctrl->setParameter($this, "section", "meta_annotation");
2745  $this->tpl->setVariable("ACTION_ADD_ANNOTATION",
2746  $this->ctrl->getLinkTarget($this, "addSection"));
2747  $this->tpl->parseCurrentBlock();
2748  }
2749  else
2750  {
2751  foreach($anno_ids as $anno_id)
2752  {
2753  $this->ctrl->setParameter($this, 'meta_index', $anno_id);
2754  $this->ctrl->setParameter($this, "section", "meta_annotation");
2755 
2756  $this->md_section = $this->md_obj->getAnnotation($anno_id);
2757 
2758  $this->tpl->setCurrentBlock("annotation_loop");
2759  $this->tpl->setVariable("ANNOTATION_ID", $anno_id);
2760  $this->tpl->setVariable("TXT_ANNOTATION", $this->lng->txt("meta_annotation"));
2761  $this->ctrl->setParameter($this, "meta_index", $anno_id);
2762  $this->tpl->setVariable("ACTION_DELETE",
2763  $this->ctrl->getLinkTarget($this, "deleteSection"));
2764  $this->ctrl->setParameter($this, "section", "meta_annotation");
2765  $this->tpl->setVariable("ACTION_ADD",
2766  $this->ctrl->getLinkTarget($this, "addSection"));
2767  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("meta_delete"));
2768  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("meta_add"));
2769 
2770  $this->tpl->setVariable("TXT_ENTITY", $this->lng->txt("meta_entity"));
2771  $this->tpl->setVariable("VAL_ENTITY", ilUtil::prepareFormOutput($this->md_section->getEntity()));
2772  $this->tpl->setVariable("TXT_DATE", $this->lng->txt("meta_date"));
2773  $this->tpl->setVariable("VAL_DATE", ilUtil::prepareFormOutput($this->md_section->getDate()));
2774 
2775  /* Description */
2776  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2777  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("meta_value"));
2778  $this->tpl->setVariable("VAL_DESCRIPTION", ilUtil::prepareFormOutput($this->md_section->getDescription()));
2779  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("meta_language"));
2780  $this->tpl->setVariable("VAL_DESCRIPTION_LANGUAGE",
2781  $this->__showLanguageSelect('annotation['.$anno_id.'][Language]',
2782  $this->md_section->getDescriptionLanguageCode()));
2783 
2784  $this->tpl->parseCurrentBlock();
2785  }
2786 
2787  $this->tpl->setCurrentBlock("annotation");
2788  $this->tpl->setVariable("EDIT_ACTION",$this->ctrl->getFormAction($this));
2789  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2790  $this->tpl->parseCurrentBlock();
2791  }
2792  }
2793 
2794  function updateAnnotation()
2795  {
2796  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
2797 
2798  // relation
2799  foreach($ids = $this->md_obj->getAnnotationIds() as $id)
2800  {
2801  // entity
2802  $annotation = $this->md_obj->getAnnotation($id);
2803  $annotation->setEntity(ilUtil::stripSlashes($_POST['annotation'][$id]['Entity']));
2804  $annotation->setDate(ilUtil::stripSlashes($_POST['annotation'][$id]['Date']));
2805  $annotation->setDescription(ilUtil::stripSlashes($_POST['annotation'][$id]['Description']));
2806  $annotation->setDescriptionLanguage(
2807  new ilMDLanguageItem($_POST['annotation'][$id]['Language']));
2808 
2809  $annotation->update();
2810  }
2811 
2812  $this->callListeners('Annotation');
2813  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2814  $this->listSection();
2815  }
2816 
2817  /*
2818  * list classification section
2819  */
2821  {
2822  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.md_editor.html','Services/MetaData');
2823  $this->__setTabs('meta_classification');
2824  $this->tpl->addBlockFile('MD_CONTENT','md_content','tpl.md_classification.html','Services/MetaData');
2825 
2826  $class_ids = $this->md_obj->getClassificationIds();
2827  if (!is_array($class_ids) || count($class_ids) == 0)
2828  {
2829  $this->tpl->setCurrentBlock("no_classification");
2830  $this->tpl->setVariable("TXT_NO_CLASSIFICATION", $this->lng->txt("meta_no_classification"));
2831  $this->tpl->setVariable("TXT_ADD_CLASSIFICATION", $this->lng->txt("meta_add"));
2832  $this->ctrl->setParameter($this, "section", "meta_classification");
2833  $this->tpl->setVariable("ACTION_ADD_CLASSIFICATION",
2834  $this->ctrl->getLinkTarget($this, "addSection"));
2835  $this->tpl->parseCurrentBlock();
2836  }
2837  else
2838  {
2839  foreach($class_ids as $class_id)
2840  {
2841  $this->md_section = $this->md_obj->getClassification($class_id);
2842  $this->ctrl->setParameter($this, "section", "meta_classification");
2843 
2844  /* TaxonPath */
2845  $tp_ids = $this->md_section->getTaxonPathIds();
2846  foreach ($tp_ids as $tp_id)
2847  {
2848  $tax_path = $this->md_section->getTaxonPath($tp_id);
2849 
2850  $tax_ids = $tax_path->getTaxonIds();
2851 
2852  foreach($tax_ids as $tax_id)
2853  {
2854  $taxon = $tax_path->getTaxon($tax_id);
2855 
2856  if (count($tax_ids) > 1)
2857  {
2858  $this->tpl->setCurrentBlock("taxon_delete");
2859  $this->ctrl->setParameter($this, "meta_index", $tax_id);
2860  $this->ctrl->setParameter($this, "meta_path", "classification_taxon");
2861  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_ACTION_DELETE",
2862  $this->ctrl->getLinkTarget($this, "deleteElement"));
2863  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2864  $this->tpl->parseCurrentBlock();
2865  }
2866 
2867  $this->tpl->setCurrentBlock("taxonpath_taxon_loop");
2868  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_NO", $tax_id);
2869  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TAXONPATH_NO", $tp_id);
2870  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_TAXON", $this->lng->txt("meta_taxon"));
2871  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2872  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_VAL_TAXON", ilUtil::prepareFormOutput($taxon->getTaxon()));
2873  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_ID", $this->lng->txt("meta_id"));
2874  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_VAL_ID", ilUtil::prepareFormOutput($taxon->getTaxonId()));
2875  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2876  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_VAL_TAXON_LANGUAGE",
2877  $this->__showLanguageSelect('classification[TaxonPath][Taxon]['.$tax_id.'][Language]',
2878  $taxon->getTaxonLanguageCode()));
2879 
2880  $this->ctrl->setParameter($this, "section_element", "Taxon_".$class_id);
2881  $this->ctrl->setParameter($this, "meta_index", $tp_id);
2882  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_ACTION_ADD",
2883  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2884  $this->tpl->setVariable("TAXONPATH_TAXON_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2885  $this->tpl->parseCurrentBlock();
2886  }
2887 
2888  if (count($tp_ids) > 1)
2889  {
2890  $this->tpl->setCurrentBlock("taxonpath_delete");
2891  $this->ctrl->setParameter($this, "meta_index", $tp_id);
2892  $this->ctrl->setParameter($this, "meta_path", "classification_taxon_path");
2893  $this->tpl->setVariable("TAXONPATH_LOOP_ACTION_DELETE",
2894  $this->ctrl->getLinkTarget($this, "deleteElement"));
2895  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2896  $this->tpl->parseCurrentBlock();
2897  }
2898 
2899  $this->tpl->setCurrentBlock("taxonpath_loop");
2900  $this->tpl->setVariable("TAXONPATH_LOOP_NO", $tp_id);
2901  $this->tpl->setVariable("TAXONPATH_LOOP_ROWSPAN", (3 * count($tax_ids)) + 2);
2902  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_TAXONPATH", $this->lng->txt("meta_taxon_path"));
2903  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_SOURCE", $this->lng->txt("meta_source"));
2904  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2905  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2906  $this->tpl->setVariable("TAXONPATH_LOOP_VAL_SOURCE", ilUtil::prepareFormOutput($tax_path->getSource()));
2907  $this->tpl->setVariable("TAXONPATH_LOOP_VAL_SOURCE_LANGUAGE",
2908  $this->__showLanguageSelect('classification[TaxonPath]['.$tp_id.'][Source][Language]',
2909  $tax_path->getSourceLanguageCode()));
2910  $this->ctrl->setParameter($this, "section_element", "TaxonPath_".$class_id);
2911  $this->ctrl->setParameter($this, "meta_index", $class_id);
2912  $this->tpl->setVariable("TAXONPATH_LOOP_ACTION_ADD",
2913  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2914  $this->tpl->setVariable("TAXONPATH_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2915  $this->tpl->parseCurrentBlock();
2916  }
2917 
2918  /* Description */
2919  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("meta_description"));
2920  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("meta_value"));
2921  $this->tpl->setVariable("VAL_DESCRIPTION",
2922  ilUtil::prepareFormOutput($this->md_section->getDescription()));
2923  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("meta_language"));
2924  $this->tpl->setVariable("VAL_DESCRIPTION_LANGUAGE",
2925  $this->__showLanguageSelect('classification['.$class_id.'][Language]',
2926  $this->md_section->getDescriptionLanguageCode()));
2927 
2928  /* Keyword */
2929  $key_ids = $this->md_section->getKeywordIds();
2930  foreach ($key_ids as $key_id)
2931  {
2932  if (count($key_ids) > 1)
2933  {
2934  $this->ctrl->setParameter($this, "meta_index", $key_id);
2935  $this->ctrl->setParameter($this, "meta_path", "classification_keyword");
2936  $this->tpl->setCurrentBlock("keyword_delete");
2937  $this->tpl->setVariable("KEYWORD_LOOP_ACTION_DELETE",
2938  $this->ctrl->getLinkTarget($this, "deleteElement"));
2939  $this->tpl->setVariable("KEYWORD_LOOP_TXT_DELETE", $this->lng->txt("meta_delete"));
2940  $this->tpl->parseCurrentBlock();
2941  }
2942 
2943  $keyword = $this->md_section->getKeyword($key_id);
2944  $this->tpl->setCurrentBlock("keyword_loop");
2945  $this->tpl->setVariable("KEYWORD_LOOP_NO", $key_id);
2946  $this->tpl->setVariable("KEYWORD_LOOP_TXT_KEYWORD", $this->lng->txt("meta_keyword"));
2947  $this->tpl->setVariable("KEYWORD_LOOP_TXT_VALUE", $this->lng->txt("meta_value"));
2948  $this->tpl->setVariable("KEYWORD_LOOP_VAL",
2949  ilUtil::prepareFormOutput($keyword->getKeyword()));
2950  $this->tpl->setVariable("KEYWORD_LOOP_TXT_LANGUAGE", $this->lng->txt("meta_language"));
2951  $this->tpl->setVariable("KEYWORD_LOOP_VAL_LANGUAGE",
2952  $this->__showLanguageSelect('classification[Keyword]['.$key_id.'][Language]',
2953  $keyword->getKeywordLanguageCode()));
2954  $this->ctrl->setParameter($this, "meta_index", $class_id);
2955  $this->ctrl->setParameter($this, "section_element", "Keyword_".$class_id);
2956  $this->tpl->setVariable("KEYWORD_LOOP_ACTION_ADD",
2957  $this->ctrl->getLinkTarget($this, "addSectionElement"));
2958  $this->tpl->setVariable("KEYWORD_LOOP_TXT_ADD", $this->lng->txt("meta_add"));
2959  $this->tpl->parseCurrentBlock();
2960  }
2961 
2962  $this->tpl->setCurrentBlock("classification_loop");
2963  $this->tpl->setVariable("TXT_CLASSIFICATION", $this->lng->txt("meta_classification"));
2964  $this->ctrl->setParameter($this, "meta_index", $class_id);
2965  $this->tpl->setVariable("ACTION_DELETE",
2966  $this->ctrl->getLinkTarget($this, "deleteSection"));
2967  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("meta_delete"));
2968  $this->tpl->setVariable("ACTION_ADD",
2969  $this->ctrl->getLinkTarget($this, "addSection"));
2970  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("meta_add"));
2971 
2972  $this->tpl->setVariable("TXT_NEW_ELEMENT", $this->lng->txt("meta_new_element"));
2973  $this->tpl->setVariable("TXT_TAXONPATH", $this->lng->txt("meta_taxon_path"));
2974  $this->tpl->setVariable("TXT_KEYWORD", $this->lng->txt("meta_keyword"));
2975  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("meta_add"));
2976 
2977  $this->tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
2978  $this->tpl->setVariable("CLASS_ID", $class_id);
2979  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("meta_purpose"));
2980  $this->tpl->setVariable("TXT_DISCIPLINE", $this->lng->txt("meta_learning_resource_type"));
2981  $this->tpl->setVariable("TXT_IDEA", $this->lng->txt("meta_idea"));
2982  $this->tpl->setVariable("TXT_PREREQUISITE", $this->lng->txt("meta_prerequisite"));
2983  $this->tpl->setVariable("TXT_EDUCATIONALOBJECTIVE", $this->lng->txt("meta_educational_objective"));
2984  $this->tpl->setVariable("TXT_ACCESSIBILITYRESTRICTIONS", $this->lng->txt("meta_accessibility_restrictions"));
2985  $this->tpl->setVariable("TXT_EDUCATIONALLEVEL", $this->lng->txt("meta_educational_level"));
2986  $this->tpl->setVariable("TXT_SKILLLEVEL", $this->lng->txt("meta_skill_level"));
2987  $this->tpl->setVariable("TXT_SECURITYLEVEL", $this->lng->txt("meta_security_level"));
2988  $this->tpl->setVariable("TXT_COMPETENCY", $this->lng->txt("meta_competency"));
2989  $this->tpl->setVariable("VAL_PURPOSE_" . strtoupper($this->md_section->getPurpose()), " selected");
2990  $this->tpl->parseCurrentBlock();
2991  }
2992 
2993  $this->tpl->setCurrentBlock("classification");
2994  $this->tpl->setVariable("EDIT_ACTION",
2995  $this->ctrl->getFormAction($this));
2996  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2997  $this->tpl->parseCurrentBlock();
2998  }
2999  }
3000 
3002  {
3003  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
3004 
3005  // relation
3006  foreach($ids = $this->md_obj->getClassificationIds() as $id)
3007  {
3008  // entity
3009  $classification = $this->md_obj->getClassification($id);
3010  $classification->setPurpose($_POST['classification'][$id]['Purpose']);
3011 
3012  $classification->setDescription(ilUtil::stripSlashes($_POST['classification'][$id]['Description']));
3013  $classification->setDescriptionLanguage(
3014  new ilMDLanguageItem($_POST['classification'][$id]['Language']));
3015 
3016  $classification->update();
3017 
3018  $key_ids = $classification->getKeywordIds();
3019  foreach ($key_ids as $key_id)
3020  {
3021  $keyword = $classification->getKeyword($key_id);
3022  $keyword->setKeyword(ilUtil::stripSlashes($_POST['classification']['Keyword'][$key_id]['Value']));
3023  $keyword->setKeywordLanguage(
3024  new ilMDLanguageItem($_POST['classification']['Keyword'][$key_id]['Language']));
3025  $keyword->update();
3026  }
3027 
3028  $tp_ids = $classification->getTaxonPathIds();
3029  foreach ($tp_ids as $tp_id)
3030  {
3031  $tax_path = $classification->getTaxonPath($tp_id);
3032  $tax_path->setSource(ilUtil::stripSlashes($_POST['classification']['TaxonPath'][$tp_id]['Source']['Value']));
3033  $tax_path->setSourceLanguage(
3034  new ilMDLanguageItem($_POST['classification']['TaxonPath'][$tp_id]['Source']['Language']));
3035  $tax_path->update();
3036 
3037  $tax_ids = $tax_path->getTaxonIds();
3038 
3039  foreach($tax_ids as $tax_id)
3040  {
3041  $taxon = $tax_path->getTaxon($tax_id);
3042  $taxon->setTaxon(ilUtil::stripSlashes($_POST['classification']['TaxonPath']['Taxon'][$tax_id]['Value']));
3043  $taxon->setTaxonLanguage(
3044  new ilMDLanguageItem($_POST['classification']['TaxonPath']['Taxon'][$tax_id]['Language']));
3045  $taxon->setTaxonId(ilUtil::stripSlashes($_POST['classification']['TaxonPath']['Taxon'][$tax_id]['Id']));
3046  $taxon->update();
3047  }
3048  }
3049 
3050 
3051  }
3052 
3053  $this->callListeners('Classification');
3054  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
3055  $this->listSection();
3056  }
3057 
3058  function deleteElement()
3059  {
3060  include_once 'Services/MetaData/classes/class.ilMDFactory.php';
3061 
3062  $md_element = ilMDFactory::_getInstance($_GET['meta_path'],$_GET['meta_index'],$_GET['meta_technical']);
3063  $md_element->delete();
3064 
3065  $this->listSection();
3066 
3067  return true;
3068  }
3069 
3070  function deleteSection()
3071  {
3072  include_once 'Services/MetaData/classes/class.ilMDFactory.php';
3073 
3074  $md_element = ilMDFactory::_getInstance($_GET['section'],$_GET['meta_index']);
3075  $md_element->delete();
3076 
3077  $this->listSection();
3078 
3079  return true;
3080  }
3081 
3082  function addSection()
3083  {
3084  // Switch section
3085  switch($_GET['section'])
3086  {
3087  case 'meta_technical':
3088  $this->md_section =& $this->md_obj->addTechnical();
3089  $this->md_section->save();
3090  break;
3091 
3092 
3093  case 'meta_lifecycle':
3094  $this->md_section =& $this->md_obj->addLifecycle();
3095  $this->md_section->save();
3096  $con =& $this->md_section->addContribute();
3097  $con->save();
3098 
3099  $ent =& $con->addEntity();
3100  $ent->save();
3101  break;
3102 
3103  case 'meta_meta_metadata':
3104  $this->md_section = $this->md_obj->addMetaMetadata();
3105  $this->md_section->save();
3106 
3107  $ide =& $this->md_section->addIdentifier();
3108  $ide->save();
3109 
3110  $con =& $this->md_section->addContribute();
3111  $con->save();
3112 
3113  $ent =& $con->addEntity();
3114  $ent->save();
3115  break;
3116 
3117  case 'meta_rights':
3118  $this->md_section = $this->md_obj->addRights();
3119  $this->md_section->save();
3120  break;
3121 
3122  case 'meta_educational':
3123  $this->md_section = $this->md_obj->addEducational();
3124  $this->md_section->save();
3125  break;
3126 
3127  case 'meta_relation':
3128  $this->md_section = $this->md_obj->addRelation();
3129  $this->md_section->save();
3130  $ident = $this->md_section->addIdentifier_();
3131  $ident->save();
3132  $des = $this->md_section->addDescription();
3133  $des->save();
3134  break;
3135 
3136  case 'meta_annotation':
3137  $this->md_section = $this->md_obj->addAnnotation();
3138  $this->md_section->save();
3139  break;
3140 
3141  case 'meta_classification':
3142  $this->md_section = $this->md_obj->addClassification();
3143  $this->md_section->save();
3144 
3145  $taxon_path =& $this->md_section->addTaxonPath();
3146  $taxon_path->save();
3147 
3148  $taxon =& $taxon_path->addTaxon();
3149  $taxon->save();
3150 
3151  $key =& $this->md_section->addKeyword();
3152  $key->save();
3153  break;
3154 
3155  }
3156 
3157  $this->listSection();
3158  return true;
3159  }
3160 
3162  {
3163  $section_element = (empty($_POST['section_element']))
3164  ? $_GET['section_element']
3165  : $_POST['section_element'];
3166 
3167 
3168  // Switch section
3169  switch($_GET['section'])
3170  {
3171  case 'meta_technical':
3172  $this->md_section =& $this->md_obj->getTechnical();
3173  break;
3174 
3175  case 'meta_lifecycle':
3176  $this->md_section =& $this->md_obj->getLifecycle();
3177  break;
3178 
3179  case 'meta_meta_metadata':
3180  $this->md_section =& $this->md_obj->getMetaMetadata();
3181  break;
3182 
3183  case 'meta_general':
3184  $this->md_section = $this->md_obj->getGeneral();
3185  break;
3186 
3187  case 'meta_educational':
3188  $this->md_section = $this->md_obj->getEducational();
3189  break;
3190 
3191  case 'meta_classification':
3192  $arr = explode("_", $section_element);
3193  $section_element = $arr[0];
3194  $this->md_section = $this->md_obj->getClassification($arr[1]);
3195  break;
3196  }
3197 
3198  // Switch new element
3199  switch($section_element)
3200  {
3201  case 'meta_or_composite':
3202  $md_new =& $this->md_section->addOrComposite();
3203  $md_new = $md_new->addRequirement();
3204  break;
3205 
3206  case 'meta_requirement':
3207  $md_new =& $this->md_section->addRequirement();
3208  break;
3209 
3210  case 'meta_location':
3211  $md_new =& $this->md_section->addLocation();
3212  break;
3213 
3214  case 'meta_format':
3215  $md_new = $this->md_section->addFormat();
3216  break;
3217 
3218  case 'meta_entity':
3219  $md_new = $this->md_section->getContribute((int) $_GET['meta_index']);
3220  $md_new = $md_new->addEntity();
3221  break;
3222 
3223  case 'meta_identifier':
3224  $md_new = $this->md_section->addIdentifier();
3225  break;
3226 
3227  case 'meta_contribute':
3228  $md_new =& $this->md_section->addContribute();
3229  $md_new->save();
3230  $md_new = $md_new->addEntity();
3231  break;
3232 
3233  case 'educational_language':
3234  case 'meta_language':
3235  $md_new = $this->md_section->addLanguage();
3236  break;
3237 
3238  case 'educational_description':
3239  case 'meta_description':
3240  $md_new = $this->md_section->addDescription();
3241  break;
3242 
3243  case 'Keyword':
3244  case 'meta_keyword':
3245  $md_new = $this->md_section->addKeyword();
3246  break;
3247 
3248  case 'educational_typical_age_range':
3249  $md_new = $this->md_section->addTypicalAgeRange();
3250  break;
3251 
3252  case 'relation_resource_identifier':
3253  $rel = $this->md_obj->getRelation($_GET['meta_index']);
3254  $md_new = $rel->addIdentifier_();
3255  break;
3256 
3257  case 'relation_resource_description':
3258  $rel = $this->md_obj->getRelation($_GET['meta_index']);
3259  $md_new = $rel->addDescription();
3260  break;
3261 
3262  case 'TaxonPath':
3263  $md_new = $this->md_section->addTaxonPath();
3264  $md_new->save();
3265  $md_new = $md_new->addTaxon();
3266  break;
3267 
3268  case 'Taxon':
3269  $tax_path = $this->md_section->getTaxonPath($_GET['meta_index']);
3270  $md_new = $tax_path->addTaxon();
3271  break;
3272  }
3273 
3274  $md_new->save();
3275 
3276  $this->listSection();
3277 
3278  return true;
3279  }
3280 
3281  function listSection()
3282  {
3283  switch($_REQUEST['section'])
3284  {
3285  case 'meta_general':
3286  return $this->listGeneral();
3287 
3288  case 'meta_lifecycle':
3289  return $this->listLifecycle();
3290 
3291  case 'meta_technical':
3292  return $this->listTechnical();
3293 
3294  case 'meta_meta_metadata':
3295  return $this->listMetaMetadata();
3296 
3297  case 'debug':
3298  return $this->debug();
3299 
3300  case 'meta_rights':
3301  return $this->listRights();
3302 
3303  case 'meta_educational':
3304  return $this->listEducational();
3305 
3306  case 'meta_relation':
3307  return $this->listRelation();
3308 
3309  case 'meta_annotation':
3310  return $this->listAnnotation();
3311 
3312  case 'meta_classification':
3313  return $this->listClassification();
3314 
3315  default:
3316  if($this->md_obj->obj_type=='sahs'||$this->md_obj->obj_type=='sco')
3317  return $this->listQuickEdit_scorm();
3318  else
3319  return $this->listQuickEdit();
3320  }
3321  }
3322 
3323 
3324  // PRIVATE
3326  {
3327  if(count($subs = $this->md_section->getPossibleSubelements()))
3328  {
3329  //$subs = array_merge(array('' => 'meta_please_select'),$subs);
3330 
3331  $this->tpl->setCurrentBlock("subelements");
3332  $this->tpl->setVariable("SEL_SUBELEMENTS",ilUtil::formSelect('','section_element',$subs));
3333  $this->tpl->setVariable("TXT_NEW_ELEMENT", $this->lng->txt("meta_new_element"));
3334  $this->tpl->parseCurrentBlock();
3335 
3336  $this->tpl->setVariable("TXT_ADD",$this->lng->txt('meta_add'));
3337 
3338  }
3339  return true;
3340  }
3341 
3342 
3343 
3344  function __setTabs($a_active)
3345  {
3346  $tabs = array('meta_quickedit' => 'listQuickEdit',
3347  'meta_general' => 'listGeneral',
3348  'meta_lifecycle' => 'listLifecycle',
3349  'meta_meta_metadata' => 'listMetaMetadata',
3350  'meta_technical' => 'listTechnical',
3351  'meta_educational' => 'listEducational',
3352  'meta_rights' => 'listRights',
3353  'meta_relation' => 'listRelation',
3354  'meta_annotation' => 'listAnnotation',
3355  'meta_classification' => 'listClassification');
3356 
3357  if(DEVMODE)
3358  {
3359  $tabs['debug'] = 'debug';
3360  }
3361 
3362  foreach($tabs as $key => $target)
3363  {
3364  if($a_active == $key)
3365  {
3366  $active = true;
3367  }
3368  else
3369  {
3370  $active = false;
3371  }
3372  $this->ctrl->setParameter($this,'section',$key);
3373  $this->tabs_gui->addSubTabTarget($key, $this->ctrl->getLinkTarget($this,'listSection'),
3374  "", "", "", $active);
3375  }
3376  #$this->tpl->setVariable("SUB_TABS", $tab_gui->getHTML());
3377  return true;
3378  }
3379 
3380 
3384  function __showLanguageSelect($a_name, $a_value = "")
3385  {
3386  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
3387 
3388  $tpl = new ilTemplate("tpl.lang_selection.html", true, true,
3389  "Services/MetaData");
3390 
3391  foreach(ilMDLanguageItem::_getLanguages() as $code => $text)
3392  {
3393  $tpl->setCurrentBlock("lg_option");
3394  $tpl->setVariable("VAL_LG", $code);
3395  $tpl->setVariable("TXT_LG", $text);
3396 
3397  if ($a_value != "" &&
3398  $a_value == $code)
3399  {
3400  $tpl->setVariable("SELECTED", "selected");
3401  }
3402 
3403  $tpl->parseCurrentBlock();
3404  }
3405  $tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("meta_please_select"));
3406  $tpl->setVariable("SEL_NAME", $a_name);
3407 
3408  $return = $tpl->get();
3409  unset($tpl);
3410 
3411  return $return;
3412  }
3413 
3414  function __buildMonthsSelect($sel_month)
3415  {
3416  for($i = 0;$i <= 24;$i++)
3417  {
3418  $options[$i] = sprintf('%02d',$i);
3419  }
3420  return ilUtil::formSelect($sel_month,'tlt[mo]',$options,false,true);
3421  }
3422 
3423 
3424  function __buildDaysSelect($sel_day)
3425  {
3426  for($i = 0;$i <= 31;$i++)
3427  {
3428  $options[$i] = sprintf('%02d',$i);
3429  }
3430  return ilUtil::formSelect($sel_day,'tlt[d]',$options,false,true);
3431  }
3432 
3433 
3434 
3435  // Observer methods
3436  function addObserver(&$a_class,$a_method,$a_element)
3437  {
3438  $this->observers[$a_element]['class'] =& $a_class;
3439  $this->observers[$a_element]['method'] =& $a_method;
3440 
3441  return true;
3442  }
3443  function callListeners($a_element)
3444  {
3445  if(isset($this->observers[$a_element]))
3446  {
3447  $class =& $this->observers[$a_element]['class'];
3448  $method = $this->observers[$a_element]['method'];
3449 
3450  return $class->$method($a_element);
3451  }
3452  return false;
3453  }
3454 
3455 
3456 }
3457 ?>