From f683f211be55f5dcf2366d416a1d36b7315b6b49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de>
Date: Thu, 16 Jul 2015 18:12:34 +0200
Subject: [PATCH] refs #5636: * updated searchspecs.yaml for better
 JournalTitle search * removed getLinkISN() from Record view helper *
 implemented three-way journal-link generation in SolrAI templates: ** first
 the containerId is used if any exists ** second search for an issn if any
 exist ** third and last search for journal title

---
 local/alpha/config/vufind/searchspecs.yaml    |  2 +-
 local/config/vufind/searchspecs.yaml          |  4 +--
 .../dev/config/vufind/searchspecs.yaml.sample |  2 +-
 module/finc/src/finc/RecordDriver/SolrAI.php  | 23 +++-----------
 .../finc/src/finc/View/Helper/Root/Record.php | 14 ---------
 .../templates/RecordDriver/SolrAI/core.phtml  | 31 ++++++++++++++++---
 .../RecordDriver/SolrAI/link-isn.phtml        | 15 ++++++++-
 .../RecordDriver/SolrAI/result-list.phtml     | 27 ++++++++++++++--
 8 files changed, 72 insertions(+), 46 deletions(-)

diff --git a/local/alpha/config/vufind/searchspecs.yaml b/local/alpha/config/vufind/searchspecs.yaml
index 9f7dd7d1c23..2b741dc3e11 100644
--- a/local/alpha/config/vufind/searchspecs.yaml
+++ b/local/alpha/config/vufind/searchspecs.yaml
@@ -364,7 +364,7 @@ JournalTitle:
     series2:
       - [onephrase, 50]
       - [and , ~]
-  FilterQuery: "format:Journal"
+  FilterQuery: "format:Journal OR format:Article OR format:ElectronicBookPart"
 #  ExactSettings:
 #    DismaxFields:
 #      - title_full_unstemmed^450
diff --git a/local/config/vufind/searchspecs.yaml b/local/config/vufind/searchspecs.yaml
index 9f7dd7d1c23..0b6369cf8f4 100644
--- a/local/config/vufind/searchspecs.yaml
+++ b/local/config/vufind/searchspecs.yaml
@@ -364,7 +364,7 @@ JournalTitle:
     series2:
       - [onephrase, 50]
       - [and , ~]
-  FilterQuery: "format:Journal"
+  FilterQuery: "format:Journal OR format:Article OR format:ElectronicBookPart"
 #  ExactSettings:
 #    DismaxFields:
 #      - title_full_unstemmed^450
@@ -596,7 +596,7 @@ AllFields:
       - [onephrase, 500]
     imprint:
       - [onephrase, 500]
-      
+
 #  ExactSettings:
 #    DismaxFields:
 #      - title_full_unstemmed^600
diff --git a/local/dev/config/vufind/searchspecs.yaml.sample b/local/dev/config/vufind/searchspecs.yaml.sample
index 9f7dd7d1c23..2b741dc3e11 100644
--- a/local/dev/config/vufind/searchspecs.yaml.sample
+++ b/local/dev/config/vufind/searchspecs.yaml.sample
@@ -364,7 +364,7 @@ JournalTitle:
     series2:
       - [onephrase, 50]
       - [and , ~]
-  FilterQuery: "format:Journal"
+  FilterQuery: "format:Journal OR format:Article OR format:ElectronicBookPart"
 #  ExactSettings:
 #    DismaxFields:
 #      - title_full_unstemmed^450
diff --git a/module/finc/src/finc/RecordDriver/SolrAI.php b/module/finc/src/finc/RecordDriver/SolrAI.php
index 0a1a6c923f1..47934e336c1 100644
--- a/module/finc/src/finc/RecordDriver/SolrAI.php
+++ b/module/finc/src/finc/RecordDriver/SolrAI.php
@@ -119,7 +119,6 @@ class SolrAI extends SolrDefault implements
      * place, publisher and data.
      *
      * @return array
