1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Dummy module implementing a search type for search module testing.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_search_info().
|
10
|
*/
|
11
|
function search_extra_type_search_info() {
|
12
|
return array(
|
13
|
'title' => 'Dummy search type',
|
14
|
'path' => 'dummy_path',
|
15
|
'conditions_callback' => 'search_extra_type_conditions',
|
16
|
);
|
17
|
}
|
18
|
|
19
|
/**
|
20
|
* Test conditions callback for hook_search_info().
|
21
|
*/
|
22
|
function search_extra_type_conditions() {
|
23
|
$conditions = array();
|
24
|
|
25
|
if (!empty($_REQUEST['search_conditions'])) {
|
26
|
$conditions['search_conditions'] = $_REQUEST['search_conditions'];
|
27
|
}
|
28
|
return $conditions;
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Implements hook_search_execute().
|
33
|
*
|
34
|
* This is a dummy search, so when search "executes", we just return a dummy
|
35
|
* result containing the keywords and a list of conditions.
|
36
|
*/
|
37
|
function search_extra_type_search_execute($keys = NULL, $conditions = NULL) {
|
38
|
if (!$keys) {
|
39
|
$keys = '';
|
40
|
}
|
41
|
return array(
|
42
|
array(
|
43
|
'link' => url('node'),
|
44
|
'type' => 'Dummy result type',
|
45
|
'title' => 'Dummy title',
|
46
|
'snippet' => "Dummy search snippet to display. Keywords: {$keys}\n\nConditions: " . print_r($conditions, TRUE),
|
47
|
),
|
48
|
);
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Implements hook_search_page().
|
53
|
*
|
54
|
* Adds some text to the search page so we can verify that it runs.
|
55
|
*/
|
56
|
function search_extra_type_search_page($results) {
|
57
|
$output['prefix']['#markup'] = '<h2>Test page text is here</h2> <ol class="search-results">';
|
58
|
|
59
|
foreach ($results as $entry) {
|
60
|
$output[] = array(
|
61
|
'#theme' => 'search_result',
|
62
|
'#result' => $entry,
|
63
|
'#module' => 'search_extra_type',
|
64
|
);
|
65
|
}
|
66
|
$output['suffix']['#markup'] = '</ol>' . theme('pager');
|
67
|
|
68
|
return $output;
|
69
|
}
|