Permalink
Browse files

Query Media with the public function allFolders() has been removed in…

… wt2.0. We need to make our own function.

See: app\Http\Controllers\ListController.php
  • Loading branch information...
JustCarmen committed Jun 3, 2018
1 parent a86b6a5 commit 1eb1ec249f70726f1baae75eea1ef6f6e77ddf3b
Showing with 29 additions and 1 deletion.
  1. +29 −1 app/FancyImagebarClass.php
@@ -135,6 +135,34 @@ protected function getPhotos() {
}
}
/**
* Generate a list of all the folders in a current tree.
*
* @param Tree $tree
*
* @return string[]
*/
private function allFolders(Tree $tree) {
$folders = Database::prepare(
"SELECT SQL_CACHE LEFT(multimedia_file_refn, CHAR_LENGTH(multimedia_file_refn) - CHAR_LENGTH(SUBSTRING_INDEX(multimedia_file_refn, '/', -1))) AS media_path" .
" FROM `##media_file`" .
" WHERE m_file = ?" .
" AND multimedia_file_refn NOT LIKE 'http://%'" .
" AND multimedia_file_refn NOT LIKE 'https://%'" .
" GROUP BY 1" .
" ORDER BY 1"
)->execute([
$tree->getTreeId(),
])->fetchOneColumn();
// Ensure we have an empty (top level) folder.
if (!$folders || reset($folders) !== '') {
array_unshift($folders, '');
}
return array_combine($folders, $folders);
}
/**
* Get a list of all the media folders
*
@@ -145,7 +173,7 @@ protected function listMediaFolders() {
global $WT_TREE;
$MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY');
$folders = QueryMedia::folderListAll();
$folders = $this->allFolders($WT_TREE);
array_shift($folders);
$folderlist = [];

0 comments on commit 1eb1ec2

Please sign in to comment.