summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallery_filter.inc15
-rw-r--r--gallery_search.inc1
-rw-r--r--gallery_settings.inc52
3 files changed, 60 insertions, 8 deletions
diff --git a/gallery_filter.inc b/gallery_filter.inc
index 2156336..33bee2c 100644
--- a/gallery_filter.inc
+++ b/gallery_filter.inc
@@ -27,6 +27,7 @@ function gallery_filter_process($text) {
$default['item_frame'] = variable_get('gallery_filter_default_item_frame', 'none');
$default['show'] = variable_get('gallery_filter_default_show', array('none'));
$default['target'] = variable_get('gallery_filter_default_link_target', '');
+ $default['link'] = variable_get('gallery_filter_default_link', '');
}
$head_array = array();
@@ -68,12 +69,19 @@ function gallery_filter_process($text) {
}
// convert into G2-compatible arguments (use new param to make a clearer)
$g2_params['blocks'] = implode('|', is_array($params['type']) ? $params['type'] : array_fill(0, $params['n'], $params['type']));
- $g2_params['show'] = is_array($params['show']) ? implode('|', $params['show']) : '';
- $g2_params['maxSize'] = $params['maxsize'];
- $g2_params['exactSize'] = $params['exactsize'];
+ $g2_params['show'] = is_array($params['show']) ? implode('|', $params['show']) : '';
+ if (isset($params['maxsize']) && !empty($params['maxsize'])) {
+ $g2_params['maxSize'] = $params['maxsize'];
+ unset($g2_params['exactSize']);
+ }
+ if (isset($params['exactsize']) && !empty($params['exactsize'])) {
+ $g2_params['exactSize'] = $params['exactsize'];
+ unset($g2_params['maxSize']);
+ }
$g2_params['albumFrame'] = $params['album_frame'];
$g2_params['itemFrame'] = $params['item_frame'];
$g2_params['linkTarget'] = $params['target'];
+ $g2_params['link'] = $params['link'];
// fetch the images and format output
list($ret, $content, $head) = GalleryEmbed::getImageBlock($g2_params);
@@ -119,6 +127,7 @@ function _gallery_filter_sanitize($key, $value) {
case 'album_frame':
case 'item_frame':
case 'target':
+ case 'link':
return preg_replace('/\W/', '', $value);
case 'type':
case 'show':
diff --git a/gallery_search.inc b/gallery_search.inc
index fcb4946..6ed2cc9 100644
--- a/gallery_search.inc
+++ b/gallery_search.inc
@@ -35,6 +35,7 @@ function _gallery_search($op = 'search', $keys = NULL) {
$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', '');
+ $params['link'] = variable_get('gallery_search_link', '');
$show_thumbs = variable_get('gallery_search_show_thumbs', 1);
// loop over the results
diff --git a/gallery_settings.inc b/gallery_settings.inc
index 30ed899..fe16407 100644
--- a/gallery_settings.inc
+++ b/gallery_settings.inc
@@ -562,7 +562,7 @@ function _gallery_settings_blocks() {
$form['blocks']['image']['gallery_link'] = array(
'#type' => 'textfield',
- '#title' => t('Link'),
+ '#title' => t('Image Link'),
'#default_value' => variable_get('gallery_link', ''),
'#size' => 20,
'#maxlength' => 20,
@@ -677,7 +677,7 @@ function _gallery_settings_blocks() {
$form['blocks']['grid']['gallery_grid_link'] = array(
'#type' => 'textfield',
- '#title' => t('Link'),
+ '#title' => t('Image Link'),
'#default_value' => variable_get('gallery_grid_link', ''),
'#size' => 20,
'#maxlength' => 20,
@@ -708,8 +708,10 @@ function _gallery_settings_blocks_validate($form_id, $form_values) {
function _gallery_settings_filter() {
$plugin_status = gallery_plugin_status(array('imageblock', 'imageframe'));
-
- $desc = t('The Gallery Filter requires the Gallery2 Image Block plugin (!imageblock_status) and
+
+ $desc = t('Note that changing the defaults here will change the all the gallery filter images
+ on the site, not just new images. ');
+ $desc .= t('The Gallery Filter requires the Gallery2 Image Block plugin (!imageblock_status) and
optionally the Gallery2 Image Frame plugin (!imageframe_status).', array(
'!imageblock_status' => theme('gallery_plugin_status_message', $plugin_status['imageblock']),
'!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']),
@@ -750,7 +752,9 @@ function _gallery_settings_filter() {
'#default_value' => variable_get('gallery_filter_prefix', 'G2'),
'#size' => 10,
'#maxlength' => 10,
- '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].'),
+ '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].
+ Be careful when changing this as any pages using the previous prefix will not be changed
+ and so will not be filtered correctly.'),
);
$form['filter']['gallery_filter_default_block_type'] = array(
@@ -855,7 +859,22 @@ function _gallery_settings_filter() {
'#maxlength' => 20,
'#description' => t('Enter a link target (e.g. "_blank", "_new").'),
);
+
+ $form['filter']['gallery_filter_default_link'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default Image Link'),
+ '#default_value' => variable_get('gallery_filter_default_link', ''),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('By default the image has a link to the item in the Gallery. This
+ can be overridden here (or leave empty for the default). Use \'none\' for no link, or a URL
+ to link somewhere else instead.'),
+ );
}
+ // Include both #submit handlers so that the default system submit
+ // is also called to save all the variables.
+ $form['#submit']['_gallery_settings_filter_submit'] = array();
+ $form['#submit']['system_settings_form_submit'] = array();
return system_settings_form($form);
}
@@ -887,6 +906,18 @@ function _gallery_settings_filter_validate($form_id, $form_values) {
}
}
+function _gallery_settings_filter_submit($form_id, $form_values) {
+// The default values have changed, so the pages containing the gallery filter need
+// to be updated (or else it would only occur on an edit), so empty the filter cache.
+
+// Find out which formats are using the gallery filter
+ $result = db_query("SELECT format FROM {filters} WHERE module = 'gallery'");
+ while ($format = db_fetch_object($result)) {
+ cache_clear_all($format->format .':', 'cache_filter', TRUE);
+ }
+ drupal_set_message('The gallery filter cache has been cleared so that the new defaults apply.');
+}
+
function _gallery_settings_g2image() {
$plugin_status = gallery_plugin_status(array('imageblock'));
@@ -1236,6 +1267,17 @@ function _gallery_settings_search() {
'#maxlength' => 20,
'#description' => t('Enter a link target (e.g. "_blank", "_new").'),
);
+
+ $form['search']['thumbs']['gallery_search_default_link'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Image Link'),
+ '#default_value' => variable_get('gallery_search_default_link', ''),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('By default the image has a link to the item in the Gallery. This
+ can be overridden here (or leave empty for the default). Use \'none\' for no link, or a
+ URL to link somewhere else instead.'),
+ );
}
}