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