From 2465bdb28c133eeefbb95697fe240c6e491447ea Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 16 Nov 2012 11:44:48 -0500 Subject: [PATCH] Fixed bug: tab class refactoring broke Authority module; made Authority module more robust by standardizing routing. --- module/VuFind/config/module.config.php | 4 ++++ .../VuFind/Controller/AuthorityController.php | 21 +++++++++++++------ .../src/VuFind/RecordDriver/SolrAuth.php | 7 +++++++ .../templates/authority/record.phtml | 2 +- .../templates/authority/record.phtml | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index b2119e96145..d6614d5e856 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -282,6 +282,9 @@ $config = array( // driver is not defined here, it will inherit configuration from a configured // parent class. 'recorddriver_tabs' => array( + 'VuFind\RecordDriver\SolrAuth' => array( + 'Details' => 'StaffViewMARC', + ), 'VuFind\RecordDriver\SolrDefault' => array( 'Holdings' => 'HoldingsILS', 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', @@ -470,6 +473,7 @@ $config = array( $recordRoutes = array( 'record' => 'Record', 'missingrecord' => 'MissingRecord', + 'solrauthrecord' => 'Authority', 'summonrecord' => 'SummonRecord', 'worldcatrecord' => 'WorldcatRecord' ); diff --git a/module/VuFind/src/VuFind/Controller/AuthorityController.php b/module/VuFind/src/VuFind/Controller/AuthorityController.php index c81e4fef2b4..fb9cc489c41 100644 --- a/module/VuFind/src/VuFind/Controller/AuthorityController.php +++ b/module/VuFind/src/VuFind/Controller/AuthorityController.php @@ -55,6 +55,12 @@ class AuthorityController extends AbstractSearch */ public function homeAction() { + // If we came in with a record ID, forward to the record action: + if ($id = $this->params()->fromRoute('id', false)) { + $this->getRequest()->getQuery()->set('id', $id); + return $this->forwardTo('Authority', 'Record'); + } + // Do nothing -- just display template return $this->createViewModel(); } @@ -66,12 +72,15 @@ class AuthorityController extends AbstractSearch */ public function recordAction() { - return $this->createViewModel( - array( - 'driver' => $this->getSearchManager()->setSearchClassId('SolrAuth') - ->getResults()->getRecord($this->params()->fromQuery('id')) - ) - ); + $id = $this->params()->fromQuery('id'); + $cfg = $this->getServiceLocator()->get('Config'); + $driver = $this->getSearchManager()->setSearchClassId('SolrAuth') + ->getResults()->getRecord($id); + $request = $this->getRequest(); + $tabs = $this->getServiceLocator() + ->get('VuFind\RecordTabPluginManager') + ->getTabsForRecord($driver, $cfg['recorddriver_tabs'], $request); + return $this->createViewModel(array('driver' => $driver, 'tabs' => $tabs)); } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php b/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php index 58f3bdb6271..b24cca0055d 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php @@ -38,6 +38,13 @@ namespace VuFind\RecordDriver; */ class SolrAuth extends SolrMarc { + /** + * Used for identifying database records + * + * @var string + */ + protected $resourceSource = 'SolrAuth'; + /** * Get the short (pre-subtitle) title of the record. * diff --git a/themes/blueprint/templates/authority/record.phtml b/themes/blueprint/templates/authority/record.phtml index 5743b79b685..73bf63b69d4 100644 --- a/themes/blueprint/templates/authority/record.phtml +++ b/themes/blueprint/templates/authority/record.phtml @@ -1,2 +1,2 @@ <? $this->layout()->breadcrumbs = ' '; ?> -<?=$this->record($this->driver)->getTab('details')?> \ No newline at end of file +<?=$this->record($this->driver)->getTab($this->tabs['Details'])?> \ No newline at end of file diff --git a/themes/jquerymobile/templates/authority/record.phtml b/themes/jquerymobile/templates/authority/record.phtml index 502045b67e0..ae55ebc78f6 100644 --- a/themes/jquerymobile/templates/authority/record.phtml +++ b/themes/jquerymobile/templates/authority/record.phtml @@ -1,7 +1,7 @@ <div data-role="page"> <?=$this->mobileMenu()->header(array('searchLink' => 'authority-home'))?> <div data-role="content"> - <?=$this->record($this->driver)->getTab('details')?> + <?=$this->record($this->driver)->getTab($this->tabs['Details'])?> </div> <?=$this->mobileMenu()->footer()?> </div> \ No newline at end of file -- GitLab