diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 816dae7e4a2..ebbcadaf944 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -18,6 +18,7 @@ EditPageMeta=Edit Meta EditPageSource=Edit HTML Source EditPageContent=Edit with CKEditor Website=Web site +AddWebsite=Add website Webpage=Web page/container AddPage=Add page/container HomePage=Home Page @@ -49,3 +50,4 @@ WebsiteId=Website ID CreateByFetchingExternalPage=Create page/container by fetching page from external URL... OrEnterPageInfoManually=Or create empty page from scratch... FetchAndCreate=Fetch and Create +ExportSite=Export site diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 85752a3158f..c48e81c9e03 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -96,6 +96,7 @@ $action=GETPOST('action','alpha'); if (GETPOST('delete')) { $action='delete'; } if (GETPOST('preview')) $action='preview'; +if (GETPOST('createsite')) { $action='createsite'; } if (GETPOST('create')) { $action='create'; } if (GETPOST('editmedias')) { $action='editmedias'; } if (GETPOST('editcss')) { $action='editcss'; } @@ -155,9 +156,67 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain * Actions */ -if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. +if (GETPOST('refreshsite')) // If we change the site, we reset the pageid and cancel addsite action. +{ + $pageid=0; + if ($action == 'addsite') $action = 'preview'; +} if (GETPOST('refreshpage') && ! in_array($action, array('updatecss'))) $action='preview'; + +// Add site +if ($action == 'addsite') +{ + $db->begin(); + + if (! $error && empty(GETPOST('WEBSITE_REF','alpha'))) + { + $error++; + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); + } + if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF','alpha'))) + { + $error++; + setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); + } + + if (! $error) + { + $tmpobject=new Website($db); + $tmpobject->ref = GETPOST('WEBSITE_REF','alpha'); + $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION','alpha'); + $tmpobject->virtualhost = GETPOST('WEBSITE_VIRTUALHOST','alpha'); + + $result = $tmpobject->create($user); + if ($result <= 0) + { + $error++; + setEventMessages($tmpobject->error, $tmpobject->errors, 'errors'); + } + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs'); + $action=''; + + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); + exit; + } + else + { + $db->rollback(); + $action='createsite'; + } + + if (! $error) + { + $action = 'preview'; + $id = $object->id; + } +} + // Add page if ($action == 'add') { @@ -820,6 +879,10 @@ llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, print "\n".'
'; print ''; +if ($action == 'createsite') +{ + print ''; +} if ($action == 'create') { print ''; @@ -865,6 +928,10 @@ if (count($object->records) > 0) { // ***** Part for web sites + print '
'; + print ''; + print '
'; + print '
'; print $langs->trans("Website").': '; print '
'; @@ -907,7 +974,7 @@ if (count($object->records) > 0) print '   '; print ''; - print ''; + //print ''; print ''; print ''; @@ -963,7 +1030,7 @@ if (count($object->records) > 0) print '
'; - print '
'; + print '
'; print ''; print '
'; @@ -1091,7 +1158,7 @@ if (count($object->records) > 0) // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (! in_array($action, array('editcss','editmenu','editmedias','create','createpagefromclone'))) + if (! in_array($action, array('editcss','editmenu','editmedias','createsite','create','createpagefromclone'))) { if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; @@ -1268,13 +1335,80 @@ if ($action == 'editcss') print '
'; } +if ($action == 'createsite') +{ + print '
'; + + print '
'; + + /*$h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath('/websites/index.php',1).'?id='.$object->id; + $head[$h][1] = $langs->trans("AddSite"); + $head[$h][2] = 'card'; + $h++; + + dol_fiche_head($head, 'card', $langs->trans("AddSite"), -1, 'globe'); + */ + if ($action == 'create') print_fiche_titre($langs->trans("AddSite")); + + print ''."\n"; + //print '
'; + + print ''; + + if (GETPOST('WEBSITE_REF')) $siteref=GETPOST('WEBSITE_REF','alpha'); + if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc=GETPOST('WEBSITE_DESCRIPTION','alpha'); + + print ''; + + print ''; + + print ''; + + + print '
'; + print $langs->trans('Ref'); + print ''; + print ''; + print '
'; + print $langs->trans('Description'); + print ''; + print ''; + print '
'; + print $form->textwithpicto($langs->trans('Virtualhost'), $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/websites/websiteref'), 1, 'help', '', 0, 2, 'tooltipvirtual'); + print ''; + print ''; + print '
'; + + if ($action == 'createsite') + { + print '
'; + + print ''; + print ''; + + print '
'; + } + + + //print '
'; + + //dol_fiche_end(); + + print '
'; + + print '
'; +} + if ($action == 'editmeta' || $action == 'create') { print '
'; print '
'; - $h = 0; + /*$h = 0; $head = array(); $head[$h][0] = dol_buildpath('/websites/index.php',1).'?id='.$object->id; @@ -1282,10 +1416,11 @@ if ($action == 'editmeta' || $action == 'create') $head[$h][2] = 'card'; $h++; - //dol_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe'); + dol_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe'); + */ if ($action == 'create') print_fiche_titre($langs->trans("AddPage")); - print ''."\n"; + print ''."\n"; //print '
'; if ($action == 'create')