extract data-preparation from Etemplate\Widget\Vfs::beforeSendToClient() to use it to send the data to client-side in an AJAX call

This commit is contained in:
Ralf Becker 2022-02-03 15:33:10 +02:00
parent 1c053ade4c
commit 10d61dd4c7

View File

@ -71,8 +71,21 @@ class Vfs extends File
$path = Api\Link::vfs_path($app, $id, '', true); $path = Api\Link::vfs_path($app, $id, '', true);
if (!empty($relpath)) $path .= '/' . $relpath; if (!empty($relpath)) $path .= '/' . $relpath;
if (true) $value = array(); $value = self::findAttachments($path);
}
}
}
/**
* Find all attachments, can be used to prepare the data for the widget on client-side
*
* @param string $path eg. "/apps/$app/$id/$rel_path"
* @return array
* @throws Api\Exception\AssertionFailed
*/
public static function findAttachments($path)
{
$value = [];
// Single file, already existing // Single file, already existing
if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
{ {
@ -114,8 +127,7 @@ class Vfs extends File
$value[] = $file_info; $value[] = $file_info;
} }
} }
} return $value;
}
} }
public static function ajax_upload() public static function ajax_upload()