/** * parse * * @access public * */ public function fillTemplate() { include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; $desc = ilMDRights::_lookupDescription($this->rbac_id, $this->obj_id); if (!$this->settings->isCopyrightSelectionActive() or !count($entries = ilMDCopyrightSelectionEntry::_getEntries())) { $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt('meta_copyright')); $this->tpl->setVariable('COPYRIGHT_VAL', ilUtil::prepareFormOutput($desc)); return true; } $default_id = ilMDCopyrightSelectionEntry::_extractEntryId($desc); include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; $found = false; foreach ($entries as $entry) { $this->tpl->setCurrentBlock('copyright_selection'); if ($entry->getEntryId() == $default_id) { $found = true; $this->tpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"'); } $this->tpl->setVariable('COPYRIGHT_ID', $entry->getEntryId()); $this->tpl->setVariable('COPYRIGHT_TITLE', $entry->getTitle()); $this->tpl->setVariable('COPYRIGHT_DESCRIPTION', $entry->getDescription()); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('copyright_selection'); if (!$found) { $this->tpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"'); } $this->tpl->setVariable('COPYRIGHT_ID', 0); $this->tpl->setVariable('COPYRIGHT_TITLE', $this->lng->txt('meta_cp_own')); $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt('meta_copyright')); if (!$found) { $this->tpl->setVariable('COPYRIGHT_VAL', $desc); } }
/** * test MetaData * @group IL_Init * @return */ public function testRights() { include_once './Services/MetaData/classes/class.ilMDRights.php'; include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php'; $con = new ilMDRights(1, 2, 'xxx'); $con->setDescription('Amaya'); $ret = $con->save(); $this->assertGreaterThan(0, $ret); $con->setDescription('Opera'); $con->update(); $con->read(); $desc = $con->getDescription(); $this->assertEquals('Opera', $desc); $con->delete(); }
function &getRights() { include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRights.php'; if ($id = ilMDRights::_getId($this->getRBACId(), $this->getObjId())) { $rig =& new ilMDRights(); $rig->setMetaId($id); return $rig; } return false; }
/** * Init quick edit form. */ public function initQuickEditForm() { global $lng, $ilCtrl; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form = new ilPropertyFormGUI(); // title $ti = new ilTextInputGUI($this->lng->txt("title"), "gen_title"); $ti->setMaxLength(200); $ti->setSize(50); $ti->setRequired(true); $ti->setValue($this->md_section->getTitle()); $this->form->addItem($ti); // description(s) foreach ($ids = $this->md_section->getDescriptionIds() as $id) { $md_des = $this->md_section->getDescription($id); $ta = new ilTextAreaInputGUI($this->lng->txt("meta_description"), "gen_description[" . $id . "][description]"); $ta->setCols(50); $ta->setRows(4); $ta->setValue($md_des->getDescription()); if (count($ids) > 1) { $ta->setInfo($this->lng->txt("meta_l_" . $md_des->getDescriptionLanguageCode())); } $this->form->addItem($ta); } // language(s) $first = ""; $options = ilMDLanguageItem::_getLanguages(); foreach ($ids = $this->md_section->getLanguageIds() as $id) { $md_lan = $this->md_section->getLanguage($id); $first_lang = $md_lan->getLanguageCode(); $si = new ilSelectInputGUI($this->lng->txt("meta_language"), "gen_language[" . $id . "][language]"); $si->setOptions($options); $si->setValue($md_lan->getLanguageCode()); $this->form->addItem($si); $first = false; } if ($first) { $si = new ilSelectInputGUI($this->lng->txt("meta_language"), "gen_language[][language]"); $si->setOptions($options); $this->form->addItem($si); } // keyword(s) $first = true; $keywords = array(); foreach ($ids = $this->md_section->getKeywordIds() as $id) { $md_key = $this->md_section->getKeyword($id); if (trim($md_key->getKeyword()) != "") { $keywords[$md_key->getKeywordLanguageCode()][] = $md_key->getKeyword(); } } foreach ($keywords as $lang => $keyword_set) { $kw = new ilTextInputGUI($this->lng->txt("keywords"), "keywords[value][" . $lang . "]"); $kw->setDataSource($this->ctrl->getLinkTarget($this, "keywordAutocomplete", "", true)); $kw->setMaxLength(200); $kw->setSize(50); $kw->setMulti(true); if (count($keywords) > 1) { $kw->setInfo($this->lng->txt("meta_l_" . $lang)); } $this->form->addItem($kw); asort($keyword_set); $kw->setValue($keyword_set); } if (count($keywords) == 0) { $kw = new ilTextInputGUI($this->lng->txt("keywords"), "keywords[value][" . $first_lang . "]"); $kw->setDataSource($this->ctrl->getLinkTarget($this, "keywordAutocomplete", "", true)); $kw->setMaxLength(200); $kw->setSize(50); $kw->setMulti(true); $this->form->addItem($kw); } // Lifecycle... // Authors $ta = new ilTextAreaInputGUI($this->lng->txt('authors') . "<br />" . "(" . sprintf($this->lng->txt('md_separated_by'), $this->md_settings->getDelimiter()) . ")", "life_authors"); $ta->setCols(50); $ta->setRows(2); if (is_object($this->md_section = $this->md_obj->getLifecycle())) { $sep = $ent_str = ""; foreach ($ids = $this->md_section->getContributeIds() as $con_id) { $md_con = $this->md_section->getContribute($con_id); if ($md_con->getRole() == "Author") { foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) { $md_ent = $md_con->getEntity($ent_id); $ent_str = $ent_str . $sep . $md_ent->getEntity(); $sep = $this->md_settings->getDelimiter() . " "; } } } $ta->setValue($ent_str); } $this->form->addItem($ta); // copyright include_once "./Services/MetaData/classes/class.ilCopyrightInputGUI.php"; $cp = new ilCopyrightInputGUI($this->lng->txt("meta_copyright"), "copyright"); $cp->setCols(50); $cp->setRows(3); $desc = ilMDRights::_lookupDescription($this->md_obj->getRBACId(), $this->md_obj->getObjId()); $val["ta"] = $desc; $cp->setValue($val); $this->form->addItem($cp); // typical learning time include_once "./Services/MetaData/classes/class.ilTypicalLearningTimeInputGUI.php"; $tlt = new ilTypicalLearningTimeInputGUI($this->lng->txt("meta_typical_learning_time"), "tlt"); $edu = $this->md_obj->getEducational(); if (is_object($edu)) { $tlt->setValueByLOMDuration($edu->getTypicalLearningTime()); } $this->form->addItem($tlt); $this->form->addCommandButton("updateQuickEdit", $lng->txt("save")); $this->form->setTitle($this->lng->txt("meta_quickedit")); $this->form->setFormAction($ilCtrl->getFormAction($this)); return $this->form; }