delete table of property from documentation

This commit is contained in:
Lamrani Abdel 2023-03-20 19:43:23 +01:00
parent 88785f2a2c
commit 742890157a
2 changed files with 51 additions and 0 deletions

View File

@ -620,3 +620,48 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
}
return 1;
}
/**
* Search a string and return all lines needed from file
* @param string $file file for searching
* @param string $start start line if exist
* @param string $end end line if exist
* @return string return the content needed
*/
function getFromFile($file, $start, $end)
{
$i = 1;
$keys = array();
$lines = file($file);
// Search for start and end lines
foreach ($lines as $i => $line) {
if (strpos($line, $start) !== false) {
// Copy lines until the end on array
while (($line = $lines[++$i]) !== false) {
if (strpos($line, $end) !== false) {
break;
}
$keys[] = $line;
}
break;
}
}
$content = implode("", $keys);
return $content;
}
/**
* 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);
$string = getFromFile($file, $start, $end);
dolReplaceInFile($file, array($string => ''));
dolReplaceInFile($file, array($start => '', $end => ''));
}

View File

@ -1914,6 +1914,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'
);
// 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
// load class and check if menu exist for this object
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];