fix to fix PR
This commit is contained in:
parent
e36391c6ab
commit
40b20d510d
@ -138,6 +138,6 @@ RegenerateWebsiteContent=Regenerate web site cache files
|
|||||||
AllowedInFrames=Allowed in Frames
|
AllowedInFrames=Allowed in Frames
|
||||||
DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties.
|
DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties.
|
||||||
GenerateSitemaps=Generate website sitemap file
|
GenerateSitemaps=Generate website sitemap file
|
||||||
BackToPreview= Back to preview
|
ConfirmGenerateSitemaps=If you confirm, you will erase the existing sitemap file...
|
||||||
GeneratedSitemapsFiles = Generated sitemap files
|
ConfirmSitemapsCreation=Confirm sitemap generation
|
||||||
EnterWebsiteUrl= Enter your website URL
|
SitemapGenerated=Sitemap Generated
|
||||||
|
|||||||
@ -2155,6 +2155,65 @@ if ($action == 'regeneratesite')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
$formadmin = new FormAdmin($db);
|
||||||
|
$formwebsite = new FormWebsite($db);
|
||||||
|
$formother = new FormOther($db);
|
||||||
|
$domainname = '0.0.0.0:8080';
|
||||||
|
$tempdir = $conf->website->dir_output.'/'.$websitekey.'/';
|
||||||
|
|
||||||
|
// Confirm generation of website sitemaps
|
||||||
|
if($action == 'confirmgeneratesitemaps'){
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref),'generatesitemaps', '', "yes", 1);
|
||||||
|
$action = 'preview';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate web site sitemaps
|
||||||
|
if ($action == 'generatesitemaps') {
|
||||||
|
$domtree = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
$root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
|
||||||
|
$domtree->formatOutput = true;
|
||||||
|
|
||||||
|
$sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms, w.virtualhost";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w";
|
||||||
|
$sql .= " WHERE wp.type_container IN ('page', 'blogpost')";
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num_rows = $db->num_rows($resql);
|
||||||
|
if ($num_rows > 0) {
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num_rows) {
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
$url = $domtree->createElement('url');
|
||||||
|
$pageurl = $objp->pageurl;
|
||||||
|
if ($objp->lang) {
|
||||||
|
$pageurl = $objp->lang.'/'.$pageurl;
|
||||||
|
}
|
||||||
|
if ($objp->virtualhost) {
|
||||||
|
$domainname = $objp->virtualhost;
|
||||||
|
}
|
||||||
|
$loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl);
|
||||||
|
$lastmod = $domtree->createElement('lastmod', $objp->tms);
|
||||||
|
|
||||||
|
$url->appendChild($loc);
|
||||||
|
$url->appendChild($lastmod);
|
||||||
|
$root->appendChild($url);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$domtree->appendChild($root);
|
||||||
|
if ($domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml'))
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("SitemapGenerated"), null, 'mesgs');
|
||||||
|
} else {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$action = 'preview';
|
||||||
|
}
|
||||||
|
|
||||||
// Import site
|
// Import site
|
||||||
if ($action == 'importsiteconfirm')
|
if ($action == 'importsiteconfirm')
|
||||||
{
|
{
|
||||||
@ -2251,11 +2310,6 @@ if ($action == 'importsiteconfirm')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
$formadmin = new FormAdmin($db);
|
|
||||||
$formwebsite = new FormWebsite($db);
|
|
||||||
$formother = new FormOther($db);
|
|
||||||
$formfile = new FormFile($db);
|
|
||||||
|
|
||||||
$helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
|
$helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
|
||||||
|
|
||||||
@ -2470,11 +2524,9 @@ if (!GETPOST('hide_websitemenu'))
|
|||||||
print '<a href="'.$_SERVER["PHP_SEFL"].'?action=regeneratesite&website='.$website->ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'"><span class="fa fa-cogs"><span></a>';
|
print '<a href="'.$_SERVER["PHP_SEFL"].'?action=regeneratesite&website='.$website->ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'"><span class="fa fa-cogs"><span></a>';
|
||||||
|
|
||||||
print ' ';
|
print ' ';
|
||||||
|
|
||||||
if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite'))
|
// Generate site map
|
||||||
{
|
print '<a href="'.$_SERVER["PHP_SEFL"].'?action=confirmgeneratesitemaps&website='.$website->ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'"><span class="fa fa-sitemap"><span></a>';
|
||||||
print dolButtonToOpenUrlInDialogPopup('generate_sitemap', $langs->transnoentitiesnoconv("GenerateSitemaps"), '<span class="fa fa-sitemap"><span>', '/website/index.php?action=generatesitemapsdomainname&website='.$website->ref, $disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
print ' ';
|
print ' ';
|
||||||
|
|
||||||
@ -2579,7 +2631,7 @@ if (!GETPOST('hide_websitemenu'))
|
|||||||
// Toolbar for pages
|
// Toolbar for pages
|
||||||
//
|
//
|
||||||
|
|
||||||
if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm', 'generatesitemaps')) && !$file_manager)
|
if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm')) && !$file_manager)
|
||||||
{
|
{
|
||||||
print '</div>'; // Close current websitebar to open a new one
|
print '</div>'; // Close current websitebar to open a new one
|
||||||
|
|
||||||
@ -3800,70 +3852,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$domainname = '0.0.0.0:8080';
|
// Print formconfirm
|
||||||
$tempdir = $conf->website->dir_temp.'/'.$websitekey.'/';
|
if ($action == 'preview'){
|
||||||
|
print $formconfirm;
|
||||||
// Form URL for generate web site sitemaps
|
|
||||||
if ($action == 'generatesitemapsdomainname'){
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="text/plain">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$token.'">';
|
|
||||||
print '<input type="hidden" name="action" value="generatesitemaps">';
|
|
||||||
print '<input type="hidden" name="website" value="'.$website->ref.'">';
|
|
||||||
print '<div class="fiche center"><br>';
|
|
||||||
print '<div class="titre inline-block">'.$langs->trans('EnterWebsiteUrl').'</div><br>';
|
|
||||||
print '<input id ="domainname" type="text" name="domainname" value="">'.$form->textwithpicto('', $langs->trans("Exemple").': www.exemple.com').'<br><br>';
|
|
||||||
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans("Next")).'">';
|
|
||||||
print '</div>';
|
|
||||||
print '</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate web site sitemaps
|
|
||||||
if ($action == 'generatesitemaps') {
|
|
||||||
if (!empty($_POST['domainname'])) {
|
|
||||||
$domainname = $_POST['domainname'];
|
|
||||||
}
|
|
||||||
$container_array = array();
|
|
||||||
$sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp";
|
|
||||||
$sql .= " WHERE wp.type_container IN ('page', 'blogpost')";
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
$num_rows = $db->num_rows($resql);
|
|
||||||
if ($num_rows > 0) {
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num_rows) {
|
|
||||||
$objp = $db->fetch_object($resql);
|
|
||||||
$container_array[] = $objp;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_dir($tempdir)) {
|
|
||||||
mkdir($tempdir);
|
|
||||||
}
|
|
||||||
$domtree = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$domtree->formatOutput = true;
|
|
||||||
$root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
|
|
||||||
foreach ($container_array as $container) {
|
|
||||||
$url = $domtree->createElement('url');
|
|
||||||
$pageurl = $container->pageurl;
|
|
||||||
if ($container->lang) {
|
|
||||||
$pageurl = $container->lang.'/'.$pageurl;
|
|
||||||
}
|
|
||||||
$loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl);
|
|
||||||
$lastmod = $domtree->createElement('lastmod', $container->tms);
|
|
||||||
|
|
||||||
$url->appendChild($loc);
|
|
||||||
$url->appendChild($lastmod);
|
|
||||||
$root->appendChild($url);
|
|
||||||
}
|
|
||||||
$domtree->appendChild($root);
|
|
||||||
$domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml');
|
|
||||||
print '<br>';
|
|
||||||
print $formfile->showdocuments('website', 'temp/'.$websitekey, $tempdir, $_SERVER["PHP_SELF"].'?action=""', $liste, 0, '', 1, 1, 0, 0, 0, '', $langs->trans("GeneratedSitemapsFiles"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'editfile' || $action == 'file_manager')
|
if ($action == 'editfile' || $action == 'file_manager')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user