Commit fac262b1 authored by profix898's avatar profix898

- bugfix: empty title not handled in status reports

- bugfix: advanced search broken
- task: unify head html output (in _search.inc)
- task: make filter tag case-insensitive
parent a56fdb8f
......@@ -333,7 +333,7 @@ function gallery_form_alter(&$form, $form_state, $form_id) {
// Add a custom search form
else if ($form_id == 'search_form' && arg(1) == 'gallery' && variable_get('gallery_search_advanced', 1) && user_access('access gallery')) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_search.inc');
_gallery_search_form($form);
_gallery_search_form($form, $form_state);
}
// Add _validate() handler for external authentication
else if ($form_id == 'user_login_block' || $form_id == 'user_login') {
......@@ -382,7 +382,7 @@ function gallery_elements() {
*/
function gallery_g2image_textarea($element) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_g2image.inc');
if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery')
if (_gallery_g2image_page_match() && (arg(0) != variable_get('gallery_base', 'gallery'))
&& (variable_get('gallery_g2image_mode', 'disabled') == 'standalone')
&& (user_access('access standalone g2image'))) {
gallery_g2image_add_js();
......
......@@ -55,7 +55,7 @@ function gallery_filter_process($text) {
foreach ($args as $arg) {
list($key, $value) = array_filter(explode('=', $arg));
if (!empty($value)) {
$key = preg_replace('/\W/', '', $key);
$key = strtolower(preg_replace('/\W/', '', $key));
$params[$key] = _gallery_filter_sanitize($key, $value);
}
}
......@@ -151,7 +151,7 @@ function gallery_filter_process($text) {
* (sanitize filter parameters)
*/
function _gallery_filter_sanitize($key, $value) {
switch (strtolower($key)) {
switch ($key) {
case 'n':
case 'size':
case 'maxsize':
......
......@@ -14,7 +14,7 @@ function _gallery_search($op = 'search', $keys = NULL) {
return t('Gallery');
case 'search':
$results = array();
$html_head = array();
$head_array = array();
$items_per_row = variable_get('gallery_search_num_per_row', 3);
$rows_per_pager = variable_get('gallery_search_rows_per_pager', 4);
$matches = _gallery_search_pager_search($keys, $items_per_row * $rows_per_pager);
......@@ -43,12 +43,12 @@ function _gallery_search($op = 'search', $keys = NULL) {
// Get a thumbnail for this item
if ($show_thumbs) {
$params['itemId'] = $item['itemId'];
list($ret, $thumbnail, $head) = GalleryEmbed::getImageBlock($params);
list($ret, $thumbnail, $head) = GalleryEmbed::getBlock('imageblock', 'ImageBlock', $params);
if ($ret) {
$thumbnail = t('n/a');
}
if ($head) {
$html_head[] = $head;
$head_array[] = $head;
}
}
// Generate a snippet with highlighted search keys
......@@ -67,8 +67,9 @@ function _gallery_search($op = 'search', $keys = NULL) {
);
}
}
if ($html_head) {
drupal_set_html_head(implode("\n", array_unique($html_head)));
// Add html head items and css
if (count($head_array)) {
gallery_set_head(implode("\n", array_unique($head_array)));
}
return $results;
}
......@@ -99,7 +100,7 @@ function _gallery_search_pager_search(&$keys, $limit = 10, $element = 0) {
/**
* Function _gallery_search_perform().
*/
function _gallery_search_perform(&$keys, $offset = 0, $limit = -1) {
function _gallery_search_perform($keys, $offset = 0, $limit = -1) {
list($search_interface, $options) = _gallery_search_init();
if (!isset($search_interface)) {
return array();
......@@ -125,7 +126,7 @@ function _gallery_search_perform(&$keys, $offset = 0, $limit = -1) {
/**
* Function _gallery_search_form().
*/
function _gallery_search_form(&$form) {
function _gallery_search_form(&$form, $form_state) {
list($search_interface, $options) = _gallery_search_init();
if (!count($options)) {
return;
......@@ -154,20 +155,20 @@ function _gallery_search_form(&$form) {
'#suffix' => '</div>',
);
$form['#validate']['_gallery_search_validate'] = array();
$form['#validate'][] = '_gallery_search_validate';
}
/**
* Function _gallery_search_validate().
*/
function _gallery_search_validate($form_id, $form_values, $form) {
$keys = $form_values['processed_keys'];
function _gallery_search_validate($form, &$form_state) {
$keys = $form_state['values']['processed_keys'];
// Append field options to query
if (isset($form_values['fields']) && is_array($form_values['fields'])) {
$form_values['fields'] = array_filter($form_values['fields']);
if (count($form_values['fields'])) {
$keys = search_query_insert($keys, 'fields', implode(',', array_keys($form_values['fields'])));
form_set_value($form['basic']['inline']['processed_keys'], trim($keys));
if (isset($form_state['values']['fields']) && is_array($form_state['values']['fields'])) {
$form_state['values']['fields'] = array_filter($form_state['values']['fields']);
if (count($form_state['values']['fields'])) {
$keys = search_query_insert($keys, 'fields', implode(',', array_keys($form_state['values']['fields'])));
form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment