diff --git a/targets/cufts/css/roblib_search_cufts.base.css b/targets/cufts/css/roblib_search_cufts.base.css deleted file mode 100644 index 2277c3c..0000000 --- a/targets/cufts/css/roblib_search_cufts.base.css +++ /dev/null @@ -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; -} - diff --git a/targets/cufts/js/cufts_results.js b/targets/cufts/js/cufts_results.js deleted file mode 100644 index 9133578..0000000 --- a/targets/cufts/js/cufts_results.js +++ /dev/null @@ -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 = '
'; - item_str += '
'; - item_str += '' + val.title + ''; - item_str += '
'; - item_str += '
'; - items.push(item_str); - jQuery.each(val.fulltext_coverages, function(key3, val3) { - if(typeof val3 !== 'undefined' && val3 != null ){ - content[counter] += '
' + val3 + "
"; - } - }); - jQuery.each(val["links"], function(key4, val4) { - if(typeof val4.print_coverage !== 'undefined' && val4.print_coverage != null ){ - content[counter] += '
' + val4.print_coverage + "
"; - } - }); - 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('see all ' + data.numOfResults + ' results'); - } - else - { - jQuery('#' + 'roblib-search-content-cufts').empty().append('

no result

'); - jQuery('#' + 'roblib-search-cufts-more').empty(); - } - }); - } -} - - - diff --git a/targets/cufts/roblib_search_cufts.info b/targets/cufts/roblib_search_cufts.info deleted file mode 100644 index f6620e2..0000000 --- a/targets/cufts/roblib_search_cufts.info +++ /dev/null @@ -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 \ No newline at end of file diff --git a/targets/cufts/roblib_search_cufts.install b/targets/cufts/roblib_search_cufts.install deleted file mode 100644 index a4abe2d..0000000 --- a/targets/cufts/roblib_search_cufts.install +++ /dev/null @@ -1,2 +0,0 @@ - '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'] = '
'; - $variables['title_suffix'] ='
'; - } -} - -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( - '

- provides a target for the Roblib search module. This target uses javascript - to render the results. -

' - ); - } -} - diff --git a/targets/cufts/theme/roblib-search-cufts.tpl.php b/targets/cufts/theme/roblib-search-cufts.tpl.php deleted file mode 100644 index 384e554..0000000 --- a/targets/cufts/theme/roblib-search-cufts.tpl.php +++ /dev/null @@ -1,12 +0,0 @@ - -
-
- - -
diff --git a/targets/cufts/theme/theme.inc b/targets/cufts/theme/theme.inc deleted file mode 100644 index 3780ba5..0000000 --- a/targets/cufts/theme/theme.inc +++ /dev/null @@ -1,28 +0,0 @@ - array('search_url' => $search_url,'url'=>$url,'suffix'=>$url_suffix)), array('type' => 'setting')); - -} -?>