diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index 51ebb2e9e32..cce4a063ca6 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -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']."
\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.='
'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
+ $this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
+ if ($count > $countdeleted) $this->output.='
'.$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;
+ }
}
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index eff7077db81..a915728903c 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -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 '';
print '
| '; - print $cron['label']; - print ' | '; + print ''; + print $cron['label']; + print ' | '; - print '';
- if ($cron['jobtype']=='method')
- {
- $text=$langs->trans("CronClass");
- $texttoshow=$langs->trans('CronModule').': '.$module.' '; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].' '; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].' '; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print ' | ';
+ print '';
+ if ($cron['jobtype']=='method')
+ {
+ $text=$langs->trans("CronClass");
+ $texttoshow=$langs->trans('CronModule').': '.$module.' '; + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].' '; + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].' '; + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; + $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + elseif ($cron['jobtype']=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + print $form->textwithpicto($text, $texttoshow, 1); + print ' | ';
- print ''; - 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 ' | '; + print ''; + 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 ' | '; - print ''; - print $cron['status']; - print ' | '; + print ''; + print $cron['status']; + print ' | '; - print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ' | '; + print ''; + if (!empty($cron['comment'])) {print $cron['comment'];} + print ' | '; - print '
| '.$langs->trans("None").' | |||||||||
| '.$langs->trans("None").' | |||||||||
| '; - print $cron['label']; - print ' | '; + print ''; + print $cron['label']; + print ' | '; - print '';
- if ($cron['jobtype']=='method')
- {
- $text=$langs->trans("CronClass");
- $texttoshow=$langs->trans('CronModule').': '.$module.' '; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].' '; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].' '; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print ' | ';
+ print '';
+ if ($cron['jobtype']=='method')
+ {
+ $text=$langs->trans("CronClass");
+ $texttoshow=$langs->trans('CronModule').': '.$module.' '; + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].' '; + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].' '; + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; + $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + elseif ($cron['jobtype']=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow.=' '.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.=' '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + print $form->textwithpicto($text, $texttoshow, 1); + print ' | ';
- print ''; - 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 ' | '; + print ''; + 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 ' | '; - print ''; - print $cron['status']; - print ' | '; + print ''; + print $cron['status']; + print ' | '; - print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ' | '; + print ''; + if (!empty($cron['comment'])) {print $cron['comment'];} + print ' | '; - print '
| '.$langs->trans("None").' | |||||||||
| '.$langs->trans("None").' | |||||||||