protected function DisplayFileList::processServerFileList in Filebrowser 3.x
Same name and namespace in other branches
- 8.2 src/File/DisplayFileList.php \Drupal\filebrowser\File\DisplayFileList::processServerFileList()
1 call to DisplayFileList::processServerFileList()
- DisplayFileList::createFileDisplayList in src/File/DisplayFileList.php
- Creates the data required to build the Filebrowser listing in following steps
File
- src/File/DisplayFileList.php, line 190
Class
- DisplayFileList
- Class FileDisplayList
@package Drupal\filebrowser
This class holds the list of files to be displayed on the filebrowser node.
These files are retrieved from the filesystem and filtered for user and node access.
The array produced by this class…
Namespace
Drupal\filebrowser\File
Code
protected function processServerFileList() {
$stats = [
'folders_count' => 0,
'files_count' => 0,
'total_size' => 0,
];
$encoding = $this->node->filebrowser->encoding;
$db_content = $this->storage
->loadRecordsFromRoot($this->node
->id(), $this->relativePath);
if (!is_null($this->serverFileList)) {
foreach ($this->serverFileList as $key => $fs_file) {
$file_relative_path = $this
->buildFileRelativePath($fs_file->filename, $encoding);
if (!isset($db_content[$file_relative_path])) {
$db_content[$file_relative_path] = [
'exists' => true,
'nid' => $this->node
->id(),
'root' => $this->relativePath,
'path' => $file_relative_path,
'description' => $this
->t('No description.'),
'file_data' => $fs_file,
];
}
$db_content[$file_relative_path]['exists'] = true;
$db_content[$file_relative_path]['display_name'] = $fs_file->filename;
$result_file = new DisplayFile($this->node
->id());
$result_file
->fileSetData($file_relative_path, $fs_file, $stats, $db_content[$file_relative_path], $this->fsRoot);
$result_list[$fs_file->filename] = $result_file;
}
}
if ($this->isSubDir) {
$subDir = new DisplayFile($this->node
->id());
$result_list['..'] = $subDir
->createSubdir($this->relativePath);
$file = new DisplayFile($this->node
->id());
$result_list['.'] = $file
->createUpDir($this->relativePath);
$this
->createUpDirContent($db_content['/']);
if (!isset($db_content[$this->relativePath])) {
$db_content[$this->relativePath] = [
'exists' => TRUE,
'nid' => $this->node
->id(),
'root' => $this->relativePath,
'path' => $this->relativePath,
];
}
$db_content[$this->relativePath]['exists'] = true;
$db_content[$this->relativePath]['display_name'] = '.';
}
else {
if (!isset($db_content['/'])) {
$db_content['/'] = [
'nid' => $this->node
->id(),
'root' => '/',
'path' => '/',
];
}
$db_content['/']['exists'] = true;
$db_content['/']['display_name'] = '.';
$result_file = new DisplayFile($this->node
->id());
$result_list['.'] = $result_file
->createUpDir($this->relativePath);
}
$this->data['stats'] = $this
->buildStatistics($result_list);
$this->data['relative_path'] = $this->relativePath;
$this
->dbSync($db_content, $result_list, $this->data);
return $result_list;
}