forked from Aspen-Discovery/aspen-discovery
-
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.
Merge pull request #144 from Chloe070196/libkey_integration
Libkey integration
- Loading branch information
Showing
9 changed files
with
347 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
class LibKeyDriver { | ||
|
||
public function getLibKeyLink(string $doiUrl): string | null { | ||
require_once ROOT_DIR . '/sys/LibKey/LibKeySetting.php'; | ||
$activeLibrary = Library::getActiveLibrary(); | ||
$settings = new LibKeySetting(); | ||
$settings->whereAdd("id=$activeLibrary->libKeySettingId"); | ||
if ($settings->find(true)) { | ||
$settings->fetch(); | ||
} | ||
$curlWrapper = new CurlWrapper; | ||
$response = $curlWrapper->curlGetPage("https://public-api.thirdiron.com/public/v1/libraries/" . $settings->libraryId . "/articles/doi/" . $this->extractDoi($doiUrl) . "?access_token=" . $settings->apiKey); | ||
if (empty($response)) { | ||
return null; | ||
} | ||
return json_decode($response, true)["data"]["bestIntegratorLink"]["bestLink"]; | ||
} | ||
public function extractDoi(string $url): string { | ||
$doi = str_replace(["https://doi.org/", "http://"], "", $url); | ||
return $doi; | ||
} | ||
} |
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,76 @@ | ||
<?php | ||
|
||
require_once ROOT_DIR . '/Action.php'; | ||
require_once ROOT_DIR . '/services/Admin/ObjectEditor.php'; | ||
require_once ROOT_DIR . '/sys/LibKey/LibKeySetting.php'; | ||
|
||
class Admin_LibKeySettings extends ObjectEditor { | ||
function getObjectType(): string { | ||
return 'LibKeySetting'; | ||
} | ||
|
||
function getToolName(): string { | ||
return 'LibKeySettings'; | ||
} | ||
|
||
function getModule(): string { | ||
return 'LibKey'; | ||
} | ||
|
||
function getPageTitle(): string { | ||
return 'LibKey Settings'; | ||
} | ||
|
||
function getAllObjects($page, $recordsPerPage): array { | ||
$object = new LibKeySetting(); | ||
$object->limit(($page - 1) * $recordsPerPage, $recordsPerPage); | ||
$this->applyFilters($object); | ||
$object->orderBy($this->getSort()); | ||
$object->find(); | ||
$objectList = []; | ||
while ($object->fetch()) { | ||
$objectList[$object->id] = clone $object; | ||
} | ||
return $objectList; | ||
} | ||
|
||
function getDefaultSort(): string { | ||
return 'name asc'; | ||
} | ||
|
||
function getObjectStructure($context = ''): array { | ||
return LibKeySetting::getObjectStructure($context); | ||
} | ||
|
||
function getPrimaryKeyColumn(): string { | ||
return 'id'; | ||
} | ||
|
||
function getIdKeyColumn(): string { | ||
return 'id'; | ||
} | ||
|
||
function getAdditionalObjectActions($existingObject): array { | ||
return []; | ||
} | ||
|
||
function getInstructions(): string { | ||
return 'https://help.aspendiscovery.org/help/integration/enrichment'; | ||
} | ||
|
||
function getBreadcrumbs(): array { | ||
$breadcrumbs = []; | ||
$breadcrumbs[] = new Breadcrumb('/Admin/Home', 'Administration Home'); | ||
$breadcrumbs[] = new Breadcrumb('/Admin/Home#third_party_enrichment', 'Third Party Enrichment'); | ||
$breadcrumbs[] = new Breadcrumb('/Admin/LibKeySettings', 'LibKey Settings'); | ||
return $breadcrumbs; | ||
} | ||
|
||
function getActiveAdminSection(): string { | ||
return 'third_party_enrichment'; | ||
} | ||
|
||
function canView(): bool { | ||
return UserAccount::userHasPermission('Administer LibKey Settings'); | ||
} | ||
} |
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
Oops, something went wrong.