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";
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/functionscli.lib.php';
58include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
59include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
60include_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
62$hookmanager->initHooks(array(
'cli'));
71if (!empty($dolibarr_main_db_readonly)) {
72 print
"Error: instance in read-onyl mode\n";
77$result = $website->fetch(0, $websiteref);
79 print
'Error, web site '.$websiteref.
' not found'.
"\n";
85$listofpages = $websitepagestatic->fetchAll($website->id,
'',
'', $max);
87global $dolibarr_main_data_root;
88$pathofwebsite = $dolibarr_main_data_root.
'/website/'.$websiteref;
91foreach ($listofpages as $websitepage) {
92 $filealias = $pathofwebsite.
'/'.$websitepage->pageurl.
'.php';
93 $filetpl = $pathofwebsite.
'/page'.$websitepage->id.
'.tpl.php';
94 if ($mode ==
'confirm') {
98 print
"Generation of page done - pageid = ".$websitepage->id.
" - ".$websitepage->pageurl.
"\n";
101 if ($max && $nbgenerated >= $max) {
102 print
'Nb max of record ('.$max.
') reached. We stop now.'.
"\n";
107if ($mode ==
'confirm') {
108 print $nbgenerated.
" page(s) generated into ".$pathofwebsite.
"\n";
110 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).