Merge pull request #24287 from lamrani002/deleteFromDocMB
NEW functionality delete table of property from documentation
This commit is contained in:
commit
458431facb
@ -613,6 +613,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
|||||||
}
|
}
|
||||||
// end table
|
// end table
|
||||||
$table .= "|===";
|
$table .= "|===";
|
||||||
|
$table .= "__ end table for object $objectname";
|
||||||
//write in file
|
//write in file
|
||||||
$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS'=> $table));
|
$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS'=> $table));
|
||||||
if ($writeInFile<0) {
|
if ($writeInFile<0) {
|
||||||
@ -621,6 +622,23 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete property from documentation if we delete object
|
||||||
|
* @param string $file file or path
|
||||||
|
* @param string $objectname name of object wants to deleted
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function deletePropsFromDoc($file, $objectname)
|
||||||
|
{
|
||||||
|
|
||||||
|
$start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : ";
|
||||||
|
$end = "__ end table for object ".ucfirst($objectname);
|
||||||
|
$str = file_get_contents($file);
|
||||||
|
$search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s';
|
||||||
|
$new_contents = preg_replace($search, '', $str);
|
||||||
|
file_put_contents($file, $new_contents);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search a string and return all lines needed from file
|
* Search a string and return all lines needed from file
|
||||||
* @param string $file file for searching
|
* @param string $file file for searching
|
||||||
|
|||||||
@ -1542,6 +1542,13 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
|||||||
setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors');
|
setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
// check if documentation was generate and add table of properties object
|
||||||
|
$file = $destdir.'/class/'.strtolower($objectname).'.class.php';
|
||||||
|
$destfile = $destdir.'/doc/Documentation.asciidoc';
|
||||||
|
|
||||||
|
if (file_exists($destfile)) {
|
||||||
|
writePropsInAsciiDoc($file, $objectname, $destfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Edit sql with new properties
|
// Edit sql with new properties
|
||||||
@ -1870,6 +1877,12 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) {
|
|||||||
'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>'core/modules/'.strtolower($module).'/doc/pdf_standard_'.strtolower($objectname).'.modules.php'
|
'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>'core/modules/'.strtolower($module).'/doc/pdf_standard_'.strtolower($objectname).'.modules.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// delete property if documentation was generated
|
||||||
|
$file_doc = $dirins.'/'.strtolower($module).'/doc/Documentation.asciidoc';
|
||||||
|
if (file_exists($file_doc)) {
|
||||||
|
deletePropsFromDoc($file_doc, $objectname);
|
||||||
|
}
|
||||||
|
|
||||||
//menu for the object selected
|
//menu for the object selected
|
||||||
// load class and check if menu exist for this object
|
// load class and check if menu exist for this object
|
||||||
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
|
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user