40 $mastercontent =
'<?php'.
"\n";
41 $mastercontent .=
'// File generated to link to the master file - DO NOT MODIFY - It is just an include'.
"\n";
42 $mastercontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
43 $mastercontent .=
" if (! defined('USEEXTERNALSERVER')) define('USEEXTERNALSERVER', 1);\n";
44 $mastercontent .=
" require_once '".DOL_DOCUMENT_ROOT.
"/master.inc.php';\n";
45 $mastercontent .=
"}\n";
46 $mastercontent .=
'?>'.
"\n";
47 $result = file_put_contents($filemaster, $mastercontent);
48 if (!empty($conf->global->MAIN_UMASK))
49 @chmod($filemaster, octdec($conf->global->MAIN_UMASK));
69 dol_syslog(
"dolSavePageAlias We regenerate the alias page filealias=".$filealias);
71 $aliascontent =
'<?php'.
"\n";
72 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
73 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
74 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.
'.tpl.php\'; ';
75 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
76 $aliascontent .=
'?>'.
"\n";
77 $result = file_put_contents($filealias, $aliascontent);
78 if ($result ===
false) {
79 dol_syslog(
"Failed to write file ".$filealias, LOG_WARNING);
81 if (!empty($conf->global->MAIN_UMASK)) {
82 @chmod($filealias, octdec($conf->global->MAIN_UMASK));
86 if ($objectpage->lang && in_array($objectpage->lang, explode(
',', $object->otherlang))) {
87 $dirname = dirname($filealias);
88 $filename = basename($filealias);
89 $filealiassub = $dirname.
'/'.$objectpage->lang.
'/'.$filename;
91 $aliascontent =
'<?php'.
"\n";
92 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
93 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
94 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
95 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
96 $aliascontent .=
'?>'.
"\n";
97 $result = file_put_contents($filealiassub, $aliascontent);
98 if ($result ===
false) {
99 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
101 if (!empty($conf->global->MAIN_UMASK)) {
102 @chmod($filealiassub, octdec($conf->global->MAIN_UMASK));
106 elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
107 if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) {
108 $dirname = dirname($filealias);
109 $filename = basename($filealias);
110 foreach (explode(
',', $object->otherlang) as $sublang) {
111 $filealiassub = $dirname.
'/'.$sublang.
'/'.$filename;
113 $aliascontent =
'<?php'.
"\n";
114 $aliascontent .=
"// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
115 $aliascontent .=
'global $dolibarr_main_data_root;'.
"\n";
116 $aliascontent .=
'if (empty($dolibarr_main_data_root)) require \'../page'.$objectpage->id.
'.tpl.php\'; ';
117 $aliascontent .=
'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.
'.tpl.php\';'.
"\n";
118 $aliascontent .=
'?>'.
"\n";
119 $result = file_put_contents($filealiassub, $aliascontent);
120 if ($result ===
false) {
121 dol_syslog(
"Failed to write file ".$filealiassub, LOG_WARNING);
123 if (!empty($conf->global->MAIN_UMASK)) {
124 @chmod($filealiassub, octdec($conf->global->MAIN_UMASK));
130 return ($result ?
true:
false);
149 dol_syslog(
"We regenerate the tpl page filetpl=".$filetpl);
151 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
155 if ($objectpage->lang) $shortlangcode = substr($objectpage->lang, 0, 2);
156 if (empty($shortlangcode)) $shortlangcode = substr($object->lang, 0, 2);
159 $tplcontent .=
"<?php // BEGIN PHP\n";
160 $tplcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
161 $tplcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {\n";
162 $tplcontent .=
' $pathdepth = count(explode(\'/\', $_SERVER[\'SCRIPT_NAME\'])) - 2;'.
"\n";
163 $tplcontent .=
' require_once ($pathdepth ? str_repeat(\'../\', $pathdepth) : \'./\').\'master.inc.php\';'.
"\n";
164 $tplcontent .=
"} // Not already loaded\n";
165 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
166 $tplcontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
167 $tplcontent .=
"ob_start();\n";
168 $tplcontent .=
"// END PHP ?>\n";
169 if (!empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
171 $tplcontent .=
"<!DOCTYPE html>\n";
173 $tplcontent .=
'<html'.($shortlangcode ?
' lang="'.$shortlangcode.
'"' :
'').
'>'.
"\n";
174 $tplcontent .=
'<head>'.
"\n";
175 $tplcontent .=
'<title>'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'</title>'.
"\n";
176 $tplcontent .=
'<meta charset="utf-8">'.
"\n";
177 $tplcontent .=
'<meta http-equiv="content-type" content="text/html; charset=utf-8" />'.
"\n";
178 $tplcontent .=
'<meta name="robots" content="index, follow" />'.
"\n";
179 $tplcontent .=
'<meta name="viewport" content="width=device-width, initial-scale=1.0">'.
"\n";
180 $tplcontent .=
'<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).
'" />'.
"\n";
181 $tplcontent .=
'<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0,
'UTF-8').
'" />'.
"\n";
182 $tplcontent .=
'<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0,
'UTF-8').
'" />'.
"\n";
183 $tplcontent .=
'<meta name="generator" content="'.DOL_APPLICATION_TITLE.
' '.DOL_VERSION.
' (https://www.dolibarr.org)" />'.
"\n";
184 $tplcontent .=
'<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).
'" />'.
"\n";
186 if ($object->virtualhost) {
187 $tplcontent .=
'<link rel="canonical" href="'.(($objectpage->id == $object->fk_default_home) ?
'/' : (($shortlangcode != substr($object->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php')).
'" />'.
"\n";
192 $tplcontent .=
'<?php if ($_SERVER["PHP_SELF"] == "'.(($object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr($object->lang, 0, 2)) ?
'/'.$shortlangcode :
'')).
'/'.$objectpage->pageurl.
'.php") { ?>'.
"\n";
193 $tplcontent .=
'<link rel="alternate" hreflang="'.$shortlangcode.
'" href="'.(($object->fk_default_home == $objectpage->id) ?
'/' : (($shortlangcode != substr($object->lang, 0, 2)) ?
'/'.$shortlangcode :
'').
'/'.$objectpage->pageurl.
'.php').
'" />'.
"\n";
196 $translationof = $objectpage->fk_page;
197 if ($translationof) {
199 $tmppage->fetch($translationof);
200 if ($tmppage->id > 0) {
201 $tmpshortlangcode =
'';
202 if ($tmppage->lang) $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
203 if (empty($tmpshortlangcode)) $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $object->lang);
204 if ($tmpshortlangcode != $shortlangcode) {
205 $tplcontent .=
'<link rel="alternate" hreflang="'.$tmpshortlangcode.
'" href="'.($object->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php').
'" />'.
"\n";
210 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page where fk_page IN ('.$objectpage->id.($translationof ?
", ".$translationof :
"").
")";
211 $resql = $db->query($sql);
214 $num_rows = $db->num_rows(
$resql);
217 while ($obj = $db->fetch_object(
$resql))
219 $tmpshortlangcode =
'';
220 if ($obj->lang) $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $obj->lang);
221 if ($tmpshortlangcode != $shortlangcode) {
222 $tplcontent .=
'<link rel="alternate" hreflang="'.$tmpshortlangcode.
'" href="'.($object->fk_default_home == $obj->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$obj->pageurl.
'.php').
'" />'.
"\n";
229 $tplcontent .=
'<?php } ?>'.
"\n";
232 $tplcontent .=
'<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'.
"\n";
233 $tplcontent .=
'<!-- Include link to CSS file -->'.
"\n";
235 $tplcontent .=
'<link rel="stylesheet" href="/styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'.
"\n";
236 $tplcontent .=
'<!-- Include link to JS file -->'.
"\n";
237 $tplcontent .=
'<script src="/javascript.js.php"></script>'.
"\n";
239 $tplcontent .=
'<!-- Include HTML header from common file -->'.
"\n";
240 $tplcontent .=
'<?php if (file_exists(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")) include DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html"; ?>'.
"\n";
241 $tplcontent .=
'<!-- Include HTML header from page header block -->'.
"\n";
242 $tplcontent .= preg_replace(
'/<\/?html>/ims',
'', $objectpage->htmlheader).
"\n";
243 $tplcontent .=
'</head>'.
"\n";
245 $tplcontent .=
'<!-- File generated by Dolibarr website module editor -->'.
"\n";
246 $tplcontent .=
'<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
247 $tplcontent .= $objectpage->content.
"\n";
248 $tplcontent .=
'</body>'.
"\n";
249 $tplcontent .=
'</html>'.
"\n";
251 $tplcontent .=
'<?php // BEGIN PHP'.
"\n";
252 $tplcontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.
');'.
"\n";
253 $tplcontent .=
"// END PHP ?>\n";
256 $result = file_put_contents($filetpl, $tplcontent);
257 if (!empty($conf->global->MAIN_UMASK)) {
258 @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
285 $indexcontent =
'<?php'.
"\n";
286 $indexcontent .=
"// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
287 $indexcontent .=
'$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'.
"\n";
288 $indexcontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
289 $indexcontent .=
'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'.
"\n";
290 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
291 $indexcontent .=
" require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
292 $indexcontent .=
' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'.
"\n";
293 $indexcontent .=
"}\n";
294 $indexcontent .=
"include_once './".basename($filetpl).
"'\n";
295 $indexcontent .=
'// END PHP ?>'.
"\n";
297 $result1 = file_put_contents($fileindex, $indexcontent);
298 if (!empty($conf->global->MAIN_UMASK)) {
299 @chmod($fileindex, octdec($conf->global->MAIN_UMASK));
307 $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.
'/website/samples/wrapper.php');
309 $result2 = file_put_contents($filewrapper, $wrappercontent);
310 if (!empty($conf->global->MAIN_UMASK)) {
311 @chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
317 return ($result1 && $result2);
330 global $conf, $pathofwebsite;
332 dol_syslog(
"Save html header into ".$filehtmlheader);
335 $result = file_put_contents($filehtmlheader, $htmlheadercontent);
336 if (!empty($conf->global->MAIN_UMASK))
337 @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
351 global $conf, $pathofwebsite;
356 $result = file_put_contents($filecss, $csscontent);
357 if (!empty($conf->global->MAIN_UMASK))
358 @chmod($filecss, octdec($conf->global->MAIN_UMASK));
372 global $conf, $pathofwebsite;
377 $result = file_put_contents($filejs, $jscontent);
378 if (!empty($conf->global->MAIN_UMASK))
379 @chmod($filejs, octdec($conf->global->MAIN_UMASK));
393 global $conf, $pathofwebsite;
395 dol_syslog(
"Save robot file into ".$filerobot);
398 $result = file_put_contents($filerobot, $robotcontent);
399 if (!empty($conf->global->MAIN_UMASK))
400 @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
414 global $conf, $pathofwebsite;
416 dol_syslog(
"Save htaccess file into ".$filehtaccess);
419 $result = file_put_contents($filehtaccess, $htaccess);
420 if (!empty($conf->global->MAIN_UMASK))
421 @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
435 global $conf, $pathofwebsite;
437 dol_syslog(
"Save manifest.js.php file into ".$file);
440 $result = file_put_contents($file, $content);
441 if (!empty($conf->global->MAIN_UMASK))
442 @chmod($file, octdec($conf->global->MAIN_UMASK));
456 global $conf, $pathofwebsite;
458 dol_syslog(
"Save README.md file into ".$file);
461 $result = file_put_contents($file, $content);
462 if (!empty($conf->global->MAIN_UMASK))
463 @chmod($file, octdec($conf->global->MAIN_UMASK));
477 global $conf, $langs, $db, $form;
479 $dirthemes = array(
'/doctemplates/websites');
480 if (!empty($conf->modules_parts[
'websitetemplates']))
482 foreach ($conf->modules_parts[
'websitetemplates'] as $reldir)
484 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
487 $dirthemes = array_unique($dirthemes);
492 print '<!-- For website template import -->'.
"\n";
493 print '<table class="noborder centpercent">';
496 print '<tr class="liste_titre"><th class="titlefield">';
497 print $form->textwithpicto($langs->trans(
"Templates"), $langs->trans(
"ThemeDir").
' : '.join(
", ", $dirthemes));
499 print '<th class="right">';
500 $url =
'https://www.dolistore.com/43-web-site-templates';
501 print '<a href="'.$url.
'" target="_blank">';
502 print $langs->trans(
'DownloadMoreSkins');
506 print '<tr><td colspan="'.$colspan.
'">';
508 print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
510 if (count($dirthemes)) {
512 foreach ($dirthemes as $dir)
515 $dirtheme = DOL_DATA_ROOT.$dir;
516 if (is_dir($dirtheme))
518 $handle = opendir($dirtheme);
519 if (is_resource($handle))
521 while (($subdir = readdir($handle)) !==
false)
523 if (is_file($dirtheme.
"/".$subdir) && substr($subdir, 0, 1) <>
'.'
524 && substr($subdir, 0, 3) <>
'CVS' && preg_match(
'/\.zip$/i', $subdir))
526 $subdirwithoutzip = preg_replace(
'/\.zip$/i',
'', $subdir);
529 if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match(
'/_dev$/i', $subdir))
continue;
530 if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match(
'/_exp$/i', $subdir))
continue;
532 print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
534 $file = $dirtheme.
"/".$subdirwithoutzip.
".jpg";
535 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.
".jpg";
537 if (!file_exists($file)) $url = DOL_URL_ROOT.
'/public/theme/common/nophoto.png';
539 $originalfile = basename($file);
540 $entity = $conf->entity;
541 $modulepart =
'doctemplateswebsite';
547 if (!empty($urladvanced)) $ret .=
'<a class="'.$urladvanced[
'css'].
'" target="'.$urladvanced[
'target'].
'" mime="'.$urladvanced[
'mime'].
'" href="'.$urladvanced[
'url'].
'">';
548 else $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
550 print '<img class="img-skinthumb shadow" src="'.$url.
'" border="0" alt="'.$title.
'" title="'.$title.
'" style="margin-bottom: 5px;">';
555 print '<br><a href="'.$_SERVER[
"PHP_SELF"].
'?action=importsiteconfirm&website='.$website->ref.
'&templateuserfile='.$subdir.
'" class="button">'.$langs->trans(
"Load").
'</a>';
565 print '<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
568 print '</div></td></tr></table>';
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
isMultiLang()
Return if web site is a multilanguage web site.
dolSaveMasterFile($filemaster)
Save content of a page on disk.
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dol_filesize($pathoffile)
Return size of a file.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
Save content of a page on disk (page name is generally ID_of_page.php).
showWebsiteTemplates(Website $website)
Show list of themes.
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
Save content of the index.php and/or wrapper.php page.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
dolSaveReadme($file, $content)
Save content of a page on disk.
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
print
Draft customers invoices.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)