/** * @group IL_Init * @param * @return */ public function testCopyright() { include_once './Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; $cpr = new ilMDCopyrightSelectionEntry(0); $cpr->setTitle("1"); $cpr->setDescription("2"); $cpr->setLanguage('en'); $cpr->setCopyright("3"); $cpr->setCosts(true); $cpr->add(); $entry = $cpr->getEntryId(); $this->assertGreaterThan(0, $entry); $cpr = new ilMDCopyrightSelectionEntry($entry); $ret = $cpr->getTitle(); $this->assertEquals($ret, '1'); $ret = $cpr->getDescription(); $this->assertEquals($ret, '2'); $ret = $cpr->getCopyright(); $this->assertEquals($ret, '3'); $ret = $cpr->getLanguage(); $this->assertEquals($ret, 'en'); $cpr->setTitle('11'); $cpr->update(); $cpr->delete(); }
/** * 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); } }
/** * Parse records * * @access public * @param array array of record objects * */ public function parseSelections() { foreach (ilMDCopyrightSelectionEntry::_getEntries() as $entry) { $tmp_arr['id'] = $entry->getEntryId(); $tmp_arr['title'] = $entry->getTitle(); $tmp_arr['description'] = $entry->getDescription(); $tmp_arr['used'] = $entry->getUsage(); $tmp_arr['preview'] = $entry->getCopyright(); $entry_arr[] = $tmp_arr; } $this->setData($entry_arr ? $entry_arr : array()); }
/** * delete entries * * @access public * */ public function deleteEntries() { if (!is_array($_POST['entry_id']) or !count($_POST['entry_id'])) { ilUtil::sendInfo($this->lng->txt('select_one')); $this->showCopyrightSettings(); return true; } include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; foreach ($_POST["entry_id"] as $entry_id) { $entry = new ilMDCopyrightSelectionEntry($entry_id); $entry->delete(); } ilUtil::sendInfo($this->lng->txt('md_copyrights_deleted')); $this->showCopyrightSettings(); return true; }
/** * Parse copyright * * * @access public * @static * * @param string copyright */ public static function _parseCopyright($a_copyright) { include_once 'Services/MetaData/classes/class.ilMDSettings.php'; $settings = ilMDSettings::_getInstance(); if (!$settings->isCopyrightSelectionActive()) { return $a_copyright; } include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; return ilMDCopyrightSelectionEntry::_lookupCopyright($a_copyright); }
/** * Insert property html */ function insert(&$a_tpl) { include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; $ttpl = new ilTemplate("tpl.prop_copyright.html", true, true, "Services/MetaData"); $entries = ilMDCopyrightSelectionEntry::_getEntries(); $use_selection = $this->settings->isCopyrightSelectionActive() && count($entries); $val = $this->getValue(); if ($use_selection) { $default_id = ilMDCopyrightSelectionEntry::_extractEntryId($val["ta"]); include_once 'Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php'; $found = false; foreach ($entries as $entry) { $ttpl->setCurrentBlock('copyright_selection'); if ($entry->getEntryId() == $default_id) { $found = true; $ttpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"'); } $ttpl->setVariable('COPYRIGHT_ID', $entry->getEntryId()); $ttpl->setVariable('COPYRIGHT_TITLE', $entry->getTitle()); $ttpl->setVariable('COPYRIGHT_DESCRIPTION', $entry->getDescription()); $ttpl->setVariable('SPOST_VAR', $this->getPostVar()); $ttpl->parseCurrentBlock(); } $ttpl->setCurrentBlock('copyright_selection'); if (!$found) { $ttpl->setVariable('COPYRIGHT_CHECKED', 'checked="checked"'); } $ttpl->setVariable('COPYRIGHT_ID', 0); $ttpl->setVariable('COPYRIGHT_TITLE', $this->lng->txt('meta_cp_own')); $ttpl->setVariable('SPOST_VAR', $this->getPostVar()); $ttpl->parseCurrentBlock(); } if ($this->getCols() > 5) { $ttpl->setCurrentBlock("prop_ta_c"); $ttpl->setVariable("COLS", $this->getCols()); $ttpl->parseCurrentBlock(); } else { $ttpl->touchBlock("prop_ta_w"); } $ttpl->setCurrentBlock("prop_copyright"); $ttpl->setVariable("ROWS", $this->getRows()); if (!$this->getDisabled()) { $ttpl->setVariable("POST_VAR", $this->getPostVar()); } $ttpl->setVariable("ID", $this->getFieldId()); if ($this->getDisabled()) { $ttpl->setVariable('DISABLED', 'disabled="disabled" '); } if ($this->getDisabled()) { $ttpl->setVariable("HIDDEN_INPUT", $this->getHiddenTag($this->getPostVar(), $this->getValue())); } if (!$use_selection || !$found) { $ttpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($val["ta"])); } $ttpl->parseCurrentBlock(); $a_tpl->setCurrentBlock("prop_generic"); $a_tpl->setVariable("PROP_GENERIC", $ttpl->get()); $a_tpl->parseCurrentBlock(); }