dolibarr/htdocs/core/lib/doleditor.lib.php

122 lines
3.9 KiB
PHP
Raw Permalink Normal View History

<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 12:43:12 +00:00
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
2019-01-28 20:39:22 +00:00
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
FIX: Resolve possibly-undefined-variable cases flagged by PHPStan (#39523) * FIX: Resolve possibly-undefined-variable cases flagged by PHPStan Fixes several cases of the variable.undefined PHPStan rule instead of just excluding them via the baseline: a wrong variable used to build a delete link (dir_add_card.php), an uninitialized $result across a try/catch (CMailFile), missing GETPOST reads ($mode, $fk_project/$date reset via unset() creating cross-branch ambiguity), a missing $r contract check (commonfieldsinimport.inc.php), missing @var/global annotations for $conf/$langs/$bc, dead extrafields-display code guarded by the wrong condition (expedition/card.php), and an undefined $soc passed to formAddObjectLine() where objects have no buyer thirdparty (replaced with null). Corresponding entries removed from dev/build/phpstan/phpstan-baseline.neon. * FIX: Resolve more possibly-undefined-variable cases flagged by PHPStan Second batch of variable.undefined fixes removed from the baseline: - Complex conditional flows PHPStan can't prove exhaustive (Stripe key selection in commoninvoice.class.php, a situation-invoice loop var in pdf_sponge.modules.php, a product loop var in stock/movement_list.php) fixed by adding a definite initialization before the ambiguous branch. - A commented-out $linkback assignment restored in expensereport/payment/info.php. - Missing GETPOST reads added (holiday/list.php update-date filters, product/stock/info.php $action/$socid, projet/comment.php $mode). - A dead-code $mesg call to dol_htmloutput_mesg() removed from admin_hrm.php (messages are already shown via setEventMessages()). - Redundant isset() checks removed in product/reassort.php and reassortlot.php where $type is unconditionally set earlier in the same file, so the isset()-false branch was unreachable dead code. - $user documented as always available in public/bookcal/index.php (NOREQUIREUSER is not defined on that page). - A genuinely missing $tmpcode initialization fixed in attendee_new.php, suggestbooth.php and suggestconference.php: when an existing thirdparty is reused (or SOCIETE_CODECLIENT_ADDON has no auto-numbering), $tmpcode was never set before being assigned to code_client/code_fournisseur. * add phan fix * add phan fix * fix * fix * fix
2026-08-15 16:33:12 +00:00
* Copyright (C) 2026 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
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
* \file htdocs/core/lib/doleditor.lib.php
* \brief Ensemble de functions de base pour la gestion des utilisaterus et groups
*/
/**
* Show list of ckeditor's themes.
*
* @param User|null $fuser User concerned or null for global theme
* @param int $edit 1 to add edit form
* @return void
*/
function show_skin($fuser, $edit = 0)
{
global $conf, $langs, $db;
global $bc;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$formother = new FormOther($db);
$dirskins = array('/public/includes/ckeditor/ckeditor/skins');
2021-02-23 21:03:23 +00:00
if (!empty($conf->modules_parts['theme'])) { // Using this feature slow down application
foreach ($conf->modules_parts['theme'] as $reldir) {
$dirskins = array_merge($dirskins, (array) ($reldir.'theme'));
}
}
$dirskins = array_unique($dirskins);
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
2023-01-09 11:30:56 +00:00
$selected_theme = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa');
$colspan = 2;
2024-10-26 14:22:05 +00:00
print '<table class="noborder centpercent">';
FIX: Resolve possibly-undefined-variable cases flagged by PHPStan (#39523) * FIX: Resolve possibly-undefined-variable cases flagged by PHPStan Fixes several cases of the variable.undefined PHPStan rule instead of just excluding them via the baseline: a wrong variable used to build a delete link (dir_add_card.php), an uninitialized $result across a try/catch (CMailFile), missing GETPOST reads ($mode, $fk_project/$date reset via unset() creating cross-branch ambiguity), a missing $r contract check (commonfieldsinimport.inc.php), missing @var/global annotations for $conf/$langs/$bc, dead extrafields-display code guarded by the wrong condition (expedition/card.php), and an undefined $soc passed to formAddObjectLine() where objects have no buyer thirdparty (replaced with null). Corresponding entries removed from dev/build/phpstan/phpstan-baseline.neon. * FIX: Resolve more possibly-undefined-variable cases flagged by PHPStan Second batch of variable.undefined fixes removed from the baseline: - Complex conditional flows PHPStan can't prove exhaustive (Stripe key selection in commoninvoice.class.php, a situation-invoice loop var in pdf_sponge.modules.php, a product loop var in stock/movement_list.php) fixed by adding a definite initialization before the ambiguous branch. - A commented-out $linkback assignment restored in expensereport/payment/info.php. - Missing GETPOST reads added (holiday/list.php update-date filters, product/stock/info.php $action/$socid, projet/comment.php $mode). - A dead-code $mesg call to dol_htmloutput_mesg() removed from admin_hrm.php (messages are already shown via setEventMessages()). - Redundant isset() checks removed in product/reassort.php and reassortlot.php where $type is unconditionally set earlier in the same file, so the isset()-false branch was unreachable dead code. - $user documented as always available in public/bookcal/index.php (NOREQUIREUSER is not defined on that page). - A genuinely missing $tmpcode initialization fixed in attendee_new.php, suggestbooth.php and suggestconference.php: when an existing thirdparty is reused (or SOCIETE_CODECLIENT_ADDON has no auto-numbering), $tmpcode was never set before being assigned to code_client/code_fournisseur. * add phan fix * add phan fix * fix * fix * fix
2026-08-15 16:33:12 +00:00
$var = 0;
// Title
2021-02-23 21:03:23 +00:00
print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
print '<th class="right">';
print '</th></tr>';
print '<tr class="oddeven">';
2021-02-23 21:03:23 +00:00
print '<td>'.$langs->trans("ThemeDir").'</td>';
print '<td>';
foreach ($dirskins as $dirskin) {
echo '"'.$dirskin.'" ';
}
print '</td>';
print '</tr>';
//
print '<tr class="oddeven"><td colspan="'.$colspan.'">';
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
$i = 0;
2021-02-23 21:03:23 +00:00
foreach ($dirskins as $dir) {
//print $dirroot.$dir;exit;
$dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
$urltheme = dol_buildpath($dir, 1);
2021-02-23 21:03:23 +00:00
if (is_dir($dirskin)) {
$handle = opendir($dirskin);
2021-02-23 21:03:23 +00:00
if (is_resource($handle)) {
while (($subdir = readdir($handle)) !== false) {
2023-12-27 11:12:20 +00:00
if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) != '.'
&& substr($subdir, 0, 3) != 'CVS' && !preg_match('/common|phones/i', $subdir)) {
// Disable not stable themes (dir ends with _exp or _dev)
2023-04-28 14:05:25 +00:00
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && preg_match('/_dev$/i', $subdir)) {
2021-02-23 21:03:23 +00:00
continue;
}
2023-04-28 14:05:25 +00:00
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && preg_match('/_exp$/i', $subdir)) {
2021-02-23 21:03:23 +00:00
continue;
}
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
2021-02-23 21:03:23 +00:00
if ($subdir == $selected_theme) {
print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
} else {
print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
}
print '</div>';
$i++;
}
}
}
}
}
print '</div></td></tr></table>';
print '</td></tr>';
print '</table>';
}