function xnpbookGetMetadata($prefix, $item_id) { $mydirpath = dirname(dirname(__FILE__)); $mydirname = basename($mydirpath); if (!in_array($prefix, array('oai_dc', 'junii2'))) { return false; } // detail information $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail'); $author_handler =& xoonips_getormhandler($mydirname, 'author'); $detail_obj =& $detail_handler->get($item_id); if (empty($detail_obj)) { return false; } $detail = $detail_obj->getArray(); $criteria = new Criteria('book_id', $item_id); $criteria->setSort('author_order'); $author_objs =& $author_handler->getObjects($criteria); $detail['authors'] = array(); foreach ($author_objs as $author_obj) { $detail['authors'][] = $author_obj->get('author'); } // basic information $basic = xnpGetBasicInformationArray($item_id); $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']); // indexes $indexes = array(); if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) { foreach ($xids as $xid) { if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) { $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); } } } // files $files = array(); $mimetypes = array(); if ($detail['attachment_dl_limit'] == 0) { $file_handler =& xoonips_gethandler('xoonips', 'file'); $files = $file_handler->getFilesInfo($item_id, 'book_pdf'); foreach ($files as $file) { if (!in_array($file['mime_type'], $mimetypes)) { $mimetypes[] = $file['mime_type']; } } } // related to $related_to_handler =& xoonips_getormhandler('xoonips', 'related_to'); $related_to_ids = $related_to_handler->getChildItemIds($item_id); $related_tos = array(); foreach ($related_to_ids as $related_to_id) { $related_tos[] = array('item_id' => $related_to_id, 'item_url' => XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $related_to_id); } // repository configs $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']); // assign template global $xoopsTpl; $tpl = new XoopsTpl(); $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins'; $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('detail', $detail); $tpl->assign('indexes', $indexes); $tpl->assign('files', $files); $tpl->assign('mimetypes', $mimetypes); $tpl->assign('related_tos', $related_tos); $tpl->assign('repository', $repository); $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml'); return $xml; }
function xoonipsGetIndexCountInfo($xnpsid, $xid) { $index = array(); $result = xnp_get_index($xnpsid, $xid, $index); if ($result != RES_OK) { redirect_header(XOOPS_URL . '/index.php', 3, "ERROR"); break; } $openLevel = $index['open_level']; $indexes = array(); $result = xnp_get_all_indexes($xnpsid, array(), $indexes); if ($result != RES_OK) { redirect_header(XOOPS_URL . '/index.php', 3, "ERROR"); break; } $indexesLen = count($indexes); if ($openLevel == OL_PRIVATE) { $indexUID = $index['owner_uid']; $indexCount = 0; for ($i = 0; $i < $indexesLen; $i++) { if ($indexes[$i]['owner_uid'] == $indexUID) { $indexCount++; } } global $account; $indexNumberLimit = $account['index_number_limit']; $limitLabel = _MD_XOONIPS_INDEX_NUMBER_OF_PRIVATE_INDEX_LABEL; } else { if ($openLevel == OL_GROUP_ONLY) { $xgroup_handler =& xoonips_gethandler('xoonips', 'group'); $indexGID = $index['owner_gid']; $xg_obj =& $xgroup_handler->getGroupObject($indexGID); if (!is_object($xg_obj)) { redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ERROR_GROUP_SELECT); exit; } $indexCount = 0; for ($i = 0; $i < $indexesLen; $i++) { if ($indexes[$i]['owner_gid'] == $indexGID) { $indexCount++; } } $indexNumberLimit = $xg_obj->get('group_index_number_limit'); $limitLabel = _MD_XOONIPS_INDEX_NUMBER_OF_GROUP_INDEX_LABEL; } else { return array(false, false, false); } } return array($limitLabel, $indexCount, $indexNumberLimit); }
function xnp_update_index($sid, $newIndex) { global $xoopsDB; $result = RES_ERROR; $result = _xnpal_sessionID2UID($sid, $uid); // sid から uid を得る if ($result != RES_OK) { return $result; } $oldIndex = array(); $result = xnp_get_index($sid, $newIndex['item_id'], $oldIndex); if ($result == RES_OK) { $newParentIndex = array(); $result = xnp_get_index($sid, $newIndex['parent_index_id'], $newParentIndex); if ($result == RES_OK) { $oldParentIndex = array(); $result = xnp_get_index($sid, $oldIndex['parent_index_id'], $oldParentIndex); if ($result == RES_OK) { $newIndex["titles"] = isset($newIndex["titles"]) && is_array($newIndex["titles"]) ? $newIndex["titles"] : array(); $newIndex["keywords"] = isset($newIndex["keywords"]) && is_array($newIndex["keywords"]) ? $newIndex["keywords"] : array(); $newIndex["item_id"] = isset($newIndex["item_id"]) ? (int) $newIndex["item_id"] : 0; $newIndex["item_type_id"] = isset($newIndex["item_type_id"]) ? (int) $newIndex["item_type_id"] : 0; $newIndex["contributor_uid"] = isset($newIndex["contributor_uid"]) ? (int) $newIndex["contributor_uid"] : 0; $newIndex["description"] = isset($newIndex["description"]) ? (string) $newIndex["description"] : ""; $newIndex["last_update_date"] = isset($newIndex["last_update_date"]) ? (int) $newIndex["last_update_date"] : 0; $newIndex["creation_date"] = isset($newIndex["creation_date"]) ? (int) $newIndex["creation_date"] : 0; $newIndex["parent_index_id"] = isset($newIndex["parent_index_id"]) ? (int) $newIndex["parent_index_id"] : 0; $newIndex["owner_uid"] = isset($newIndex["owner_uid"]) ? (int) $newIndex["owner_uid"] : 0; $newIndex["owner_gid"] = isset($newIndex["owner_gid"]) ? (int) $newIndex["owner_gid"] : 0; $newIndex["open_level"] = isset($newIndex["open_level"]) ? (int) $newIndex["open_level"] : 0; $newIndex["sort_number"] = isset($newIndex["sort_number"]) ? (int) $newIndex["sort_number"] : 0; $result = _xnpal_updateIndexInternal($sid, $uid, $newIndex, $oldIndex, $newParentIndex, $oldParentIndex); } else { } } else { } } else { } if ($result == RES_OK) { _xnpal_setLastErrorString(""); } return $result; }
die('illegal request'); } do { $export_dir = xoonips_create_temporary_dir(); if (!$export_dir) { $system_message = "can't make directory '{$export_dir}'"; $op = 'list'; break; } //chdir($export_dir); if ($export_type == 'index') { // // exprot index tree structure only // $index = array(); $res = xnp_get_index($_SESSION['XNPSID'], intval($index_id), $index); if ($res != RES_OK) { $system_message = "can't get indexes"; $op = 'list'; break; } $tmpfile = tempnam("/tmp", "XNP"); $filename = "{$export_dir}/index.xml"; $fp = fopen($tmpfile, "w"); if (!$fp) { $system_message = "can't open file '{$tmpfile}' for write."; $op = 'list'; break; } if (xoonips_export_index_xml($fp, $index_id, $recursive_index == 1)) { fclose($fp);
$system_message .= '<span style="color: red;">' . _MD_XOONIPS_ITEM_WARNING_ITEM_STORAGE_LIMIT . '(gid=' . $gid . ')</span><br />'; } } } //check registration to Private Index //if there is no registration, registration of items are forbidden. $user = array(); $private_index_flag = false; // true if private index is selected $public_index_flag = false; // true if public index is selected $group_index_flag = false; // true if group index is selected foreach ($checked_xids as $xid) { $index = array(); $result = xnp_get_index($xnpsid, $xid, $index); if ($result != RES_OK) { continue; } if ($index['open_level'] == OL_PRIVATE) { $private_index_flag = true; } else { if ($index['open_level'] == OL_GROUP_ONLY) { $group_index_flag = true; } else { if ($index['open_level'] == OL_PUBLIC) { $public_index_flag = true; } } } }
function xnpconferenceGetMetadata($prefix, $item_id) { $mydirpath = dirname(dirname(__FILE__)); $mydirname = basename($mydirpath); if (!in_array($prefix, array('oai_dc', 'junii2'))) { return false; } // detail information $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail'); $author_handler =& xoonips_getormhandler($mydirname, 'author'); $detail_obj =& $detail_handler->get($item_id); if (empty($detail_obj)) { return false; } $detail = $detail_obj->getArray(); $criteria = new Criteria('conference_id', $item_id); $criteria->setSort('author_order'); $author_objs =& $author_handler->getObjects($criteria); $detail['authors'] = array(); foreach ($author_objs as $author_obj) { $detail['authors'][] = $author_obj->get('author'); } $detail['conference_from_iso8601'] = xnpISO8601($detail['conference_from_year'], $detail['conference_from_month'], $detail['conference_from_mday']); $detail['conference_to_iso8601'] = xnpISO8601($detail['conference_to_year'], $detail['conference_to_month'], $detail['conference_to_mday']); $types = xnpconferenceGetTypes(); $detail['presentation_type_display'] = $types[$detail['presentation_type']]; // basic information $basic = xnpGetBasicInformationArray($item_id); $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']); // indexes $indexes = array(); if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) { foreach ($xids as $xid) { if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) { $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); } } } // files $files = array(); $mimetypes = array(); $file_handler =& xoonips_gethandler('xoonips', 'file'); if ($detail['attachment_dl_limit'] == 0) { $files = $file_handler->getFilesInfo($item_id, 'conference_file'); foreach ($files as $file) { if (!in_array($file['mime_type'], $mimetypes)) { $mimetypes[] = $file['mime_type']; } } } // related to $related_to_handler =& xoonips_getormhandler('xoonips', 'related_to'); $related_to_ids = $related_to_handler->getChildItemIds($item_id); $related_tos = array(); foreach ($related_to_ids as $related_to_id) { $related_tos[] = array('item_id' => $related_to_id, 'item_url' => XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $related_to_id); } // repository configs $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']); // conference date if ($detail['conference_from_year'] == $detail['conference_to_year']) { if ($detail['conference_from_month'] == $detail['conference_to_month']) { if ($detail['conference_from_mday'] == $detail['conference_to_mday']) { if ($basic['lang'] == 'jpn') { $fmt = "%1\$d年%2\$d月%3\$d日"; } else { $fmt = '%7$s %3$d, %1$d'; } } else { if ($basic['lang'] == 'jpn') { $fmt = "%1\$d年%2\$d月%3\$d〜%6\$d日"; } else { $fmt = '%7$s %3$d-%6$d, %1$d'; } } } else { if ($basic['lang'] == 'jpn') { $fmt = "%1\$d年%2\$d月%3\$d日〜%5\$d月%6\$d日"; } else { $fmt = '%7$s %3$d-%8$s %6$d, %1$d'; } } } else { if ($basic['lang'] == 'jpn') { $fmt = "%1\$d年%2\$d月%3\$d日〜%4\$d年%5\$d月%6\$d日"; } else { $fmt = '%7$s %3$d %1$d-%8$s %6$d %4$d'; } } $month_str = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'); $detail['conference_date'] = sprintf($fmt, $detail['conference_from_year'], $detail['conference_from_month'], $detail['conference_from_mday'], $detail['conference_to_year'], $detail['conference_to_month'], $detail['conference_to_mday'], $month_str[$detail['conference_from_month']], $month_str[$detail['conference_to_month']]); if (_CHARSET != 'UTF-8' && ($basic['lang'] = 'jpn')) { $detail['conference_date'] = mb_convert_encoding($detail['conference_date'], _CHARSET, 'UTF-8'); } // assign template global $xoopsTpl; $tpl = new XoopsTpl(); $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins'; $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('detail', $detail); $tpl->assign('indexes', $indexes); $tpl->assign('files', $files); $tpl->assign('mimetypes', $mimetypes); $tpl->assign('related_tos', $related_tos); $tpl->assign('repository', $repository); $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml'); return $xml; }
function xnppaperGetMetadata($prefix, $item_id) { $mydirpath = dirname(dirname(__FILE__)); $mydirname = basename($mydirpath); if (!in_array($prefix, array('oai_dc', 'junii2'))) { return false; } // module config $mhandler =& xoops_gethandler('module'); $chandler =& xoops_gethandler('config'); $module = $mhandler->getByDirname($mydirname); $mconfig = $chandler->getConfigsByCat(false, $module->get('mid')); // detail information $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail'); $author_handler =& xoonips_getormhandler($mydirname, 'author'); $detail_obj =& $detail_handler->get($item_id); if (empty($detail_obj)) { return false; } $detail = $detail_obj->getArray(); $criteria = new Criteria('paper_id', $item_id); $criteria->setSort('author_order'); $author_objs =& $author_handler->getObjects($criteria); $detail['authors'] = array(); foreach ($author_objs as $author_obj) { $detail['authors'][] = $author_obj->get('author'); } $detail['start_page'] = ''; $detail['end_page'] = ''; if (!empty($detail['page'])) { if (preg_match('/^(\\d+)\\s*[- ,_]+\\s*(\\d+)$/', $detail['page'], $matches)) { $detail['start_page'] = intval($matches[1]); $slen = strlen($matches[1]); $elen = strlen($matches[2]); if ($slen <= $elen) { $detail['end_page'] = intval($matches[2]); } else { $detail['end_page'] = intval(substr($matches[1], 0, $slen - $elen) . $matches[2]); } } else { $detail['start_page'] = $detail['end_page'] = intval($detail['page']); } } if ($mconfig['abstract_access_rights'] != 1) { // abstract has no rights to the public $detail['abstract'] = ''; } // basic information $basic = xnpGetBasicInformationArray($item_id); $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']); // indexes $indexes = array(); if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) { foreach ($xids as $xid) { if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) { $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); } } } // files $files = array(); $mimetypes = array(); $file_handler =& xoonips_gethandler('xoonips', 'file'); if ($mconfig['pdf_access_rights'] == 1) { $files = $file_handler->getFilesInfo($item_id, 'paper_pdf_reprint'); foreach ($files as $file) { if (!in_array($file['mime_type'], $mimetypes)) { $mimetypes[] = $file['mime_type']; } } } // related to $related_to_handler =& xoonips_getormhandler('xoonips', 'related_to'); $related_to_ids = $related_to_handler->getChildItemIds($item_id); $related_tos = array(); foreach ($related_to_ids as $related_to_id) { $related_tos[] = array('item_id' => $related_to_id, 'item_url' => XOOPS_URL . '/modules/xoonips/detail.php?item_id=' . $related_to_id); } // repository configs $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']); // assign template global $xoopsTpl; $tpl = new XoopsTpl(); $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins'; $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('detail', $detail); $tpl->assign('indexes', $indexes); $tpl->assign('files', $files); $tpl->assign('mimetypes', $mimetypes); $tpl->assign('related_tos', $related_tos); $tpl->assign('repository', $repository); $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml'); return $xml; }
/** * export index * * @param fhdl file handle that indexes are exported to. * @param index_id id of index to display * @param recurse true:export recursively index that hangs under index_id. * @return true:success, false:failure */ function xnpExportIndex($fhdl, $index_id, $recurse) { if (!$fhdl) { return false; } $myts =& MyTextSanitizer::getInstance(); $xnpsid = $_SESSION['XNPSID']; $index = array(); $child = array(); $res = xnp_get_index($xnpsid, $index_id, $index); if ($res != RES_OK) { return false; } $res = xnp_get_indexes($xnpsid, $index_id, array(), $child); if ($res != RES_OK) { return false; } if (!fwrite($fhdl, "<index parent_id=\"{$index['parent_index_id']}\" id=\"{$index_id}\">\n" . '<title>' . $myts->htmlSpecialChars($index['titles'][DEFAULT_INDEX_TITLE_OFFSET]) . "</title>\n" . "</index>\n")) { return false; } $xml = array(); if ($recurse) { $res = xnp_get_indexes($xnpsid, $index_id, array('orders' => array(array('sort_number', 0))), $child); if ($res == RES_OK) { foreach ($child as $i) { if (!xnpExportIndex($fhdl, $i['item_id'], $recurse)) { return false; } } } } return true; }
function xnpbinderGetMetadata($prefix, $item_id) { $mydirpath = dirname(dirname(__FILE__)); $mydirname = basename($mydirpath); if (!in_array($prefix, array('oai_dc', 'junii2'))) { return false; } // detail information $detail_handler =& xoonips_getormhandler($mydirname, 'item_detail'); $detail_obj =& $detail_handler->get($item_id); if (empty($detail_obj)) { return false; } $detail = $detail_obj->getArray(); $detail['links'] = xnpbidner_get_child_item_urls($item_id); // basic information $basic = xnpGetBasicInformationArray($item_id); $basic['publication_date_iso8601'] = xnpISO8601($basic['publication_year'], $basic['publication_month'], $basic['publication_mday']); // indexes $indexes = array(); if (xnp_get_index_id_by_item_id($_SESSION['XNPSID'], $item_id, $xids) == RES_OK) { foreach ($xids as $xid) { if (xnp_get_index($_SESSION['XNPSID'], $xid, $index) == RES_OK) { $indexes[] = xnpGetIndexPathServerString($_SESSION['XNPSID'], $xid); } } } // repository configs $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $repository = array('download_file_compression' => $xconfig_handler->getValue('download_file_compression'), 'nijc_code' => $xconfig_handler->getValue('repository_nijc_code'), 'publisher' => $xconfig_handler->getValue('repository_publisher'), 'institution' => $xconfig_handler->getValue('repository_institution'), 'meta_author' => $myxoopsConfigMetaFooter['meta_author']); // assign template global $xoopsTpl; $tpl = new XoopsTpl(); $tpl->plugins_dir[] = XOONIPS_PATH . '/class/smarty/plugins'; $tpl->assign($xoopsTpl->get_template_vars()); $tpl->assign('basic', $basic); $tpl->assign('detail', $detail); $tpl->assign('indexes', $indexes); $tpl->assign('repository', $repository); $xml = $tpl->fetch('db:' . $mydirname . '_oaipmh_' . $prefix . '.xml'); return $xml; }
/** * check rights to access to item_id. to control displaying PDF Reprint and Abstract. * @return OL_PRIVATE accessible by way of private index * @return OL_GROUP_ONLY accessible by way of group index * @return OL_PUBLIC accessible by way of public index * @reutrn false can't access or error */ function xnpGetAccessRights($item_id) { $xnpsid = $_SESSION['XNPSID']; $xids = array(); $result = xnp_get_index_id_by_item_id($xnpsid, $item_id, $xids); if ($result != RES_OK) { return false; } $len = count($xids); $indexes = array(); $open_levels = array(); for ($i = 0; $i < $len; $i++) { $xid = $xids[$i]; $index = array(); $result = xnp_get_index($xnpsid, $xid, $index); if ($result == RES_OK) { $open_levels[$index['open_level']] = true; } } if (isset($open_levels[OL_PRIVATE])) { return OL_PRIVATE; } if (isset($open_levels[OL_GROUP_ONLY])) { return OL_GROUP_ONLY; } if (isset($open_levels[OL_PUBLIC])) { return OL_PUBLIC; } return false; }