Skip to content

Commit

Permalink
Merge pull request #50 from AlexanderBlanchardAC/summon_new_features
Browse files Browse the repository at this point in the history
Summon new features
  • Loading branch information
AlexanderBlanchardAC authored May 21, 2024
2 parents 063e933 + 8717820 commit a83ed39
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 23 deletions.
27 changes: 18 additions & 9 deletions code/web/RecordDrivers/SummonRecordDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ public function isValid() {
}

public function getBookcoverUrl($size='large', $absolutePath = false) {
// require_once ROOT_DIR . '/sys/LibraryLocation/Library.php';
global $library;

global $configArray;
if ($size == 'small' || $size == 'medium'){
$sizeInArray = 'thumbnail_m';
}else{
$sizeInArray = 'thumbnail_l';
}
if (!empty($this->record[$sizeInArray][0])) {
$imageDimensions = getimagesize($this->record[$sizeInArray][0]);
if ($sizeInArray == 'thumbnail_m' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
} elseif ($sizeInArray == 'thumbnail_l' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
}

if ($library->showAvailableCoversInSummon) {
if(!empty($this->record[$sizeInArray][0])){
$imagePath = $this->record[$sizeInArray][0];

$imageDimensions = getImageSize($imagePath);
if($imageDimensions[0] > 10){
return $imagePath;
}
}
}
if ($absolutePath) {
$bookCoverUrl = $configArray['Site']['url'];
Expand Down Expand Up @@ -242,6 +248,9 @@ public function getStaffView() {
public function getTitle() {
if (isset($this->record['Title'])) {
$title=$this->record['Title'][0];
if (isset($this->record['Subtitle'])) {
$title .= ': ' . $this->record['Subtitle'][0];
}
} else {
$title='Unknown Title';
}
Expand Down Expand Up @@ -339,8 +348,8 @@ public function getPrimaryAuthor() {
}

public function getAuthor() {
if(isset($this->record['Author'][0])) {
$author=$this->record['Author'][0];
if(isset($this->record['Author_xml'][0]['fullname'])) {
$author=$this->record['Author_xml'][0]['fullname'];
} else {
$author='Unknown Title';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{strip}
{* TODO: Consider renaming classes to assume they are under the exploreMoreBar class *}
{if !empty($showExploreMoreOptions)}
<div class="exploreMoreBar row">
{*<div class="label-left">*}
<div class="label-top">
Expand Down Expand Up @@ -50,4 +51,9 @@
</div>

</div>
{/strip}
{else}
<div>
</div>
{/if}
{/strip}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{if !empty($showMoreInfo)}
{if $showMoreInfo !== false}
<div class="btn-group btn-group-sm">
<a href="{if !empty($summUrl)}{$summUrl}{else}{$recordDriver->getLinkUrl()}{/if}" class="btn btn-sm btn-tools" onclick="AspenDiscovery.EBSCO.trackEdsUsage('{$recordDriver->getPermanentId()}')" target="_blank" aria-label="{translate text='More Info' isPublicFacing=true} ({translate text='opens in new window' isPublicFacing=true})"><i class="fas fa-external-link-alt" role="presentation"></i> {translate text="More Info" isPublicFacing=true}</a>
<a href="{if !empty($summUrl)}{$summUrl}{else}{$recordDriver->getLinkUrl()}{/if}" class="btn btn-sm btn-tools" onclick="AspenDiscovery.Summon.trackSummonUsage('{$recordDriver->getPermanentId()}')" target="_blank" aria-label="{translate text='More Info' isPublicFacing=true} ({translate text='opens in new window' isPublicFacing=true})"><i class="fas fa-external-link-alt" role="presentation"></i> {translate text="More Info" isPublicFacing=true}</a>
</div>
{/if}
{if $showFavorites == 1}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.google.com/
HostUrl=https://files.mtstatic.com/site_11811/55152/0?Expires=1708452791&Signature=O-eIysOYl-1drJTT2f6LTnuDXMhKycAnvuWBQT53Y5WC-uFeYwIE744-kFoVgc-gDsc1ODNBFX1G09SEdxs6NAzaBLFM1c9V0Xq3GZiKsUMivxIQC8YNpa9VHLWM0KE-snOgnMcGuuzuqvpFNAZA5J7FNpYuE~F2eWzOKKYIdhw_&Key-Pair-Id=APKAJ5Y6AV4GI7A555NA
9 changes: 9 additions & 0 deletions code/web/release_notes/24.06.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@

//other


//morgan
- Added new Documentation links to several settings pages (*MKD*)
- Updates to default user roles: removed testing roles and a couple uncommonly used roles; updated role titles (*MKD*)


## This release includes code contributions from
- ByWater Solutions
- Mark Noble (MDN)
- Kirstin Kroeger (KK)
- Kodi Lein (KL)
- Liz Rea (LR)
- Morgan Daigneault (MKD)

- PTFS Europe
- Alexander Blanchard (AB)
- Jacob O'Mara (JO)



7 changes: 7 additions & 0 deletions code/web/sys/DBMaintenance/summon_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,12 @@ function getSummonUpdates() {
'ALTER TABLE library ADD COLUMN summonApiPassword VARCHAR(50)',
],
],
'add_book_cover_display_control_in_library_settings' => [
'title' => 'Display Available Book Covers in Summon',
'description' => 'Whether to display available book covers in Summon Searcher',
'sql' => [
"ALTER TABLE library ADD COLUMN showAvailableCoversInSummon TINYINT(1) DEFAULT 0",
],
],
];
}
17 changes: 17 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/24.06.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,26 @@ function getUpdates24_06_00(): array {
"ALTER TABLE ebsco_eds_settings ADD COLUMN fullTextLimiter TINYINT NOT NULL DEFAULT 1;",
],
], //full_text_limiter
//alexander - PTFS Europe
'summon_ip_addresses' => [
'title' => 'Summon IP address configuration',
'description' => 'Allow configuration of which IP addresses should automatically authenticate with Summon',
'continueOnError' => true,
'sql' => [
'ALTER TABLE ip_lookup ADD COLUMN authenticatedForSummon TINYINT DEFAULT 0',
]
], //summon authentication
'explore_more_section_control' => [
'title' => 'Explore More Section Control',
'description' => 'Allow control over whether the Explore More Section is displayed',
'sql' => [
"ALTER TABLE layout_settings ADD COLUMN showExploreMoreOptions TINYINT DEFAULT '1'",
]
],//control_whether_the_explore_more_box_is_displayed

//other



];
}
10 changes: 5 additions & 5 deletions code/web/sys/ExploreMore.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
global $enabledModules;
if (!empty($searchTerm) && array_key_exists('Summon', $enabledModules) && $library->summonSettingsId != -1 && $activeSection != 'summon') {
//Load Summon Options
/** @var Search_Object_SummonSearcher $summonSearcher */
/** @var SearchObject_SummonSearcher $summonSearcher */
$summonSearcher = SearchObjectFactory::initSearchObject('Summon');
$summonSearcher->setSearchTerms([
'lookfor' => $searchTerm,
Expand All @@ -745,9 +745,9 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
$numMatches = $summonResults['recordCount'];
if ($numMatches > 1) {
if ($appliedTheme != null && !empty($appliedTheme->articlesDBImage)) {
//TODO path to image files
$image = '/files/origional/' . $appliedTheme->articlesDBImage;
} else {
//TODO inset path to default image
$image = '/interface/themes/responsive/images/summon.png';
}
$exploreMoreOptions['searchLinks'][] = [
'label' => translate([
Expand All @@ -760,8 +760,8 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
1 => $searchTerm,
'isPublicFacing' => true,
]),
//'image' => $image,
//'link' => TODO,
'image' => $image,
'link' => '/Summon/Results?lookfor=' . urlencode($searchTerm),
'openInNewWindow' => false,
];
}
Expand Down
1 change: 1 addition & 0 deletions code/web/sys/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ function loadDisplayOptions($fromBookCoverProcessing = false) {
$this->assign('showDisplayNameInHeader', $library->showDisplayNameInHeader);
$this->assign('externalMaterialsRequestUrl', $library->externalMaterialsRequestUrl);
$this->assign('languageAndDisplayInHeader', $library->languageAndDisplayInHeader);
$this->assign('showExploreMoreOptions', $library->getLayoutSettings()->showExploreMoreOptions);

if ($location != null) {
$this->assign('showDisplayNameInHeader', $location->showDisplayNameInHeader);
Expand Down
11 changes: 10 additions & 1 deletion code/web/sys/LibraryLocation/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class Library extends DataObject {

//Summon Settings
public $summonSettingsId;
public $showAvailableCoversInSummon;

//SSO
public /** @noinspection PhpUnused */
Expand Down Expand Up @@ -3703,7 +3704,6 @@ static function getObjectStructure($context = ''): array {
'label' => 'Summon',
'hideInLists' => true,
'renderAsHeading' => true,
// 'permissions' => ['A'],
'properties' => [
'summonSettingsId' => [
'property' => 'summonSettingsId',
Expand All @@ -3714,6 +3714,14 @@ static function getObjectStructure($context = ''): array {
'hideInLists' => true,
'default' => -1,
],
'showAvailableCoversInSummon' => [
'property' => 'showAvailableCoversInSummon',
'type' => 'checkbox',
'label' => 'Show Available Covers in Summon',
'description' => 'Determine whether or not available book covers should be displayed in Summon',
'hideInLists' => true,
'default' => 0,
],
],
],

Expand Down Expand Up @@ -4951,6 +4959,7 @@ public function getApiInfo(): array {
'passwordLabel' => $this->loginFormPasswordLabel ?? 'Library Card Number',
'code' => $this->ilsCode,
'finePaymentType' => (int)$this->finePaymentType,
'showAvailableCoversInSummon' => $this->showAvailableCoversInSummon,
];
if (empty($this->baseUrl)) {
$apiInfo['baseUrl'] = $configArray['Site']['url'];
Expand Down
88 changes: 82 additions & 6 deletions code/web/sys/SearchObject/SummonSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
protected $searchType = 'basic';

/** Values for the options array*/
protected $holdings = false;
protected $holdings = true;
protected $didYouMean = false;
protected $language = 'en';
protected $idsToFetch = array();
/**@var int */
protected $maxTopics = 1;
protected $groupFilters = array();
protected $rangeFilters = array();
protected $openAccessFilter = false;
protected $expand = false;
protected $sortOptions = array();
Expand All @@ -58,6 +57,7 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
protected $defaultSort = 'relevance';
protected $query;
protected $filters = array();
protected $rangeFilters = array();

/**
* @var int
Expand Down Expand Up @@ -92,6 +92,18 @@ class SearchObject_SummonSearcher extends SearchObject_BaseSearcher{
'SourceType,or,1,30',
];

protected $limits = [
'IsPeerReviewed,or,1,30',
'IsScholarly,or,1,30',
];

protected $rangeFacets = [
];

protected $limitList = [];
protected $limitFields;


protected $facetFields;

public function __construct() {
Expand Down Expand Up @@ -233,13 +245,15 @@ public function getOptions () {
//Fetch specific records
's.fids' =>$this->idsToFetch,
//Side facets to filter by
's.ff' =>$this->facets,
's.ff' =>array_merge($this->facets, $this->limits),
//Filters that are active - from side facets
's.fvf' => $this->getSummonFilters(),
//Default 1
's.rec.topic.max' => $this->maxTopics,
//Filters
's.fvgf' => $this->groupFilters,
//Range Facets
's.rff' => $this->rangeFacets,
//Filters
's.rf' => $this->rangeFilters,
//Order results
Expand Down Expand Up @@ -275,9 +289,28 @@ public function processData($recordData) {
$this->page = $recordData['query']['pageNumber'];
$this->resultsTotal = $recordData['recordCount'];
$this->filters = $recordData['query']['facetValueFilters'];
$this->facetFields= $recordData['facetFields'];
$splitFacets = $this->splitFacets($recordData['facetFields']);
$this->facetFields = $splitFacets['facetFields'];
$this->limitFields = $splitFacets['limitFields'];
}
return $recordData;
return $recordData;
}

public function splitFacets($combinedFacets) {
$splitFacets = [];
foreach($combinedFacets as $facet) {
foreach ($this->facets as $facetName) {
if (strpos($facetName, $facet['displayName']) !== false) {
$splitFacets['facetFields'][] = $facet;
}
}
foreach ($this->limits as $limitName) {
if (strpos($limitName, $facet['displayName']) !== false) {
$splitFacets['limitFields'][] = $facet;
}
}
}
return $splitFacets;
}

/**
Expand Down Expand Up @@ -428,7 +461,6 @@ public function renderLinkWithSort($newSort) {
*/
public function getFacetSet() {
$availableFacets = [];
$label = '';
$this->filters = [];
if (isset($this->facetFields)) {
foreach ($this->facetFields as $facetField) {
Expand All @@ -445,6 +477,11 @@ public function getFacetSet() {
if ($facetId == 'ContentType') {
$availableFacets[$facetId]['collapseByDefault'] = false;
}

if ($facetId == 'IsScholarly' || $facetId == 'IsPeerReviewed') {
$availableFacets[$facetId]['multiSelect'] = false;
}

$list = [];
foreach ($facetField['counts'] as $value) {
$facetValue = $value['value'];
Expand All @@ -469,6 +506,41 @@ public function getFacetSet() {
return $availableFacets;
}

public function getLimitList() {

$availableLimits=[];
if (isset($this->limitFields)){
foreach($this->limitFields as $limitOption){
$limitId = $limitOption['displayName'];
$parts = preg_split('/(?=[A-Z])/', $limitId, -1, PREG_SPLIT_NO_EMPTY);
$displayName = implode(' ', $parts);

foreach($limitOption['counts'] as $value){
if ($value['value'] == 'true') {
$availableLimits[$limitId] = [
'display' => $displayName,
'value' => $limitId,
'isApplied' => ($this->limiters[$limitId]) == 'y' ? 1 : 0,
'url' => $this->renderLinkWithLimiter($limitId),
'removalUrl' => $this->renderLinkWithoutLimiter($limitId),
];
}
}

}
}
return $availableLimits;
}

public function createSearchLimits() {
foreach ($this->limiters as $limiter => $limiterOptions) {
if ($this->limiters[$limiter] == 'y') {
$this->limitList[$limiter] = $limiterOptions;
}
}
return $this->limitList;
}

//Retreive a specific record - used to retreive bookcovers
public function retrieveRecord ($id) {
$baseUrl = $this->summonBaseApi . '/' .$this->version . '/' .$this->service;
Expand All @@ -484,6 +556,10 @@ public function retrieveRecord ($id) {
//Compile filter options chosen in side facets and add to filter array to be passed in via options array
public function getSummonFilters() {
$this->filters = array();
$this->createSearchLimits();
if (isset($this->limitList) && isset($this->filterList)) {
$this->filterList = array_merge($this->limitList, $this->filterList);
}
foreach ($this->filterList as $key => $value) {
if (is_array($value)) {
foreach ($value as $val) {
Expand Down
Loading

0 comments on commit a83ed39

Please sign in to comment.