forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2aaf3c
commit 6ead6ba
Showing
14 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/** | ||
* Demo (fake data) DOI linker | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2023. | ||
* | ||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package DOI | ||
* @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:doi_linkers Wiki | ||
*/ | ||
|
||
namespace VuFind\IdentifierLinker; | ||
|
||
use function count; | ||
|
||
/** | ||
* Demo (fake data) DOI linker | ||
* | ||
* @category VuFind | ||
* @package DOI | ||
* @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:doi_linkers Wiki | ||
*/ | ||
class Demo implements IdentifierLinkerInterface | ||
{ | ||
/** | ||
* Possible icon values | ||
* | ||
* @var array | ||
*/ | ||
protected $icons = ['browzine-issue', 'browzine-pdf', null]; | ||
|
||
/** | ||
* Given an array of identifier arrays, perform a lookup and return an associative array | ||
* of arrays, matching the keys of the input array. Each output array contains one or more | ||
* associative arrays with required 'link' (URL to related resource) and 'label' (display text) | ||
* keys and an optional 'icon' (URL to icon graphic) or localIcon (name of configured icon in | ||
* theme) key. | ||
* | ||
* @param array[] $idArray Identifiers to look up | ||
* | ||
* @return array | ||
*/ | ||
public function getLinks(array $idArray) | ||
{ | ||
$response = []; | ||
$supportedIdTypes = ['doi', 'isbn', 'issn']; | ||
foreach ($idArray as $key => $ids) { | ||
foreach ($supportedIdTypes as $type) { | ||
if ($id = $ids[$type] ?? null) { | ||
$icon = $this->icons[rand(0, count($this->icons) - 1)]; | ||
$response[$key][] = [ | ||
'link' => 'https://vufind.org', | ||
'label' => 'Demonstrating ' . strtoupper($type) . " link for $id with icon " | ||
. ($icon ?? '[null]'), | ||
'localIcon' => $icon, | ||
]; | ||
} | ||
} | ||
} | ||
return $response; | ||
} | ||
} |
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
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
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
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
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
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
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