2
0
forked from Wavyzz/dolibarr

Debug module website

This commit is contained in:
Laurent Destailleur
2017-12-19 12:54:10 +01:00
parent 89a62103ca
commit feaff433b8
4 changed files with 42 additions and 12 deletions

View File

@@ -5595,7 +5595,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
* Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval). * Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
* *
* @param string $text Source string in which we must do substitution * @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal')
* @param Translate $outputlangs Output language * @param Translate $outputlangs Output language
* @return string Output string after substitutions * @return string Output string after substitutions
* @see complete_substitutions_array * @see complete_substitutions_array

View File

@@ -62,3 +62,5 @@ WebsiteAccounts=Web site accounts
AddWebsiteAccount=Create web site account AddWebsiteAccount=Create web site account
BackToListOfThirdParty=Back to list for Third Party BackToListOfThirdParty=Back to list for Third Party
DisableSiteFirst=Disable website first DisableSiteFirst=Disable website first
MyContainerTitle=My web site title
AnotherContainer=Another container

View File

@@ -514,7 +514,9 @@ if ($action == 'addcontainer')
$objectpage->lang = GETPOST('WEBSITE_LANG','aZ09'); $objectpage->lang = GETPOST('WEBSITE_LANG','aZ09');
$objectpage->htmlheader = GETPOST('htmlheader','none'); $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>'; $substitutionarray=array();
$substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs);
$objectpage->content = make_substitutions(file_get_contents(DOL_DOCUMENT_ROOT.'/website/pagetemplate.html'), $substitutionarray);
} }
if (! $error) if (! $error)
@@ -605,13 +607,17 @@ if ($action == 'addcontainer')
if (! dol_is_file($filehtmlheader)) if (! dol_is_file($filehtmlheader))
{ {
$htmlheadercontent = "<html>\n<!-- HTML header content (common for all pages) -->\n</html>"; $htmlheadercontent ="<html>\n";
$htmlheadercontent.='<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>'."\n";
$htmlheadercontent.='<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>'."\n";
$htmlheadercontent.='<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />'."\n";
$htmlheadercontent.="</html>";
$result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); $result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
} }
if (! dol_is_file($filecss)) if (! dol_is_file($filecss))
{ {
$csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; }"; $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}";
$result=dolSaveCssFile($filecss, $csscontent); $result=dolSaveCssFile($filecss, $csscontent);
} }
@@ -1634,7 +1640,7 @@ if ($action == 'editcss')
{ {
$csscontent = GETPOST('WEBSITE_CSS_INLINE'); $csscontent = GETPOST('WEBSITE_CSS_INLINE');
} }
if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }'; if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}";
if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha')) if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
{ {
@@ -1650,16 +1656,23 @@ if ($action == 'editcss')
if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha')) if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
{ {
$htmlheader = @file_get_contents($filehtmlheader); $htmlheadercontent = @file_get_contents($filehtmlheader);
// Clean the php htmlheader file to remove php code and get only html part // Clean the php htmlheader file to remove php code and get only html part
$htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheader); $htmlheadercontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheadercontent);
} }
else else
{ {
$htmlheader = GETPOST('WEBSITE_HTML_HEADER'); $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER');
} }
if (! trim($htmlheader)) $htmlheader="<html>\n<!-- HTML header content (common for all pages) -->\n</html>"; if (! trim($htmlheadercontent))
else $htmlheader='<html>'."\n".trim($htmlheader)."\n".'</html>'; {
$htmlheadercontent ="<html>\n";
$htmlheadercontent.='<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>'."\n";
$htmlheadercontent.='<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>'."\n";
$htmlheadercontent.='<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />'."\n";
$htmlheadercontent.="</html>";
}
else $htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>';
if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha')) if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
{ {
@@ -1737,7 +1750,7 @@ if ($action == 'editcss')
print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
print '</td><td>'; print '</td><td>';
$doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheader, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print $doleditor->Create(1, '', true, 'HTML Header', 'html');
print '</td></tr>'; print '</td></tr>';

View File

@@ -0,0 +1,15 @@
<div class="dolcontenteditable" contenteditable="true">
<div style="text-align: center"><h1>__[MAIN_INFO_SOCIETE_NOM]__</h1><br>
__(MyContainerTitle)__
</div>
</div>
<div class="dolcontenteditable" contenteditable="true">
<br>
<div style="text-align: center">__(AnotherContainer)__</div>
<br>
</div>
<div class="dolcontenteditable" contenteditable="true">
<br>
<div style="text-align: center">__WEBSITE_CREATE_BY__</div>
<br>
</div>