dolibarr/htdocs/webportal/controllers/default.controller.class.php

92 lines
2.2 KiB
PHP
Raw Normal View History

2023-09-12 15:12:30 +02:00
<?php
/*
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/webportal/controllers/default.controller.class.php
* \ingroup webportal
* \brief This file is a controller for default
*/
2023-09-12 15:12:30 +02:00
2023-09-12 16:05:24 +02:00
/**
* Class for DefaultController
*/
2023-09-12 15:12:30 +02:00
class DefaultController extends Controller
{
/**
* Check current access to controller
*
* @return bool
*/
2023-09-12 15:26:12 +02:00
public function checkAccess()
{
$this->accessRight = true;
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
return parent::checkAccess();
}
2023-09-12 15:12:30 +02:00
/**
* Action method is called before html output
* can be used to manage security and change context
*
2024-02-08 14:11:54 +01:00
* @return int Return integer < 0 on error, > 0 on success
2023-09-12 15:12:30 +02:00
*/
2023-09-12 15:26:12 +02:00
public function action()
{
global $langs;
$context = Context::getInstance();
if (!$context->controllerInstance->checkAccess()) {
2024-02-08 14:11:54 +01:00
return -1;
2023-09-12 15:26:12 +02:00
}
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
$hookRes = $this->hookDoAction();
if (empty($hookRes)) {
$context->title = $langs->trans('WebPortalHomeTitle');
$context->desc = $langs->trans('WebPortalHomeDesc');
//$context->doNotDisplayHeaderBar=1;// hide default header
}
2024-02-08 14:11:54 +01:00
return 1;
2023-09-12 15:26:12 +02:00
}
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
/**
* Display
*
2023-09-12 17:08:19 +02:00
* @return void
2023-09-12 15:26:12 +02:00
*/
public function display()
{
$context = Context::getInstance();
if (!$context->controllerInstance->checkAccess()) {
$this->display404();
return;
}
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
$this->loadTemplate('header');
$this->loadTemplate('menu');
2023-09-28 10:44:22 +02:00
$this->loadTemplate('hero-header-banner');
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
$hookRes = $this->hookPrintPageView();
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
if (empty($hookRes)) {
$this->loadTemplate('home');
}
2023-09-12 15:12:30 +02:00
2023-09-12 15:26:12 +02:00
$this->loadTemplate('footer');
}
2023-09-12 15:12:30 +02:00
}