27if (!defined(
'NOSESSION')) {
28 define(
'NOSESSION',
'1');
31$sapi_type = php_sapi_name();
32$script_file = basename(__FILE__);
36if (substr($sapi_type, 0, 3) ==
'cgi') {
37 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
42define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
46$mode = empty($argv[1]) ?
'' : $argv[1];
47$websiteref = empty($argv[2]) ?
'' : $argv[2];
48$max = (int) ((!isset($argv[3]) || (empty($argv[3]) && $argv[3] !==
'0')) ?
'10' : $argv[3]);
50if (empty($argv[2]) || !in_array($argv[1], array(
'test',
'confirm')) || empty($websiteref)) {
51 print
'***** '.$script_file.
' *****'.
"\n";
52 print
"Usage: $script_file (test|confirm) website [nbmaxrecord]\n";
54 print
"Regenerate all pages of a web site.\n";
58require $path.
"../../htdocs/master.inc.php";
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/functionscli.lib.php';
60include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
61include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
62include_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
69$hookmanager->initHooks(array(
'cli'));
78if (!empty($dolibarr_main_db_readonly)) {
79 print
"Error: instance in read-onyl mode\n";
84$result = $website->fetch(0, $websiteref);
86 print
'Error, web site '.$websiteref.
' not found'.
"\n";
92$listofpages = $websitepagestatic->fetchAll($website->id,
'',
'', $max);
94global $dolibarr_main_data_root;
95$pathofwebsite = $dolibarr_main_data_root.
'/website/'.$websiteref;
98foreach ($listofpages as $websitepage) {
99 $filealias = $pathofwebsite.
'/'.$websitepage->pageurl.
'.php';
100 $filetpl = $pathofwebsite.
'/page'.$websitepage->id.
'.tpl.php';
101 if ($mode ==
'confirm') {
105 print
"Generation of page done - pageid = ".$websitepage->id.
" - ".$websitepage->pageurl.
"\n";
108 if ($max && $nbgenerated >= $max) {
109 print
'Nb max of record ('.$max.
') reached. We stop now.'.
"\n";
114if ($mode ==
'confirm') {
115 print $nbgenerated.
" page(s) generated into ".$pathofwebsite.
"\n";
117 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).