From 317ddec570910d18cb028ddfbc159943b7993fdc Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Sat, 10 May 2025 00:05:36 +0200 Subject: [PATCH] Enhance website config page (#34082) * enhance website config page * fix --- htdocs/core/lib/website2.lib.php | 62 ++++++++++++++++++++++++++++++++ htdocs/core/website.inc.php | 2 +- htdocs/theme/eldy/global.inc.php | 5 +++ htdocs/theme/md/style.css.php | 5 +++ htdocs/website/index.php | 25 ++++++++----- 5 files changed, 90 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index d1e835d44ab..4b7bd92a323 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -327,7 +327,69 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, // Page content $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; + + // Import necessary environment for the config page + if ($objectpage->type_container == 'setup') { + $content = ''; + $content .= ''."\n"; + $tplcontent .= $content."\n"; + } + $tplcontent .= $objectpage->content."\n"; + + // Add logic to handle view and actions for managing parameters in the config page + if ($objectpage->type_container == 'setup') { + $content = '
'."\n"; + $content .= 'trans(\'SetupAndProperties\'), \'\', \'title_setup\');' . "\n"; + $content .= '' . "\n"; + $content .= 'if (!empty($message)) {' . "\n"; + $content .= ' print $message;' . "\n"; + $content .= '}' . "\n"; + $content .= '' . "\n"; + $content .= 'if (!empty($formSetup->items)) {' . "\n"; + $content .= ' $html = \'\';' . "\n"; + $content .= '' . "\n"; + $content .= ' $html .= \'
\';' . "\n"; + $content .= ' // Generate hidden values from $formSetup->formHiddenInputs' . "\n"; + $content .= ' if (!empty($formSetup->formHiddenInputs) && is_array($formSetup->formHiddenInputs)) {' . "\n"; + $content .= ' foreach ($formSetup->formHiddenInputs as $hiddenKey => $hiddenValue) {' . "\n"; + $content .= ' $html .= \'\';' . "\n"; + $content .= ' }' . "\n"; + $content .= ' }' . "\n"; + $content .= '' . "\n"; + $content .= ' // Generate output table' . "\n"; + $content .= ' $html .= $formSetup->generateTableOutput(true);' . "\n"; + $content .= '' . "\n"; + $content .= ' // Submit button' . "\n"; + $content .= ' $html .= \'\';' . "\n"; + $content .= ' $html .= \'\';' . "\n"; + $content .= ' $html .= \'
\';' . "\n"; + $content .= ' $html .= \'
\';' . "\n"; + $content .= ' $html .= \'\';' . "\n"; + $content .= ' $html .= \'
\';' . "\n"; + $content .= ' $html .= \'
\';' . "\n"; + $content .= '' . "\n"; + $content .= ' print $html;' . "\n"; + $content .= '}' . "\n"; + $content .= '?>' . "\n"; + $content .= '
' . "\n"; + $tplcontent .= $content."\n"; + } + + $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 447290b909a..3fdee498d18 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -99,7 +99,7 @@ if (!empty($pageid) && $pageid > 0) { $pagelangs->setDefaultLang($websitepage->lang ? $websitepage->lang : $weblangs->shortlang); - if (!defined('USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array('menu', 'other')) || empty($websitepage->status) && !defined('USEDOLIBARRSERVER'))) { + if (!defined('USEDOLIBARREDITOR') && (in_array($websitepage->type_container, array('menu', 'setup', 'other')) || empty($websitepage->status) && !defined('USEDOLIBARRSERVER'))) { $weblangs->load("website"); // Security options diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 77392705387..1ae7bb0e9c3 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6172,6 +6172,11 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im margin: unset; } +#divbodywebsite #websitetemplateconfigpage{ + max-width: 1200px; + margin: 50px auto 0; +} + /* ============================================================================== */ /* Module agenda */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 062f716fc52..3dcf49af9a0 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6123,6 +6123,11 @@ span.websitebuttonsitepreviewdisabled img, a.websitebuttonsitepreviewdisabled im margin: unset; } +#divbodywebsite #websitetemplateconfigpage{ + max-width: 1200px; + margin: 50px auto 0; +} + /* ============================================================================== */ /* Module agenda */ diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ab03f3ad322..b9668273034 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3520,7 +3520,9 @@ if (!GETPOST('hide_websitemenu')) { print ''.img_picto($langs->trans($text_off), 'switch_on').''; } } else { - print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'website='.urlencode($website->ref).'&pageid='.((int) $websitepage->id)); + if ($objectpage->type_container != 'setup') { // we do not allow to change status of setup pages + print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'website='.urlencode($website->ref).'&pageid='.((int) $websitepage->id)); + } } //print ''; print ''; @@ -3674,14 +3676,21 @@ if (!GETPOST('hide_websitemenu')) { print ''."\n"; print '
'; - print '
'; // Button includes dynamic content - print $langs->trans("ShowSubcontainers"); - if (!getDolGlobalString('WEBSITE_SUBCONTAINERSINLINE')) { - print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', 0, 0, 0, '', 'nomarginleft').''; - } else { - print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', 0, 0, 0, '', 'nomarginleft').''; + // Force to show subcontainers if we are in setup mode + if ($objectpage->type_container == 'setup') { + dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); + } + + if ($objectpage->type_container != 'setup') { + print '
'; // Button includes dynamic content + print $langs->trans("ShowSubcontainers"); + if (!getDolGlobalString('WEBSITE_SUBCONTAINERSINLINE')) { + print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', 0, 0, 0, '', 'nomarginleft').''; + } else { + print ''.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', 0, 0, 0, '', 'nomarginleft').''; + } + print '
'; } - print '
'; print '
'; // Button edit inline