there are some functions available by the core.
if
/framework/functions.php is loaded, you can choose.

<?php
function file_list($directory, $skip = array(), $show_hidden = false)
function scan_current_dir($root = '', $search = '/.*/')
function directory_list($directory, $show_hidden = false)
?>
each of this functions has a short description before.
for your requirements:
<?php
$aFoundFiles = scan_current_dir(WB_PATH.'/media/test');
$sContent = '<ul>\n\t<li>'.implode( "</li>\n\t<li>", $aFoundFiles['path'])."</li>\n</ul>\n";
$sText = implode(' ', $aFoundFiles['path']);
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_wysiwyg` ';
$sql .= 'SET `content`=\''.mysql_real_escape_string($sContent).'\', ';
$sql .= '`text`=\''.mysql_real_escape_string($sText).'\' ';
$sql .= 'WHERE `section_id`=36';
$database->query($sql);
?>
so you have a HTML-formated list in `content` and plain text for search in `text`