Skip to content

Commit

Permalink
New features & bug fix
Browse files Browse the repository at this point in the history
Bug fix for
Full Text and Peer Reviewed limiters - zero results
#14

New feature:
Option to hide PDF and HTML from result list
#13
  • Loading branch information
blackmolly committed Aug 13, 2018
1 parent 05b19c5 commit f6c435f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/install/ebsco.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ ebsco_password: "[Your api password]"
ebsco_interface: "Drupal EDS API module "
ebsco_organization: "[Institution name] "
ebsco_local_ips: ""
ebsco_show_pdf_links: 1
ebsco_show_html_links: 1
4 changes: 4 additions & 0 deletions config/schema/ebsco.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ ebsco.settings:
type: string
ebsco_local_ips:
type: string
ebsco_show_pdf_links:
type: integer
ebsco_show_html_links:
type: integer
26 changes: 20 additions & 6 deletions ebsco.module
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ function template_preprocess_ebsco_results(&$variables) {
$variables["relatedContent"]="";
$variables["processHtmlRecords"]="";
$variables['lookfor'] = '';

// get settings to display or not PDF and HTML Links
$showPDFlink=\Drupal::config('ebsco.settings')->get('ebsco_show_pdf_links', 1);
$showHTMLlink=\Drupal::config('ebsco.settings')->get('ebsco_show_html_links', 1);


if (isset($params['lookfor'])) {
$variables['lookfor'] = $params['lookfor'];
} else if (isset($params['group'])) {
Expand Down Expand Up @@ -945,6 +951,7 @@ function template_preprocess_ebsco_results(&$variables) {
$fulltextUrl= \Drupal\Core\Url::fromRoute('ebsco.fulltext', array('id' => $id))->toString();
$pdfUrl= \Drupal\Core\Url::fromRoute('ebsco.pdf', array('id' => $id))->toString();


$recordHtml="<li>"
.'<div class="record-number floatleft">'.$record->result_id.'</div>'

Expand Down Expand Up @@ -1035,13 +1042,20 @@ function template_preprocess_ebsco_results(&$variables) {

// PDF and HTML processing
$recordHtml.='<div class="result-line5">';
if ($record->full_text_availability){
$recordHtml.= '<a href="' . $fulltextUrl . '#html" class="icon html fulltext _record_link">'.t('HTML full text')."</a>&nbsp; &nbsp;";
}

if ($showHTMLlink==1) {
if ($record->full_text_availability){
$recordHtml.= '<a href="' . $fulltextUrl . '#html" class="icon html fulltext _record_link">'.t('HTML full text')."</a>&nbsp; &nbsp;";
}

}

if ($showPDFlink==1) {
if ($record->pdf_availability){
$recordHtml.= ' <a href="' . $pdfUrl . '" class="icon pdf fulltext" target="_blank">'.t('PDF full text')."</a>";
}
}

if ($record->pdf_availability){
$recordHtml.= ' <a href="' . $pdfUrl . '" class="icon pdf fulltext" target="_blank">'.t('PDF full text')."</a>";
}

$recordHtml.='</div>'

Expand Down
10 changes: 9 additions & 1 deletion lib/EBSCOAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,15 @@ public function apiSearch($search,
$query['limiter']='';
foreach ($limiters as $field => $limiter) {
// e.g. LA99:English,French,German.
$query['limiter'].= $field . ':' . implode(',', $limiter);
if ($query['limiter']=="")
{
$query['limiter'].= $field . ':' . implode(',', $limiter);
}
else
{
// add next limiters s addlimiter()
$limiters[$field][] = $limiter;
}
}
}
if (!empty($expanders)) {
Expand Down
42 changes: 41 additions & 1 deletion src/Form/EbscoAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$config->set("ebsco_organization", $values["ebsco_organization"]);
$config->set("ebsco_profile", $values["ebsco_profile"]);
$config->set("ebsco_local_ips", $values["ebsco_local_ips"]);
$config->set("ebsco_show_pdf_links", $values["ebsco_show_pdf_links"]);
$config->set("ebsco_show_html_links", $values["ebsco_show_html_links"]);
$config->save();

}
Expand Down Expand Up @@ -125,6 +127,20 @@ public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $for
'#required' => TRUE,
];

$form['ebsco_credentials']['ebsco_guest'] = [
'#type' => 'radios',
'#title' => t('Guest ?'),
'#default_value' => $config->get('ebsco_guest'),
'#description' => t("The Guest session."),
'#options' => [
t('No'),
t('Yes'),
],
'#required' => TRUE,
];



$form['ebsco_general'] = [
'#type' => 'fieldset',
'#title' => t('General Settings'),
Expand Down Expand Up @@ -165,7 +181,31 @@ public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $for
'#options' => \EBSCODocument::mode_options(),
'#required' => TRUE,
];


$form['ebsco_general']['ebsco_show_pdf_links'] = [
'#type' => 'radios',
'#title' => t('Show PDF Links ?'),
'#default_value' => $config->get('ebsco_show_pdf_links'),
'#description' => t("If the PDF link from EBSCO databases should be displayed in the result list or record level"),
'#options' => [
t('No'),
t('Yes'),
],
'#required' => TRUE,
];

$form['ebsco_general']['ebsco_show_html_links'] = [
'#type' => 'radios',
'#title' => t('Show HTML Links ?'),
'#default_value' => $config->get('ebsco_show_html_links'),
'#description' => t("If the HTML link from EBSCO databases should be displayed in the result list or record level"),
'#options' => [
t('No'),
t('Yes'),
],
'#required' => TRUE,
];

return parent::buildForm($form, $form_state);
}

Expand Down

0 comments on commit f6c435f

Please sign in to comment.