dolibarr 24.0.0-beta
abstractcard.controller.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19require_once __DIR__ . '/../class/controller.class.php';
20
30abstract class AbstractCardController extends Controller
31{
35 public $formCard;
36
42 public function display()
43 {
45 if (!$context->controllerInstance->checkAccess()) {
46 $this->display404();
47 return;
48 }
49
50 $this->loadTemplate('header', [
51 'body-class' => empty($this->formCard->modal) ? '' : '--is-modal'
52 ]);
53
54 if (empty($this->formCard->modal)) {
55 $this->loadTemplate('menu');
56 $this->loadTemplate('hero-header-banner');
57 }
58
59 // @phpstan-ignore-next-line
60 if (isset($this->formCard)) {
61 $hookRes = $this->hookPrintPageView();
62 if (empty($hookRes)) {
63 print '<main class="container">';
64 if ($this->formCard->object->id > 0) {
65 if ($this->formCard->action == 'edit' && $this->formCard->permissiontoadd) {
66 $this->loadTemplate('card-edit');
67 } else {
68 $this->loadTemplate('card-view');
69 }
70 }
71 print '</main>';
72 }
73 } else {
74 $this->loadTemplate('404');
75 }
76
77 $this->loadTemplate('footer');
78 }
79}
Class for AbstractCardController.
static getInstance()
Singleton method to create one instance of this object.
Class to manage pages.
hookPrintPageView($parameters=array())
Execute hook PrintPageView.
display404()
Display error template.
loadTemplate($templateName, $vars=false)
Load a template .tpl file.
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42