Browse Source

removed the cufts target module cufts no longer exists

d9
ppound 3 years ago
parent
commit
f517b52050
  1. 12
      targets/cufts/css/roblib_search_cufts.base.css
  2. 61
      targets/cufts/js/cufts_results.js
  3. 8
      targets/cufts/roblib_search_cufts.info
  4. 2
      targets/cufts/roblib_search_cufts.install
  5. 203
      targets/cufts/roblib_search_cufts.module
  6. 12
      targets/cufts/theme/roblib-search-cufts.tpl.php
  7. 28
      targets/cufts/theme/theme.inc

12
targets/cufts/css/roblib_search_cufts.base.css

@ -1,12 +0,0 @@
/*
Document : roblib_search_cufts
Created on : Jun 10, 2013, 3:07:56 PM
Author : yqjiang
Description:
Purpose of the stylesheet follows.
*/
.cufts-issns , .cufts-fulltext-coverages{
padding-left: 10px; font-size: smaller;
}

61
targets/cufts/js/cufts_results.js

@ -1,61 +0,0 @@
Drupal.behaviors.roblib_search_cufts = {
attach: function(context, settings) {
url = settings.roblib_search_cufts.search_url;
jQuery.getJSON(url, function(data) {
var items = [];
var numberOfDocs = 0;
try {
numberOfDocs = data.journals.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-cufts').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-cufts-roblib-search-cufts-results').hide();
} else {
var counter = 0;
var divs = new Array();
var content = new Array();
jQuery.each(data.journals, function(key, val) {
id = 'roblib_cufts_results_' + counter;
content[counter] = "";
divs[counter] = id;
var item_str = '<div class ="roblib-search-row" id="' + id + '">';
item_str += '<div class="roblib-title cufts">';
item_str += '<a href = "' + val.url + '">' + val.title + '</a>';
item_str += '</div>';
item_str += '</div>';
items.push(item_str);
jQuery.each(val.fulltext_coverages, function(key3, val3) {
if(typeof val3 !== 'undefined' && val3 != null ){
content[counter] += '<div class="cufts-coverage">' + val3 + "</div>";
}
});
jQuery.each(val["links"], function(key4, val4) {
if(typeof val4.print_coverage !== 'undefined' && val4.print_coverage != null ){
content[counter] += '<div class="cufts-coverage">' + val4.print_coverage + "</div>";
}
});
counter++;
});
jQuery('#' + 'roblib-search-content-cufts').empty().append(items.join(''));
qtipify(divs, content, 'Coverage');
}
var originURL = settings.roblib_search_cufts.url;
var originSuffix = settings.roblib_search_cufts.suffix;
var newSuffix = originSuffix.replace("&format=json", "");
if (parseInt(data.numOfResults) > 0)
{
jQuery('#' + 'roblib-search-cufts-more').empty().append('<a href="' + originURL + newSuffix + '">see all ' + data.numOfResults + ' results</a>');
}
else
{
jQuery('#' + 'roblib-search-content-cufts').empty().append('<p>no result</p>');
jQuery('#' + 'roblib-search-cufts-more').empty();
}
});
}
}

8
targets/cufts/roblib_search_cufts.info

@ -1,8 +0,0 @@
name = Roblib Search Cufts
dependencies[] = roblib_search
configure = admin/roblib_search/cufts_search
description = implements the Roblib Search modules _roblib_search hook
package = Roblib Search
version = 7.x-dev
core = 7.x
stylesheets[all][] = css/roblib_search_cufts.base.css

2
targets/cufts/roblib_search_cufts.install

@ -1,2 +0,0 @@
<?php

203
targets/cufts/roblib_search_cufts.module

@ -1,203 +0,0 @@
<?php
/**
* @file
* Implementation of Roblib search for searching several targets.
*/
/**
* Implements hook_menu().
*/
function roblib_search_cufts_menu() {
$items = array();
$items['admin/roblib_search/cufts_search'] = array(
'title' => 'Cufts Search Target configuration',
'description' => 'Configuration for the Roblib evergreen search target',
'page callback' => 'drupal_get_form',
'page arguments' => array('roblib_search_cufts_config_form'),
'access arguments' => array('access administration pages'),
'type' => MENU_NORMAL_ITEM,
);
$items['roblib_search/cufts/ajax/%'] = array(
'title' => 'cufts ajax',
'page callback' => 'roblib_search_cufts_ajax',
'page arguments' => array(3),
'type' => MENU_CALLBACK,
'access arguments' => array('search roblib cufts'),
);
return $items;
}
function roblib_search_cufts_config_form($form, &$form_state) {
$form['roblib_search_cufts_url'] = array(
'#type' => 'textfield',
'#title' => t('Cufts url'),
'#default_value' => variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'),
'#description' => t('The base Cufts URL, for example http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?'),
'#required' => TRUE,
);
$form['roblib_search_cufts_search_suffix'] = array(
'#type' => 'textfield',
'#title' => t('Cufts search suffix'),
'#default_value' => variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms='),
'#description' => t('The suffix will be appended to the base url for searches, for example browse_field=title&search_type=startswith&format=json&search_terms='),
'#required' => TRUE,
);
$form['roblib_search_cufts_num_results'] = array(
'#type' => 'textfield',
'#title' => t('Number of results to return'),
'#default_value' => variable_get('roblib_search_cufts_num_results', '5'),
'#description' => t('The number of results to display in the Bento box'),
'#required' => TRUE,
);
return system_settings_form($form);
}
/**
* Implements hook_permission().
*/
function roblib_search_cufts_permission() {
return array(
'search roblib cufts' => array(
'title' => t('Search the cufts target'),
'description' => t('Search oblib cufts target. This permission exposes the search blocks and allows you to see search results.'),
),
'administer roblib search cufts' => array(
'title' => t('Administer Roblib Search Cufts'),
'description' => t('Administer settings for the Roblib cufts search client.'),
),
);
}
/**
* Implements hook_theme().
*/
function roblib_search_cufts_theme() {
// set path
$path = drupal_get_path('module', 'roblib_search_cufts');
$file = 'theme.inc';
return array(
// results page
'roblib_search_cufts' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-cufts',
'variables' => array('results'=>NULL)
)
);
}
function roblib_search_cufts_preprocess_panels_pane(&$variables, $hook){
if($variables['pane']->subtype == 'roblib_search_cufts-roblib_search_cufts_results'){
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-cufts-header">';
$variables['title_suffix'] ='</div>';
}
}
function roblib_search_cufts_block_info() {
$blocks['roblib_search_cufts_results'] = array(
// info: The name of the block.
'info' => t('Cufts Search Results block'),
// Block caching options (per role, per user, etc.)
'cache' => DRUPAL_CACHE_PER_ROLE, // default
);
return $blocks;
}
function roblib_search_cufts_block_view($delta = '') {
switch ($delta) {
case 'roblib_search_cufts_results':
$block['subject'] = t('Journals');
$block['content'] = theme('roblib_search_cufts', array('results' => NULL)); //we will get the results via javascript
break;
}
return $block;
}
function roblib_search_cufts_ajax($query) {
print roblib_search_cufts_get_results($query);
exit();
}
/**
*
* @param string $query
* @return string
* json string
*/
function roblib_search_cufts_get_results($query = NULL) {
drupal_add_css(drupal_get_path('module', 'roblib_search_cufts') . '/css/roblib_search_cufts.theme.css');
// Url parameters.
if (!isset($query)) {
if (isset($_GET['roblib_query'])) {
$query = $_GET['roblib_query'];
}
else {
return '';
}
}
$query = str_replace(' ', '%20', $query);
//http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?browse_field=title&search_type=startswith&format=json&search_terms=dog&submit=Search
$url = variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?');
$url_suffix = variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms=');
$number_of_records = variable_get('roblib_search_cufts_num_results', '5');
$search_url = $url . $url_suffix . $query . '&submit=Search';
//get the total number of result
$results = drupal_http_request($search_url);
if ($results->code == '200') {
$output = $results->data;
}
else {
$output = $results->status_message;
}
$start_index = strpos($output,'"total_count":')+ strlen('"total_count":');
$end_index = strlen($output)-1;
$length=$end_index-$start_index;
$num_of_result = substr($output,$start_index,$length);
$search_url = $search_url . '&per_page='.$number_of_records;
$results = drupal_http_request($search_url);
if ($results->code == '200') {
$output = $results->data;
}
else {
$output = $results->status_message;
}
$output = str_replace('"total_count":', '"numOfResults":'.$num_of_result.',"total_count":',$output);
return $output;
}
/**
* Implements hook_help().
*
* @param type $path
* @param type $arg
* @return type
*/
function roblib_search_cufts_help($path, $arg) {
switch ($path) {
case 'admin/help#roblib_search_cufts':
return t(
'<p>
provides a target for the Roblib search module. This target uses javascript
to render the results.
</p>'
);
}
}

12
targets/cufts/theme/roblib-search-cufts.tpl.php

@ -1,12 +0,0 @@
<?php
/**
* @file roblib-search-cufts.tpl.php
*
*/
?>
<div class ="roblib-search-more" id="roblib-search-cufts-more"></div>
<div class ="roblib-search-content cufts" id="roblib-search-content-cufts">
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div>

28
targets/cufts/theme/theme.inc

@ -1,28 +0,0 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
function roblib_search_cufts_preprocess_roblib_search_cufts(&$variables) {
global $base_url;
if (!isset($query)) {
if (isset($_GET['roblib_query'])) {
$query = $_GET['roblib_query'];
}
else {
return '';
}
}
$spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/'.'spinner.gif';
$variables['spinner_path'] = $spinner_path;
$search_url = $base_url .'/roblib_search/cufts/ajax/'.urlencode($query);
drupal_add_js(drupal_get_path('module', 'roblib_search_cufts') . '/js/cufts_results.js');
$url = variable_get('roblib_search_cufts_url', 'http://cufts2.lib.sfu.ca/CJDB/PCU/browse/show?');
$url_suffix = variable_get('roblib_search_cufts_search_suffix', 'browse_field=title&search_type=startswith&format=json&search_terms=').$query;
drupal_add_js(array('roblib_search_cufts' => array('search_url' => $search_url,'url'=>$url,'suffix'=>$url_suffix)), array('type' => 'setting'));
}
?>
Loading…
Cancel
Save