function metadataFormat($identifier = null) { if ($identifier != null) { $parsed = parent::parseIdentifier($identifier); if (!$parsed) { return false; } //$identifier is wrong $tmparray = array(); if (xnp_get_item_types($tmparray) == RES_OK) { foreach ($tmparray as $i) { if ($i['item_type_id'] == $parsed['item_type_id']) { $itemtype = $i; $item_type = $itemtype['display_name']; break; } } } include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp']; $f = $itemtype['name'] . 'SupportMetadataFormat'; if (!function_exists($f)) { return false; } if (!$f($this->metadataPrefix, $parsed['item_id'])) { return false; } } return "<metadataFormat>\n<metadataPrefix>oai_dc</metadataPrefix>\n<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>\n<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>\n</metadataFormat>"; }
function filesize_by_item_id($iids) { if (count($iids) == 0) { return 0; } $itemtypes = array(); if (xnp_get_item_types($itemtypes) != RES_OK) { return 0; } $ret = 0.0; foreach ($itemtypes as $i) { if ($i['item_type_id'] == ITID_INDEX) { continue; } $modname = $i['name']; global $xoopsDB; $table = $xoopsDB->prefix("{$modname}_item_detail"); $id_name = preg_replace('/^xnp/', '', $modname) . "_id"; $query = "SELECT {$id_name} FROM {$table} where {$id_name} IN (" . implode(", ", $iids) . ")"; $result = $xoopsDB->query($query); if ($result) { $mod_iids = array(); while (list($id) = $xoopsDB->fetchRow($result)) { $mod_iids[] = $id; } include_once "../{$modname}/include/view.php"; $fname = "{$modname}GetDetailInformationTotalSize"; if (function_exists($fname)) { $ret += $fname($mod_iids); } } } return $ret; }
$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']; break; } } } // include view.php include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp']; $title = $formdata->getValue('post', 'title', 's', false); if (!isset($title)) {
function ListSets($args) { $attrs = array_merge($args, array('verb' => 'ListSets')); $limit_row = REPOSITORY_RESPONSE_LIMIT_ROW; $path_alllist = null; $msg = null; $start_index = 0; $resumptionToken = null; $resumptionToken_msg = ""; // get item type list $itemtypes = null; xnp_get_item_types($itemtypes); // check resumptionToken parameter. if (isset($args['resumptionToken'])) { $resumptionToken = $args['resumptionToken']; $result = getResumptionToken($resumptionToken); // echo "result="; var_dump($result); echo "\n"; if (count($result) > 1) { if (isset($result['last_item_id'])) { $start_index = $result['last_item_id']; } if (isset($result['args']['item_all_count'])) { $item_all_count = $result['args']['item_all_count']; } //expire resumptionToken if index tree is modified after resumptionToken has published $path_alllist = xnpListIndexTree(XOONIPS_LISTINDEX_PUBLICONLY); if (!$path_alllist || count($path_alllist) + count($itemtypes) != $item_all_count) { expireResumptionToken($args['resumptionToken']); $msg = $this->error('badResumptionToken', 'repository has been modified'); } } else { $msg = $this->error('badResumptionToken', ''); } } if (!$msg) { // list sets if (!$path_alllist) { $path_alllist = xnpListIndexTree(XOONIPS_LISTINDEX_PUBLICONLY); } $spec_list = $path_alllist; // add item type if ($itemtypes) { foreach ($itemtypes as $v) { $spec_list[] = $v; } } // create string by item index and item type $ct = min($start_index + $limit_row, count($spec_list)); for ($i = $start_index; $i < $ct; $i++) { $v = $spec_list[$i]; if (isset($v['id_fullpath'])) { $path_ar = explode(",", $v['id_fullpath']); $spec = "index" . implode(":index", $path_ar); $setname = $v['fullpath']; } else { $spec = $v['name']; $setname = $v['display_name']; } if (extension_loaded('mbstring')) { $setname = mb_convert_encoding($setname, "UTF-8", _CHARSET); } else { $setname = utf8_encode($setname); } $setname = htmlspecialchars($setname, ENT_QUOTES); $msg .= " <set>\n" . " <setSpec>" . $spec . "</setSpec>\n" . " <setName>" . $setname . "</setName>\n" . " </set>\n"; } // set or expire resumption token $leftcount = count($spec_list) - $start_index; if ($resumptionToken && $leftcount < $limit_row) { expireResumptionToken($resumptionToken); } if ($leftcount > $limit_row) { $args['item_all_count'] = count($spec_list); // set optional value(count). $resumptionToken = session_id(); setResumptionToken($resumptionToken, '', 'ListSets', $args, $ct, $limit_row, time() + REPOSITORY_RESUMPTION_TOKEN_EXPIRE_TERM); $resumptionToken_msg = "<resumptionToken>{$resumptionToken}</resumptionToken>\n"; } else { $resumptionToken_msg = ""; } return $this->header() . $this->request($attrs) . "<ListSets>\n" . $msg . $resumptionToken_msg . "</ListSets>\n" . $this->footer(); } else { // error return $this->header() . $this->request($attrs) . $msg . $this->footer(); } }
<input type='hidden' name='index_id' value='{$index_id}' /> <input type='hidden' name='recursive_index' value='{$recursive_index}' /> </form> EOT; include XOOPS_ROOT_PATH . '/footer.php'; } else { if ($export_type == 'item') { $xoopsOption['template_main'] = 'xoonips_export_license.html'; include XOOPS_ROOT_PATH . '/header.php'; if ($index_id != '') { $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";
} //retrieve item detail and set item type id to $item_type_id; $item_compo_handler =& xoonips_getormcompohandler('xoonips', 'item'); if (!$item_compo_handler->getPerm($item_id, $uid, 'read')) { redirect_header('user.php', 3, _MD_XOONIPS_ITEM_FORBIDDEN); } $item =& $item_compo_handler->get($item_id); if (!$item) { redirect_header('user.php', 3, _MD_XOONIPS_ITEM_FORBIDDEN); } $basic =& $item->getVar('basic'); $item_type_id = $basic->get('item_type_id'); //retrieve module name to $modname $tmp = array(); $itemtypes = array(); if (xnp_get_item_types($tmp) != RES_OK) { redirect_header(XOOPS_URL . '/', 3, "ERROR xnp_get_item_types"); break; } else { foreach ($tmp as $i) { $itemtypes[$i['item_type_id']] = $i; } $itemtype = $itemtypes[$item_type_id]; $modname = $itemtype['name']; } if ($op == 'reject_certify' || $op == 'accept_certify' || $op == 'withdraw') { $item_lock_handler =& xoonips_getormhandler('xoonips', 'item_lock'); $succeeded_index_ids = array(); foreach ($formdata->getValueArray('post', 'index_ids', 'i', true) as $index_id) { if ($op == 'withdraw' && $item_lock_handler->isLocked($item_id)) { redirect_header(XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $item_id, 5, sprintf(_MD_XOONIPS_ERROR_CANNOT_WITHDRAW_LOCKED_ITEM, xoonips_get_lock_type_string($item_lock_handler->getLockType($item_id))));
/** * Return xml with Basic information. * * To write xml of item to specified folder. * * In the case of writing attachment file, at first create a files/ folder * in the specified folder. * next it write attachment file to the folder. * * path of xml file is "${export_path}/${item_id}.xml" * path of attchment file is "${export_path}/files/${file_id}" * * If unknown item_id or error in database exists, return false. * * @param export_path folder that export file is written to. * @param export_xml name of export file(xml file) * @param item_id item id that is exported * @param attachment true if attachment files are exported, else false. * @return returns array( * 'path' => folder that export files are written to. * 'xml' => file path of xml(relative path of 'path') * 'attachments' => arary( file path of attachment 1, file path of * attachment2, .... ) ) (relative path of 'path') * return false if failed. */ function xnpExportItem($export_path, $item_id, $attachment = false, $is_absolute, $base_index_id = false) { $filename = "{$export_path}/{$item_id}.xml"; $tmpfile = tempnam('/tmp', 'XooNIps'); $fhdl = fopen($tmpfile, 'w'); if (!$fhdl) { xoonips_error("can't open file '{$tmpfile}' for write."); return false; } $xnpsid = $_SESSION['XNPSID']; $item = array(); $itemtypes = array(); $res = xnp_get_item($xnpsid, $item_id, $item); if ($res != RES_OK) { return false; } $res = xnp_get_item_types($itemtypes); if ($res != RES_OK) { return false; } else { foreach ($itemtypes as $i) { if ($i['item_type_id'] == $item['item_type_id']) { $itemtype = $i; break; } } } if (!isset($itemtype)) { return false; } include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp']; if (!fwrite($fhdl, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<item version=\"1.00\">\n")) { return false; } // item type module doesn't support export $func = "{$itemtype['name']}ExportItem"; if (!function_exists($func)) { return false; } if (!xnpExportBasic($fhdl, $item_id, $is_absolute, $base_index_id)) { return false; } $attachment_files = $func($export_path, $fhdl, $item_id, $attachment); if (!$attachment_files) { return false; } if (!fwrite($fhdl, "</item>\n")) { return false; } fclose($fhdl); // convert encoding for client environment $fp_r = fopen($tmpfile, 'r'); $fp_w = fopen($filename, 'w'); if (!$fp_r || !$fp_w) { if (!$fp_r) { xoonips_error("can't open file '{$tmpfile}' for read."); } if (!$fp_w) { xoonips_error("can't open file '{$filename}' for write."); } unlink($tmpfile); unlink($filename); if ($fp_r) { fclose($fp_r); } if ($fp_w) { fclose($fp_w); } return false; } $unicode =& xoonips_getutility('unicode'); while (!feof($fp_r)) { fputs($fp_w, $unicode->encode_utf8(fgets($fp_r, 131072), xoonips_get_server_charset())); } fclose($fp_r); fclose($fp_w); unlink($tmpfile); return array('path' => $export_path, 'xml' => "{$item_id}.xml", 'attachments' => $attachment_files['attachments']); }
/** * Item's information registered in binder specified by $binder_id * is read from database and it returns as association_array. * * Structure of assciation_array * array( 'html' => HTML of item's information, 'item_id' => number of item_id ) * * @param binder_id "ID of the binder for processing" * @return Array => Execution result * @return false => Miss * */ function xnpbinder_get_registered_items($binder_id) { $items = array(); $cri = array(); $item_id = array(); if (xnp_get_item_id_by_binder_id($_SESSION['XNPSID'], $binder_id, $cri, $item_id) != RES_OK) { return false; } if (xnp_get_items($_SESSION['XNPSID'], $item_id, $cri, $items) != RES_OK) { return false; } $itemtypes = array(); // $itemtypes[<item_type_id>]=array( detail of an itemtype ); $tmp = array(); if (xnp_get_item_types($tmp) != RES_OK) { redirect_header(XOOPS_URL . '/modules/xoonips/index.php', 3, 'ERROR xnp_get_item_types '); break; } else { foreach ($tmp as $i) { $itemtypes[$i['item_type_id']] = $i; } } $item_details = array(); foreach ($items as $i) { if (array_key_exists($i['item_type_id'], $itemtypes)) { $itemtype = $itemtypes[$i['item_type_id']]; include_once XOOPS_ROOT_PATH . '/modules/' . $itemtype['viewphp']; eval("\$body = " . $itemtype['name'] . "GetListBlock( \$i );"); $item_details[] = array('item_id' => $i['item_id'], 'html' => $body); } } return $item_details; }
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; }