configure your embedded Gallery.',
array('@link' => url('admin/settings/gallery')));
gallery_error($err_msg, $ret, TRUE);
return;
}
// Image block options for search
$params['blocks'] = "specificItem";
$param_show_array = variable_get('gallery_search_block_show', array());
$params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : "";
$params['maxSize'] = variable_get('gallery_search_maxsize', 160);
$params['albumFrame'] = variable_get('gallery_search_album_frame', 'none');
$params['itemFrame'] = variable_get('gallery_search_item_frame', 'none');
$params['linkTarget'] = variable_get('gallery_search_link_target', '');
$show_g2_thumbs = variable_get('gallery_search_show_thumbs', 1);
$max_items = variable_get('gallery_search_max_items', 50);
list ($ret, $results) = GalleryEmbed::searchScan($keys, $max_items);
if (!$ret) {
/**
* Format of $results is:
* [GalleryCoreSearch] => Array(
[start] => 1
[end] => 13
[count] => 13
[results] => Array(
[0] => Array(
[itemId] => 46
[fields] => Array(
[0] => Array([key] => Title, [value] => DSCN2884.JPG)
[1] => Array([key] => Summary, [value] => )
[2] => Array([key] => Keywords, [value] => )
[3] => Array([key] => Description, [value] => )
[4] => Array([key] => Owner, [value] => Me )
)
)
[1] => ...
[name] => Gallery Core
)
[comment] => ...
[CustomField] => ...
[MultiLang] => ...
Other modules
)
* You can set the maximum number of items, but not a start offset, unfortunately.
*/
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
// Copy the results to a new array, and overwrite the results portions to a new format
$find = $results;
$g2_thumb = '';
foreach ($results as $name => $module) {
if (count($module['results']) > 0) {
$this_module_results = array();
foreach ($module['results'] as $result) {
$excerpt = array();
$g2_thumb = '';
foreach ($result['fields'] as $field) {
if (preg_match("/$keys/i", $field['value'])) {
$excerpt[] = ''.$field['key'] .': '.
search_excerpt($keys, $field['value']);
}
}
$link = $urlGenerator->generateUrl(array('itemId' => $result['itemId']),
array('htmlEntities' => false));
if ($show_g2_thumbs) {
$params['itemId'] = $result['itemId'];
// No error checking. If it failed then no thumb is returned. Should be OK
// (maybe there is no thumb for that item)
list($ret, $g2_thumb, $head) = GalleryEmbed::getImageBlock($params);
if ($head) {
$g2_head[] = $head;
}
}
$this_module_results[] = array(
'title' => $result['fields'][0]['value'],
'link' => $link,
'type' => '',
'snippet' => implode('
', $excerpt),
'extra' => array(),
'g2_thumb' => $g2_thumb,
);
}
$find[$name]['results'] = $this_module_results;
}
}
// Try not to send the G2 head information multiple times
if ($g2_head) {
drupal_set_html_head(implode("\n", array_unique($g2_head)));
}
return $find;
}
}
}
/**
* Implementation of hook_search_page to override how to display the search results
*/
function _gallery_search_page($results) {
$num_items_per_row = variable_get('gallery_search_num_per_row', 3);
$max_rows_per_pager = variable_get('gallery_search_max_rows_per_pager', 5);
$max_items = variable_get('gallery_search_max_items', 50);
$header = array_fill(0, $num_items_per_row, '');
$output = '
'. $item['snippet'] . '
' : '') . '' . implode(' - ', $info) .'