function _filebrowser_load_description_file in Filebrowser 6.2
Same name and namespace in other branches
- 8 filebrowser.common.inc \_filebrowser_load_description_file()
- 7.4 filebrowser.common.inc \_filebrowser_load_description_file()
- 7.2 filebrowser.common.inc \_filebrowser_load_description_file()
- 7.3 filebrowser.common.inc \_filebrowser_load_description_file()
2 calls to _filebrowser_load_description_file()
File
- includes/
metadata.inc, line 51
Code
function _filebrowser_load_description_file($path, $replace = NULL) {
static $descriptions = array();
if ($replace) {
$descriptions[$path] = $replace;
}
if (!isset($descriptions[$path])) {
$descriptions[$path] = array(
'data' => array(),
);
$description_file = $path . '/descript.ion';
if (!file_exists($description_file)) {
$description_file = $path . '/file.bbs';
}
if (file_exists($description_file)) {
$descriptions[$path]['file'] = $description_file;
foreach (file($description_file) as $line) {
if (trim($line) == '' || strpos(trim($line), '#') === 0) {
continue;
}
$matches = array();
preg_match('/"([^"]+)"\\s+(.*)|(\\S+)\\s+(.*)/', $line, $matches);
//print_r($matches);echo '<br>';
$name = !empty($matches[1]) ? $matches[1] : $matches[3];
// issue 2353211 temp solution
//$description = !empty($matches[2]) ? $matches[2] : isset($matches[4]) ? $matches[4]: '';
$description = !empty($matches[2]) ? $matches[2] : '';
$description = str_replace('\\n', "\n", $description);
if (isset($descriptions[$path][$name])) {
$descriptions[$path]['data'][$name] .= ' ' . trim($description);
}
else {
$descriptions[$path]['data'][$name] = trim($description);
}
}
}
}
return $descriptions[$path];
}