Exemplo n.º 1
0
/**
 * Formulates the advanced search form array
 *
 * @return array Drupal search form array
 */
function sopac_search_form_adv()
{
    $locum = sopac_get_locum();
    $locum_cfg = $locum->locum_config;
    $getvars = sopac_parse_get_vars();
    $actions = sopac_parse_uri();
    if ($actions[0] == "search") {
        if ($actions[3]) {
            $actions[2] = $actions[2] . "/" . $actions[3];
            urlencode($actions[2]);
        }
        $search_query = $actions[2];
        $stype_selected = $actions[1] ? 'cat_' . $actions[1] : 'cat_keyword';
    }
    $sformats = array('' => 'Everything');
    foreach ($locum_cfg[format_groups] as $sfmt => $sfmt_codes) {
        $sformats[preg_replace('/,[ ]*/', '|', trim($sfmt_codes))] = ucfirst($sfmt);
    }
    $stypes = array('cat_keyword' => 'Keyword', 'cat_title' => 'Title', 'cat_author' => 'Author', 'cat_series' => 'Series', 'cat_tags' => 'Tags', 'cat_reviews' => 'Reviews', 'cat_subject' => 'Subject', 'cat_callnum' => 'Call Number', 'cat_isn' => 'ISBN or ISSN');
    $sortopts = array('' => 'Relevance', 'atoz' => 'Alphabetical A to Z', 'ztoa' => 'Alphabetical Z to A', 'catalog_newest' => 'Just Added', 'newest' => 'Pub date: Newest', 'oldest' => 'Pub date: Oldest', 'author' => 'Alphabetically by Author', 'top_rated' => 'Top Rated Items', 'popular_week' => 'Most Popular this Week', 'popular_month' => 'Most Popular this Month', 'popular_year' => 'Most Popular this Year', 'popular_total' => 'All Time Most Popular');
    // Initialize the form
    $form = array('#attributes' => array('class' => 'search-form'), '#validate' => array('sopac_search_catalog_validate'), '#submit' => array('sopac_search_catalog_submit'));
    $form['search_query'] = array('#type' => 'textfield', '#title' => t('Search term or phrase'), '#default_value' => $search_query, '#size' => 50, '#maxlength' => 255);
    $form['search_type'] = array('#type' => 'select', '#title' => t('Search by'), '#default_value' => $stype_selected, '#options' => $stypes);
    $form['sort'] = array('#type' => 'select', '#title' => t('Sorted by'), '#default_value' => '', '#options' => $sortopts);
    $form['age_group'] = array('#type' => 'select', '#title' => 'in age group', '#options' => array('' => "Any Age Group", 'adult' => "Adult", 'teen' => "Teen", 'youth' => "Youth"));
    $form['limit_avail'] = array('#type' => 'select', '#title' => 'limit to items on shelf at', '#options' => array_merge(array('' => '--', 'any' => "Any Location"), $locum_cfg['branches']), '#default_value' => $getvars['limit_avail'], '#suffix' => "</div>");
    if (count($locum_cfg[collections])) {
        foreach ($locum_cfg[collections] as $loc_collect_key => $loc_collect_var) {
            $loc_collect[$loc_collect_key] = $loc_collect_key;
        }
        $form['collection'] = array('#type' => 'select', '#title' => t('In these collections'), '#size' => 5, '#default_value' => $getvars[collection], '#options' => $loc_collect, '#multiple' => TRUE);
    }
    asort($locum_cfg[formats]);
    $form['search_format'] = array('#type' => 'select', '#title' => t('In these formats'), '#size' => 5, '#default_value' => $getvars[search_format], '#options' => $locum_cfg[formats], '#multiple' => TRUE);
    $form['publisher'] = array('#type' => 'textfield', '#title' => t('Publisher'), '#size' => 20, '#maxlength' => 255);
    $form['pub_year_start'] = array('#type' => 'textfield', '#title' => t('Published year between'), '#size' => 20, '#maxlength' => 255);
    $form['pub_year_end'] = array('#type' => 'textfield', '#title' => t('and'), '#size' => 20, '#maxlength' => 255);
    $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
    $form['clear'] = array('#name' => 'clear', '#type' => 'button', '#value' => t('Reset'), '#attributes' => array('onclick' => 'this.form.reset(); return false;'));
    return $form;
}
Exemplo n.º 2
0
function theme_sopac_review_block($block_type)
{
    global $user;
    $max_shown = 10;
    // TODO make this configurable
    $uri = sopac_parse_uri();
    // get_reviews($uid = NULL, $bnum_arr = NULL, $rev_id_arr = NULL, $limit = 10, $offset = 0, $order = 'ORDER BY rev_create_date DESC')
    $insurge = sopac_get_insurge();
    $locum = sopac_get_locum();
    switch ($block_type) {
        case 'personal':
            $reviews = $insurge->get_reviews($user->uid, NULL, NULL, $max_shown);
            $no_rev = t('You have not written any reviews yet.');
            break;
        case 'record':
            $bnum_arr[] = $uri[1];
            $locum_result = $locum->get_bib_item($uri[1]);
            $reviews = $insurge->get_reviews(NULL, $bnum_arr, NULL, $max_shown);
            $no_rev = t('No reviews have been written yet for ') . '<i>' . $locum_result['title'] . '</i>.';
            break;
        case 'overview':
        default:
            $reviews = $insurge->get_reviews(NULL, NULL, NULL, $max_shown);
            $no_rev = t('No reviews have been written yet.');
            break;
    }
    $result_page = '';
    if (count($reviews['reviews'])) {
        foreach ($reviews['reviews'] as $insurge_review) {
            $locum_result = $locum->get_bib_item($insurge_review['bnum']);
            $title_arr = explode(':', htmlentities($locum_result['title'], ENT_NOQUOTES, 'UTF-8'));
            $title = trim($title_arr[0]);
            $review_link = 'review/view/' . $insurge_review['rev_id'];
            $item_link = variable_get('sopac_url_prefix', 'cat/seek') . '/record/' . $insurge_review['bnum'];
            $result_page .= '<div class="review-block-list-item">';
            $result_page .= '<div class="review-block-revtitle">' . l(htmlentities($insurge_review['rev_title'], ENT_NOQUOTES, 'UTF-8'), $review_link) . '</div>';
            $result_page .= '<div class="review-block-itemtitle">' . t('A review of ') . '<span class="review-block-itemtitle-title">' . l($title, $item_link) . '</span></div>';
            $result_page .= "</div>\n";
        }
    } else {
        $result_page = $no_rev;
    }
    return $result_page;
}
Exemplo n.º 3
0
/**
 * Returns the form array for saving searches
 *
 * @return array Drupal form array.
 */
function sopac_savesearch_form()
{
    global $user;
    $search_path = str_replace('/savesearch/', '/search/', $_GET['q']);
    $search_query = sopac_make_pagevars(sopac_parse_get_vars());
    $uri_arr = sopac_parse_uri();
    $form_desc = 'How would you like to label your ' . $uri_arr[1] . ' search for "' . l($uri_arr[2], $search_path, array('query' => $search_query)) . '" ?';
    $form['#redirect'] = 'user/library/searches';
    $form['sopac_savesearch_form'] = array('#type' => 'fieldset', '#title' => t($form_desc), '#collapsible' => FALSE);
    $form['sopac_savesearch_form']['searchname'] = array('#type' => 'textfield', '#title' => t('Search Label'), '#size' => 48, '#maxlength' => 128, '#required' => TRUE, '#default_value' => 'My custom ' . $uri_arr[1] . ' search for "' . $uri_arr[2] . '"');
    $form['sopac_savesearch_form']['uri'] = array('#type' => 'hidden', '#value' => $search_path . '?' . $search_query);
    $form['sopac_savesearch_form']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
    return $form;
}