Skip to content

Commit

Permalink
Debug module website
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 19, 2017
1 parent 89a6210 commit feaff43
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/lib/functions.lib.php
Expand Up @@ -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).
*
* @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
* @return string Output string after substitutions
* @see complete_substitutions_array
Expand Down
4 changes: 3 additions & 1 deletion htdocs/langs/en_US/website.lang
Expand Up @@ -61,4 +61,6 @@ WebsiteAccount=Web site account
WebsiteAccounts=Web site accounts
AddWebsiteAccount=Create web site account
BackToListOfThirdParty=Back to list for Third Party
DisableSiteFirst=Disable website first
DisableSiteFirst=Disable website first
MyContainerTitle=My web site title
AnotherContainer=Another container
33 changes: 23 additions & 10 deletions htdocs/website/index.php
Expand Up @@ -514,7 +514,9 @@
$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>';
$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)
Expand Down Expand Up @@ -605,13 +607,17 @@

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);
}

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);
}

Expand Down Expand Up @@ -1634,7 +1640,7 @@
{
$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'))
{
Expand All @@ -1650,16 +1656,23 @@

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
$htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheader);
$htmlheadercontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheadercontent);
}
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>";
else $htmlheader='<html>'."\n".trim($htmlheader)."\n".'</html>';
if (! trim($htmlheadercontent))
{
$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'))
{
Expand Down Expand Up @@ -1737,7 +1750,7 @@
print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
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 '</td></tr>';
Expand Down
15 changes: 15 additions & 0 deletions htdocs/website/pagetemplate.html
@@ -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>

0 comments on commit feaff43

Please sign in to comment.