Last active
November 7, 2017 12:02
-
-
Save mjlassila/45c951a2b4ff22b1a3dc3f7af2d9e25d to your computer and use it in GitHub Desktop.
Upotetun OpenURL-metadatan parannukset Finnaan Mendeleytä yms. varten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FinnaCustom\RecordDriver; | |
use Zend\ServiceManager\ServiceManager; | |
/** | |
* Record Driver Factory Class | |
* location: /module/FinnaCustom/src/FinnaCustom/RecordDriver/Factory.php | |
* | |
* @category VuFind | |
* @package RecordDrivers | |
* @author Demian Katz <demian.katz@villanova.edu> | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | |
* @link https://vufind.org/wiki/development:plugins:hierarchy_components Wiki | |
* | |
* @codeCoverageIgnore | |
*/ | |
class Factory extends \Finna\RecordDriver\Factory | |
{ | |
/** | |
* Factory for SolrDefault record driver. | |
* | |
* @param ServiceManager $sm Service manager. | |
* | |
* @return SolrDefault | |
*/ | |
public static function getSolrMarc(ServiceManager $sm) | |
{ | |
$driver = new SolrMarc( | |
$sm->getServiceLocator()->get('VuFind\Config')->get('config'), | |
null, | |
$sm->getServiceLocator()->get('VuFind\Config')->get('searches') | |
); | |
$driver->attachILS( | |
$sm->getServiceLocator()->get('VuFind\ILSConnection'), | |
$sm->getServiceLocator()->get('VuFind\ILSHoldLogic'), | |
$sm->getServiceLocator()->get('VuFind\ILSTitleHoldLogic') | |
); | |
$driver->attachSearchService($sm->getServiceLocator()->get('VuFind\Search')); | |
return $driver; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* FinnaCustom Module Configuration | |
* | |
* PHP version 5 | |
* | |
* Copyright (C) The National Library of Finland 2014-2016. | |
* | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License version 2, | |
* as published by the Free Software Foundation. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program; if not, write to the Free Software | |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
* | |
* @category VuFind | |
* @package Finna | |
* @author Ere Maijala <ere.maijala@helsinki.fi> | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | |
* @link http://github.com/KDK-Alli/NDL-VuFind2 NDL-VuFind2 | |
*/ | |
namespace FinnaCustom\Module\Configuration; | |
$config = [ | |
'vufind' => [ | |
'plugin_managers' =>[ | |
'recorddriver'=>[ | |
'factories' => [ | |
'solrmarc'=>'FinnaCustom\RecordDriver\Factory::getSolrMarc' | |
] | |
] | |
] | |
], | |
'router' => [ | |
'routes' => [ | |
'record-order' => [ | |
'type' => 'Zend\Mvc\Router\Http\Segment', | |
'options' => [ | |
'route' => '/Record/[:id]/Order', | |
'constraints' => [ | |
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', | |
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | |
], | |
'defaults' => [ | |
'controller' => 'Record', | |
'action' => 'Order', | |
] | |
] | |
], | |
'record-request' => [ | |
'type' => 'Zend\Mvc\Router\Http\Segment', | |
'options' => [ | |
'route' => '/Record/[:id]/Request', | |
'constraints' => [ | |
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', | |
'action' => '[a-zA-Z][a-zA-Z0-9_-]*', | |
], | |
'defaults' => [ | |
'controller' => 'Record', | |
'action' => 'Request', | |
] | |
] | |
] | |
] | |
], | |
'controllers' => [ | |
'factories' => [ | |
'record' => 'FinnaCustom\Controller\Factory::getRecordController', | |
] | |
] | |
]; | |
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FinnaCustom\RecordDriver; | |
class SolrMarc extends \Finna\RecordDriver\SolrMarc | |
{ | |
use \Finna\RecordDriver\SolrFinna; | |
/** | |
* Get OpenURL parameters for a book. | |
* location: /module/FinnaCustom/src/FinnaCustom/RecordDriver/SolrMarc.php | |
* @return array | |
*/ | |
public function getBookOpenUrlParams() | |
{ | |
$params = $this->getDefaultOpenUrlParams(); | |
$params['rft_val_fmt'] = 'info:ofi/fmt:kev:mtx:book'; | |
$params['rft.genre'] = 'book'; | |
$params['rft.btitle'] = $params['rft.title']; | |
$series = $this->getSeries(); | |
if (count($series) > 0) { | |
// Handle both possible return formats of getSeries: | |
$params['rft.series'] = is_array($series[0]) ? | |
$series[0]['name'] : $series[0]; | |
} | |
$params['rft.au'] = $this->getPrimaryAuthor(); | |
$publishers = $this->getPublishers(); | |
if (count($publishers) > 0) { | |
$params['rft.pub'] = $publishers[0]; | |
} | |
$params['rft.edition'] = $this->getEdition(); | |
$params['rft.isbn'] = (string)$this->getCleanISBN(); | |
$extents = $this->getExtent(); | |
if (count($extents) > 0) { | |
$params['rft.pages'] = preg_replace( '/[^0-9]/', '', $extents[0] ); | |
} | |
unset($params['rft.pub']); | |
unset($params['rft.date']); | |
$pubPlaces = $this->tryMethod('getPlacesOfPublication'); | |
$pubDates = $this->tryMethod('getPublicationDates'); | |
$pubNames = $this->tryMethod('getPublishers'); | |
if (is_array($pubPlaces) && is_array($pubDates) && is_array($pubNames)) { | |
$total = max(count($pubPlaces), count($pubDates), count($pubNames)); | |
// if we have pub dates but no other details, we still want to export the year: | |
if ($total == 0 && count($pubDates) > 0) { | |
$total = 1; | |
} | |
for ($i = 0; $i < $total; $i++) { | |
if (isset($pubPlaces[$i])) { | |
$params['rft.place'] = rtrim(str_replace(array('[', ']'), '', $pubPlaces[$i]), ':, '); | |
} | |
if (isset($pubNames[$i])) { | |
$pubName = preg_replace('/\s*:[^;:]*\bjakaja\b[^;:]*/', '', $pubNames[$i]); | |
if ($pubName) { | |
$params['rft.pub'] = rtrim($pubName, ", "); | |
} | |
} | |
$date = trim($pubDates[$i], '[]. '); | |
if (strlen($date) > 4) { | |
$date = $this->dateTime()->extractYear($date); | |
} | |
if ($date) { | |
$params['rft.date'] = $date; | |
} | |
} | |
} | |
return $params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment