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