-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.php
77 lines (72 loc) · 2.59 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
* CMS module: Download Gallery 3
* Copyright and more information see file info.php
*/
function download_gallery_3_search($func_vars) {
extract($func_vars, EXTR_PREFIX_ALL, 'func');
$tablename = 'mod_download_gallery_3';
// how many lines of excerpt we want to have at most
$max_excerpt_num = $func_default_max_excerpt;
$divider = ".";
$result = false;
// fetch all active download-gallery-items (from active groups) from this section
$table_files = "`".TABLE_PREFIX.$tablename."_files`";
$table_groups = "`".TABLE_PREFIX.$tablename."_groups`";
$query = $func_database->query("
SELECT `f`.`title`, `f`.`filename`, `f`.`description`, `f`.`modified_when`, `f`.`modified_by`
FROM $table_files AS f LEFT OUTER JOIN $table_groups AS g ON `f`.`group_id` = `g`.`group_id`
WHERE `f`.`section_id`='$func_section_id' AND `f`.`active` = '1' AND ( `g`.`active` IS NULL OR `g`.`active` = '1' )
ORDER BY `f`.`title` ASC
");
// here, we call print_excerpt() only once for _all_ items
// $res['modified_when'] and ..by'] doesn't make sense in this case.
if($query->numRows() > 0) {
$text = "";
while($res = $query->fetchRow()) {
$text .= $res['title'].$divider.$res['filename'].$divider.$res['description'].$divider;
}
$mod_vars = array(
'page_link' => $func_page_link,
'page_link_target' => "#wb_section_$func_section_id",
'page_title' => $func_page_title,
'page_description' => $func_page_description,
'page_modified_when' => 0,
'page_modified_by' => "",
'text' => $text,
'max_excerpt_num' => $max_excerpt_num
);
if(print_excerpt2($mod_vars, $func_vars)) {
$result = true;
}
}
// now fetch group-titles - ignore those without (active) items
$table_groups = "`".TABLE_PREFIX.$tablename."_groups`";
$table_files = "`".TABLE_PREFIX.$tablename."_files`";
$query = $func_database->query("
SELECT `g`.`title`
FROM $table_groups AS g INNER JOIN $table_files AS f ON `g`.`group_id` = `f`.`group_id`
WHERE `g`.`section_id`='$func_section_id' AND `g`.`active` = '1' AND `f`.`active` = '1'
");
// now call print_excerpt() for all groups, too
if($query->numRows() > 0) {
$text = "";
while($res = $query->fetchRow()) {
$text .= $res['title'].$divider;
}
$mod_vars = array(
'page_link' => $func_page_link,
'page_link_target' => "#wb_section_$func_section_id",
'page_title' => $func_page_title,
'page_description' => $func_page_description,
'page_modified_when' => 0,
'page_modified_by' => "",
'text' => $text,
'max_excerpt_num' => $max_excerpt_num
);
if(print_excerpt2($mod_vars, $func_vars)) {
$result = true;
}
}
return $result;
}