25if (!defined(
'NOSESSION')) {
26 define(
'NOSESSION',
'1');
29$sapi_type = php_sapi_name();
30$script_file = basename(__FILE__);
34if (substr($sapi_type, 0, 3) ==
'cgi') {
35 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
40define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
44$mode = empty($argv[1]) ?
'' : $argv[1];
45$websiteref = empty($argv[2]) ?
'' : $argv[2];
46$max = (!isset($argv[3]) || (empty($argv[3]) && $argv[3] !==
'0')) ?
'10' : $argv[3];
48if (empty($argv[2]) || !in_array($argv[1], array(
'test',
'confirm')) || empty($websiteref)) {
49 print
'***** '.$script_file.
' *****'.
"\n";
50 print
"Usage: $script_file (test|confirm) website [nbmaxrecord]\n";
52 print
"Regenerate all pages of a web site.\n";
56require $path.
"../../htdocs/master.inc.php";
57include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
58include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
59include_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
68if (!empty($dolibarr_main_db_readonly)) {
69 print
"Error: instance in read-onyl mode\n";
74$result = $website->fetch(0, $websiteref);
76 print
'Error, web site '.$websiteref.
' not found'.
"\n";
84$listofpages = $websitepagestatic->fetchAll($website->id,
'',
'', $max);
86global $dolibarr_main_data_root;
87$pathofwebsite = $dolibarr_main_data_root.
'/website/'.$websiteref;
90foreach ($listofpages as $websitepage) {
91 $filealias = $pathofwebsite.
'/'.$websitepage->pageurl.
'.php';
92 $filetpl = $pathofwebsite.
'/page'.$websitepage->id.
'.tpl.php';
93 if ($mode ==
'confirm') {
97 print
"Generation of page done - pageid = ".$websitepage->id.
" - ".$websitepage->pageurl.
"\n";
100 if ($max && $nbgenerated >= $max) {
101 print
'Nb max of record ('.$max.
') reached. We stop now.'.
"\n";
106if ($mode ==
'confirm') {
107 print $nbgenerated.
" page(s) generated into ".$pathofwebsite.
"\n";
109 print $nbgenerated.
" page(s) found but not generated (test mode)\n";
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).