Add website page type for ajax
This commit is contained in:
parent
eda41b96ca
commit
87c445bbf1
9 changed files with 99 additions and 60 deletions
|
|
@ -33,6 +33,9 @@ LabelPaymentTerm
|
|||
Message
|
||||
Map
|
||||
Reservation
|
||||
CompletePage
|
||||
PortionOfPage
|
||||
AjaxComponent
|
||||
|
||||
# Others
|
||||
ACCOUNTING_ACCOUNT_CUSTOMER
|
||||
|
|
|
|||
|
|
@ -67,11 +67,14 @@ SuppliersOrdersRunning
|
|||
TasksOnOpenedProject
|
||||
ThirdPartyCustomersWithIdProf12
|
||||
TicketPublicInfoCreateTicket
|
||||
Title1
|
||||
Title2
|
||||
TitreRequestCP
|
||||
UseAsciiDocFormat
|
||||
UsePassword
|
||||
ViewPageInNewTab
|
||||
WEBSITE_PAGE_EXAMPLE
|
||||
WebpageContent
|
||||
YourTicketSuccessfullySaved
|
||||
#
|
||||
# ██████╗ █████╗ ██████╗ ████████╗██████╗
|
||||
|
|
|
|||
|
|
@ -113,10 +113,10 @@ class FormWebsite
|
|||
|
||||
$langs->load("admin");
|
||||
|
||||
$sql = "SELECT rowid, code, label, entity";
|
||||
$sql = "SELECT rowid, code, label, entity, position, typecontainer";
|
||||
$sql .= " FROM ".$this->db->prefix().'c_type_container';
|
||||
$sql .= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
|
||||
$sql .= " ORDER BY label";
|
||||
$sql .= " ORDER BY typecontainer DESC, position ASC, label ASC";
|
||||
|
||||
dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
|
@ -129,9 +129,24 @@ class FormWebsite
|
|||
print '<option value="-1"> </option>';
|
||||
}
|
||||
|
||||
$lasttypecontainer = '';
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
if ($obj->typecontainer != $lasttypecontainer) {
|
||||
print '<option value="0" disabled>--- ';
|
||||
$transcodecontainer = ucfirst($obj->typecontainer);
|
||||
if ($obj->typecontainer == 'page') {
|
||||
$transcodecontainer = 'CompletePage';
|
||||
}
|
||||
if ($obj->typecontainer == 'container') {
|
||||
$transcodecontainer = 'PortionOfPage';
|
||||
}
|
||||
print $langs->trans($transcodecontainer);
|
||||
print ' ---</option>';
|
||||
$lasttypecontainer = $obj->typecontainer;
|
||||
}
|
||||
|
||||
if ($selected == $obj->rowid || $selected == $obj->code) {
|
||||
print '<option value="'.$obj->code.'" selected>';
|
||||
} else {
|
||||
|
|
@ -342,25 +357,21 @@ class FormWebsite
|
|||
}
|
||||
$out = '<div id="template-selector" class="template-container hidden">';
|
||||
|
||||
$templates = array(
|
||||
'empty' => 'empty',
|
||||
//'text' => 'dynamic',
|
||||
'basic' => 'basic',
|
||||
//'news' => 'news',
|
||||
//'commerce' => 'commerce',
|
||||
);
|
||||
// We disable some not ready templates
|
||||
unset($arrayofsamples['dynamiccontent']);
|
||||
unset($arrayofsamples['news']);
|
||||
|
||||
$templates = $arrayofsamples;
|
||||
|
||||
foreach ($templates as $template => $templateFunction) {
|
||||
if ($template == 'text') {
|
||||
$substitutionarray = array();
|
||||
$substitutionarray['__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
|
||||
$substitutionarray = array();
|
||||
$substitutionarray['__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
|
||||
$substitutionarray['__WEBSITE_CONTENT__'] = $langs->trans("WebpageContent");
|
||||
$substitutionarray['__WEBSITE_TITLE1__'] = $langs->trans("Title1");
|
||||
$substitutionarray['__WEBSITE_TITLE2__'] = $langs->trans("Title2");
|
||||
|
||||
$pathtoTemplateFile = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.dol_sanitizeFileName(strtolower($arrayofsamples['dynamiccontent'])).'.html';
|
||||
$contentHtml = file_exists($pathtoTemplateFile) ? make_substitutions(@file_get_contents($pathtoTemplateFile), $substitutionarray) : '';
|
||||
} else {
|
||||
$contentHtml = getHtmlOfLayout($template);
|
||||
}
|
||||
$pathtoTemplateFile = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.dol_sanitizeFileName($template).'.html';
|
||||
$contentHtml = file_exists($pathtoTemplateFile) ? make_substitutions(@file_get_contents($pathtoTemplateFile), $substitutionarray) : '';
|
||||
|
||||
$out .= '<div class="template-option" data-template="'.$template.'" data-content="'.htmlentities($contentHtml).'">';
|
||||
$out .= '<img class="maillayout" alt="'.$template.'" src="'.DOL_URL_ROOT.'/theme/common/maillayout/'.$template.'.png" />';
|
||||
|
|
|
|||
|
|
@ -323,10 +323,19 @@ DELETE FROM llx_c_action_trigger WHERE code = 'BILLREC_AUTOCREATEBILL';
|
|||
|
||||
-- element_element, see https://github.com/Dolibarr/dolibarr/pull/29329
|
||||
|
||||
ALTER TABLE element_element ADD COLUMN relationtype varchar(64) DEFAULT NULL AFTER targettype;
|
||||
ALTER TABLE llx_element_element ADD COLUMN relationtype varchar(64) DEFAULT NULL AFTER targettype;
|
||||
|
||||
ALTER TABLE llx_ecm_files DROP column keyword;
|
||||
|
||||
ALTER TABLE llx_c_type_container ADD COLUMN typecontainer varchar(10) DEFAULT 'page';
|
||||
UPDATE llx_c_type_container SET typecontainer = 'container' WHERE code IN ('banner', 'other', 'menu');
|
||||
--UPDATE llx_c_type_container SET typecontainer = 'page' WHERE code IN ('page', 'blogpost');
|
||||
UPDATE llx_c_type_container SET position = 10 WHERE code IN ('page');
|
||||
UPDATE llx_c_type_container SET position = 20 WHERE code IN ('blogpost');
|
||||
|
||||
INSERT INTO llx_c_type_container(code, entity, label, active, module, position, typecontainer) VALUES ('ajax', 1, 'Ajax', 1, 'system', 10, 'ajax');
|
||||
|
||||
|
||||
-- knowledgemanagement module
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CREATE','Knowledgerecord created','Executed when a knowledgerecord is created','knowledgemanagement',57001);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_MODIFY','Knowledgerecord modified','Executed when a knowledgerecord is modified','knowledgemanagement',57002);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
-- ========================================================================
|
||||
-- Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2022 Juanjo Menent <jmenent@2byte.es>
|
||||
--
|
||||
--
|
||||
--
|
||||
-- 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
|
||||
|
|
@ -31,8 +31,9 @@ create table llx_c_type_container
|
|||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
code varchar(32) NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
label varchar(128) NOT NULL,
|
||||
label varchar(128) NOT NULL,
|
||||
module varchar(32) NULL,
|
||||
typecontainer varchar(10) DEFAULT 'page',
|
||||
position integer DEFAULT 0,
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
)ENGINE=innodb;
|
||||
|
|
|
|||
|
|
@ -240,3 +240,6 @@ ExportSiteLabel=Would you like to export the website by downloading a zip file ?
|
|||
ExportSiteGitLabel=Would you like to export into a directory on the server ?
|
||||
ExportPath=path to export file
|
||||
SourceFiles = *If the path is absolute, it must start with a / *If not it will be within install/doctemplates/websites/ followed by the entered path.
|
||||
CompletePage=Complete page
|
||||
PortionOfPage=Portion of page
|
||||
AjaxComponent=Ajax component
|
||||
|
|
|
|||
|
|
@ -4348,31 +4348,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
|
|||
$formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ? GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container), 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Example/templates of page
|
||||
if ($action == 'createcontainer') {
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->withaiprompt = 'html';
|
||||
$formmail->withlayout = 1;
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired tdtop">';
|
||||
//print $langs->trans('WEBSITE_PAGE_EXAMPLE');
|
||||
print '</td><td class="tdtop">';
|
||||
|
||||
$out = '';
|
||||
|
||||
$showlinktolayout = $formmail->withlayout;
|
||||
$showlinktolayoutlabel = $langs->trans("FillPageWithALayout");
|
||||
$showlinktoai = ($formmail->withaiprompt && isModEnabled('ai')) ? 'textgenerationwebpage' : '';
|
||||
$showlinktoailabel = $langs->trans("FillPageWithAIContent");
|
||||
$htmlname = 'content';
|
||||
|
||||
// Fill $out
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php';
|
||||
|
||||
print $out;
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Title
|
||||
print '<tr><td class="fieldrequired">';
|
||||
print $langs->trans('WEBSITE_TITLE');
|
||||
|
|
@ -4569,6 +4544,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
|
|||
|
||||
$fuser = new User($db);
|
||||
|
||||
// Date last modification
|
||||
if ($action != 'createcontainer') {
|
||||
print '<tr><td>';
|
||||
print $langs->trans('DateLastModification');
|
||||
|
|
@ -4588,23 +4564,45 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr id="pageContent" class="hideobject"><td class="tdtop">';
|
||||
$url = 'https://wiki.dolibarr.org/index.php/Module_Website';
|
||||
// Content - Example/templates of page
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->withaiprompt = 'html';
|
||||
$formmail->withlayout = 1;
|
||||
$showlinktolayout = $formmail->withlayout;
|
||||
$showlinktoai = ($formmail->withaiprompt && isModEnabled('ai')) ? 'textgenerationwebpage' : '';
|
||||
if ($action == 'createcontainer' && $showlinktolayout && $showlinktoai) {
|
||||
print '<tr><td class="titlefield tdtop">';
|
||||
$url = 'https://wiki.dolibarr.org/index.php/Module_Website';
|
||||
|
||||
$htmltext = '<small>';
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource1", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource2", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource3", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSourceMore", $url);
|
||||
$htmltext .= '<br>';
|
||||
$htmltext .= '</small>';
|
||||
if ($conf->browser->layout == 'phone') {
|
||||
print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution');
|
||||
} else {
|
||||
//img_help(($tooltiptrigger != '' ? 2 : 1), $alt)
|
||||
print $form->textwithpicto($langs->trans("PreviewPageContent").' '.img_help(2, $langs->trans("PreviewPageContent")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution');
|
||||
$htmltext = '<small>';
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource1", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource2", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource3", $url);
|
||||
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSourceMore", $url);
|
||||
$htmltext .= '<br>';
|
||||
$htmltext .= '</small>';
|
||||
if ($conf->browser->layout == 'phone') {
|
||||
print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution');
|
||||
} else {
|
||||
//img_help(($tooltiptrigger != '' ? 2 : 1), $alt)
|
||||
print $form->textwithpicto($langs->trans("PreviewPageContent").' '.img_help(2, $langs->trans("PreviewPageContent")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution');
|
||||
}
|
||||
print '</td><td class="tdtop">';
|
||||
|
||||
$out = '';
|
||||
|
||||
$showlinktolayoutlabel = $langs->trans("FillPageWithALayout");
|
||||
$showlinktoailabel = $langs->trans("FillPageWithAIContent");
|
||||
$htmlname = 'content';
|
||||
// Fill $out
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php';
|
||||
|
||||
print $out;
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr id="pageContent" class="hideobject"><td class="tdtop">';
|
||||
print '</td><td>';
|
||||
//$doleditor = new DolEditor('content', GETPOST('content', 'restricthtmlallowunvalid'), '', 200, 'dolibarr_mailings', 'In', true, true, true, 40, '90%');
|
||||
$doleditor = new DolEditor('contentpreview', GETPOST('content', 'none'), '', 200, 'dolibarr_mailings', 'In', true, true, true, 40, '90%');
|
||||
|
|
|
|||
10
htdocs/website/samples/page-sample-basic.html
Normal file
10
htdocs/website/samples/page-sample-basic.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<!-- Enter here your HTML content. Add a section with an id tag and tag contenteditable="true" if you want to use the inline editor for the content -->
|
||||
<section id="mysection1" contenteditable="true">
|
||||
|
||||
<h1>__WEBPAGE_TITLE__</h1>
|
||||
<h2>__WEBPAGE_TITLE2__</h2>
|
||||
<p>
|
||||
__WEBPAGE_CONTENT
|
||||
</p>
|
||||
|
||||
</section>
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- Enter here your HTML content. Add a section with an id tag and tag contenteditable="true" if you want to use the inline editor for the content -->
|
||||
<section id="mysection1" contenteditable="true">
|
||||
|
||||
</section>
|
||||
|
|
|
|||
Loading…
Reference in a new issue