27 function gal_searcher($q, $offset) |
27 function gal_searcher($q, $offset) |
28 { |
28 { |
29 global $db, $session, $paths, $template, $plugins; // Common objects |
29 global $db, $session, $paths, $template, $plugins; // Common objects |
30 |
30 |
31 $fulltext_col = 'MATCH(img_title, img_desc) AGAINST (\'' . $db->escape($q) . '\' IN BOOLEAN MODE)'; |
31 $fulltext_col = 'MATCH(img_title, img_desc) AGAINST (\'' . $db->escape($q) . '\' IN BOOLEAN MODE)'; |
32 $sql = "SELECT img_id, img_title, img_desc, $fulltext_col AS score, CHAR_LENGTH(img_desc) AS length FROM ".table_prefix."gallery |
32 $sql = "SELECT img_id, img_title, img_desc, is_folder, $fulltext_col AS score, CHAR_LENGTH(img_desc) AS length FROM ".table_prefix."gallery |
33 WHERE $fulltext_col > 0 |
33 WHERE $fulltext_col > 0 |
34 AND is_folder=0 |
34 AND ( ( is_folder=1 AND folder_parent IS NULL ) OR is_folder!=1 ) |
35 ORDER BY score DESC;"; |
35 ORDER BY is_folder DESC, score DESC, img_title ASC;"; |
36 if ( !$db->sql_unbuffered_query($sql) ) |
36 if ( !$db->sql_unbuffered_query($sql) ) |
37 { |
37 { |
38 echo $db->get_error(); |
38 echo $db->get_error(); |
39 return false; |
39 return false; |
40 } |
40 } |
41 echo "<h3>Image results</h3>"; |
41 echo "<h3>Image results</h3>"; |
42 if ( $row = $db->fetchrow() ) |
42 if ( $row = $db->fetchrow() ) |
43 { |
43 { |
44 echo '<table border="0" cellspacing="8"><tr>'; |
44 echo '<table border="0" cellspacing="8"><tr>'; |
45 $renderer = new SnaprFormatter(); |
45 $renderer = new SnaprFormatter(); |
|
46 $fullpage = $paths->fullpage; |
|
47 $paths->fullpage = $paths->nslist['Special'] . 'Gallery'; |
46 do |
48 do |
47 { |
49 { |
48 echo $renderer->render(false, $row, false); |
50 echo $renderer->render(false, $row, false); |
49 } |
51 } |
50 while ( $row = $db->fetchrow() ); |
52 while ( $row = $db->fetchrow() ); |
|
53 $paths->fullpage = $fullpage; |
51 echo '</tr></table>'; |
54 echo '</tr></table>'; |
52 } |
55 } |
53 else |
56 else |
54 { |
57 { |
55 echo '<p>No image results.</p>'; |
58 echo '<p>No image results.</p>'; |