function get_item_details($data, $meta_options) { global $errors; if (check_for_bad_data($data)) { return false; } $html = ''; if (isset($data->mods)) { //mods $html .= parse_metadata($data->mods, $meta_options, $html); } else { if (isset($data->_source)) { //solr_only = true $html .= parse_metadata($data->_source, $meta_options, $html, true); } } $niec_facets = get_option('drstk_niec_metadata'); $niec_facets_to_display = array(); if (is_array($niec_facets)) { foreach ($niec_facets as $facet) { $niec_facets_to_display[$facet] = drstk_get_facet_name($facet, true); } } if (get_option('drstk_niec') == 'on' && count($niec_facets_to_display) > 0 && isset($data->niec)) { $html = parse_metadata($data->niec, $niec_facets_to_display, $html); } return $html; }
/** * Load scripts for the browse/search page * */ function drstk_browse_script() { global $wp_query; global $VERSION; global $sub_collection_pid; global $errors; //this enqueues the JS file wp_register_script('drstk_browse', plugins_url('/assets/js/browse.js', __FILE__), array('jquery')); wp_enqueue_script('drstk_browse'); $search_options = get_option('drstk_search_metadata'); $browse_options = get_option('drstk_browse_metadata'); $default_sort = get_option('drstk_default_sort'); $default_facet_sort = get_option('drstk_facet_sort_order'); //this creates a unique nonce to pass back and forth from js/php to protect $browse_nonce = wp_create_nonce('browse_drs'); $facets = drstk_get_facets_to_display(); $facets_to_display = array(); foreach ($facets as $facet) { $facets_to_display[$facet] = drstk_get_facet_name($facet); } $niec_facets = get_option('drstk_niec_metadata'); $niec_facets_to_display = array(); if (is_array($niec_facets)) { foreach ($niec_facets as $facet) { $niec_facets_to_display[$facet] = drstk_get_facet_name($facet, true); } } //this allows an ajax call from browse.js $browse_obj = array('ajax_url' => admin_url('admin-ajax.php'), 'nonce' => $browse_nonce, 'template' => $wp_query->query_vars['drstk_template_type'], 'home_url' => drstk_home_url(), 'sub_collection_pid' => $sub_collection_pid, 'search_options' => json_encode($search_options), 'browse_options' => json_encode($browse_options), 'errors' => json_encode($errors), 'facets_to_display' => $facets_to_display, 'default_sort' => $default_sort, 'default_facet_sort' => $default_facet_sort); if (get_option('drstk_niec') == 'on' && count($niec_facets_to_display) > 0) { $browse_obj['niec_facets_to_display'] = $niec_facets_to_display; } wp_localize_script('drstk_browse', 'browse_obj', $browse_obj); }