function b_xoonips_login_show() { global $xoopsUser; // hide block during site login if (is_object($xoopsUser)) { return false; } // get xoops configurations $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $usercookie = $myxoopsConfig['usercookie']; $use_ssl = $myxoopsConfig['use_ssl']; $sslloginlink = $myxoopsConfig['sslloginlink']; // set variables $block = array(); $block['lang_username'] = _MB_XOONIPS_LOGIN_USERNAME; if ($usercookie != '' && isset($_COOKIE[$usercookie])) { $block['unamevalue'] = $_COOKIE[$usercookie]; } else { $block['unamevalue'] = ''; } $block['lang_password'] = _MB_XOONIPS_LOGIN_PASSWORD; $block['lang_login'] = _MB_XOONIPS_LOGIN_LOGIN; $block['lang_lostpass'] = _MB_XOONIPS_LOGIN_LOSTPASS; $block['lang_registernow'] = _MB_XOONIPS_LOGIN_USERREG; if ($use_ssl == 1 && $sslloginlink != '') { $block['use_ssl'] = $use_ssl; $block['sslloginlink'] = $sslloginlink; } // $block['lang_rememberme'] = _MB_XOONIPS_LOGIN_REMEMBERME; return $block; }
/** * constractor * * @access private */ function XooNIpsUtilityLanguagemanager() { $this->setSingleton(); $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', $myxoopsConfig['language']); if (defined('XOOPS_TRUST_PATH') && XOOPS_TRUST_PATH != '') { $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; if (file_exists($langmanpath)) { require_once $langmanpath; $this->d3langman_instance =& D3LanguageManager::getInstance(); } } }
function XoopsGTicket() { $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); // language file if (defined('XOOPS_ROOT_PATH') && !empty($myxoopsConfig['language']) && !strstr($myxoopsConfig['language'], '/')) { if (file_exists(dirname(__DIR__) . '/language/' . $myxoopsConfig['language'] . '/gticket_messages.phtml')) { include dirname(__DIR__) . '/language/' . $myxoopsConfig['language'] . '/gticket_messages.phtml'; } } // default messages if (empty($this->messages)) { $this->messages = array('err_general' => 'GTicket Error', 'err_nostubs' => 'No stubs found', 'err_noticket' => 'No ticket found', 'err_nopair' => 'No valid ticket-stub pair found', 'err_timeout' => 'Time out', 'err_areaorref' => 'Invalid area or referer', 'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?', 'btn_repost' => 'repost'); } }
$posi_title = $posi_obj->getVar('posi_title', 'e'); $ret[$posi_id] = $posi_title; } return $ret; } // initialize variable $op = $formdata->getValue('both', 'op', 's', false, 'editprofile'); $xmember_handler =& xoonips_gethandler('xoonips', 'member'); $is_admin = $xmember_handler->isAdmin($myuid); $is_moderator = $xmember_handler->isModerator($myuid); if (!$is_admin && !$is_moderator && $myuid != $uid) { redirect_header(XOOPS_URL . '/', 3, _US_NOEDITRIGHT); exit; } $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $myxoopsConfigUser =& xoonips_get_xoops_configs(XOOPS_CONF_USER); $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $xconfig_keys = array('realname' => _US_REALNAME, 'address' => _MD_XOONIPS_ACCOUNT_ADDRESS, 'company_name' => _MD_XOONIPS_ACCOUNT_COMPANY_NAME, 'division' => _MD_XOONIPS_ACCOUNT_DIVISION, 'tel' => _MD_XOONIPS_ACCOUNT_TEL, 'country' => _MD_XOONIPS_ACCOUNT_COUNTRY, 'zipcode' => _MD_XOONIPS_ACCOUNT_ZIPCODE, 'fax' => _MD_XOONIPS_ACCOUNT_FAX); $xconfig_vars = array(); foreach ($xconfig_keys as $key => $label) { $xconfig_vars[$key] = $xconfig_handler->getValue('account_' . $key . '_optional'); } $u_handler =& xoonips_getormhandler('xoonips', 'xoops_users'); $xu_handler =& xoonips_getormhandler('xoonips', 'users'); $u_obj =& $u_handler->get($uid); $xu_obj =& $xu_handler->get($uid); if (!is_object($u_obj) || !is_object($xu_obj)) { // user not found redirect_header(XOOPS_URL . '/', 3, _US_SELECTNG); exit; }
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; }
/** * record view top page event (ETID_VIEW_TOP_PAGE: 22) * * @access public * @return bool false if failure */ function recordViewTopPageEvent() { // get start page script name global $xoopsRequestUri; $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $startpage_url = XOOPS_URL . '/index.php'; if (isset($myxoopsConfig['startpage']) && $myxoopsConfig['startpage'] != '' && $myxoopsConfig['startpage'] != '--') { $module_handler =& xoops_gethandler('module'); $startpage_module =& $module_handler->get($myxoopsConfig['startpage']); $startpage_dirname = $startpage_module->dirname(); $startpage_url = XOOPS_URL . '/modules/' . $startpage_dirname . '/index.php'; } $startpage_script = ''; if (preg_match('/^(\\S+):\\/\\/([^\\/]+)((\\/[^\\/]+)*\\/index.php)$/', $startpage_url, $matches)) { $startpage_script = $matches[3]; } // get current script name $current_script = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : ''; // compare start page script name with current script name if ($startpage_script != $current_script) { // current url is not top page return false; } // record event $obj =& $this->create(); $obj->set('event_type_id', ETID_VIEW_TOP_PAGE); $obj->set('exec_uid', $this->getExecUid()); // force insertion return $this->insert($obj, true); }
$textutil =& xoonips_getutility('text'); $formdata =& xoonips_getutility('formdata'); $op_list = array('certify', 'uncertify_confirm', 'uncertify'); $op = $formdata->getValue('post', 'op', 's', false, ''); $certify_uid = $formdata->getValue('post', 'certify_uid', 'i', false, 0); if ($op == '') { } else { if (in_array($op, $op_list)) { if ($certify_uid == 0) { die('illegal request'); } } else { die('illegal request'); } } $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); require XOOPS_ROOT_PATH . '/header.php'; if ($op == 'certify') { // check token ticket if (!$xoopsGTicket->check(true, 'xoonips_certify_user')) { exit; } //certify user $user = array(); $result = xnp_get_account($xnpsid, $certify_uid, $user); if ($result != RES_OK) { redirect_header('certifyuser.php', 3, _MD_XOONIPS_ACCOUNT_CANNOT_ACQUIRE_USER_INFO . "(in xnp_get_account result={$result})"); exit; } else { if (empty($user)) { redirect_header('certifyuser.php', 3, _MD_XOONIPS_ACCOUNT_CANNOT_ACQUIRE_USER_INFO . "(user information is empty)");
/** * GC expired sessions */ function gcSession() { $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $session_expire = $myxoopsConfig['session_expire']; $expire_time = time() + 60 * $session_expire; $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log'); $join = new XooNIpsJoinCriteria('session', 'sess_id', 'sess_id', 'LEFT', 'ts'); $criteria = new Criteria('ISNULL(ts.sess_id)', 1); // set fieldlist for same field name 'sess_id' $fieldlist = $GLOBALS['xoopsDB']->prefix('xoonips_session') . '.*'; $sessions =& $this->getObjects($criteria, false, $fieldlist, false, $join); foreach ($sessions as $session) { $su_uid = $session->get('su_uid'); $uid = $session->get('uid'); // terminate switch user mode if ($su_uid) { if (!$eventlog_handler->recordEndSuEvent($uid, $su_uid, $expire_time)) { return false; } } // insert logout event if (!$eventlog_handler->recordLogoutEvent($uid, $expire_time)) { return false; } // remove xoonips session (force deletion) if (!$this->delete($session, true)) { return false; } } return true; }
/** * execute login * * @param[in] $vars[0] id (use '' if guest login) * @param[in] $vars[1] pass (use '' if guest login) * @param[out] $response->result true:success, false:failed * @param[out] $response->error error information * @param[out] $response->success session id * @return false if error */ function execute(&$vars, &$response) { $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); // parameter check $error =& $response->getError(); if (count($vars) > 2) { $error->add(XNPERR_EXTRA_PARAM); } if (count($vars) < 2) { $error->add(XNPERR_MISSING_PARAM); } // if (isset($vars[0]) && strlen($vars[0]) > 25) { $error->add(XNPERR_INVALID_PARAM, 'too long parameter 1'); } // if ($error->get(0)) { // return if parameter error $response->setResult(false); return; } else { $id = $vars[0]; $pass = $vars[1]; } $member_handler =& xoonips_gethandler('xoonips', 'member'); $user_handler =& xoonips_getormhandler('xoonips', 'users'); $eventlog_handler =& xoonips_getormhandler('xoonips', 'event_log'); $xconfig_handler =& xoonips_getormhandler('xoonips', 'config'); $transaction = XooNIpsTransaction::getInstance(); $transaction->start(); if ($id == '') { $target_user = $xconfig_handler->getValue(XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_KEY); if ($pass != '' || $target_user != XNP_CONFIG_PUBLIC_ITEM_TARGET_USER_ALL) { $transaction->rollback(); $response->error->add(XNPERR_AUTH_FAILURE); $response->setResult(false); return false; } $user = false; $uid = UID_GUEST; $groups = array(); } else { $user =& $member_handler->loginUser($id, $pass); if (!$user) { $transaction->rollback(); // insert login failure event if (!$eventlog_handler->recordLoginFailureEvent($id)) { $response->error->add(XNPERR_SERVER_ERROR, "cannot insert event"); } // return error $response->error->add(XNPERR_AUTH_FAILURE); $response->setResult(false); return false; } $xoonips_user = $user->getVar('xoonips_user'); $uid = $xoonips_user->get('uid'); $xoops_user_handler =& xoops_gethandler('user'); $xoops_user = $xoops_user_handler->get($uid); if (0 == $xoops_user->getVar('level', 'n') || !$xoonips_user->get('activate')) { // not activated, not certified // return error $transaction->rollback(); $response->error->add(XNPERR_AUTH_FAILURE); $response->setResult(false); return false; } $groups = $xoops_user->getGroups(); } if ($myxoopsConfig['closesite'] == 1) { $allowed = false; if ($user) { foreach ($groups as $group) { if (in_array($group, $myxoopsConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) { $allowed = true; break; } } } if (!$allowed) { // site closed $transaction->rollback(); $response->error->add(XNPERR_AUTH_FAILURE); $response->setResult(false); return false; } } // remove expired xoonips sessions $session_handler =& xoonips_getormhandler('xoonips', 'session'); if (!$session_handler->gcSession()) { $transaction->rollback(); $response->error->add(XNPERR_SERVER_ERROR, "failed to gc session"); $response->setResult(false); return false; } // record $uid $_SESSION = array(); $_SESSION['xoopsUserId'] = $uid; $_SESSION['xoopsUserGroups'] = $groups; // set XNPSID(for old routines) $_SESSION['XNPSID'] = $uid == UID_GUEST ? SID_GUEST : session_id(); if ($user) { // update last_login $xoops_user->setVar('last_login', time()); if (!$xoops_user_handler->insert($xoops_user)) { } // init xoonips_session $session_handler->initSession($uid); // insert login event $eventlog_handler->recordLoginSuccessEvent($uid); } $transaction->commit(); $response->setSuccess(session_id()); $response->setResult(true); return 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; }
// User is guest group, and guest isn't admitted to access the page. redirect_header('user.php', 3, _MD_XOONIPS_ITEM_FORBIDDEN); exit; } $uid = UID_GUEST; } else { if ($xoopsUser && !$xoopsUser->isAdmin($xoopsModule->getVar('mid')) && !xnp_is_activated($xnpsid, $xoopsUser->getVar('uid'))) { // disable to access by not certified user without xoonips admin redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_MODERATOR_NOT_ACTIVATED); exit; } else { $uid = $_SESSION['xoopsUserId']; } } $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $doi_column_name = XNP_CONFIG_DOI_FIELD_PARAM_NAME; $item_id = $formdata->getValue('both', 'item_id', 'i', false, 0); $op = $formdata->getValue('both', 'op', 's', false, ''); $doi = ''; if ($doi_column_name != '') { $doi = $formdata->getValue('both', $doi_column_name, 's', false, ''); } // update $item_id by the ID specified by given doi if exists $$doi_column_name param. if ($doi != '') { $new_item_ids = array(); $result = xnpGetItemIdByDoi($doi, $new_item_ids); // error check. $new_item_ids must be one. if (count($new_item_ids) == 0) { redirect_header(XOOPS_URL . '/', 3, _MD_XOONIPS_ITEM_DOI_NOT_FOUND); exit;
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; }
/** * constructor * * @access public */ function XooNIpsUtilityFeed() { $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF); $myxoopsConfigMetaFooter =& xoonips_get_xoops_configs(XOOPS_CONF_METAFOOTER); $this->textutil =& xoonips_getutility('text'); $this->site_title = $this->textutil->xml_special_chars($myxoopsConfig['sitename']); $this->site_url = XOOPS_URL . '/'; $this->site_language = _LANGCODE; $this->site_author = $this->textutil->xml_special_chars($myxoopsConfigMetaFooter['meta_author']); $this->site_description = $this->textutil->xml_special_chars($myxoopsConfigMetaFooter['meta_description']); $this->site_copyright = $this->textutil->xml_special_chars($myxoopsConfigMetaFooter['meta_copyright']); $this->items = array(); }
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; }
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; }