2
0
forked from Wavyzz/dolibarr

Fix module website

This commit is contained in:
Laurent Destailleur
2017-12-12 01:40:34 +01:00
parent 48aada6090
commit 9880ef7364
6 changed files with 61 additions and 55 deletions

View File

@@ -160,17 +160,20 @@ function dolWebsiteSaveContent($content)
* Clean an HTML page to report only content, so we can include it into another page.
* It outputs content of file sanitized from html and body part.
*
* @param string $contentfile Path to file to include (must include website root. Example: 'mywebsite/mypage.php')
* @param string $containeralias Path to file to include (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php')
* @return void
*/
function dolIncludeHtmlContent($contentfile)
function includeContainer($containeralias)
{
global $conf, $db, $langs, $mysoc, $user, $website;
global $includehtmlcontentopened;
global $websitekey;
$MAXLEVEL=20;
$fullpathfile=DOL_DATA_ROOT.'/website/'.$contentfile;
if (! preg_match('/\.php$/i', $containeralias)) $containeralias.='.php';
$fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containeralias;
if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
$includehtmlcontentopened++;
@@ -193,7 +196,7 @@ function dolIncludeHtmlContent($contentfile)
if (! $res)
{
print 'ERROR: FAILED TO INCLUDE PAGE '.$contentfile.".\n";
print 'ERROR: FAILED TO INCLUDE PAGE '.$containeralias.".\n";
}
$includehtmlcontentopened--;

View File

@@ -40,7 +40,7 @@ VirtualHostUrlNotDefined=URL of the virtual host served by external web server n
NoPageYet=No pages yet
SyntaxHelp=Help on specific syntax tips
YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor.
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php dolIncludeHtmlContent($websitekey.'/alias_of_container_to_include.php'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
ClonePage=Clone page/container
CloneSite=Clone site
SiteAdded=Web site added

View File

@@ -39,7 +39,7 @@ VirtualHostUrlNotDefined=URL du virtual host servit par le serveur web externe n
NoPageYet=Pas de page pour l'instant
SyntaxHelp=Help on specific syntax tips
YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor.
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php dolIncludeHtmlContent($websitekey.'/alias_of_container_to_include.php'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include.php'); ?&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br><br><span class="fa fa-picture-o"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/medias (open access), syntax is:<br><strong>&lt;a href="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
ClonePage=Cloner la page/contenair
CloneSite=Cloner le site
SiteAdded=Web site added

View File

@@ -3798,10 +3798,6 @@ A.none, A.none:active, A.none:visited, A.none:hover {
.cke_dialog {
border: 1px #bbb solid ! important;
}
.cke_editable
{
margin: 5px !important;
}
/*.cke_editor table, .cke_editor tr, .cke_editor td
{
border: 0px solid #FF0000 !important;
@@ -3823,11 +3819,13 @@ a.cke_dialog_ui_button
{
vertical-align: bottom ! important;
}
/*
.cke_editable
{
line-height: 1.4 !important;
margin: 6px !important;
}
*/
a.cke_dialog_ui_button_ok span {
text-shadow: none !important;
color: #333 !important;

View File

@@ -3873,10 +3873,6 @@ A.none, A.none:active, A.none:visited, A.none:hover {
.cke_dialog {
border: 1px #bbb solid ! important;
}
.cke_editable
{
margin: 5px !important;
}
/*.cke_editor table, .cke_editor tr, .cke_editor td
{
border: 0px solid #FF0000 !important;
@@ -3898,11 +3894,13 @@ a.cke_dialog_ui_button
{
vertical-align: bottom ! important;
}
/*
.cke_editable
{
line-height: 1.4 !important;
margin: 6px !important;
}
*/
a.cke_dialog_ui_button_ok span {
text-shadow: none !important;
color: #333 !important;

View File

@@ -62,7 +62,7 @@ $file_manager = GETPOST('file_manager', 'alpha');
if (GETPOST('delete')) { $action='delete'; }
if (GETPOST('preview')) $action='preview';
if (GETPOST('createsite')) { $action='createsite'; }
if (GETPOST('create')) { $action='create'; }
if (GETPOST('createcontainer')) { $action='createcontainer'; }
if (GETPOST('editcss')) { $action='editcss'; }
if (GETPOST('editmenu')) { $action='editmenu'; }
if (GETPOST('setashome')) { $action='setashome'; }
@@ -107,7 +107,7 @@ if ($website)
}
if ($pageid < 0) $pageid = 0;
if (($pageid > 0 || $pageref) && $action != 'add')
if (($pageid > 0 || $pageref) && $action != 'addcontainer')
{
$res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
$pageid = $objectpage->id;
@@ -162,7 +162,7 @@ if ($action == 'adddir' && $permtouploadfile)
else
{
setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors');
$action = "create";
$action = "createcontainer";
}
clearstatcache();
@@ -240,8 +240,8 @@ if ($action == 'addsite')
}
}
// Add page
if ($action == 'add')
// Add page/container
if ($action == 'addcontainer')
{
dol_mkdir($pathofwebsite);
@@ -276,13 +276,13 @@ if ($action == 'add')
{
$error++;
setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors');
$action='create';
$action='createcontainer';
}
elseif ($tmp['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors');
$action='create';
$action='createcontainer';
}
else
{
@@ -383,13 +383,13 @@ if ($action == 'add')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='create';
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='create';
$action='createcontainer';
}
else
{
@@ -448,13 +448,13 @@ if ($action == 'add')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
$action='create';
$action='createcontainer';
}
elseif ($tmpgeturl['http_code'] != '200')
{
$error++;
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
$action='create';
$action='createcontainer';
}
else
{
@@ -504,6 +504,8 @@ if ($action == 'add')
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG','aZ09');
$objectpage->htmlheader = GETPOST('htmlheader','none');
$objectpage->content = '<div class="dolcontenteditable" contenteditable="true"><div class="center"><h1>'.$langs->trans("MyContainerTitle").'</h1>'.$langs->trans("MyContainerContent").'</div><br><br></div>';
}
if (! $error)
@@ -512,19 +514,19 @@ if ($action == 'add')
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++;
$action='create';
$action='createcontainer';
}
else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl))
{
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors');
$error++;
$action='create';
$action='createcontainer';
}
if (empty($objectpage->title))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors');
$error++;
$action='create';
$action='createcontainer';
}
}
@@ -535,6 +537,7 @@ if ($action == 'add')
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
$action='createcontainer';
}
}
if (! $error)
@@ -1222,9 +1225,9 @@ if ($action == 'createsite')
{
print '<input type="hidden" name="action" value="addsite">';
}
if ($action == 'create')
if ($action == 'createcontainer')
{
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="action" value="addcontainer">';
}
if ($action == 'editcss')
{
@@ -1265,6 +1268,7 @@ print '<div>';
$style='';
if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;';
if (! GETPOST('hide_websitemenu'))
{
//var_dump($objectpage);exit;
@@ -1400,18 +1404,18 @@ if (count($object->records) > 0)
print '</div>';
print '<div class="websiteselection hideonsmartphoneimp">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'" name="create">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'" name="createcontainer">';
print '</div>';
print '<div class="websiteselection">';
if ($action != 'add')
if ($action != 'addcontainer')
{
$out='';
$out.='<select name="pageid" id="pageid" class="minwidth200 maxwidth300">';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
@@ -1526,7 +1530,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','file_manager','createsite','create','createpagefromclone')))
if (! in_array($action, array('editcss','editmenu','file_manager','createsite','createcontainer','createpagefromclone')))
{
if (preg_match('/^create/',$action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
@@ -1737,7 +1741,7 @@ if ($action == 'createsite')
dol_fiche_head($head, 'card', $langs->trans("AddSite"), -1, 'globe');
*/
if ($action == 'create') print_fiche_titre($langs->trans("AddSite"));
if ($action == 'createcontainer') print_fiche_titre($langs->trans("AddSite"));
print '<!-- Add site -->'."\n";
//print '<div class="fichecenter">';
@@ -1772,7 +1776,7 @@ if ($action == 'createsite')
{
print '<div class="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Create").'">';
print '<input class="button" type="submit" name="addcontainer" value="'.$langs->trans("Create").'">';
print '<input class="button" type="submit" name="preview" value="'.$langs->trans("Cancel").'">';
print '</div>';
@@ -1788,7 +1792,7 @@ if ($action == 'createsite')
print '<br>';
}
if ($action == 'editmeta' || $action == 'create')
if ($action == 'editmeta' || $action == 'createcontainer')
{
print '<div class="fiche">';
@@ -1804,33 +1808,36 @@ if ($action == 'editmeta' || $action == 'create')
dol_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe');
*/
if ($action == 'create') print_fiche_titre($langs->trans("AddPage"));
if ($action == 'createcontainer') print_fiche_titre($langs->trans("AddPage"));
print '<!-- Edit or create page -->'."\n";
print '<!-- Edit or create page/container -->'."\n";
//print '<div class="fichecenter">';
if ($action == 'create')
if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
{
print '<br>';
if ($action == 'createcontainer')
{
print '<br>';
print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">';
print $langs->trans("URL");
print '</td><td>';
print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="http://externalsite/pagetofetch"> ';
print '<input class="button" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">';
print '</td></tr>';
print '</table>';
print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">';
print $langs->trans("URL");
print '</td><td>';
print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="http://externalsite/pagetofetch"> ';
print '<input class="button" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">';
print '</td></tr>';
print '</table>';
print '<br>';
print '<br>';
print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>';
print ' * '.$langs->trans("OrEnterPageInfoManually").'<br><hr>';
}
}
print '<table class="border" width="100%">';
if ($action != 'create')
if ($action != 'createcontainer')
{
print '<tr><td class="titlefield fieldrequired">';
print $langs->trans('IDOfPage');
@@ -1913,11 +1920,11 @@ if ($action == 'editmeta' || $action == 'create')
print '</table>';
if ($action == 'create')
if ($action == 'createcontainer')
{
print '<div class="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Create").'">';
print '<input class="button" type="submit" name="addcontainer" value="'.$langs->trans("Create").'">';
print '<input class="button" type="submit" name="preview" value="'.$langs->trans("Cancel").'">';
print '</div>';