/** * convert id format from "[nijc_code]:[XNP_CONFIG_DOI_FIELD_PARAM_NAME]/[sort id(doi)]" to "[nijc_code]/[item type id].[item id]" * @param id OAI-PMH identifier * @return converted id string. * @return "": nijc_code not equal own nijc_code or doi above XNP_CONFIG_DOI_FIELD_PARAM_MAXLEN. */ function convertIdentifierFormat($id) { $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $id_str = $id; $parsed = $this->parseIdentifier2($id_str); if ($parsed) { if (strlen($parsed['doi']) > XNP_CONFIG_DOI_FIELD_PARAM_MAXLEN) { return ""; } // check valid support nijc_code. if ($parsed['nijc_code'] != $xconfig_handler->getValue('repository_nijc_code')) { return ""; } $iids = array(); $item_info = ""; $res = xnpGetItemIdByDoi($parsed['doi'], $iids); if ($res == RES_OK && isset($iids[0]) && xnp_get_item($_SESSION['XNPSID'], $iids[0], $item_info) == RES_OK) { $id_str = $parsed['nijc_code'] . "/" . $item_info['item_type_id'] . "." . $iids[0]; } else { return ""; } } return $id_str; }
/** * * generate XML from <record> to </record> * check errors * - nijc_code of identifier = Setting of Site Configuration? * - Do part of item_type_id in identifier match installed itemtypes? * - Do part of item_id in identifier match registered items? * - Can itemtype generate metadata? * * @param $identifier: identifier of item to generate XML * @param $index_tree_list: array of convert from index id to index path string. * @return array( generated XML, true ) in success to generate <record> * @return array( error XML, false ) in success to generate <record>, return <error> ... </error>. * */ function record($identifier, $index_tree_list) { $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $parsed = $identifier; if ($parsed['is_deleted'] == 1) { //return only header if item is deleted return array("<record>\n" . $this->oaipmh_header($identifier, $index_tree_list) . "</record>\n", true); } //return error if nijc_code mismatched $nijc_code = $xconfig_handler->getValue('repository_nijc_code'); if (empty($nijc_code) || $nijc_code != $parsed['nijc_code']) { return array(parent::error('idDoesNotExist', ''), false); } //return error if item_id mismatched $item = array(); $result = xnp_get_item($_SESSION['XNPSID'], $parsed['item_id'], $item); if ($result != RES_OK) { return array(parent::error('idDoesNotExist', 'item_id not found'), false); } //return error if item_type_id mismatched if ($result == RES_OK && $item['item_type_id'] != $parsed['item_type_id']) { return array(parent::error('idDoesNotExist', 'item_type_id not found'), false); } include_once XOOPS_ROOT_PATH . '/modules/' . $parsed['item_type_viewphp']; $f = $parsed['item_type_name'] . 'GetMetadata'; if (!function_exists($f)) { return array(parent::error('idDoesNotExist', "function {$f} not defined"), false); } return array("<record>\n" . $this->oaipmh_header($identifier, $index_tree_list) . $f($this->metadataPrefix, $parsed['item_id']) . "</record>\n", true); }
foreach (array('item_id' => array('i', 0), 'op' => array('s', '')) as $k => $meta) { list($type, $default) = $meta; ${$k} = $formdata->getValue('both', $k, $type, false, $default); } xoonips_deny_guest_access(); $uid = $_SESSION['xoopsUserId']; $textutil =& xoonips_getutility('text'); //error if item is locked $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock'); if ($item_lock_handler->isLocked($item_id)) { redirect_header(XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $item_id, 5, sprintf(_MD_XOONIPS_ERROR_CANNOT_EDIT_LOCKED_ITEM, xoonips_get_lock_type_string($item_lock_handler->getLockType($item_id)))); exit; } //retrieve item detail and set item type id to $item_type_id; $item = array(); if (xnp_get_item($xnpsid, $item_id, $item) != RES_OK) { redirect_header(XOOPS_URL . '/', 3, "ERROR xnp_get_item"); break; } else { $item_type_id = $item['item_type_id']; } //retrive module name to $itemtype $itemtypes = array(); if (xnp_get_item_types($itemtypes) != RES_OK) { redirect_header(XOOPS_URL . '/', 3, "ERROR xnp_get_item_types"); break; } else { foreach ($itemtypes as $i) { if ($i['item_type_id'] == $item_type_id) { $itemtype = $i; $modname = $itemtype['name'];
$ids = xoonips_get_all_item_ids_to_export($index_id, $xoopsUser->getVar('uid'), $recursive_item); } $ids = array_unique($ids); $tmp = array(); $itemtypes = array(); $res = xnp_get_item_types($tmp); foreach ($tmp as $i) { $itemtypes[$i['item_type_id']] = $i; } // split items between required to agree license and no needs. // $items['export'] = array( does not required items ); // $items['license_required'] = array( required items ); $items = array(); foreach ($ids as $i) { $item_basic = array(); $res = xnp_get_item($_SESSION['XNPSID'], $i, $item_basic); //TODO TO FIX THAT XNP_GET_ITEM CAN'T GET ITEM if ($res == RES_OK && array_key_exists($item_basic['item_type_id'], $itemtypes)) { $func_license_required = $itemtypes[$item_basic['item_type_id']]['name'] . "GetLicenseRequired"; $func_license = $itemtypes[$item_basic['item_type_id']]['name'] . "GetLicenseStatement"; $func_html = $itemtypes[$item_basic['item_type_id']]['name'] . "GetListBlock"; $func_export = $itemtypes[$item_basic['item_type_id']]['name'] . "ExportItem"; include_once XOOPS_ROOT_PATH . "/modules/" . $itemtypes[$item_basic['item_type_id']]['viewphp']; $license_required = function_exists($func_license_required) ? $func_license_required($i) : false; list($license, $use_cc) = function_exists($func_license) ? $func_license($i) : array('', false); $html = function_exists($func_html) ? $func_html($item_basic) : ''; if (!function_exists($func_export) || !export_item_enable($i)) { $key = 'not_export'; } else { if ($license_required) { $key = 'license_required';
function xnppaperGetEditBlock($item_id) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $textutil =& xoonips_getutility('text'); // retrieve blocks of BasicInformation / index $basic = xnpGetBasicInformationEditBlock($item_id); $index = xnpGetIndexEditBlock($item_id); $paper_pdf_reprint = xnpGetAttachmentEditBlock($item_id, 'paper_pdf_reprint'); // retrieve DetailInformation $title = $formdata->getValue('post', 'title', 's', false); if (isset($title)) { $detail = _xnppaper_get_form_request(); } else { if (!empty($item_id)) { $detail = xnppaperGetDetailInformation($item_id); $item = array(); $result = xnp_get_item($_SESSION['XNPSID'], $item_id, $item); } else { $detail = array(); } } foreach ($detail as $key => $val) { $detail[$key] = $textutil->html_special_chars($detail[$key]); } // assign to template global $xoopsTpl; $tpl = new XoopsTpl(); $tpl->assign($xoopsTpl->get_template_vars()); // variables assigned to xoopsTpl are copied to $tpl $tpl->assign('basic', $basic); $tpl->assign('index', $index); $tpl->assign('paper_pdf_reprint', $paper_pdf_reprint); $tpl->assign('detail', $detail); if (!$formdata->getValue('get', 'post_id', 's', false)) { $detail_handler =& xoonips_getormhandler('xnppaper', 'item_detail'); $detail_orm =& $detail_handler->get($item_id); $tpl->assign('xnppaper_author', xoonips_get_multiple_field_template_vars($detail_orm->getAuthors(), 'xnppaper', 'author')); } else { $tpl->assign('xnppaper_author', xoonips_get_multiple_field_template_vars(xoonips_get_orm_from_post('xnppaper', 'author'), 'xnppaper', 'author')); } // for pubmed fillin $tpl->assign('is_register', false); $tpl->assign('myurl', XOOPS_URL . '/modules/xoonips/edit.php'); // return HTML return $tpl->fetch('db:xnppaper_register_block.html'); }
/** * * export Basic information of item * * @param fhdl file handle that items are exported to. * @param item_id id of the item to change into XML. * @return true:success, false:failure */ function xnpExportBasic($fhdl, $item_id, $is_absolute, $base_index_id = false) { if (!$fhdl) { return false; } $xnpsid = $_SESSION['XNPSID']; $item = array(); $account = array(); $res = xnp_get_item($xnpsid, $item_id, $item); if ($res != RES_OK) { return false; } return xnpBasicInformation2XML($fhdl, $item, $is_absolute, $base_index_id); }
function xnpGetBasicInformationMetadata($metadataPrefix, $item_id) { $textutil =& xoonips_getutility('text'); $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $basic = array(); xnp_get_item($_SESSION['XNPSID'], $item_id, $basic); $tmparray = array(); if (xnp_get_item_types($tmparray) == RES_OK) { foreach ($tmparray as $i) { if ($i['item_type_id'] == $basic['item_type_id']) { $itemtype = $i; break; } } } $nijc_code = $xconfig_handler->getValue('repository_nijc_code'); if ($basic['doi'] == "") { $identifier = $nijc_code . '/' . $basic['item_type_id'] . '.' . $basic['item_id']; } else { $identifier = $nijc_code . ':' . XNP_CONFIG_DOI_FIELD_PARAM_NAME . '/' . $basic['doi']; } if ($metadataPrefix == 'junii' || $metadataPrefix == 'junii2') { $lines = array(); $publisher = $xconfig_handler->getValue('repository_publisher'); $institution = $xconfig_handler->getValue('repository_institution'); $meta_author = $myxoopsConfigMetaFooter['meta_author']; if (strcasecmp($publisher, 'meta_author') == 0) { $publisher = $meta_author; } else { if (strcasecmp($publisher, 'creator') == 0) { $publisher = _MD_XOONIPS_ITEM_CONTRIBUTOR_LABEL; } else { if (strcasecmp($publisher, 'none') == 0) { $publisher = null; } } } if (strcasecmp($institution, 'meta_author') == 0) { $institution = $meta_author; } else { if (strcasecmp($institution, 'creator') == 0) { $institution = _MD_XOONIPS_ITEM_CONTRIBUTOR_LABEL; } else { if (strcasecmp($institution, 'none') == 0) { $institution = null; } } } $lines[] = "<title>" . $textutil->xml_special_chars(reset($basic['titles'])) . "</title>"; while (next($basic['titles'])) { $lines[] = "<title>" . $textutil->xml_special_chars(current($basic['titles'])) . "</title>"; } $lines[] = "<identifier>" . $textutil->xml_special_chars($identifier) . "</identifier>"; $lines[] = "<identifier xsi:type=\"URL\">" . $textutil->xml_special_chars(xnpGetItemDetailURL($basic['item_id'], $basic['doi'])) . "</identifier>"; $lines[] = "<type>itemType:" . $textutil->xml_special_chars($itemtype['name']) . "</type>"; $lines[] = "<language xsi:type=\"ISO639-2\">" . $textutil->xml_special_chars($basic['lang']) . "</language>"; if ($institution != null) { $lines[] = "<institution>" . $textutil->xml_special_chars($institution) . "</institution>"; } if ($publisher != null) { $lines[] = "<publisher>" . $textutil->xml_special_chars($publisher) . "</publisher>"; } $subject = array(); $index_ids = array(); $res = xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $index_ids); if ($res == RES_OK) { foreach ($index_ids as $xid) { if ($xid > 0) { $index = array(); $result = xnp_get_index($_SESSION['XNPSID'], $xid, $index); if ($result == 0) { $str = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); $subject[] = "{$str}"; } } } } if (!empty($basic['keywords'])) { $subject = array_merge($subject, $basic['keywords']); } $lines[] = "<subject>" . $textutil->xml_special_chars(implode(', ', $subject)) . "</subject>"; $lines[] = "<description>comment:" . $textutil->xml_special_chars($basic['description']) . "</description>"; return implode("\n", $lines); } else { if ($metadataPrefix == 'oai_dc') { /* title, identifier, type, language, subject, description */ $lines = array(); $publisher = $xconfig_handler->getValue('repository_publisher'); $meta_author = $myxoopsConfigMetaFooter['meta_author']; if (strcasecmp($publisher, 'meta_author') == 0) { $publisher = $meta_author; } else { if (strcasecmp($publisher, 'creator') == 0) { $publisher = _MD_XOONIPS_ITEM_CONTRIBUTOR_LABEL; } else { if (strcasecmp($publisher, 'none') == 0) { $publisher = null; } } } $lines[] = "<dc:title>" . $textutil->xml_special_chars($basic['title']) . "</dc:title>"; $lines[] = "<dc:identifier>" . $textutil->xml_special_chars($identifier) . "</dc:identifier>"; $lines[] = "<dc:identifier>" . $textutil->xml_special_chars(xnpGetItemDetailURL($basic['item_id'], $basic['doi'])) . "</dc:identifier>"; $lines[] = "<dc:type>itemType:" . $textutil->xml_special_chars($itemtype['name']) . "</dc:type>"; $lines[] = "<dc:language>" . $textutil->xml_special_chars($basic['lang']) . "</dc:language>"; if ($publisher != null) { $lines[] = "<dc:publisher>" . $textutil->xml_special_chars($publisher) . "</dc:publisher>"; } $subject = array(); $index_ids = array(); $res = xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $index_ids); if ($res == RES_OK) { foreach ($index_ids as $xid) { if ($xid > 0) { $index = array(); $result = xnp_get_index($_SESSION['XNPSID'], $xid, $index); if ($result == 0) { $str = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); $subject[] = "{$str}"; } } } } if (!empty($basic['keywords'])) { $subject = array_merge($subject, $basic['keywords']); } foreach ($subject as $str) { $lines[] = "<dc:subject>" . $textutil->xml_special_chars($str) . "</dc:subject>"; } $lines[] = "<dc:description>comment:" . $textutil->xml_special_chars($basic['description']) . "</dc:description>"; return implode("\n", $lines) . "\n"; } } return false; }