From a2a20c1815bfb8918cc38eac119b95ac4b6c0214 Mon Sep 17 00:00:00 2001 From: fisharebest Date: Wed, 30 Jan 2013 12:56:30 +0000 Subject: #1104494 - svn 14680 - Folder Media List shows all tree media --- library/WT/Query/Media.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'library/WT/Query/Media.php') diff --git a/library/WT/Query/Media.php b/library/WT/Query/Media.php index 6c94de7c10..5bcccde588 100644 --- a/library/WT/Query/Media.php +++ b/library/WT/Query/Media.php @@ -65,24 +65,18 @@ class WT_Query_Media { // Generate a filtered, sourced, privacy-checked list of media objects - for the media list. public static function mediaList($folder, $subfolders, $sort, $filter) { + // All files in the folder, plus external files $sql = "SELECT 'OBJE' AS type, m_id AS xref, m_file AS ged_id, m_gedcom AS gedrec, m_titl, m_filename" . " FROM `##media`" . " WHERE m_file=?" . - " AND (m_filename LIKE CONCAT(?, '%', ?, '%')" . - " OR m_filename LIKE CONCAT('http://%', ?, '%')" . - " OR m_filename LIKE CONCAT('https://%', ?, '%')" . - " OR m_titl LIKE CONCAT('%', ?, '%')" . - " )"; + " AND (m_filename LIKE CONCAT(?, '%') OR m_filename LIKE 'http://%' OR m_filename LIKE 'https://%')"; $args = array( WT_GED_ID, $folder, - $filter, - $filter, - $filter, - $filter, ); + // Exclude subfolders switch ($subfolders) { case 'include': // subfolders are included by default @@ -95,6 +89,13 @@ class WT_Query_Media { throw new Exception('Bad argument (subfolders=', $subfolders, ') in WT_Query_Media::mediaList()'); } + // Apply search terms + if ($filter) { + $sql .= " AND (m_filename LIKE CONCAT('%', ?, '%') OR m_titl LIKE CONCAT('%', ?, '%'))"; + $args[] = $filter; + $args[] = $filter; + } + switch ($sort) { case 'file': $sql .= " ORDER BY m_filename"; -- cgit v1.3