Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
LayoutClass
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
110
1<?php
2
3/**
4 * Helper class for managing bootstrap theme's high-level (body vs. sidebar) page
5 * layout.
6 *
7 * PHP version 8
8 *
9 * Copyright (C) Villanova University 2011.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2,
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 *
24 * @category VuFind
25 * @package  View_Helpers
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
28 * @link     https://vufind.org/wiki/development Wiki
29 */
30
31namespace VuFind\View\Helper\Bootstrap5;
32
33/**
34 * Helper class for managing bootstrap theme's high-level (body vs. sidebar) page
35 * layout.
36 *
37 * @category VuFind
38 * @package  View_Helpers
39 * @author   Demian Katz <demian.katz@villanova.edu>
40 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
41 * @link     https://vufind.org/wiki/development Wiki
42 */
43class LayoutClass extends \VuFind\View\Helper\AbstractLayoutClass
44{
45    /**
46     * Helper to allow easily configurable page layout -- given a broad class
47     * name, return appropriate CSS classes to lay out the page according to
48     * the current configuration file settings.
49     *
50     * @param string $class      Type of class to return ('mainbody' or 'sidebar')
51     * @param bool   $hasSidebar Whether sidebar is available
52     *
53     * @return string       CSS classes to apply
54     */
55    public function __invoke($class, $hasSidebar = true)
56    {
57        switch ($class) {
58            case 'mainbody':
59                if (!$hasSidebar) {
60                    $side = $this->rtl ? 'right' : 'left';
61                } else {
62                    $side = $this->sidebarOnLeft ? 'right' : 'left';
63                }
64                return "mainbody $side";
65            case 'sidebar':
66                return $this->sidebarOnLeft
67                    ? 'sidebar left hidden-print'
68                    : 'sidebar right hidden-print';
69            case 'offcanvas-row':
70                if (!$this->offcanvas) {
71                    return '';
72                }
73                return $this->sidebarOnLeft
74                    ? 'vufind-offcanvas vufind-offcanvas-left'
75                    : 'vufind-offcanvas vufind-offcanvas-right';
76        }
77        throw new \Exception('Unexpected class: ' . $class);
78    }
79}