mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Fix filter to find files of a ref.
This commit is contained in:
@@ -981,14 +981,15 @@ class FormFile
|
||||
* You may want to call this into a div like this:
|
||||
* print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
|
||||
*
|
||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||
* @param string $modulepart 'propal', 'facture', 'facture_fourn', ...
|
||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
* @param string $filedir Full path to directory to scan
|
||||
* @param string $filter Filter filenames on this regex string (Example: '\.pdf$')
|
||||
* @param string $morecss Add more css to the download picto
|
||||
* @param string $allfiles 0=Only generated docs, 1=All files
|
||||
* @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
|
||||
*/
|
||||
public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '', $morecss = 'valignmiddle')
|
||||
public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '', $morecss = 'valignmiddle', $allfiles = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@@ -1006,12 +1007,11 @@ class FormFile
|
||||
$entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default
|
||||
}
|
||||
|
||||
// Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files)
|
||||
// @todo Why not showing by default all files by just removing the '[^\-]+' at end of regex ?
|
||||
if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) {
|
||||
$filterforfilesearch = preg_quote(basename($modulesubdir), '/');
|
||||
// Get list of files starting with name of ref (Note: files with '^ref\.extension' are generated files, files with '^ref-...' are uploaded files)
|
||||
if ($allfiles || !empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) {
|
||||
$filterforfilesearch = '^'.preg_quote(basename($modulesubdir), '/');
|
||||
} else {
|
||||
$filterforfilesearch = preg_quote(basename($modulesubdir), '/').'[^\-]+';
|
||||
$filterforfilesearch = '^'.preg_quote(basename($modulesubdir), '/').'\.';
|
||||
}
|
||||
$file_list = dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview
|
||||
|
||||
|
||||
Reference in New Issue
Block a user