From a594e0c9566c4388ed91edef3a6f1d472fd029ac Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 20 Feb 2013 12:35:22 -0500 Subject: [PATCH] Decoupled LayoutClass helper from ConfigReader. --- .../View/Helper/Blueprint/LayoutClass.php | 27 ++++++++++++++----- themes/blueprint/theme.config.php | 9 ++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Blueprint/LayoutClass.php b/module/VuFind/src/VuFind/View/Helper/Blueprint/LayoutClass.php index b4bd04c7e88..4b2f0bd5e9c 100644 --- a/module/VuFind/src/VuFind/View/Helper/Blueprint/LayoutClass.php +++ b/module/VuFind/src/VuFind/View/Helper/Blueprint/LayoutClass.php @@ -27,7 +27,6 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Blueprint; -use VuFind\Config\Reader as ConfigReader, Zend\View\Helper\AbstractHelper; /** * Helper class for managing blueprint theme's high-level (body vs. sidebar) page @@ -39,8 +38,25 @@ use VuFind\Config\Reader as ConfigReader, Zend\View\Helper\AbstractHelper; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ -class LayoutClass extends AbstractHelper +class LayoutClass extends \Zend\View\Helper\AbstractHelper { + /** + * Does the sidebar go on the left? + * + * @var bool + */ + protected $left; + + /** + * Constructor + * + * @param bool $left Does the sidebar go on the left? + */ + public function __construct($left = false) + { + $this->left = $left; + } + /** * Helper to allow easily configurable page layout -- given a broad class * name, return appropriate CSS classes to lay out the page according to @@ -52,14 +68,11 @@ class LayoutClass extends AbstractHelper */ public function __invoke($class) { - $config = ConfigReader::getConfig(); - $left = !isset($config->Site->sidebarOnLeft) - ? false : $config->Site->sidebarOnLeft; switch ($class) { case 'mainbody': - return $left ? 'span-18 push-5 last' : 'span-18'; + return $this->left ? 'span-18 push-5 last' : 'span-18'; case 'sidebar': - return $left ? 'span-5 pull-18 sidebarOnLeft' : 'span-5 last'; + return $this->left ? 'span-5 pull-18 sidebarOnLeft' : 'span-5 last'; default: return ''; } diff --git a/themes/blueprint/theme.config.php b/themes/blueprint/theme.config.php index cc04d0335c6..33baa793c59 100644 --- a/themes/blueprint/theme.config.php +++ b/themes/blueprint/theme.config.php @@ -21,8 +21,15 @@ return array( ), 'favicon' => 'vufind-favicon.ico', 'helpers' => array( + 'factories' => array( + 'layoutclass' => function ($sm) { + $config = \VuFind\Config\Reader::getConfig(); + $left = !isset($config->Site->sidebarOnLeft) + ? false : $config->Site->sidebarOnLeft; + return new \VuFind\View\Helper\Blueprint\LayoutClass($left); + }, + ), 'invokables' => array( - 'layoutclass' => 'VuFind\View\Helper\Blueprint\LayoutClass', 'search' => 'VuFind\View\Helper\Blueprint\Search', ) ) -- GitLab