2023-09-12 13:12:30 +00:00
< ? php
2024-01-08 10:40:03 +00:00
/* Copyright ( C ) 2023 - 2024 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2023 - 2024 Lionel Vessiller < lvessiller @ easya . solutions >
* Copyright ( C ) 2023 - 2024 Patrice Andreani < pandreani @ easya . solutions >
2024-11-04 22:53:20 +00:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2023-09-12 13:12:30 +00:00
*
* 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 />.
*/
/**
2024-01-24 13:20:38 +00:00
* \file htdocs / webportal / admin / configcss . php
2023-09-12 13:12:30 +00:00
* \ingroup webportal
* \brief WebPortal setup page .
*/
// Load Dolibarr environment
2024-01-27 01:44:56 +00:00
require_once " ../../main.inc.php " ;
2024-11-04 22:53:20 +00:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*/
2025-09-15 13:33:15 +00:00
require_once DOL_DOCUMENT_ROOT . " /core/lib/admin.lib.php " ;
require_once DOL_DOCUMENT_ROOT . " /webportal/lib/webportal.lib.php " ;
2024-11-04 22:53:20 +00:00
2023-09-12 13:12:30 +00:00
// Translations
2024-01-28 15:36:01 +00:00
$langs -> loadLangs ( array ( " admin " , " hrm " , " other " , " website " ));
2023-09-12 13:12:30 +00:00
2024-06-30 19:02:50 +00:00
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
2023-09-12 13:12:30 +00:00
$hookmanager -> initHooks ( array ( 'webportalsetup' , 'globalsetup' ));
2024-01-27 01:44:56 +00:00
// Parameters
$action = GETPOST ( 'action' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2024-01-27 11:08:28 +00:00
if ( empty ( $action )) {
$action = 'edit' ;
}
2023-09-12 13:12:30 +00:00
// Access control
if ( ! $user -> admin ) {
2023-09-12 13:26:12 +00:00
accessforbidden ();
2023-09-12 13:12:30 +00:00
}
2025-09-15 13:33:15 +00:00
$object = new stdClass ();
2023-09-12 13:12:30 +00:00
/*
* Actions
*/
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) {
2023-09-12 13:26:12 +00:00
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2023-09-12 13:12:30 +00:00
}
// Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
$regs = array ();
if ( preg_match ( '/^(set|del)_([A-Z_]+)$/' , $action , $regs )) {
2023-09-12 13:26:12 +00:00
if ( $regs [ 1 ] == 'set' ) {
dolibarr_set_const ( $db , $regs [ 2 ], 1 , 'chaine' , 0 , '' , $conf -> entity );
} else {
dolibarr_del_const ( $db , $regs [ 2 ], $conf -> entity );
}
2023-09-12 13:12:30 +00:00
}
if ( $action == 'updatecss' ) {
2025-09-15 13:33:15 +00:00
$csscontent = GETPOST ( 'WEBPORTAL_CUSTOM_CSS' , 'restricthtml' ); // Will return a sanitized HTML content (so with double spaes that may be replaced with one, ...
$csscontent = dol_string_nohtmltag ( $csscontent , 2 , 'UTF-8' , 0 , 0 );
dolibarr_set_const ( $db , " WEBPORTAL_CUSTOM_CSS " , $csscontent , 'chaine' , 0 , '' , $conf -> entity );
setEventMessages ( $langs -> trans ( " RecordSaved " ), null );
if ( GETPOST ( 'dol_resetcache' )) {
dolibarr_set_const ( $db , " WEBPORTAL_PARAMS_REV " , getDolGlobalInt ( 'WEBPORTAL_PARAMS_REV' ) + 1 , 'chaine' , 0 , '' , $conf -> entity );
}
2023-09-12 13:12:30 +00:00
}
/*
* View
*/
2024-01-27 01:44:56 +00:00
$title = " WebPortalSetup " ;
2023-09-12 13:12:30 +00:00
$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones' ;
llxHeader (
2023-09-12 13:26:12 +00:00
'' ,
2024-01-24 13:20:38 +00:00
$langs -> trans ( $title ),
2023-09-12 13:26:12 +00:00
$wikihelp ,
'' ,
0 ,
0 ,
array (
'/includes/ace/src/ace.js' ,
'/includes/ace/src/ext-statusbar.js' ,
'/includes/ace/src/ext-language_tools.js' ,
),
array ()
2023-09-12 13:12:30 +00:00
);
// Subheader
$linkback = '<a href="' . ( $backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1' ) . '">' . $langs -> trans ( " BackToModuleList " ) . '</a>' ;
2024-01-24 13:20:38 +00:00
print load_fiche_titre ( $langs -> trans ( $title ), $linkback , 'title_setup' );
2023-09-12 13:12:30 +00:00
// Configuration header
$head = webportalAdminPrepareHead ();
2024-01-27 01:44:56 +00:00
print dol_get_fiche_head ( $head , 'css' , $langs -> trans ( $title ), - 1 , " webportal " );
2023-09-12 13:12:30 +00:00
// Setup page goes here
echo '<span class="opacitymedium">' . $langs -> trans ( " WebPortalCSS " ) . '</span><br><br>' ;
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
print '<form enctype="multipart/form-data" method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="updatecss">' ;
clearstatcache ();
// editeur CSS
print '<div class="div-table-responsive-no-min">' ;
print '<table summary="edit" class="noborder centpercent editmode tableforfield">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="2">' ;
$customcssValue = getDolGlobalString ( 'WEBPORTAL_CUSTOM_CSS' );
$doleditor = new DolEditor ( 'WEBPORTAL_CUSTOM_CSS' , $customcssValue , '80%' , 400 , 'Basic' , 'In' , true , false , 'ace' , 10 , '90%' );
$doleditor -> Create ( 0 , '' , true , 'css' , 'css' );
print '</td></tr>' . " \n " ;
print '</table>' . " \n " ;
print '</div>' ;
print '<div class="center">' ;
print '<input class="button button-save reposition buttonforacesave" type="submit" name="submit" value="' . $langs -> trans ( " Save " ) . '">' ;
2024-01-27 16:58:19 +00:00
//print '<input class="button button-cancel reposition" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
2023-09-12 13:12:30 +00:00
print '</div>' ;
print '</form>' ;
// Page end
print dol_get_fiche_end ();
// End of page
llxFooter ();
$db -> close ();