Fix generation of doc in modulebuilder
This commit is contained in:
parent
dbd96d1ac7
commit
338f8d978a
@ -90,10 +90,10 @@ class Utils
|
||||
|
||||
if ($choice=='logfile')
|
||||
{
|
||||
// Define files log
|
||||
// Define files log
|
||||
if ($dolibarr_main_data_root)
|
||||
{
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$');
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$');
|
||||
}
|
||||
|
||||
$filelog='';
|
||||
@ -105,7 +105,7 @@ class Utils
|
||||
$alreadyincluded=false;
|
||||
foreach ($filesarray as $tmpcursor)
|
||||
{
|
||||
if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded=true; }
|
||||
if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded=true; }
|
||||
}
|
||||
if (! $alreadyincluded) $filesarray[]=array('fullname'=>$filelog,'type'=>'file');
|
||||
}
|
||||
@ -121,24 +121,24 @@ class Utils
|
||||
//print "x ".$filesarray[$key]['fullname']."-".$filesarray[$key]['type']."<br>\n";
|
||||
if ($filesarray[$key]['type'] == 'dir')
|
||||
{
|
||||
$startcount=0;
|
||||
$tmpcountdeleted=0;
|
||||
$startcount=0;
|
||||
$tmpcountdeleted=0;
|
||||
$result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted);
|
||||
$count+=$result;
|
||||
$countdeleted+=$tmpcountdeleted;
|
||||
$count+=$result;
|
||||
$countdeleted+=$tmpcountdeleted;
|
||||
}
|
||||
elseif ($filesarray[$key]['type'] == 'file')
|
||||
{
|
||||
// If (file that is not logfile) or (if logfile with option logfile)
|
||||
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
|
||||
{
|
||||
$result=dol_delete_file($filesarray[$key]['fullname'], 1, 1);
|
||||
if ($result)
|
||||
{
|
||||
$count++;
|
||||
$countdeleted++;
|
||||
}
|
||||
else $counterror++;
|
||||
$result=dol_delete_file($filesarray[$key]['fullname'], 1, 1);
|
||||
if ($result)
|
||||
{
|
||||
$count++;
|
||||
$countdeleted++;
|
||||
}
|
||||
else $counterror++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,8 +154,8 @@ class Utils
|
||||
|
||||
if ($count > 0)
|
||||
{
|
||||
$this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
|
||||
if ($count > $countdeleted) $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
|
||||
$this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
|
||||
if ($count > $countdeleted) $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
|
||||
}
|
||||
else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':'');
|
||||
|
||||
@ -189,29 +189,29 @@ class Utils
|
||||
// Check compression parameter
|
||||
if (! in_array($compression, array('none', 'gz', 'bz', 'zip')))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $compression, "Compression");
|
||||
return -1;
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $compression, "Compression");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check type parameter
|
||||
if ($type == 'auto') $type = $db->type;
|
||||
if (! in_array($type, array('postgresql', 'pgsql', 'mysql', 'mysqli', 'mysqlnobin')))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
|
||||
return -1;
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check file parameter
|
||||
if ($file == 'auto')
|
||||
{
|
||||
$prefix='dump';
|
||||
$ext='.sql';
|
||||
if (in_array($type, array('mysql', 'mysqli'))) { $prefix='mysqldump'; $ext='sql'; }
|
||||
//if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; }
|
||||
if (in_array($type, array('pgsql'))) { $prefix='pg_dump'; $ext='sql'; }
|
||||
$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
|
||||
$prefix='dump';
|
||||
$ext='.sql';
|
||||
if (in_array($type, array('mysql', 'mysqli'))) { $prefix='mysqldump'; $ext='sql'; }
|
||||
//if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; }
|
||||
if (in_array($type, array('pgsql'))) { $prefix='pg_dump'; $ext='sql'; }
|
||||
$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
|
||||
}
|
||||
|
||||
$outputdir = $conf->admin->dir_output.'/backup';
|
||||
@ -221,229 +221,229 @@ class Utils
|
||||
// MYSQL
|
||||
if ($type == 'mysql' || $type == 'mysqli')
|
||||
{
|
||||
$cmddump=$conf->global->SYSTEMTOOLS_MYSQLDUMP;
|
||||
$cmddump=$conf->global->SYSTEMTOOLS_MYSQLDUMP;
|
||||
|
||||
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
|
||||
// Parameteres execution
|
||||
$command=$cmddump;
|
||||
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
|
||||
// Parameteres execution
|
||||
$command=$cmddump;
|
||||
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
|
||||
|
||||
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
|
||||
$param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host;
|
||||
$param.=" -u ".$dolibarr_main_db_user;
|
||||
if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
|
||||
if (! GETPOST("use_transaction")) $param.=" -l --single-transaction";
|
||||
if (GETPOST("disable_fk") || $usedefault) $param.=" -K";
|
||||
if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat","alpha"));
|
||||
if (GETPOST("drop_database")) $param.=" --add-drop-database";
|
||||
if (GETPOST("sql_structure") || $usedefault)
|
||||
{
|
||||
if (GETPOST("drop") || $usedefault) $param.=" --add-drop-table=TRUE";
|
||||
else $param.=" --add-drop-table=FALSE";
|
||||
}
|
||||
else
|
||||
{
|
||||
$param.=" -t";
|
||||
}
|
||||
if (GETPOST("disable-add-locks")) $param.=" --add-locks=FALSE";
|
||||
if (GETPOST("sql_data") || $usedefault)
|
||||
{
|
||||
$param.=" --tables";
|
||||
if (GETPOST("showcolumns") || $usedefault) $param.=" -c";
|
||||
if (GETPOST("extended_ins") || $usedefault) $param.=" -e";
|
||||
else $param.=" --skip-extended-insert";
|
||||
if (GETPOST("delayed")) $param.=" --delayed-insert";
|
||||
if (GETPOST("sql_ignore")) $param.=" --insert-ignore";
|
||||
if (GETPOST("hexforbinary") || $usedefault) $param.=" --hex-blob";
|
||||
}
|
||||
else
|
||||
{
|
||||
$param.=" -d"; // No row information (no data)
|
||||
}
|
||||
$param.=" --default-character-set=utf8"; // We always save output into utf8 charset
|
||||
$paramcrypted=$param;
|
||||
$paramclear=$param;
|
||||
if (! empty($dolibarr_main_db_pass))
|
||||
{
|
||||
$paramcrypted.=' -p"'.preg_replace('/./i','*',$dolibarr_main_db_pass).'"';
|
||||
$paramclear.=' -p"'.str_replace(array('"','`'),array('\"','\`'),$dolibarr_main_db_pass).'"';
|
||||
}
|
||||
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
|
||||
$param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host;
|
||||
$param.=" -u ".$dolibarr_main_db_user;
|
||||
if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
|
||||
if (! GETPOST("use_transaction")) $param.=" -l --single-transaction";
|
||||
if (GETPOST("disable_fk") || $usedefault) $param.=" -K";
|
||||
if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat","alpha"));
|
||||
if (GETPOST("drop_database")) $param.=" --add-drop-database";
|
||||
if (GETPOST("sql_structure") || $usedefault)
|
||||
{
|
||||
if (GETPOST("drop") || $usedefault) $param.=" --add-drop-table=TRUE";
|
||||
else $param.=" --add-drop-table=FALSE";
|
||||
}
|
||||
else
|
||||
{
|
||||
$param.=" -t";
|
||||
}
|
||||
if (GETPOST("disable-add-locks")) $param.=" --add-locks=FALSE";
|
||||
if (GETPOST("sql_data") || $usedefault)
|
||||
{
|
||||
$param.=" --tables";
|
||||
if (GETPOST("showcolumns") || $usedefault) $param.=" -c";
|
||||
if (GETPOST("extended_ins") || $usedefault) $param.=" -e";
|
||||
else $param.=" --skip-extended-insert";
|
||||
if (GETPOST("delayed")) $param.=" --delayed-insert";
|
||||
if (GETPOST("sql_ignore")) $param.=" --insert-ignore";
|
||||
if (GETPOST("hexforbinary") || $usedefault) $param.=" --hex-blob";
|
||||
}
|
||||
else
|
||||
{
|
||||
$param.=" -d"; // No row information (no data)
|
||||
}
|
||||
$param.=" --default-character-set=utf8"; // We always save output into utf8 charset
|
||||
$paramcrypted=$param;
|
||||
$paramclear=$param;
|
||||
if (! empty($dolibarr_main_db_pass))
|
||||
{
|
||||
$paramcrypted.=' -p"'.preg_replace('/./i','*',$dolibarr_main_db_pass).'"';
|
||||
$paramclear.=' -p"'.str_replace(array('"','`'),array('\"','\`'),$dolibarr_main_db_pass).'"';
|
||||
}
|
||||
|
||||
$errormsg='';
|
||||
$errormsg='';
|
||||
|
||||
// Debut appel methode execution
|
||||
$fullcommandcrypted=$command." ".$paramcrypted." 2>&1";
|
||||
$fullcommandclear=$command." ".$paramclear." 2>&1";
|
||||
if ($compression == 'none') $handle = fopen($outputfile, 'w');
|
||||
if ($compression == 'gz') $handle = gzopen($outputfile, 'w');
|
||||
if ($compression == 'bz') $handle = bzopen($outputfile, 'w');
|
||||
// Debut appel methode execution
|
||||
$fullcommandcrypted=$command." ".$paramcrypted." 2>&1";
|
||||
$fullcommandclear=$command." ".$paramclear." 2>&1";
|
||||
if ($compression == 'none') $handle = fopen($outputfile, 'w');
|
||||
if ($compression == 'gz') $handle = gzopen($outputfile, 'w');
|
||||
if ($compression == 'bz') $handle = bzopen($outputfile, 'w');
|
||||
|
||||
if ($handle)
|
||||
{
|
||||
$ok=0;
|
||||
dol_syslog("Run command ".$fullcommandcrypted);
|
||||
$handlein = popen($fullcommandclear, 'r');
|
||||
$i=0;
|
||||
while (!feof($handlein))
|
||||
{
|
||||
$i++; // output line number
|
||||
$read = fgets($handlein);
|
||||
// Exclude warning line we don't want
|
||||
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
|
||||
fwrite($handle,$read);
|
||||
if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1;
|
||||
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1;
|
||||
}
|
||||
pclose($handlein);
|
||||
if ($handle)
|
||||
{
|
||||
$ok=0;
|
||||
dol_syslog("Run command ".$fullcommandcrypted);
|
||||
$handlein = popen($fullcommandclear, 'r');
|
||||
$i=0;
|
||||
while (!feof($handlein))
|
||||
{
|
||||
$i++; // output line number
|
||||
$read = fgets($handlein);
|
||||
// Exclude warning line we don't want
|
||||
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
|
||||
fwrite($handle,$read);
|
||||
if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1;
|
||||
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1;
|
||||
}
|
||||
pclose($handlein);
|
||||
|
||||
if ($compression == 'none') fclose($handle);
|
||||
if ($compression == 'gz') gzclose($handle);
|
||||
if ($compression == 'bz') bzclose($handle);
|
||||
if ($compression == 'none') fclose($handle);
|
||||
if ($compression == 'gz') gzclose($handle);
|
||||
if ($compression == 'bz') bzclose($handle);
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
|
||||
$errormsg=$langs->trans("ErrorFailedToWriteInDir");
|
||||
}
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
|
||||
$errormsg=$langs->trans("ErrorFailedToWriteInDir");
|
||||
}
|
||||
|
||||
// Get errorstring
|
||||
if ($compression == 'none') $handle = fopen($outputfile, 'r');
|
||||
if ($compression == 'gz') $handle = gzopen($outputfile, 'r');
|
||||
if ($compression == 'bz') $handle = bzopen($outputfile, 'r');
|
||||
if ($handle)
|
||||
{
|
||||
// Get 2048 first chars of error message.
|
||||
$errormsg = fgets($handle,2048);
|
||||
// Close file
|
||||
if ($compression == 'none') fclose($handle);
|
||||
if ($compression == 'gz') gzclose($handle);
|
||||
if ($compression == 'bz') bzclose($handle);
|
||||
if ($ok && preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur
|
||||
else
|
||||
{
|
||||
// Renommer fichier sortie en fichier erreur
|
||||
//print "$outputfile -> $outputerror";
|
||||
@dol_delete_file($outputerror,1);
|
||||
@rename($outputfile,$outputerror);
|
||||
// Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide
|
||||
if (! $errormsg)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$errormsg=$langs->trans("ErrorFailedToRunExternalCommand");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fin execution commande
|
||||
// Get errorstring
|
||||
if ($compression == 'none') $handle = fopen($outputfile, 'r');
|
||||
if ($compression == 'gz') $handle = gzopen($outputfile, 'r');
|
||||
if ($compression == 'bz') $handle = bzopen($outputfile, 'r');
|
||||
if ($handle)
|
||||
{
|
||||
// Get 2048 first chars of error message.
|
||||
$errormsg = fgets($handle,2048);
|
||||
// Close file
|
||||
if ($compression == 'none') fclose($handle);
|
||||
if ($compression == 'gz') gzclose($handle);
|
||||
if ($compression == 'bz') bzclose($handle);
|
||||
if ($ok && preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur
|
||||
else
|
||||
{
|
||||
// Renommer fichier sortie en fichier erreur
|
||||
//print "$outputfile -> $outputerror";
|
||||
@dol_delete_file($outputerror,1);
|
||||
@rename($outputfile,$outputerror);
|
||||
// Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide
|
||||
if (! $errormsg)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$errormsg=$langs->trans("ErrorFailedToRunExternalCommand");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fin execution commande
|
||||
|
||||
$this->output = $errormsg;
|
||||
$this->error = $errormsg;
|
||||
$this->result = array("commandbackuplastdone" => $command." ".$paramcrypted, "commandbackuptorun" => "");
|
||||
//if (empty($this->output)) $this->output=$this->result['commandbackuplastdone'];
|
||||
$this->output = $errormsg;
|
||||
$this->error = $errormsg;
|
||||
$this->result = array("commandbackuplastdone" => $command." ".$paramcrypted, "commandbackuptorun" => "");
|
||||
//if (empty($this->output)) $this->output=$this->result['commandbackuplastdone'];
|
||||
}
|
||||
|
||||
// MYSQL NO BIN
|
||||
if ($type == 'mysqlnobin')
|
||||
{
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
$outputfiletemp = $outputfile.'-TMP.sql';
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
$outputfiletemp = $outputfile.'-TMP.sql';
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
|
||||
if ($compression == 'gz' or $compression == 'bz')
|
||||
{
|
||||
backup_tables($outputfiletemp);
|
||||
dol_compress_file($outputfiletemp, $outputfile, $compression);
|
||||
unlink($outputfiletemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
backup_tables($outputfile);
|
||||
}
|
||||
if ($compression == 'gz' or $compression == 'bz')
|
||||
{
|
||||
backup_tables($outputfiletemp);
|
||||
dol_compress_file($outputfiletemp, $outputfile, $compression);
|
||||
unlink($outputfiletemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
backup_tables($outputfile);
|
||||
}
|
||||
|
||||
$this->output = "";
|
||||
$this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => "");
|
||||
$this->output = "";
|
||||
$this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => "");
|
||||
}
|
||||
|
||||
// POSTGRESQL
|
||||
if ($type == 'postgresql' || $type == 'pgsql')
|
||||
{
|
||||
$cmddump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
|
||||
$cmddump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
|
||||
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
$outputfile = $outputdir.'/'.$file;
|
||||
// for compression format, we add extension
|
||||
$compression=$compression ? $compression : 'none';
|
||||
if ($compression == 'gz') $outputfile.='.gz';
|
||||
if ($compression == 'bz') $outputfile.='.bz2';
|
||||
$outputerror = $outputfile.'.err';
|
||||
dol_mkdir($conf->admin->dir_output.'/backup');
|
||||
|
||||
// Parameteres execution
|
||||
$command=$cmddump;
|
||||
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
|
||||
// Parameteres execution
|
||||
$command=$cmddump;
|
||||
if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
|
||||
|
||||
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
|
||||
//$param="-F c";
|
||||
$param="-F p";
|
||||
$param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host;
|
||||
$param.=" -U ".$dolibarr_main_db_user;
|
||||
if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
|
||||
if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting";
|
||||
if (GETPOST("drop_database")) $param.=" -c -C";
|
||||
if (GETPOST("sql_structure"))
|
||||
{
|
||||
if (GETPOST("drop")) $param.=" --add-drop-table";
|
||||
if (! GETPOST("sql_data")) $param.=" -s";
|
||||
}
|
||||
if (GETPOST("sql_data"))
|
||||
{
|
||||
if (! GETPOST("sql_structure")) $param.=" -a";
|
||||
if (GETPOST("showcolumns")) $param.=" -c";
|
||||
}
|
||||
$param.=' -f "'.$outputfile.'"';
|
||||
//if ($compression == 'none')
|
||||
if ($compression == 'gz') $param.=' -Z 9';
|
||||
//if ($compression == 'bz')
|
||||
$paramcrypted=$param;
|
||||
$paramclear=$param;
|
||||
/*if (! empty($dolibarr_main_db_pass))
|
||||
{
|
||||
$paramcrypted.=" -W".preg_replace('/./i','*',$dolibarr_main_db_pass);
|
||||
$paramclear.=" -W".$dolibarr_main_db_pass;
|
||||
}*/
|
||||
$paramcrypted.=" -w ".$dolibarr_main_db_name;
|
||||
$paramclear.=" -w ".$dolibarr_main_db_name;
|
||||
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
|
||||
//$param="-F c";
|
||||
$param="-F p";
|
||||
$param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host;
|
||||
$param.=" -U ".$dolibarr_main_db_user;
|
||||
if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
|
||||
if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting";
|
||||
if (GETPOST("drop_database")) $param.=" -c -C";
|
||||
if (GETPOST("sql_structure"))
|
||||
{
|
||||
if (GETPOST("drop")) $param.=" --add-drop-table";
|
||||
if (! GETPOST("sql_data")) $param.=" -s";
|
||||
}
|
||||
if (GETPOST("sql_data"))
|
||||
{
|
||||
if (! GETPOST("sql_structure")) $param.=" -a";
|
||||
if (GETPOST("showcolumns")) $param.=" -c";
|
||||
}
|
||||
$param.=' -f "'.$outputfile.'"';
|
||||
//if ($compression == 'none')
|
||||
if ($compression == 'gz') $param.=' -Z 9';
|
||||
//if ($compression == 'bz')
|
||||
$paramcrypted=$param;
|
||||
$paramclear=$param;
|
||||
/*if (! empty($dolibarr_main_db_pass))
|
||||
{
|
||||
$paramcrypted.=" -W".preg_replace('/./i','*',$dolibarr_main_db_pass);
|
||||
$paramclear.=" -W".$dolibarr_main_db_pass;
|
||||
}*/
|
||||
$paramcrypted.=" -w ".$dolibarr_main_db_name;
|
||||
$paramclear.=" -w ".$dolibarr_main_db_name;
|
||||
|
||||
$this->output = "";
|
||||
$this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => $command." ".$paramcrypted);
|
||||
$this->output = "";
|
||||
$this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => $command." ".$paramcrypted);
|
||||
}
|
||||
|
||||
// Clean old files
|
||||
if ($keeplastnfiles > 0)
|
||||
{
|
||||
$tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
|
||||
$i=0;
|
||||
foreach($tmpfiles as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
if ($i <= $keeplastnfiles) continue;
|
||||
dol_delete_file($val['fullname']);
|
||||
}
|
||||
$tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
|
||||
$i=0;
|
||||
foreach($tmpfiles as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
if ($i <= $keeplastnfiles) continue;
|
||||
dol_delete_file($val['fullname']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -523,4 +523,148 @@ class Utils
|
||||
return array('result'=>$result, 'output'=>$output, 'error'=>$error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate documentation of a Module
|
||||
*
|
||||
* @param string $module Module name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function generateDoc($module)
|
||||
{
|
||||
global $conf, $dirins;
|
||||
|
||||
$error = 0;
|
||||
|
||||
$modulelowercase=strtolower($module);
|
||||
|
||||
// Dir for module
|
||||
$dir = $dirins.'/'.$modulelowercase;
|
||||
// Zip file to build
|
||||
$FILENAMEDOC='';
|
||||
|
||||
// Load module
|
||||
dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
|
||||
$class='mod'.$module;
|
||||
|
||||
if (class_exists($class))
|
||||
{
|
||||
try {
|
||||
$moduleobj = new $class($db);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($e->getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module));
|
||||
exit;
|
||||
}
|
||||
|
||||
$arrayversion=explode('.',$moduleobj->version,3);
|
||||
if (count($arrayversion))
|
||||
{
|
||||
$FILENAMEASCII=strtolower($module).'.asciidoc';
|
||||
$FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF
|
||||
|
||||
$dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
|
||||
$dirofmoduletmp = dol_buildpath(strtolower($module), 0).'/doc/temp';
|
||||
$outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
|
||||
if ($dirofmodule)
|
||||
{
|
||||
if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
|
||||
if (! dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp);
|
||||
if (! is_writable($dirofmoduletmp))
|
||||
{
|
||||
$this->error = 'Dir '.$dirofmoduletmp.' does not exists or is not writable';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$destfile=$dirofmoduletmp.'/'.$FILENAMEASCII;
|
||||
|
||||
$fhandle = fopen($destfile, 'w+');
|
||||
if ($fhandle)
|
||||
{
|
||||
$specs=dol_dir_list(dol_buildpath(strtolower($module).'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/'));
|
||||
|
||||
$i = 0;
|
||||
foreach ($specs as $spec)
|
||||
{
|
||||
if (preg_match('/notindoc/', $spec['relativename'])) continue; // Discard file
|
||||
if (preg_match('/disabled/', $spec['relativename'])) continue; // Discard file
|
||||
|
||||
$pathtofile = strtolower($module).'/doc/'.$spec['relativename'];
|
||||
$format='asciidoc';
|
||||
if (preg_match('/\.md$/i', $spec['name'])) $format='markdown';
|
||||
|
||||
$filecursor = @file_get_contents($spec['fullname']);
|
||||
if ($filecursor)
|
||||
{
|
||||
fwrite($fhandle, ($i ? "\n<<<\n\n" : "").$filecursor."\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = 'Failed to concat content of file '.$spec['fullname'];
|
||||
return -1;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
fwrite($fhandle, "\n\n\n== DATA SPECIFICATIONS...\n\n");
|
||||
|
||||
// TODO
|
||||
fwrite($fhandle, "TODO...");
|
||||
|
||||
fclose($fhandle);
|
||||
}
|
||||
|
||||
$conf->global->MODULEBUILDER_ASCIIDOCTOR='asciidoctor';
|
||||
if (empty($conf->global->MODULEBUILDER_ASCIIDOCTOR))
|
||||
{
|
||||
dol_print_error('', 'Module setup not complete');
|
||||
exit;
|
||||
}
|
||||
|
||||
$command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmodule.'/'.$FILENAMEDOC;
|
||||
$outfile=$dirofmoduletmp.'/out.tmp';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||
$utils = new Utils($db);
|
||||
$resarray = $utils->executeCLI($command, $outfile);
|
||||
if ($resarray['result'] != '0')
|
||||
{
|
||||
$this->error = $resarray['error'].' '.$resarray['output'];
|
||||
}
|
||||
$result = ($resarray['result'] == 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorFailToGenerateFile", $outputfiledoc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorCheckVersionIsDefined");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||
|
||||
$langs->loadLangs(array("admin", "modulebuilder", "other", "cron"));
|
||||
|
||||
@ -98,8 +99,8 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
||||
$destdir = $dirins.'/'.strtolower($modulename);
|
||||
|
||||
$arrayreplacement=array(
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename
|
||||
);
|
||||
|
||||
$result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
|
||||
@ -143,15 +144,15 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
||||
{
|
||||
//var_dump($phpfileval['fullname']);
|
||||
$arrayreplacement=array(
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename,
|
||||
'MYMODULE'=>strtoupper($modulename),
|
||||
'My module'=>$modulename,
|
||||
'my module'=>$modulename,
|
||||
'Mon module'=>$modulename,
|
||||
'mon module'=>$modulename,
|
||||
'htdocs/modulebuilder/template'=>strtolower($modulename),
|
||||
'---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename,
|
||||
'MYMODULE'=>strtoupper($modulename),
|
||||
'My module'=>$modulename,
|
||||
'my module'=>$modulename,
|
||||
'Mon module'=>$modulename,
|
||||
'mon module'=>$modulename,
|
||||
'htdocs/modulebuilder/template'=>strtolower($modulename),
|
||||
'---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
|
||||
);
|
||||
|
||||
|
||||
@ -222,20 +223,20 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
{
|
||||
// Delete some files
|
||||
$filetogenerate = array(
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_note.php'=>strtolower($objectname).'_note.php',
|
||||
'myobject_document.php'=>strtolower($objectname).'_document.php',
|
||||
'myobject_agenda.php'=>strtolower($objectname).'_agenda.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
|
||||
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
|
||||
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
|
||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||
'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php'
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_note.php'=>strtolower($objectname).'_note.php',
|
||||
'myobject_document.php'=>strtolower($objectname).'_document.php',
|
||||
'myobject_agenda.php'=>strtolower($objectname).'_agenda.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
|
||||
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
|
||||
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
|
||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||
'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php'
|
||||
);
|
||||
|
||||
foreach($filetogenerate as $srcfile => $destfile)
|
||||
@ -258,24 +259,24 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Scan for object class files
|
||||
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
|
||||
// Scan for object class files
|
||||
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
|
||||
|
||||
$firstobjectname='';
|
||||
foreach($listofobject as $fileobj)
|
||||
$firstobjectname='';
|
||||
foreach($listofobject as $fileobj)
|
||||
{
|
||||
if (preg_match('/^api_/',$fileobj['name'])) continue;
|
||||
if (preg_match('/^actions_/',$fileobj['name'])) continue;
|
||||
|
||||
$tmpcontent=file_get_contents($fileobj['fullname']);
|
||||
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg))
|
||||
{
|
||||
if (preg_match('/^api_/',$fileobj['name'])) continue;
|
||||
if (preg_match('/^actions_/',$fileobj['name'])) continue;
|
||||
$objectnameloop = $reg[1];
|
||||
if (empty($firstobjectname)) $firstobjectname = $objectnameloop;
|
||||
}
|
||||
|
||||
$tmpcontent=file_get_contents($fileobj['fullname']);
|
||||
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg))
|
||||
{
|
||||
$objectnameloop = $reg[1];
|
||||
if (empty($firstobjectname)) $firstobjectname = $objectnameloop;
|
||||
}
|
||||
|
||||
// Regenerate left menu entry in descriptor for $objectname
|
||||
$stringtoadd="
|
||||
// Regenerate left menu entry in descriptor for $objectname
|
||||
$stringtoadd="
|
||||
\t\t\$this->menu[\$r++]=array(
|
||||
'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
@ -303,22 +304,22 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
";
|
||||
$stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd);
|
||||
$stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd);
|
||||
$stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd);
|
||||
$stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd);
|
||||
$stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd);
|
||||
$stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd);
|
||||
|
||||
$moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php';
|
||||
$moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php';
|
||||
|
||||
// TODO Allow a replace with regex using dolReplaceRegexInFile
|
||||
// TODO Avoid duplicate addition
|
||||
// TODO Allow a replace with regex using dolReplaceRegexInFile
|
||||
// TODO Avoid duplicate addition
|
||||
|
||||
dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */"));
|
||||
dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */"));
|
||||
|
||||
// Add module descriptor to list of files to replace "MyObject' string with real name of object.
|
||||
$filetogenerate[]='core/modules/mod'.$module.'.class.php';
|
||||
// Add module descriptor to list of files to replace "MyObject' string with real name of object.
|
||||
$filetogenerate[]='core/modules/mod'.$module.'.class.php';
|
||||
|
||||
// TODO
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,16 +332,16 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
|
||||
//var_dump($phpfileval['fullname']);
|
||||
$arrayreplacement=array(
|
||||
'mymodule'=>strtolower($module),
|
||||
'MyModule'=>$module,
|
||||
'MYMODULE'=>strtoupper($module),
|
||||
'My module'=>$module,
|
||||
'my module'=>$module,
|
||||
'mon module'=>$module,
|
||||
'Mon module'=>$module,
|
||||
'htdocs/modulebuilder/template/'=>strtolower($modulename),
|
||||
'myobject'=>strtolower($objectname),
|
||||
'MyObject'=>$objectname
|
||||
'mymodule'=>strtolower($module),
|
||||
'MyModule'=>$module,
|
||||
'MYMODULE'=>strtoupper($module),
|
||||
'My module'=>$module,
|
||||
'my module'=>$module,
|
||||
'mon module'=>$module,
|
||||
'Mon module'=>$module,
|
||||
'htdocs/modulebuilder/template/'=>strtolower($modulename),
|
||||
'myobject'=>strtolower($objectname),
|
||||
'MyObject'=>$objectname
|
||||
);
|
||||
|
||||
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||
@ -425,11 +426,11 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
|
||||
dol_mkdir($destdir);
|
||||
|
||||
$addfieldentry = array(
|
||||
'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'),
|
||||
'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'),
|
||||
'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp','alpha'));
|
||||
'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'),
|
||||
'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'),
|
||||
'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp','alpha'));
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
{
|
||||
@ -554,20 +555,20 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname)
|
||||
|
||||
// Delete some files
|
||||
$filetogenerate = array(
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_note.php'=>strtolower($objectname).'_note.php',
|
||||
'myobject_document.php'=>strtolower($objectname).'_document.php',
|
||||
'myobject_agenda.php'=>strtolower($objectname).'_agenda.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
|
||||
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
|
||||
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
|
||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||
'class/api_myobject.class.php'=>'class/api_'.strtolower($module).'.class.php'
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_note.php'=>strtolower($objectname).'_note.php',
|
||||
'myobject_document.php'=>strtolower($objectname).'_document.php',
|
||||
'myobject_agenda.php'=>strtolower($objectname).'_agenda.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
|
||||
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
|
||||
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
|
||||
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
|
||||
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
|
||||
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
|
||||
'class/api_myobject.class.php'=>'class/api_'.strtolower($module).'.class.php'
|
||||
);
|
||||
|
||||
$resultko = 0;
|
||||
@ -664,106 +665,20 @@ if ($dirins && $action == 'generatepackage')
|
||||
|
||||
if ($dirins && $action == 'generatedoc')
|
||||
{
|
||||
$modulelowercase=strtolower($module);
|
||||
$FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF
|
||||
$dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
|
||||
$outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
|
||||
|
||||
// Dir for module
|
||||
$dir = $dirins.'/'.$modulelowercase;
|
||||
// Zip file to build
|
||||
$FILENAMEDOC='';
|
||||
$util = new Utils($db);
|
||||
$result = $util->generateDoc($module);
|
||||
|
||||
// Load module
|
||||
dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
|
||||
$class='mod'.$module;
|
||||
|
||||
if (class_exists($class))
|
||||
if ($result > 0)
|
||||
{
|
||||
try {
|
||||
$moduleobj = new $class($db);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($e->getMessage());
|
||||
}
|
||||
setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module));
|
||||
exit;
|
||||
}
|
||||
|
||||
$arrayversion=explode('.',$moduleobj->version,3);
|
||||
if (count($arrayversion))
|
||||
{
|
||||
$FILENAMEASCII=$modulelowercase.'.asciidoc';
|
||||
$FILENAMEDOC=$modulelowercase.'.html'; // TODO Use/text PDF
|
||||
|
||||
$dirofmodule = dol_buildpath($modulelowercase, 0).'/doc';
|
||||
$dirofmoduletmp = dol_buildpath($modulelowercase, 0).'/doc/temp';
|
||||
$outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
|
||||
if ($dirofmodule)
|
||||
{
|
||||
if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
|
||||
if (! dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp);
|
||||
|
||||
|
||||
$srcfile=$dirofmodule.'/Specifications.asciidoc';
|
||||
$destfile=$dirofmoduletmp.'/'.$FILENAMEASCII;
|
||||
dol_copy($srcfile, $destfile, 0, 1);
|
||||
|
||||
$fhandle = fopen($dirofmoduletmp.'/'.$FILENAMEASCII, 'a+');
|
||||
if ($fhandle)
|
||||
{
|
||||
fwrite($fhandle, "\n\n\n== DATA SPECIFICATIONS...\n\n");
|
||||
|
||||
// TODO
|
||||
fwrite($fhandle, "TODO...");
|
||||
|
||||
fclose($fhandle);
|
||||
}
|
||||
|
||||
$conf->global->MODULEBUILDER_ASCIIDOCTOR='asciidoctor';
|
||||
if (empty($conf->global->MODULEBUILDER_ASCIIDOCTOR))
|
||||
{
|
||||
dol_print_error('', 'Module setup not complete');
|
||||
exit;
|
||||
}
|
||||
|
||||
$command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmodule.'/'.$FILENAMEDOC;
|
||||
$outfile=$dirofmoduletmp.'/out.tmp';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||
$utils = new Utils($db);
|
||||
$resarray = $utils->executeCLI($command, $outfile);
|
||||
if ($resarray['result'] != '0')
|
||||
{
|
||||
setEventMessages($resarray['error'].' '.$resarray['output'], null, 'errors');
|
||||
}
|
||||
$result = ($resarray['result'] == 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfiledoc), null, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors');
|
||||
setEventMessages($util->error, $util->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -874,10 +789,10 @@ $dirins_ok=(dol_is_dir($dirins));
|
||||
|
||||
llxHeader('', $langs->trans("ModuleBuilder"), '', '', 0, 0,
|
||||
array(
|
||||
'/includes/ace/ace.js',
|
||||
'/includes/ace/ext-statusbar.js',
|
||||
'/includes/ace/ext-language_tools.js',
|
||||
//'/includes/ace/ext-chromevox.js'
|
||||
'/includes/ace/ace.js',
|
||||
'/includes/ace/ext-statusbar.js',
|
||||
'/includes/ace/ext-language_tools.js',
|
||||
//'/includes/ace/ext-chromevox.js'
|
||||
), array());
|
||||
|
||||
|
||||
@ -1686,18 +1601,18 @@ elseif (! empty($module))
|
||||
foreach($properties as $propkey => $propval)
|
||||
{
|
||||
/* If from Reflection
|
||||
if ($propval->class == $tabobj)
|
||||
{
|
||||
$propname=$propval->getName();
|
||||
$comment=$propval->getDocComment();
|
||||
$type=gettype($tmpobjet->$propname);
|
||||
$default=$propdefault[$propname];
|
||||
// Discard generic properties
|
||||
if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
||||
if ($propval->class == $tabobj)
|
||||
{
|
||||
$propname=$propval->getName();
|
||||
$comment=$propval->getDocComment();
|
||||
$type=gettype($tmpobjet->$propname);
|
||||
$default=$propdefault[$propname];
|
||||
// Discard generic properties
|
||||
if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
||||
|
||||
// Keep or not lines
|
||||
if (in_array($propname, array('fk_element', 'lines'))) continue;
|
||||
}*/
|
||||
// Keep or not lines
|
||||
if (in_array($propname, array('fk_element', 'lines'))) continue;
|
||||
}*/
|
||||
|
||||
$propname=$propkey;
|
||||
$proplabel=$propval['label'];
|
||||
@ -1734,8 +1649,8 @@ elseif (! empty($module))
|
||||
print $propnotnull;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $propdefault;
|
||||
print '</td>';
|
||||
print $propdefault;
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print $propindex?'1':'';
|
||||
print '</td>';
|
||||
@ -1775,7 +1690,7 @@ elseif (! empty($module))
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td><span class="warning">'.$langs->trans('Failed to init the object with the new.').'</warning></td></tr>';
|
||||
print '<tr><td><span class="warning">'.$langs->trans('Failed to init the object with the new.').'</warning></td></tr>';
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
@ -1848,76 +1763,76 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
|
||||
|
||||
/*
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
if (count($menus))
|
||||
{
|
||||
foreach ($cronjobs as $cron)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
if (count($menus))
|
||||
{
|
||||
foreach ($cronjobs as $cron)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td>';
|
||||
print $cron['label'];
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $cron['label'];
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($cron['jobtype']=='method')
|
||||
{
|
||||
$text=$langs->trans("CronClass");
|
||||
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
elseif ($cron['jobtype']=='command')
|
||||
{
|
||||
$text=$langs->trans('CronCommand');
|
||||
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
print $form->textwithpicto($text, $texttoshow, 1);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($cron['jobtype']=='method')
|
||||
{
|
||||
$text=$langs->trans("CronClass");
|
||||
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
elseif ($cron['jobtype']=='command')
|
||||
{
|
||||
$text=$langs->trans('CronCommand');
|
||||
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
print $form->textwithpicto($text, $texttoshow, 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
|
||||
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
|
||||
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
|
||||
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
|
||||
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
|
||||
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
|
||||
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $cron['status'];
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $cron['status'];
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if (!empty($cron['comment'])) {print $cron['comment'];}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (!empty($cron['comment'])) {print $cron['comment'];}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
*/
|
||||
print '</form>';
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1973,76 +1888,76 @@ elseif (! empty($module))
|
||||
|
||||
print 'TODO...';
|
||||
/*
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
if (count($cronjobs))
|
||||
{
|
||||
foreach ($cronjobs as $cron)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
if (count($cronjobs))
|
||||
{
|
||||
foreach ($cronjobs as $cron)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td>';
|
||||
print $cron['label'];
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $cron['label'];
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($cron['jobtype']=='method')
|
||||
{
|
||||
$text=$langs->trans("CronClass");
|
||||
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
elseif ($cron['jobtype']=='command')
|
||||
{
|
||||
$text=$langs->trans('CronCommand');
|
||||
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
print $form->textwithpicto($text, $texttoshow, 1);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($cron['jobtype']=='method')
|
||||
{
|
||||
$text=$langs->trans("CronClass");
|
||||
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
elseif ($cron['jobtype']=='command')
|
||||
{
|
||||
$text=$langs->trans('CronCommand');
|
||||
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||
}
|
||||
print $form->textwithpicto($text, $texttoshow, 1);
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
|
||||
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
|
||||
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
|
||||
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
|
||||
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
|
||||
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
|
||||
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $cron['status'];
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $cron['status'];
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if (!empty($cron['comment'])) {print $cron['comment'];}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (!empty($cron['comment'])) {print $cron['comment'];}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
*/
|
||||
print '</form>';
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2085,8 +2000,8 @@ elseif (! empty($module))
|
||||
|
||||
$pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php';
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("HooksFile").' : <strong>'.$pathtohook.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtohook).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# MYMODULE FOR <a href="https://www.dolibarr.org">DOLIBARR ERP CRM</a>
|
||||
|
||||
## Features
|
||||
MyModuleDescription
|
||||
Description...
|
||||
|
||||
Other modules are available on <a href="https://www.dolistore.com" target="_new">Dolistore.com</a>.
|
||||
|
||||
@ -9,10 +9,11 @@ Other modules are available on <a href="https://www.dolistore.com" target="_new"
|
||||
|
||||
### Translations
|
||||
|
||||
This module contains a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service.
|
||||
Translations can be define manually by editing files into directories [langs](langs).
|
||||
|
||||
<!--
|
||||
This module contains also a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service.
|
||||
|
||||
For more informations, see the [translator's documentation](https://wiki.dolibarr.org/index.php/Translator_documentation).
|
||||
|
||||
There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
|
||||
|
||||
@ -40,18 +40,49 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
}
|
||||
|
||||
if (! isset($argv[1]) || ! $argv[1]) {
|
||||
print "Usage: ".$script_file." inputfile1\n";
|
||||
print "Usage: ".$script_file." modulename\n";
|
||||
exit(-1);
|
||||
}
|
||||
$inputfile1=$argv[1];
|
||||
$modulename=$argv[1];
|
||||
|
||||
require_once ($path."../../htdocs/master.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||
|
||||
$langs->loadLangs(array("admin", "modulebuilder", "other", "cron"));
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
// Dir for custom dirs
|
||||
$tmp=explode(',', $dolibarr_main_document_root_alt);
|
||||
$dirins = $tmp[0];
|
||||
$dirread = $dirins;
|
||||
$forceddirread = 0;
|
||||
|
||||
$tmpdir = explode('@', $module);
|
||||
if (! empty($tmpdir[1]))
|
||||
{
|
||||
$module=$tmpdir[0];
|
||||
$dirread=$tmpdir[1];
|
||||
$forceddirread=1;
|
||||
}
|
||||
|
||||
$FILEFLAG='modulebuilder.txt';
|
||||
|
||||
$now=dol_now();
|
||||
$newmask = 0;
|
||||
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||
if (empty($newmask)) // This should no happen
|
||||
{
|
||||
$newmask='0664';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -60,8 +91,22 @@ $error=0;
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
||||
print $inputfile1."<br>";
|
||||
print "modulename=".$modulename."\n";
|
||||
print "dirins=".$dirins."\n";
|
||||
|
||||
$FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF
|
||||
$dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
|
||||
$outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
|
||||
|
||||
$util = new Utils($db);
|
||||
$result = $util->generateDoc($module);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
print $langs->trans("DocFileGeneratedInto", $outputfiledoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($util->errors, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
172
scripts/modulebuilder/initmodule.php
Executable file
172
scripts/modulebuilder/initmodule.php
Executable file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file scripts/modulebuilder/initmodule.php
|
||||
* \ingroup modulebuilder
|
||||
* \brief Script to initialize a module.
|
||||
*/
|
||||
|
||||
|
||||
$sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (! isset($argv[1]) || ! $argv[1]) {
|
||||
print "Usage: ".$script_file." modulename\n";
|
||||
exit(-1);
|
||||
}
|
||||
$modulename=$argv[1];
|
||||
|
||||
require_once ($path."../../htdocs/master.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
$langs->loadLangs(array("admin", "modulebuilder", "other", "cron"));
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
// Dir for custom dirs
|
||||
$tmp=explode(',', $dolibarr_main_document_root_alt);
|
||||
$dirins = $tmp[0];
|
||||
$dirread = $dirins;
|
||||
$forceddirread = 0;
|
||||
|
||||
$tmpdir = explode('@', $module);
|
||||
if (! empty($tmpdir[1]))
|
||||
{
|
||||
$module=$tmpdir[0];
|
||||
$dirread=$tmpdir[1];
|
||||
$forceddirread=1;
|
||||
}
|
||||
|
||||
$FILEFLAG='modulebuilder.txt';
|
||||
|
||||
$now=dol_now();
|
||||
$newmask = 0;
|
||||
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||
if (empty($newmask)) // This should no happen
|
||||
{
|
||||
$newmask='0664';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
||||
print "modulename=".$modulename."\n";
|
||||
print "dirins=".$dirins."\n";
|
||||
|
||||
if (preg_match('/[^a-z0-9_]/i', $modulename))
|
||||
{
|
||||
$error++;
|
||||
print 'Error '.$langs->trans("SpaceOrSpecialCharAreNotAllowed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
|
||||
$destdir = $dirins.'/'.strtolower($modulename);
|
||||
|
||||
$arrayreplacement=array(
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename
|
||||
);
|
||||
|
||||
$result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
|
||||
//dol_mkdir($destfile);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors');
|
||||
}
|
||||
else // $result == 0
|
||||
{
|
||||
setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete some files
|
||||
dol_delete_file($destdir.'/myobject_card.php');
|
||||
dol_delete_file($destdir.'/myobject_note.php');
|
||||
dol_delete_file($destdir.'/myobject_document.php');
|
||||
dol_delete_file($destdir.'/myobject_agenda.php');
|
||||
dol_delete_file($destdir.'/myobject_list.php');
|
||||
dol_delete_file($destdir.'/lib/myobject.lib.php');
|
||||
dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php');
|
||||
dol_delete_file($destdir.'/sql/llx_mymodule_myobject.sql');
|
||||
dol_delete_file($destdir.'/sql/llx_mymodule_myobject_extrafields.sql');
|
||||
dol_delete_file($destdir.'/sql/llx_mymodule_myobject.key.sql');
|
||||
dol_delete_file($destdir.'/scripts/myobject.php');
|
||||
dol_delete_file($destdir.'/img/object_myobject.png');
|
||||
dol_delete_file($destdir.'/class/myobject.class.php');
|
||||
dol_delete_file($destdir.'/class/api_mymodule.class.php');
|
||||
}
|
||||
|
||||
// Edit PHP files
|
||||
if (! $error)
|
||||
{
|
||||
$listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1);
|
||||
foreach($listofphpfilestoedit as $phpfileval)
|
||||
{
|
||||
//var_dump($phpfileval['fullname']);
|
||||
$arrayreplacement=array(
|
||||
'mymodule'=>strtolower($modulename),
|
||||
'MyModule'=>$modulename,
|
||||
'MYMODULE'=>strtoupper($modulename),
|
||||
'My module'=>$modulename,
|
||||
'my module'=>$modulename,
|
||||
'Mon module'=>$modulename,
|
||||
'mon module'=>$modulename,
|
||||
'htdocs/modulebuilder/template'=>strtolower($modulename),
|
||||
'---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
|
||||
);
|
||||
|
||||
|
||||
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||
//var_dump($result);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user