forked from Wavyzz/dolibarr
update function for delete properties from Doc
This commit is contained in:
@@ -621,35 +621,6 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
|||||||
return 1;
|
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
|
* Delete property from documentation if we delete object
|
||||||
* @param string $file file or path
|
* @param string $file file or path
|
||||||
@@ -661,7 +632,8 @@ function deletePropsFromDoc($file, $objectname)
|
|||||||
|
|
||||||
$start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : ";
|
$start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : ";
|
||||||
$end = "== end table for object ".ucfirst($objectname);
|
$end = "== end table for object ".ucfirst($objectname);
|
||||||
$string = getFromFile($file, $start, $end);
|
$str = file_get_contents($file);
|
||||||
dolReplaceInFile($file, array($string => ''));
|
$search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s';
|
||||||
dolReplaceInFile($file, array($start => '', $end => ''));
|
$new_contents = preg_replace($search, '', $str);
|
||||||
|
file_put_contents($file, $new_contents);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user