From 09cc10cdd1016026adc00916c765031721364583 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 13 Nov 2012 14:16:19 -0500 Subject: [PATCH] Added mechanism for rendering tabs via AJAX. --- .../src/VuFind/Controller/AbstractRecord.php | 20 ++++++++++++++++--- .../blueprint/templates/record/ajaxtab.phtml | 7 +++++++ .../templates/record/ajaxtab.phtml | 7 +++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 themes/blueprint/templates/record/ajaxtab.phtml create mode 100644 themes/jquerymobile/templates/record/ajaxtab.phtml diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 28fcf35d3bd..260c21a81ca 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -222,6 +222,19 @@ class AbstractRecord extends AbstractBase return $this->showTab($this->params()->fromRoute('tab', $this->defaultTab)); } + /** + * AJAX tab action -- render a tab without surrounding context. + * + * @return mixed + */ + public function ajaxtabAction() + { + $this->loadRecord(); + return $this->showTab( + $this->params()->fromPost('tab', $this->defaultTab), true + ); + } + /** * ProcessSave -- store the results of the Save action. * @@ -529,11 +542,12 @@ class AbstractRecord extends AbstractBase /** * Display a particular tab. * - * @param string $tab Name of tab to display + * @param string $tab Name of tab to display + * @param bool $ajax Are we in AJAX mode? * * @return mixed */ - protected function showTab($tab) + protected function showTab($tab, $ajax = false) { // Special case -- handle login request (currently needed for holdings // tab when driver-based holds mode is enabled, but may also be useful @@ -559,7 +573,7 @@ class AbstractRecord extends AbstractBase $view->scrollData = $this->resultScroller()->getScrollData($driver); } - $view->setTemplate('record/view'); + $view->setTemplate($ajax ? 'record/ajaxtab' : 'record/view'); return $view; } } \ No newline at end of file diff --git a/themes/blueprint/templates/record/ajaxtab.phtml b/themes/blueprint/templates/record/ajaxtab.phtml new file mode 100644 index 00000000000..6f7d520981e --- /dev/null +++ b/themes/blueprint/templates/record/ajaxtab.phtml @@ -0,0 +1,7 @@ +<? +foreach ($this->tabs as $tab => $obj) { + if (strtolower($this->activeTab) == strtolower($tab)) { + echo $this->record($this->driver)->getTab($obj); + } +} +?> \ No newline at end of file diff --git a/themes/jquerymobile/templates/record/ajaxtab.phtml b/themes/jquerymobile/templates/record/ajaxtab.phtml new file mode 100644 index 00000000000..6f7d520981e --- /dev/null +++ b/themes/jquerymobile/templates/record/ajaxtab.phtml @@ -0,0 +1,7 @@ +<? +foreach ($this->tabs as $tab => $obj) { + if (strtolower($this->activeTab) == strtolower($tab)) { + echo $this->record($this->driver)->getTab($obj); + } +} +?> \ No newline at end of file -- GitLab