From f853d67b5c8668f601849f96ae99891263311ef6 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 2 Sep 2015 14:42:16 -0400 Subject: [PATCH] More flexible sidebar support in RTL mode. --- config/vufind/config.ini | 2 ++ .../src/VuFind/View/Helper/AbstractLayoutClass.php | 5 ++--- .../src/VuFind/View/Helper/Bootstrap3/Factory.php | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 86c369b5a86..5935eff6615 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -86,6 +86,8 @@ defaultAccountPage = Favorites admin_enabled = false ; Show sidebar on the left side instead of right sidebarOnLeft = false +; Invert the sidebarOnLeft setting for right-to-left languages? +mirrorSidebarInRTL = true ; Handle menu as an offcanvas slider at mobile sizes (in bootstrap3-based themes) offcanvas = false ; Show (true) / Hide (false) Book Bag - Default is Hide. diff --git a/module/VuFind/src/VuFind/View/Helper/AbstractLayoutClass.php b/module/VuFind/src/VuFind/View/Helper/AbstractLayoutClass.php index 633c8b222b3..9df0a7c2af0 100644 --- a/module/VuFind/src/VuFind/View/Helper/AbstractLayoutClass.php +++ b/module/VuFind/src/VuFind/View/Helper/AbstractLayoutClass.php @@ -57,11 +57,10 @@ abstract class AbstractLayoutClass extends \Zend\View\Helper\AbstractHelper * * @param bool $left Does the sidebar go on the left? * @param bool $offcanvas Is offcanvas menu active? - * @param bool $rtl Are we displaying right-to-left? */ - public function __construct($left = false, $offcanvas = false, $rtl = false) + public function __construct($left = false, $offcanvas = false) { - $this->left = (bool) $left ^ (bool) $rtl; + $this->left = $left; $this->offcanvas = $offcanvas; } diff --git a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php index ab8a50bbc03..8a57856eae0 100644 --- a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Factory.php @@ -67,11 +67,17 @@ class Factory $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); $left = !isset($config->Site->sidebarOnLeft) ? false : $config->Site->sidebarOnLeft; + $mirror = !isset($config->Site->mirrorSidebarInRTL) + ? true : $config->Site->mirrorSidebarInRTL; $offcanvas = !isset($config->Site->offcanvas) ? false : $config->Site->offcanvas; // The right-to-left setting is injected into the layout by the Bootstrapper; - // pull it back out here to avoid duplicate effort. + // pull it back out here to avoid duplicate effort, then use it to apply + // the mirror setting appropriately. $layout = $sm->getServiceLocator()->get('viewmanager')->getViewModel(); - return new LayoutClass($left, $offcanvas, $layout->rtl); + if ($layout->rtl && !$mirror) { + $left = !$left; + } + return new LayoutClass($left, $offcanvas); } } \ No newline at end of file -- GitLab