-     * @access protected
      */
     /*public function getFirstPublicationDetails()
     {
@@ -152,7 +151,6 @@ class SolrAI extends SolrDefault implements
      * Has FirstPublicationsDetails a Date in it
      *
      * @return boolean
-     * @access protected
      */
     protected function getIsPublicationDetailsDate()
     {
@@ -163,7 +161,6 @@ class SolrAI extends SolrDefault implements
      * Get the main author of the record.
      *
      * @return string
-     * @access protected
      */
     public function getPrimaryAuthor()
     {
@@ -174,7 +171,6 @@ class SolrAI extends SolrDefault implements
      * Get additional entries for personal names.
      *
      * @return array
-     * @access protected
      * @link http://www.loc.gov/marc/bibliographic/bd700.html
      */
     protected function getAdditionalAuthors()
@@ -222,7 +218,6 @@ class SolrAI extends SolrDefault implements
      * getPublicationDates(), getPublishers() and getPlacesOfPublication().
      *
      * @return array
-     * @access protected
      */
     public function getPublicationDetails()
     {
@@ -291,23 +286,19 @@ class SolrAI extends SolrDefault implements
     }
 
     /**
-     * Get the ISSN from a record.
+     * Get an array of all ISSNs associated with the record (may be empty).
      *
      * @return array
-     * @access protected
-     * @link https://intern.finc.info/fincproject/issues/969 description
      */
     public function getISSNs()
     {
-        return $this->getAIRecord('rft.issn');
+        return isset($this->fields['issn']) ? $this->fields['issn'] : [];
     }
 
     /**
      * Get the eISSN from a record.
      *
      * @return array
-     * @access protected
-     * @link https://intern.finc.info/fincproject/issues/969 description
      */
     public function getEISSNs()
     {
@@ -315,15 +306,13 @@ class SolrAI extends SolrDefault implements
     }
 
     /**
-     * Get an array of all ISSNs associated with the record (may be empty).
-     * Can be the main ISSN and the parent ISSNs.
+     * Get an array of all ISBNs associated with the record (may be empty).
      *
      * @return array
-     * @access protected
      */
     public function getISBNs()
     {
-        return $this->getAIRecord('rft.isbn');
+        return isset($this->fields['isbn']) ? $this->fields['isbn'] : [];
     }
 
     /**
@@ -356,7 +345,6 @@ class SolrAI extends SolrDefault implements
      * Return the jtitle field of ai records
      *
      * @return array   Return jtitle fields.
-     * @access public
      */
     public function getJTitle()
     {
@@ -367,7 +355,6 @@ class SolrAI extends SolrDefault implements
      * Return the jtitle field of ai records
      *
      * @return array   Return jtitle fields.
-     * @access public
      */
     public function getATitle()
     {
@@ -378,7 +365,6 @@ class SolrAI extends SolrDefault implements
      * Return the jtitle field of ai records
      *
      * @return array   Return jtitle fields.
-     * @access public
      */
     public function getBTitle()
     {
@@ -774,7 +760,6 @@ class SolrAI extends SolrDefault implements
      * @param string $key Key of record array
      *
      * @return mixed value of key
-     * @access public
      */
     public function getAIRecord($key = null)
     {
diff --git a/module/finc/src/finc/View/Helper/Root/Record.php b/module/finc/src/finc/View/Helper/Root/Record.php
index 63cb9fffe38..663e583b229 100644
--- a/module/finc/src/finc/View/Helper/Root/Record.php
+++ b/module/finc/src/finc/View/Helper/Root/Record.php
@@ -93,20 +93,6 @@ class Record extends \VuFind\View\Helper\Root\Record
         $this->resolverConfig = $resolverConfig;
     }
 
-    /**
-     * Render the link of the type ISN.
-     *
-     * @param array $issns Array with ISSNS
-     *
-     * @return string
-     */
-    public function getLinkISN($issns)
-    {
-        return $this->renderTemplate(
-            'link-isn.phtml', ['issns' => $issns]
-        );
-    }
-
     /**
      * Render a (list of) record icons.
      *
diff --git a/themes/finc/templates/RecordDriver/SolrAI/core.phtml b/themes/finc/templates/RecordDriver/SolrAI/core.phtml
index c9ae5830aae..7971276d1a0 100644
--- a/themes/finc/templates/RecordDriver/SolrAI/core.phtml
+++ b/themes/finc/templates/RecordDriver/SolrAI/core.phtml
@@ -71,8 +71,27 @@ if($loggedin = $this->auth()->isLoggedIn()) {
           <?
           $containerSource = $this->driver->getSourceIdentifier();
           $containerID = $this->driver->getContainerRecordID();
+
+          // finc specific journalLink generation
+          $journalLink = '';
+          $issns = $this->driver->getISSNs();
+
+          // first try to link to container id (VuFind stock-behaviour)
+          if ($containerID) {
+            $journalLink = $this->recordLink()->getUrl("$containerSource|$containerID");
+          }
+
+          // second try to search issn (finc specific)
+          elseif (!empty($issns)) {
+            $journalLink = $this->record($this->driver)->getLink('isn', $issns);
+          }
+
+          // third search for journal title (VuFind stock-behaviour)
+          else {
+            $journalLink = $this->record($this->driver)->getLink('journaltitle', $journalTitle);
+          }
           ?>
-          <a href="<?=($containerID ? $this->recordLink()->getUrl("$containerSource|$containerID") : $this->record($this->driver)->getLink('journaltitle', $journalTitle))?>"><?=$this->escapeHtml($journalTitle)?></a>
+          <a href="<?=$journalLink?>"><?=$this->escapeHtml($journalTitle)?></a>
           <? $ref = $this->driver->getContainerReference(); if (!empty($ref)) { echo $this->escapeHtml($ref); } ?>
         </td>
       </tr>
@@ -148,10 +167,12 @@ if($loggedin = $this->auth()->isLoggedIn()) {
           <th><?=$this->transEsc('In')?>: </th>
             <td>
               <? $jtitle = $aidatain['jtitle']; $issns = $aidatain['issns']; if (!empty($issns)): ?>
-                <a href="<?=$this->record($this->driver)->getLinkISN($issns)?>">
-                <? if (!empty($jtitle)): ?><?=$this->escapeHtml($jtitle)?><? endif; ?>
-                </a><? elseif (!empty($jtitle)): ?><?=$this->escapeHtml($jtitle)?><? endif; ?><? $volume = $aidatain['volume']; if (!empty($volume)): ?><? if (empty($jtitle)): ?>, <? endif; ?><?=$this->escapeHtml($volume) ?><? endif; ?><? $date = $aidatain['date']; if (!empty($date)): ?><? if (empty($volume)): ?>, <? endif; ?>(<?=$this->escapeHtml($date) ?>)<? endif; ?><? $issue = $aidatain['issue']; if (!empty($issue)): ?>, <?=$this->escapeHtml($issue) ?><? endif; ?><? $pages = $aidatain['pages']; if (!empty($pages)): ?>, <?=$this->transEsc('p.')?> <?=$this->escapeHtml($pages) ?><? endif; ?>
-              </td>
+                <a href="<?=$this->record($this->driver)->getLink('isn', $issns)?>"><? if (!empty($jtitle)): ?><?=$this->escapeHtml($jtitle)?><? endif; ?></a>
+              <? elseif (!empty($jtitle)): ?>
+                <?=$this->escapeHtml($jtitle)?>
+              <? endif; ?>
+              <? $volume = $aidatain['volume']; if (!empty($volume)): ?><? if (empty($jtitle)): ?>, <? endif; ?><?=$this->escapeHtml($volume) ?><? endif; ?><? $date = $aidatain['date']; if (!empty($date)): ?><? if (empty($volume)): ?>, <? endif; ?>(<?=$this->escapeHtml($date) ?>)<? endif; ?><? $issue = $aidatain['issue']; if (!empty($issue)): ?>, <?=$this->escapeHtml($issue) ?><? endif; ?><? $pages = $aidatain['pages']; if (!empty($pages)): ?>, <?=$this->transEsc('p.')?> <?=$this->escapeHtml($pages) ?><? endif; ?>
+            </td>
           </tr>
       <? endif; ?>
 
diff --git a/themes/finc/templates/RecordDriver/SolrAI/link-isn.phtml b/themes/finc/templates/RecordDriver/SolrAI/link-isn.phtml
index 042dc59736b..a7fab255f94 100644
--- a/themes/finc/templates/RecordDriver/SolrAI/link-isn.phtml
+++ b/themes/finc/templates/RecordDriver/SolrAI/link-isn.phtml
@@ -1 +1,14 @@
-<?=$this->url('search-results')?>?join=AND&amp;bool0[]=AND&amp;<? $issns = $this->issns; if (isset($issns)): ?><? foreach ($issns as $issn): ?>lookfor0[]=<?=$this->escapeHtml($issn)?>&amp;type0[]=ISN&amp;<? endforeach; ?><? endif; ?>sort=year&amp;view=list
\ No newline at end of file
+<?
+  // use advanced search if we have multiple issns
+  if (is_array($this->lookfor) && count($this->lookfor) > 1) {
+      $query = '?join=AND&amp;bool0[]=AND&amp;';
+      foreach ($this->lookfor as $issn) {
+          $query .= 'lookfor0[]=' . urlencode($issn) . '&amp;type0[]=ISN';
+      }
+  } elseif (count($this->lookfor) == 1) {
+      $query = '?lookfor=%22' . urlencode($this->lookfor[0]) . '%22&amp;type=ISN';
+  } else {
+      $query = '?lookfor=%22' . urlencode($this->lookfor) . '%22&amp;type=ISN';
+  }
+?>
+<?=$this->url('search-results') . $query?>
\ No newline at end of file
diff --git a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml
index e5900c5e108..89d46ba6232 100644
--- a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml
+++ b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml
@@ -36,10 +36,31 @@
           <? if (!empty($journalTitle)): ?>
             <?=!empty($summAuthor) ? '<br />' : ''?>
             <?=$this->transEsc('Published in')?>
-            <? $containerSource = $this->driver->getSourceIdentifier(); ?>
-            <? $containerID = $this->driver->getContainerRecordID(); ?>
+            <?
+            $containerSource = $this->driver->getSourceIdentifier();
+            $containerID = $this->driver->getContainerRecordID();
+
+            // finc specific journalLink generation
+            $journalLink = '';
+            $issns = $this->driver->getISSNs();
+
+            // first try to link to container id (VuFind stock-behaviour)
+            if ($containerID) {
+                $journalLink = $this->recordLink()->getUrl("$containerSource|$containerID");
+            }
+
+            // second try to search issn (finc specific)
+            elseif (!empty($issns)) {
+                $journalLink = $this->record($this->driver)->getLink('isn', $issns);
+            }
+
+            // third search for journal title (VuFind stock-behaviour)
+            else {
+                $journalLink = $this->record($this->driver)->getLink('journaltitle', str_replace(array('{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'), '', $journalTitle));
+            }
+            ?>
             <? /* TODO: handle highlighting more elegantly here: */?>
-            <a href="<?=($containerID ? $this->recordLink()->getUrl("$containerSource|$containerID") : $this->record($this->driver)->getLink('journaltitle', str_replace(array('{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'), '', $journalTitle)))?>"><?=$this->highlight($journalTitle) ?></a>
+            <a href="<?=$journalLink?>"><?=$this->highlight($journalTitle) ?></a>
                 <?=!empty($summDate) ? ' (' . $this->escapeHtml($summDate) . ')' : ''?>
           <? elseif (!empty($summDate)): ?>
             <?=!empty($summAuthor) ? '<br />' : ''?>
-- 
GitLab