Debug website module

This commit is contained in:
Laurent Destailleur 2018-12-17 17:29:04 +01:00
parent 4e940ebaf1
commit ffaff4dc7f
4 changed files with 45 additions and 27 deletions

View File

@ -212,6 +212,10 @@ function dolWebsiteOutput($content)
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
}
else
@ -222,6 +226,10 @@ function dolWebsiteOutput($content)
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
}
}

View File

@ -92,4 +92,5 @@ ZipOfWebsitePackageToImport=Zip file of website package
ShowSubcontainers=Include dynamic content
InternalURLOfPage=Internal URL of page
ThisPageIsTranslationOf=This page/container is translation of
ThisPageHasTranslationPages=This page/container has translation
ThisPageHasTranslationPages=This page/container has translation
NoWebSiteCreateOneFirst=No website created yet. Create on first.

View File

@ -366,7 +366,7 @@ if ($action == 'addcontainer')
$urltograb.='/';
}
$pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam)));
$urltograbdirwithoutslash = dirname($urltograb.'.');
$urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash);
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
@ -869,14 +869,14 @@ if ($action == 'updatecss')
$filemaster=$pathofwebsite.'/master.inc.php';
dol_syslog("Save master file ".$filemaster);
dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page
$result = dolSaveMasterFile($filemaster);
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Html header file
$htmlheadercontent ='';
@ -1472,8 +1472,15 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
{
if (! $error)
{
setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings');
if (empty($websitekey) || $websitekey == '-1')
{
setEventMessages($langs->trans("NoWebSiteCreateOneFirst"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings');
}
}
}
}
@ -1666,11 +1673,10 @@ if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource')
if (! GETPOST('hide_websitemenu'))
{
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">';
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">';
if (count($object->records) > 0) // There is at least one web site
{
// ***** Part for web sites
print '<!-- Bar for website -->';
print '<div class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">';
@ -1713,12 +1719,15 @@ if (count($object->records) > 0) // There is at least one web site
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
$array=array();
if ($object->id > 0)
{
$array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
}
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
if ($websitekey && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone'))
if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone'))
{
$disabled='';
if (empty($user->rights->website->write)) $disabled=' disabled="disabled"';
@ -1828,7 +1837,7 @@ if (count($object->records) > 0) // There is at least one web site
// Toolbar for pages
if ($websitekey && ! in_array($action, array('editcss','editmenu','importsite')))
if ($websitekey && $websitekey != '-1' && ! in_array($action, array('editcss','editmenu','importsite')))
{
print '</div>'; // Close current websitebar to open a new one
@ -2125,17 +2134,8 @@ if (count($object->records) > 0) // There is at least one web site
}
}
}
}
else
{
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
}
print '</div>'; // end current websitebar
print '</div>'; // end current websitebar
}
@ -2743,7 +2743,8 @@ if ($action == 'editsource')
$doleditor->Create(0, '', false);
}*/
print "</div>\n</form>\n";
print "</div>\n";
print "</form>\n";
if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')
@ -2874,8 +2875,16 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
}
else
{
print '<br><br><div class="center">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
if (empty($websitekey) || $websitekey == '-1')
{
print '<br><br><div class="center">'.$langs->trans("NoWebSiteCreateOneFirst").'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
else
{
print '<br><br><div class="center">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</center><br><br><br>';
print '<div class="center"><div class="logo_setup"></div></div>';
}
}
}