Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/search.views.inc | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
function search_views_data() { |
14 | 14 |
// Basic table information. |
15 |
|
|
16 |
// Define the base group of this table. Fields that don't |
|
17 |
// have a group defined will go into this field by default. |
|
15 |
// Define the base group of this table. Fields that don't have a group |
|
16 |
// defined will go into this field by default. |
|
18 | 17 |
$data['search_index']['table']['group'] = t('Search'); |
19 | 18 |
|
20 |
// For other base tables, explain how we join |
|
19 |
// For other base tables, explain how we join.
|
|
21 | 20 |
$data['search_index']['table']['join'] = array( |
22 | 21 |
'node' => array( |
23 | 22 |
'left_field' => 'nid', |
... | ... | |
35 | 34 |
'left_table' => 'search_index', |
36 | 35 |
'left_field' => 'word', |
37 | 36 |
'field' => 'word', |
38 |
) |
|
37 |
),
|
|
39 | 38 |
); |
40 | 39 |
|
41 | 40 |
$data['search_dataset']['table']['join'] = array( |
... | ... | |
56 | 55 |
); |
57 | 56 |
|
58 | 57 |
// ---------------------------------------------------------------- |
59 |
// Fields |
|
60 |
|
|
61 |
// score |
|
58 |
// Fields. |
|
59 |
// Score. |
|
62 | 60 |
$data['search_index']['score'] = array( |
63 | 61 |
'title' => t('Score'), |
64 | 62 |
'help' => t('The score of the search item. This will not be used if the search filter is not also present.'), |
... | ... | |
111 | 109 |
), |
112 | 110 |
); |
113 | 111 |
|
114 |
// search filter
|
|
112 |
// Search filter.
|
|
115 | 113 |
$data['search_index']['keys'] = array( |
116 |
'title' => t('Search Terms'), // The item it appears as on the UI, |
|
117 |
'help' => t('The terms to search for.'), // The help that appears on the UI, |
|
118 |
// Information for searching terms using the full search syntax |
|
114 |
// The item it appears as on the UI, |
|
115 |
'title' => t('Search Terms'), |
|
116 |
// The help that appears on the UI, |
|
117 |
'help' => t('The terms to search for.'), |
|
118 |
// Information for searching terms using the full search syntax. |
|
119 | 119 |
'filter' => array( |
120 | 120 |
'handler' => 'views_handler_filter_search', |
121 | 121 |
'no group by' => TRUE, |
... | ... | |
135 | 135 |
function search_views_plugins() { |
136 | 136 |
return; |
137 | 137 |
// DISABLED. This currently doesn't work. |
138 |
// @todo Fix this. |
|
138 | 139 |
return array( |
139 |
'module' => 'views', // This just tells our themes are elsewhere. |
|
140 |
'module' => 'views', |
|
141 |
// This just tells our themes are elsewhere. |
|
140 | 142 |
'row' => array( |
141 | 143 |
'search' => array( |
142 | 144 |
'title' => t('Search'), |
143 | 145 |
'help' => t('Display the results with standard search view.'), |
144 | 146 |
'handler' => 'views_plugin_row_search_view', |
145 | 147 |
'theme' => 'views_view_row_search', |
146 |
'path' => drupal_get_path('module', 'views') . '/modules/search', // not necessary for most modules |
|
147 |
'base' => array('node'), // only works with 'node' as base. |
|
148 |
'path' => drupal_get_path('module', 'views') . '/modules/search', |
|
149 |
// Not necessary for most modules. |
|
150 |
'base' => array('node'), |
|
151 |
// Only works with 'node' as base. |
|
148 | 152 |
'type' => 'normal', |
149 | 153 |
), |
150 | 154 |
'views_handler_argument_search' => array( |
... | ... | |
155 | 159 |
} |
156 | 160 |
|
157 | 161 |
/** |
158 |
* Template helper for theme_views_view_row_search |
|
162 |
* Template helper for theme_views_view_row_search.
|
|
159 | 163 |
*/ |
160 | 164 |
function template_preprocess_views_view_row_search(&$vars) { |
161 |
$vars['node'] = ''; // make sure var is defined. |
|
165 |
$vars['node'] = ''; |
|
166 |
// Make sure var is defined. |
|
162 | 167 |
$nid = $vars['row']->nid; |
163 | 168 |
if (!is_numeric($nid)) { |
164 | 169 |
return; |
165 | 170 |
} |
166 | 171 |
|
167 |
// @todo: Once the search row is fixed this node_load should be replace by a node_load_multiple |
|
172 |
// @todo Once the search row is fixed this node_load should be replace by a |
|
173 |
// node_load_multiple(). |
|
168 | 174 |
$node = node_load($nid); |
169 | 175 |
|
170 | 176 |
if (empty($node)) { |
... | ... | |
175 | 181 |
$node = node_build_content($node, FALSE, FALSE); |
176 | 182 |
$node->body = drupal_render($node->content); |
177 | 183 |
|
178 |
// Fetch comments for snippet |
|
184 |
// Fetch comments for snippet.
|
|
179 | 185 |
$node->body .= module_invoke('comment', 'nodeapi', $node, 'update index'); |
180 | 186 |
|
181 |
// Fetch terms for snippet |
|
187 |
// Fetch terms for snippet.
|
|
182 | 188 |
$node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); |
183 | 189 |
|
184 | 190 |
$vars['url'] = url('node/' . $nid); |
... | ... | |
196 | 202 |
$vars['info'] = implode(' - ', $info); |
197 | 203 |
|
198 | 204 |
$vars['node'] = $node; |
199 |
// @todo: get score from ???
|
|
200 |
//$vars['score'] = $item->score;
|
|
205 |
// @todo Where does the score come from?
|
|
206 |
// $vars['score'] = $item->score;
|
|
201 | 207 |
$vars['snippet'] = search_excerpt($vars['view']->value, $node->body); |
202 | 208 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules