Add folders containing matching files to the contents list when searching
This commit is contained in:
parent
8e8df39ec5
commit
2e85705a20
|
@ -30,6 +30,7 @@ if ( $row = $sth->fetch() ) {
|
|||
}
|
||||
|
||||
$data['contents'] = array();
|
||||
$foldermatch = array();
|
||||
|
||||
if ( !$searching ) {
|
||||
$contents = glob(BOOKDIR . $_SESSION['bookdir'] . "/*");
|
||||
|
@ -72,6 +73,7 @@ if ( !$searching ) {
|
|||
$item['folder'] = true;
|
||||
$item['fullpath'] = $row['path'];
|
||||
$item['displayname'] = htmlspecialchars(basename($row['path']));
|
||||
if ( !in_array($row['path'], $foldermatch) ) $foldermatch[] = $row['path'];
|
||||
$data['contents'][] = $item;
|
||||
}
|
||||
$query = "SELECT id, path, filename FROM books WHERE LOWER(filename) LIKE :searchfor ORDER BY path, filename";
|
||||
|
@ -80,6 +82,14 @@ if ( !$searching ) {
|
|||
$sth->execute();
|
||||
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
|
||||
if ( $row['path'] == "/" ) continue;
|
||||
if ( !in_array($row['path'], $foldermatch) ) {
|
||||
$foldermatch[] = $row['path'];
|
||||
$item = array();
|
||||
$item['folder'] = true;
|
||||
$item['fullpath'] = $row['path'];
|
||||
$item['displayname'] = htmlspecialchars(basename($row['path']));
|
||||
$data['contents'][] = $item;
|
||||
}
|
||||
$item = array();
|
||||
$item['folder'] = false;
|
||||
$item['fullpath'] = $row['path'] . "/" . $row['filename'];
|
||||
|
|
Loading…
Reference in New Issue
Block a user