custom
3 days ago
index.html
3 days ago
item.php
3 days ago
separator.php
3 days ago
shape.php
3 days ago
shape.php
116 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | VAPLoader::import('libraries.menu.shape'); |
| 15 | |
| 16 | /** |
| 17 | * Extends the MenuShape class to handle a collapsable left-board menu. |
| 18 | * |
| 19 | * @since 1.5 |
| 20 | * @since 1.6.3 Renamed from LeftBoardMenu to LeftboardMenuShape. |
| 21 | */ |
| 22 | class LeftboardMenuShape extends MenuShape |
| 23 | { |
| 24 | /** |
| 25 | * Flag used to check if the menu is compressed or not. |
| 26 | * |
| 27 | * @var boolean |
| 28 | */ |
| 29 | private $compressed = false; |
| 30 | |
| 31 | /** |
| 32 | * The constructor sets all the items to contain in the menu. |
| 33 | * |
| 34 | * @param array $menu The menu to push. |
| 35 | */ |
| 36 | public function __construct(array $menu = array()) |
| 37 | { |
| 38 | parent::__construct($menu); |
| 39 | |
| 40 | /** |
| 41 | * Retrieve main menu status from browser cookie. |
| 42 | * If the menu status is not set, use "expanded" |
| 43 | * status by default (1). |
| 44 | * |
| 45 | * @since 1.7 |
| 46 | */ |
| 47 | $status = JFactory::getApplication()->input->cookie->getUint('vikappointments_mainmenu_status', 1); |
| 48 | |
| 49 | // return true if collapsed (2) |
| 50 | $compressed = $status == 2 ? true : false; |
| 51 | |
| 52 | // set/unset compression mode |
| 53 | $this->compress($compressed); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Mark the menu as compressed or collapsed. |
| 58 | * |
| 59 | * @return self This object to support chaining. |
| 60 | */ |
| 61 | public function compress($compressed) |
| 62 | { |
| 63 | $this->compressed = $compressed; |
| 64 | |
| 65 | return $this; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @overrides |
| 70 | * Builds and returns the html structure of the menu that wraps the children. |
| 71 | * This method must be implemented to define a specific graphic of the menu. |
| 72 | * |
| 73 | * @param string $html The full structure of the children of the menu. |
| 74 | * |
| 75 | * @return string The html of the menu. |
| 76 | */ |
| 77 | protected function buildHtml($html) |
| 78 | { |
| 79 | $layout = new JLayoutFile('menu.leftboard.menu'); |
| 80 | |
| 81 | return $layout->render(array('html' => $html, 'compressed' => $this->compressed)); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @override |
| 86 | * Builds and returns the html opening that will wrap the body contents. |
| 87 | * This html will be displayed after the menu. |
| 88 | * |
| 89 | * @return string The body opening html. |
| 90 | * |
| 91 | * @since 1.6.3 |
| 92 | */ |
| 93 | public function openBody() |
| 94 | { |
| 95 | $layout = new JLayoutFile('menu.leftboard.body.open'); |
| 96 | |
| 97 | return $layout->render(array('compressed' => $this->compressed)); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @override |
| 102 | * Builds and returns the html closing that will wrap the body contents. |
| 103 | * This html will be displayed after the menu and the body opening. |
| 104 | * |
| 105 | * @return string The body closing html. |
| 106 | * |
| 107 | * @since 1.6.3 |
| 108 | */ |
| 109 | public function closeBody() |
| 110 | { |
| 111 | $layout = new JLayoutFile('menu.leftboard.body.close'); |
| 112 | |
| 113 | return $layout->render(); |
| 114 | } |
| 115 | } |
| 116 |