From 266b1f0e30277962dd96616d577e367fe45e4e2b Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 26 Oct 2012 11:14:34 -0400 Subject: [PATCH] Resolving VUFIND-605. - Decoupled record drivers from tab rendering - Every record tab now has a corresponding class and template - Record driver => tab mapping is handled through module.config.php - Added some missing comments to existing code --- module/VuFind/config/module.config.php | 45 ++++++++ module/VuFind/src/VuFind/Bootstrap.php | 2 +- .../src/VuFind/Controller/AbstractRecord.php | 65 +++++++++-- .../src/VuFind/RecordDriver/AbstractBase.php | 11 -- .../src/VuFind/RecordDriver/SolrDefault.php | 43 ------- .../src/VuFind/RecordDriver/SolrMarc.php | 24 ---- .../VuFind/src/VuFind/RecordDriver/Summon.php | 14 --- .../src/VuFind/RecordTab/AbstractBase.php | 85 ++++++++++++++ .../src/VuFind/RecordTab/Description.php | 50 ++++++++ .../VuFind/src/VuFind/RecordTab/Excerpt.php | 66 +++++++++++ .../src/VuFind/RecordTab/HoldingsILS.php | 50 ++++++++ .../src/VuFind/RecordTab/HoldingsWorldCat.php | 50 ++++++++ .../src/VuFind/RecordTab/PluginFactory.php | 48 ++++++++ .../src/VuFind/RecordTab/PluginManager.php | 108 ++++++++++++++++++ .../VuFind/src/VuFind/RecordTab/Reviews.php | 66 +++++++++++ .../src/VuFind/RecordTab/StaffViewArray.php | 50 ++++++++ .../src/VuFind/RecordTab/StaffViewMARC.php | 50 ++++++++ module/VuFind/src/VuFind/RecordTab/TOC.php | 61 ++++++++++ .../src/VuFind/RecordTab/TabInterface.php | 54 +++++++++ .../src/VuFind/RecordTab/UserComments.php | 50 ++++++++ .../src/VuFind/Theme/Root/Helper/Record.php | 13 ++- .../description.phtml} | 0 .../excerpt.phtml} | 0 .../holdingsils.phtml} | 0 .../holdingsworldcat.phtml} | 0 .../reviews.phtml} | 0 .../staffviewarray.phtml} | 0 .../staffviewmarc.phtml} | 0 .../tab-toc.phtml => RecordTab/toc.phtml} | 0 .../usercomments.phtml} | 0 themes/blueprint/templates/record/view.phtml | 9 +- .../description.phtml} | 0 .../excerpt.phtml} | 0 .../holdingsils.phtml} | 0 .../holdingsworldcat.phtml} | 0 .../reviews.phtml} | 0 .../staffviewarray.phtml} | 0 .../staffviewmarc.phtml} | 0 .../tab-toc.phtml => RecordTab/toc.phtml} | 0 .../usercomments.phtml} | 0 .../templates/record/header-navbar.phtml | 9 +- .../jquerymobile/templates/record/view.phtml | 8 +- 42 files changed, 918 insertions(+), 113 deletions(-) create mode 100644 module/VuFind/src/VuFind/RecordTab/AbstractBase.php create mode 100644 module/VuFind/src/VuFind/RecordTab/Description.php create mode 100644 module/VuFind/src/VuFind/RecordTab/Excerpt.php create mode 100644 module/VuFind/src/VuFind/RecordTab/HoldingsILS.php create mode 100644 module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php create mode 100644 module/VuFind/src/VuFind/RecordTab/PluginFactory.php create mode 100644 module/VuFind/src/VuFind/RecordTab/PluginManager.php create mode 100644 module/VuFind/src/VuFind/RecordTab/Reviews.php create mode 100644 module/VuFind/src/VuFind/RecordTab/StaffViewArray.php create mode 100644 module/VuFind/src/VuFind/RecordTab/StaffViewMARC.php create mode 100644 module/VuFind/src/VuFind/RecordTab/TOC.php create mode 100644 module/VuFind/src/VuFind/RecordTab/TabInterface.php create mode 100644 module/VuFind/src/VuFind/RecordTab/UserComments.php rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-description.phtml => RecordTab/description.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-excerpt.phtml => RecordTab/excerpt.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-holdings.phtml => RecordTab/holdingsils.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/WorldCat/tab-holdings.phtml => RecordTab/holdingsworldcat.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-reviews.phtml => RecordTab/reviews.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-details.phtml => RecordTab/staffviewarray.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrMarc/tab-details.phtml => RecordTab/staffviewmarc.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-toc.phtml => RecordTab/toc.phtml} (100%) rename themes/blueprint/templates/{RecordDriver/SolrDefault/tab-usercomments.phtml => RecordTab/usercomments.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-description.phtml => RecordTab/description.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-excerpt.phtml => RecordTab/excerpt.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-holdings.phtml => RecordTab/holdingsils.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/WorldCat/tab-holdings.phtml => RecordTab/holdingsworldcat.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-reviews.phtml => RecordTab/reviews.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-details.phtml => RecordTab/staffviewarray.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrMarc/tab-details.phtml => RecordTab/staffviewmarc.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-toc.phtml => RecordTab/toc.phtml} (100%) rename themes/jquerymobile/templates/{RecordDriver/SolrDefault/tab-usercomments.phtml => RecordTab/usercomments.phtml} (100%) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index ff5c5b6636c..00fb2e21279 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -246,6 +246,51 @@ $config = array( 'worldcat' => 'VuFind\RecordDriver\WorldCat', ), ), + // This section controls which tabs are used for which record driver classes. + // Each sub-array is a map from a tab name (as used in a record URL) to a tab + // service (found in recordtab_plugin_manager, below). If a particular record + // driver is not defined here, it will inherit configuration from a configured + // parent class. + 'recorddriver_tabs' => array( + 'VuFind\RecordDriver\SolrDefault' => array( + 'Holdings' => 'HoldingsILS', 'Description' => 'Description', + 'TOC' => 'TOC', 'UserComments' => 'UserComments', + 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', + 'Details' => 'StaffViewArray', + ), + 'VuFind\RecordDriver\SolrMarc' => array( + 'Holdings' => 'HoldingsILS', 'Description' => 'Description', + 'TOC' => 'TOC', 'UserComments' => 'UserComments', + 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', + 'Details' => 'StaffViewMARC', + ), + 'VuFind\RecordDriver\Summon' => array( + 'Description' => 'Description', + 'TOC' => 'TOC', 'UserComments' => 'UserComments', + 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', + 'Details' => 'StaffViewArray', + ), + 'VuFind\RecordDriver\WorldCat' => array( + 'Holdings' => 'HoldingsWorldCat', 'Description' => 'Description', + 'TOC' => 'TOC', 'UserComments' => 'UserComments', + 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', + 'Details' => 'StaffViewMARC', + ), + ), + 'recordtab_plugin_manager' => array( + 'abstract_factories' => array('VuFind\RecordTab\PluginFactory'), + 'invokables' => array( + 'description' => 'VuFind\RecordTab\Description', + 'excerpt' => 'VuFind\RecordTab\Excerpt', + 'holdingsils' => 'VuFind\RecordTab\HoldingsILS', + 'holdingsworldcat' => 'VuFind\RecordTab\HoldingsWorldCat', + 'reviews' => 'VuFind\RecordTab\Reviews', + 'staffviewarray' => 'VuFind\RecordTab\StaffViewArray', + 'staffviewmarc' => 'VuFind\RecordTab\StaffViewMARC', + 'toc' => 'VuFind\RecordTab\TOC', + 'usercomments' => 'VuFind\RecordTab\UserComments', + ), + ), 'related_plugin_manager' => array( 'abstract_factories' => array('VuFind\Related\PluginFactory'), 'invokables' => array( diff --git a/module/VuFind/src/VuFind/Bootstrap.php b/module/VuFind/src/VuFind/Bootstrap.php index 674c692044d..2af408df0f1 100644 --- a/module/VuFind/src/VuFind/Bootstrap.php +++ b/module/VuFind/src/VuFind/Bootstrap.php @@ -89,7 +89,7 @@ class Bootstrap // Use naming conventions to set up a bunch of services based on namespace: $namespaces = array( 'Auth', 'Autocomplete', 'Db\Table', 'ILS\Driver', 'Recommend', - 'RecordDriver', 'Related', 'Resolver\Driver', 'Session', + 'RecordDriver', 'RecordTab', 'Related', 'Resolver\Driver', 'Session', 'Statistics\Driver' ); foreach ($namespaces as $ns) { diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index e4f38fe776a..5cb48f9f6b9 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -41,11 +41,46 @@ use VuFind\Exception\Mail as MailException, VuFind\Export, */ class AbstractRecord extends AbstractBase { + /** + * Array of available tab options + * + * @var array + */ + protected $allTabs = null; + + /** + * Default tab to display + * + * @var string + */ protected $defaultTab = 'Holdings'; - protected $account; + + /** + * Type of record to display + * + * @var string + */ protected $searchClassId = 'Solr'; + + /** + * Should we use the result scroller? + * + * @var bool + */ protected $useResultScroller = true; + + /** + * Should we log statistics? + * + * @var bool + */ protected $logStatistics = true; + + /** + * Record driver + * + * @var \VuFind\RecordDriver\AbstractBase + */ protected $driver = null; /** @@ -170,19 +205,18 @@ class AbstractRecord extends AbstractBase */ public function homeAction() { - // Forward to default tab (first fixing it if it is invalid): - $driver = $this->loadRecord(); - $tabs = $driver->getTabs(); + // Set up default tab (first fixing it if it is invalid): + $tabs = $this->getAllTabs(); if (!isset($tabs[$this->defaultTab])) { $keys = array_keys($tabs); - $this->defaultTab = $keys[0]; + $this->defaultTab = isset($keys[0]) ? $keys[0] : null; } // Save statistics: if ($this->logStatistics) { $statController = new \VuFind\Statistics\Record(); $statController->setServiceLocator($this->getServiceLocator()); - $statController->log($driver, $this->getRequest()); + $statController->log($this->loadRecord(), $this->getRequest()); } return $this->showTab($this->params()->fromRoute('tab', $this->defaultTab)); @@ -471,6 +505,22 @@ class AbstractRecord extends AbstractBase return $this->redirect()->toUrl($target . $params); } + /** + * Get all tab information for a given driver. + * + * @return array + */ + protected function getAllTabs() + { + if (null === $this->allTabs) { + $cfg = $this->getServiceLocator()->get('Config'); + $this->allTabs = $this->getServiceLocator() + ->get('VuFind\RecordTabPluginManager') + ->getTabsForRecord($this->loadRecord(), $cfg['recorddriver_tabs']); + } + return $this->allTabs; + } + /** * Display a particular tab. * @@ -493,13 +543,14 @@ class AbstractRecord extends AbstractBase return $patron; } - $driver = $this->loadRecord(); $view = $this->createViewModel(); + $view->tabs = $this->getAllTabs(); $view->activeTab = strtolower($tab); $view->defaultTab = strtolower($this->defaultTab); // Set up next/previous record links (if appropriate) if ($this->useResultScroller) { + $driver = $this->loadRecord(); $view->scrollData = $this->resultScroller()->getScrollData($driver); } diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index d909b0a8672..a443cbd0d9e 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -322,17 +322,6 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface, return $retVal; } - /** - * Returns an associative array (action => description) of record tabs supported - * by the data. - * - * @return array - */ - public function getTabs() - { - return array(); - } - /** * Does the OpenURL configuration indicate that we should display OpenURLs in * the specified context? diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php index d778d5da22d..b159d3db2f5 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php @@ -1101,49 +1101,6 @@ class SolrDefault extends AbstractBase return false; } - /** - * Returns an associative array (action => description) of record tabs supported - * by the data. - * - * @return array - */ - public function getTabs() - { - // Turn on all tabs by default: - $allTabs = array( - 'Holdings' => 'Holdings', - 'Description' => 'Description', - 'TOC' => 'Table of Contents', - 'UserComments' => 'Comments', - 'Reviews' => 'Reviews', - 'Excerpt' => 'Excerpt', - 'Details' => 'Staff View' - ); - - // No reviews or excerpts without ISBNs/appropriate configuration: - $isbns = $this->getISBNs(); - if (empty($isbns)) { - unset($allTabs['Reviews']); - unset($allTabs['Excerpt']); - } else { - $config = ConfigReader::getConfig(); - if (!isset($config->Content->reviews)) { - unset($allTabs['Reviews']); - } - if (!isset($config->Content->excerpts)) { - unset($allTabs['Excerpt']); - } - } - - // No Table of Contents tab if no data available: - $toc = $this->getTOC(); - if (empty($toc)) { - unset($allTabs['TOC']); - } - - return $allTabs; - } - /** * Does the OpenURL configuration indicate that we should display OpenURLs in * the specified context? diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index 685179d3c51..ca4d96cf03e 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -860,30 +860,6 @@ class SolrMarc extends SolrDefault return false; } - /** - * Returns an associative array (action => description) of record tabs supported - * by the data. - * - * @return array - */ - public function getTabs() - { - $tabs = parent::getTabs(); - // Check if we need to disable the holdings tab: - if (isset($tabs['Holdings'])) { - $config = ConfigReader::getConfig(); - if (isset($config->Site->hideHoldingsTabWhenEmpty) - && $config->Site->hideHoldingsTabWhenEmpty - ) { - $catalog = $this->getILS(); - if (!$catalog->hasHoldings($this->getUniqueID())) { - unset($tabs['Holdings']); - } - } - } - return $tabs; - } - /** * Returns true if the record supports real-time AJAX status lookups. * diff --git a/module/VuFind/src/VuFind/RecordDriver/Summon.php b/module/VuFind/src/VuFind/RecordDriver/Summon.php index 03b7b9aecd2..9e294449021 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Summon.php +++ b/module/VuFind/src/VuFind/RecordDriver/Summon.php @@ -586,20 +586,6 @@ class Summon extends SolrDefault return $str; } - /** - * Returns an associative array (action => description) of record tabs supported - * by the data. - * - * @return array - */ - public function getTabs() - { - // No Holdings tab in Summon module: - $tabs = parent::getTabs(); - unset($tabs['Holdings']); - return $tabs; - } - /** * Does the OpenURL configuration indicate that we should display OpenURLs in * the specified context? diff --git a/module/VuFind/src/VuFind/RecordTab/AbstractBase.php b/module/VuFind/src/VuFind/RecordTab/AbstractBase.php new file mode 100644 index 00000000000..c77ca39b1e2 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/AbstractBase.php @@ -0,0 +1,85 @@ +<?php +/** + * Record tab abstract base class + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Record tab abstract base class + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +abstract class AbstractBase implements TabInterface +{ + /** + * Record driver associated with the tab + * + * @var \VuFind\RecordDriver\AbstractBase + */ + protected $driver = null; + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + // Assume active by default; subclasses may add rules. + return true; + } + + /** + * Set the record driver + * + * @param \VuFind\RecordDriver\AbstractBase $driver Record driver + * + * @return AbstractBase + */ + public function setRecordDriver(\VuFind\RecordDriver\AbstractBase $driver) + { + $this->driver = $driver; + return $this; + } + + /** + * Get the record driver + * + * @return \VuFind\RecordDriver\AbstractBase + * @throws \Exception + */ + protected function getRecordDriver() + { + if (null === $this->driver) { + throw new \Exception('Record driver not set.'); + } + return $this->driver; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/Description.php b/module/VuFind/src/VuFind/RecordTab/Description.php new file mode 100644 index 00000000000..d5cfe8a7060 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/Description.php @@ -0,0 +1,50 @@ +<?php +/** + * Description tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Description tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class Description extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Description'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/Excerpt.php b/module/VuFind/src/VuFind/RecordTab/Excerpt.php new file mode 100644 index 00000000000..0c166d7c6f5 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/Excerpt.php @@ -0,0 +1,66 @@ +<?php +/** + * Excerpt tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; +use VuFind\Config\Reader as ConfigReader; + +/** + * Excerpt tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class Excerpt extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Excerpt'; + } + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + $config = ConfigReader::getConfig(); + if (!isset($config->Content->excerpts)) { + return false; + } + $isbns = $this->getRecordDriver()->tryMethod('getISBNs'); + return !empty($isbns); + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php new file mode 100644 index 00000000000..1b8dd3a3018 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php @@ -0,0 +1,50 @@ +<?php +/** + * Holdings (ILS) tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Holdings (ILS) tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class HoldingsILS extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Holdings'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php b/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php new file mode 100644 index 00000000000..a3777d1931d --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php @@ -0,0 +1,50 @@ +<?php +/** + * Holdings (WorldCat) tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Holdings (WorldCat) tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class HoldingsWorldCat extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Holdings'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/PluginFactory.php b/module/VuFind/src/VuFind/RecordTab/PluginFactory.php new file mode 100644 index 00000000000..9b8b86a2320 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/PluginFactory.php @@ -0,0 +1,48 @@ +<?php +/** + * Record tab plugin factory + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Record tab plugin factory + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class PluginFactory extends \VuFind\ServiceManager\AbstractPluginFactory +{ + /** + * Constructor + */ + public function __construct() + { + $this->defaultNamespace = 'VuFind\RecordTab'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/PluginManager.php b/module/VuFind/src/VuFind/RecordTab/PluginManager.php new file mode 100644 index 00000000000..76560042652 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/PluginManager.php @@ -0,0 +1,108 @@ +<?php +/** + * Record tab plugin manager + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Record tab plugin manager + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager +{ + /** + * Return the name of the base class or interface that plug-ins must conform + * to. + * + * @return string + */ + protected function getExpectedInterface() + { + return 'VuFind\RecordTab\TabInterface'; + } + + /** + * Get an array of service names by looking up the provided record driver in + * the provided tab configuration array. + * + * @param \VuFind\RecordDriver\AbstractBase $driver Record driver + * @param array $config Tab configuration (map of + * driver class => tab service name + * + * @return array + */ + protected function getTabServiceNames(\VuFind\RecordDriver\AbstractBase $driver, + array $config + ) { + // Get the current record driver's class name, then start a loop + // in case we need to use a parent class' name to find the appropriate + // setting. + $className = get_class($driver); + while (true) { + if (isset($config[$className])) { + return $config[$className]; + } + $className = get_parent_class($className); + if (empty($className)) { + // No setting found... + return array(); + } + } + } + + /** + * Get an array of valid tabs for the provided record driver. + * + * @param \VuFind\RecordDriver\AbstractBase $driver Record driver + * @param array $config Tab configuration (map of + * driver class => tab service name + * + * @return array service name => tab object + */ + public function getTabsForRecord(\VuFind\RecordDriver\AbstractBase $driver, + array $config + ) { + $tabs = array(); + foreach ($this->getTabServiceNames($driver, $config) as $tabKey => $svc) { + if (!$this->has($svc)) { + continue; + } + $newTab = $this->get($svc); + if (method_exists($newTab, 'setRecordDriver')) { + $newTab->setRecordDriver($driver); + } + if ($newTab->isActive()) { + $tabs[$tabKey] = $newTab; + } + } + return $tabs; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/Reviews.php b/module/VuFind/src/VuFind/RecordTab/Reviews.php new file mode 100644 index 00000000000..e0b7d61d4ce --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/Reviews.php @@ -0,0 +1,66 @@ +<?php +/** + * Reviews tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; +use VuFind\Config\Reader as ConfigReader; + +/** + * Reviews tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class Reviews extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Reviews'; + } + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + $config = ConfigReader::getConfig(); + if (!isset($config->Content->reviews)) { + return false; + } + $isbns = $this->getRecordDriver()->tryMethod('getISBNs'); + return !empty($isbns); + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/StaffViewArray.php b/module/VuFind/src/VuFind/RecordTab/StaffViewArray.php new file mode 100644 index 00000000000..cf67d370a55 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/StaffViewArray.php @@ -0,0 +1,50 @@ +<?php +/** + * Staff view (array dump) tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Staff view (array dump) tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class StaffViewArray extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Staff View'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/StaffViewMARC.php b/module/VuFind/src/VuFind/RecordTab/StaffViewMARC.php new file mode 100644 index 00000000000..42852e58500 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/StaffViewMARC.php @@ -0,0 +1,50 @@ +<?php +/** + * Staff view (MARC dump) tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Staff view (MARC dump) tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class StaffViewMARC extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Staff View'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/TOC.php b/module/VuFind/src/VuFind/RecordTab/TOC.php new file mode 100644 index 00000000000..cac1b033280 --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/TOC.php @@ -0,0 +1,61 @@ +<?php +/** + * Table of Contents tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Table of Contents tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class TOC extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Table of Contents'; + } + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + $toc = $this->getRecordDriver()->tryMethod('getTOC'); + return !empty($toc); + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/TabInterface.php b/module/VuFind/src/VuFind/RecordTab/TabInterface.php new file mode 100644 index 00000000000..5813d335b7e --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/TabInterface.php @@ -0,0 +1,54 @@ +<?php +/** + * Record tab interface + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * Record tab interface + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +interface TabInterface +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription(); + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive(); +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/RecordTab/UserComments.php b/module/VuFind/src/VuFind/RecordTab/UserComments.php new file mode 100644 index 00000000000..33580341a4a --- /dev/null +++ b/module/VuFind/src/VuFind/RecordTab/UserComments.php @@ -0,0 +1,50 @@ +<?php +/** + * User comments tab + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +namespace VuFind\RecordTab; + +/** + * User comments tab + * + * @category VuFind2 + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/creating_a_session_handler Wiki + */ +class UserComments extends AbstractBase +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'Comments'; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php b/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php index 66d51e54905..cfc0824a00c 100644 --- a/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php +++ b/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php @@ -269,14 +269,19 @@ class Record extends AbstractHelper /** * Render the contents of the specified record tab. * - * @param string $tab Tab to display + * @param \VuFind\RecordTab\TabInterface $tab Tab to display * * @return string */ - public function getTab($tab) + public function getTab(\VuFind\RecordTab\TabInterface $tab) { - // Maintain full view context rather than default driver/data-only context: - return $this->renderTemplate('tab-' . $tab . '.phtml', array()); + $context = array('driver' => $this->driver, 'tab' => $tab); + $classParts = explode('\\', get_class($tab)); + $template = 'RecordTab/' . strtolower(array_pop($classParts)) . '.phtml'; + $oldContext = $this->contextHelper->apply($context); + $html = $this->view->render($template); + $this->contextHelper->restore($oldContext); + return $html; } /** diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-description.phtml b/themes/blueprint/templates/RecordTab/description.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-description.phtml rename to themes/blueprint/templates/RecordTab/description.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-excerpt.phtml b/themes/blueprint/templates/RecordTab/excerpt.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-excerpt.phtml rename to themes/blueprint/templates/RecordTab/excerpt.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-holdings.phtml b/themes/blueprint/templates/RecordTab/holdingsils.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-holdings.phtml rename to themes/blueprint/templates/RecordTab/holdingsils.phtml diff --git a/themes/blueprint/templates/RecordDriver/WorldCat/tab-holdings.phtml b/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/WorldCat/tab-holdings.phtml rename to themes/blueprint/templates/RecordTab/holdingsworldcat.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-reviews.phtml b/themes/blueprint/templates/RecordTab/reviews.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-reviews.phtml rename to themes/blueprint/templates/RecordTab/reviews.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml b/themes/blueprint/templates/RecordTab/staffviewarray.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-details.phtml rename to themes/blueprint/templates/RecordTab/staffviewarray.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrMarc/tab-details.phtml b/themes/blueprint/templates/RecordTab/staffviewmarc.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrMarc/tab-details.phtml rename to themes/blueprint/templates/RecordTab/staffviewmarc.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-toc.phtml b/themes/blueprint/templates/RecordTab/toc.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-toc.phtml rename to themes/blueprint/templates/RecordTab/toc.phtml diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/tab-usercomments.phtml b/themes/blueprint/templates/RecordTab/usercomments.phtml similarity index 100% rename from themes/blueprint/templates/RecordDriver/SolrDefault/tab-usercomments.phtml rename to themes/blueprint/templates/RecordTab/usercomments.phtml diff --git a/themes/blueprint/templates/record/view.phtml b/themes/blueprint/templates/record/view.phtml index cc0d5d8a9ea..9edaeba7d73 100644 --- a/themes/blueprint/templates/record/view.phtml +++ b/themes/blueprint/templates/record/view.phtml @@ -9,7 +9,6 @@ $this->headScript()->appendFile("check_save_statuses.js"); // Set up some variables for convenience: - $tabs = $this->driver->getTabs(); // supported tabs $id = $this->driver->getUniqueId(); $controllerClass = 'controller' . $this->record($this->driver)->getController(); $cart = $this->cart(); @@ -81,14 +80,16 @@ <?=$this->record($this->driver)->getCoreMetadata()?> </div> - <? if (count($tabs) > 0): ?> + <? if (count($this->tabs) > 0): ?> <div id="tabnav"> <ul> - <? foreach ($tabs as $tab => $desc): ?> + <? foreach ($this->tabs as $tab => $obj): ?> <? // add current tab to breadcrumbs if applicable: + $desc = $obj->getDescription(); $isCurrent = (strtolower($this->activeTab) == strtolower($tab)); if ($isCurrent) { $this->layout()->breadcrumbs .= '<span>></span><em>' . $this->transEsc($desc) . '</em>'; + $activeTabObj = $obj; } ?> <li<?=$isCurrent ? ' class="active"' : ''?>> @@ -102,7 +103,7 @@ <div class="recordsubcontent"> - <?=$this->record($this->driver)->getTab($this->activeTab)?> + <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?> </div> <span class="Z3988" title="<?=$this->escapeHtml($this->driver->getOpenURL())?>"></span> diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-description.phtml b/themes/jquerymobile/templates/RecordTab/description.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-description.phtml rename to themes/jquerymobile/templates/RecordTab/description.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-excerpt.phtml b/themes/jquerymobile/templates/RecordTab/excerpt.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-excerpt.phtml rename to themes/jquerymobile/templates/RecordTab/excerpt.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-holdings.phtml b/themes/jquerymobile/templates/RecordTab/holdingsils.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-holdings.phtml rename to themes/jquerymobile/templates/RecordTab/holdingsils.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/WorldCat/tab-holdings.phtml b/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/WorldCat/tab-holdings.phtml rename to themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-reviews.phtml b/themes/jquerymobile/templates/RecordTab/reviews.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-reviews.phtml rename to themes/jquerymobile/templates/RecordTab/reviews.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml b/themes/jquerymobile/templates/RecordTab/staffviewarray.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-details.phtml rename to themes/jquerymobile/templates/RecordTab/staffviewarray.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrMarc/tab-details.phtml b/themes/jquerymobile/templates/RecordTab/staffviewmarc.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrMarc/tab-details.phtml rename to themes/jquerymobile/templates/RecordTab/staffviewmarc.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-toc.phtml b/themes/jquerymobile/templates/RecordTab/toc.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-toc.phtml rename to themes/jquerymobile/templates/RecordTab/toc.phtml diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-usercomments.phtml b/themes/jquerymobile/templates/RecordTab/usercomments.phtml similarity index 100% rename from themes/jquerymobile/templates/RecordDriver/SolrDefault/tab-usercomments.phtml rename to themes/jquerymobile/templates/RecordTab/usercomments.phtml diff --git a/themes/jquerymobile/templates/record/header-navbar.phtml b/themes/jquerymobile/templates/record/header-navbar.phtml index e72dae19608..aecd12dddad 100644 --- a/themes/jquerymobile/templates/record/header-navbar.phtml +++ b/themes/jquerymobile/templates/record/header-navbar.phtml @@ -1,14 +1,15 @@ <? - // Get available tabs; disable "staff view" in mobile UI: - $tabs = isset($this->driver) ? $this->driver->getTabs() : array(); + // Disable "staff view" in mobile UI (we copy $this->tabs because unset doesn't + // work correctly when run directly against the view model): + $tabs = $this->tabs; unset($tabs['Details']); ?> <? if (!empty($tabs)): ?> <div data-role="navbar"> <ul> - <? foreach ($tabs as $tab => $desc): ?> + <? foreach ($tabs as $tab => $obj): ?> <li> - <a rel="external"<?=(strtolower(isset($this->activeTab) ? $this->activeTab : '') == strtolower($tab)) ? ' class="ui-btn-active"' : ''?> href="<?=$this->recordLink()->getTabUrl($this->driver, $tab)?>"><?=$this->transEsc($desc)?></a> + <a rel="external"<?=(strtolower(isset($this->activeTab) ? $this->activeTab : '') == strtolower($tab)) ? ' class="ui-btn-active"' : ''?> href="<?=$this->recordLink()->getTabUrl($this->driver, $tab)?>"><?=$this->transEsc($obj->getDescription())?></a> </li> <? endforeach; ?> </ul> diff --git a/themes/jquerymobile/templates/record/view.phtml b/themes/jquerymobile/templates/record/view.phtml index 8eafb0afd7f..ebb1eead4f8 100644 --- a/themes/jquerymobile/templates/record/view.phtml +++ b/themes/jquerymobile/templates/record/view.phtml @@ -1,7 +1,13 @@ <? // Grab tab contents up front -- this will set the page title, which we need to // do before we display the page header below. - $tab = $this->record($this->driver)->getTab($this->activeTab); + $activeTab = false; + foreach ($this->tabs as $tab => $obj) { + if (strtolower($tab) == strtolower($this->activeTab)) { + $activeTab = $tab; + } + } + $tab = $activeTab ? $this->record($this->driver)->getTab($this->tabs[$activeTab]) : ''; ?> <div data-role="page" id="Record-view"> <?=$this->mobileMenu()->header(array('searchLink' => $this->searchOptions($this->searchClassId)->getSearchHomeAction()))?> -- GitLab