summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallery_base.inc2
-rw-r--r--gallery_block.inc8
-rw-r--r--gallery_block_admin.inc141
-rw-r--r--gallery_profile/gallery_profile.module220
4 files changed, 151 insertions, 220 deletions
diff --git a/gallery_base.inc b/gallery_base.inc
index 1e244c0..5605a86 100644
--- a/gallery_base.inc
+++ b/gallery_base.inc
@@ -662,7 +662,7 @@ function gallery_get_blocks($plugin_names = NULL) {
* @param $extra
* $extra['class']:
* Optional class to apply to the block (if customized css styles are required).
- * $extra['num_colums']:
+ * $extra['num_cols']:
* If given for a 'ImageBlock' a grid block with 'num_cols' columns is generated.
* Otherwise (default) a 'normal' image block is returned.
*/
diff --git a/gallery_block.inc b/gallery_block.inc
index 006416d..c98b0c3 100644
--- a/gallery_block.inc
+++ b/gallery_block.inc
@@ -21,7 +21,7 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
$id = variable_get('gallery_block_'. $i .'_blockid', '');
$blocks['block-'. $i]['info'] = $i ? t('Gallery Block @id', array('@id' => '['. (empty($id) ? $i : $id) .']'))
: t('Gallery Navigation');
- $blocks['block-'. $i]['cache'] = variable_get('gallery_block_'. $i .'_cache', BLOCK_CACHE_PER_USER);
+ $blocks['block-'. $i]['cache'] = variable_get('gallery_block_'. $i .'_cache', BLOCK_NO_CACHE);
}
return $blocks;
case 'view':
@@ -42,7 +42,7 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
return $delta ? _gallery_block_admin_block($delta) : _gallery_block_admin_navigation();
case 'save':
require_once(drupal_get_path('module', 'gallery') .'/gallery_block_admin.inc');
- _gallery_block_admin_save($delta, $edit);
+ _gallery_block_admin_save($edit);
break;
}
}
@@ -155,10 +155,10 @@ function _gallery_block_image_block($delta, $plugin, $plugin_block) {
if (($num = $num_images - $count) > 0) {
$param_blocks_array += array_fill($count, $num, end($param_blocks_array));
}
- $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : '';
+ $params['blocks'] = implode('|', $param_blocks_array);
$params['itemId'] = variable_get($element .'_item_id', '');
$param_show_array = variable_get($element .'_block_show', array());
- $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : '';
+ $params['show'] = empty($param_show_array) ? 'none' : implode('|', $param_show_array);
if (variable_get($element .'_size_method', GALLERY_IMAGEBLOCK_SIZE_METHOD_DEFAULT) == 'maxsize') {
$params['maxSize'] = variable_get($element .'_size', GALLERY_IMAGEBLOCK_SIZE_DEFAULT);
}
diff --git a/gallery_block_admin.inc b/gallery_block_admin.inc
index 53012fe..086cb23 100644
--- a/gallery_block_admin.inc
+++ b/gallery_block_admin.inc
@@ -5,7 +5,7 @@ require_once(drupal_get_path('module', 'gallery') .'/gallery_settings.inc');
/**
* gallery.module : gallery_block_admin.inc
- * Block settings functions
+ * Gallery block settings
*/
/**
@@ -15,14 +15,16 @@ function _gallery_block_admin_navigation() {
$form['gallery_block_navigation_cache'] = array(
'#type' => 'select',
'#title' => t('Block cache'),
- '#default_value' => variable_get('gallery_block_navigation_cache', BLOCK_CACHE_PER_USER),
+ '#default_value' => variable_get('gallery_block_navigation_cache', BLOCK_NO_CACHE),
'#options' => array(
BLOCK_NO_CACHE => t('Cache disabled'),
- BLOCK_CACHE_PER_USER => t('Cache per user')
+ BLOCK_CACHE_PER_USER | BLOCK_CACHE_PER_PAGE => t('Cache per user and page'),
+ BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE => t('Cache per role and page')
),
- '#description' => t('Configure cache settings for this block. It\'s usually safe to set this to \'Cache per user\'.')
+ '#description' => t('Configure cache settings for this block. It\'s usually safe to set this to \'Cache per user and page\'.')
);
+ $form['element'] = array('#type' => 'value', '#value' => 'gallery_block_navigation');
return $form;
}
@@ -44,15 +46,27 @@ function _gallery_block_admin_block($delta) {
'#maxlength' => 255,
'#description' => t('A short identifier to distinguish blocks of the same type. (Blocks are numbered by default)')
);
+ $cache_options = array(
+ BLOCK_NO_CACHE => t('Cache disabled'),
+ BLOCK_CACHE_PER_USER | BLOCK_CACHE_PER_PAGE => t('Cache per user and page'),
+ BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE => t('Cache per role and page'),
+ BLOCK_CACHE_PER_USER => t('Cache per user'),
+ BLOCK_CACHE_PER_ROLE => t('Cache per role'),
+ BLOCK_CACHE_GLOBAL => t('Cache globally (use carefully)')
+ );
+ // Make sure the cache options are compatible with the block parameters
+ if (count($block_map[$block_type]['params'])) {
+ unset($cache_options[BLOCK_CACHE_GLOBAL]);
+ // If the block is item-specific we must (at least) cache per page
+ if (in_array('item', $block_map[$block_type]['params'])) {
+ unset($cache_options[BLOCK_CACHE_PER_ROLE], $cache_options[BLOCK_CACHE_PER_USER]);
+ }
+ }
$form['gallery_block_'. $delta .'_cache'] = array(
'#type' => 'select',
'#title' => t('Block cache'),
- '#default_value' => variable_get('gallery_block_'. $delta .'_cache', BLOCK_CACHE_PER_USER),
- '#options' => array(
- BLOCK_NO_CACHE => t('Cache disabled'),
- BLOCK_CACHE_PER_USER => t('Cache per user'),
- BLOCK_CACHE_PER_ROLE => t('Cache per role')
- ),
+ '#default_value' => variable_get('gallery_block_'. $delta .'_cache', BLOCK_NO_CACHE),
+ '#options' => $cache_options,
'#description' => _gallery_block_admin_description($block_type .'_cache'),
);
@@ -74,8 +88,8 @@ function _gallery_block_admin_block($delta) {
if ($param_form = _gallery_block_admin_block_params($delta, $plugin, $plugin_block)) {
$form[$block_type] = array(
'#type' => 'fieldset',
- '#title' => t('%block settings', array('%block' => $plugin_block)),
- '#collapsible' => FALSE,
+ '#title' => t('@block settings', array('@block' => $plugin_block)),
+ '#collapsible' => TRUE,
'#collapsed' => FALSE
);
$form[$block_type][] = $param_form;
@@ -96,14 +110,13 @@ function _gallery_block_admin_block($delta) {
* Function _gallery_block_admin_description().
*/
function _gallery_block_admin_description($element) {
- // TODO
switch($element) {
case 'imageblock_cache':
return t('Configure cache settings for this block. Unless random images are used you can safely keep this to
- \'Cache per user\' (default). If you dont have per-user permissions configured in your gallery you
- can improve performance by setting to \'Cache per role\'.');
+ \'Cache per user and page\'. If you dont have per-user permissions configured in your gallery you
+ can improve performance by setting to \'Cache per role and page\'.');
default:
- return '- description -';
+ return '';
}
}
@@ -115,7 +128,8 @@ function _gallery_block_admin_block_params($delta, $plugin, $plugin_block) {
// Image block specific settings
if ($plugin_block == 'ImageBlock') {
- return _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blocks);
+ $element = 'gallery_block_'. $delta .'_'. strtolower($plugin_block);
+ return _gallery_block_admin_imageblock($element);
}
// Block specific settings
@@ -156,21 +170,28 @@ function _gallery_block_admin_block_params($delta, $plugin, $plugin_block) {
/**
* Function _gallery_block_admin_imageblock().
*/
-function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blocks) {
+function _gallery_block_admin_imageblock($element, $title = 'Gallery Image/Grid Block', $hide_options = NULL) {
$plugin_status = gallery_plugin_status(array('imageblock', 'imageframe'));
- $form['imageblock']['#description'] = t('The Gallery Image/Grid Block 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']))
- );
+ $form['#description'] = t('The @title requires the Gallery2 Image Block plugin (!imageblock_status) and optionally
+ the Gallery2 Image Frame plugin (!imageframe_status).', array(
+ '@title' => $title,
+ '!imageblock_status' => theme('gallery_plugin_status_message', $plugin_status['imageblock']),
+ '!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']))
+ );
+
+ if ($plugin_status['imageblock'] != GALLERY_PLUGIN_ENABLED) {
+ $form['#description'] .= t(' However the Image Block plugin is unavailable.');
+ return $form;
+ }
+
+ $form['imageblock'] = array('#tree' => TRUE);
+ $form['imageblock']['element'] = array('#type' => 'value', '#value' => $element);
- $element = 'gallery_block_'. $delta .'_'. strtolower($plugin_block);
$num_cols = variable_get($element .'_num_cols', 2);
$num_rows = variable_get($element .'_num_rows', 2);
$numimages = $num_cols * $num_rows;
- $form[$element .'_num_cols'] = array(
+ $form['imageblock'][$element .'_num_cols'] = array(
'#type' => 'select',
'#title' => t('Number of columns'),
'#default_value' => variable_get($element .'_num_cols', 2),
@@ -178,7 +199,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
'#description' => t('Select the number of columns in the grid.'),
);
- $form[$element .'_num_rows'] = array(
+ $form['imageblock'][$element .'_num_rows'] = array(
'#type' => 'select',
'#title' => t('Number of rows'),
'#default_value' => variable_get($element .'_num_rows', 2),
@@ -187,7 +208,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
);
_gallery_block_options($type_map, $param_map);
- $form[$element .'_block_block'] = array(
+ $form['imageblock'][$element .'_block_block'] = array(
'#type' => 'fieldset',
'#title' => t('Image types'),
'#collapsible' => TRUE,
@@ -197,7 +218,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
);
$gallery_block_block = variable_get($element .'_block_block', array('randomImage'));
for ($i=0; $i<$numimages; $i++) {
- $form[$element .'_block_block'][$i] = array(
+ $form['imageblock'][$element .'_block_block'][$i] = array(
'#type' => 'select',
'#title' => '',
'#default_value' => isset($gallery_block_block[$i]) ? $gallery_block_block[$i] : NULL,
@@ -205,7 +226,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
);
}
- $form[$element .'_item_id'] = array(
+ $form['imageblock'][$element .'_item_id'] = array(
'#type' => 'textfield',
'#title' => t('Album or Item ID'),
'#default_value' => variable_get($element .'_item_id', ''),
@@ -216,7 +237,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
is entered, items will be taken from the current (or specified) user\'s useralbum.')
);
- $form[$element .'_block_show'] = array(
+ $form['imageblock'][$element .'_block_show'] = array(
'#type' => 'checkboxes',
'#title' => t('Image data'),
'#default_value' => variable_get($element .'_block_show', array('title', 'heading')),
@@ -224,7 +245,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
'#description' => t('Choose the item metadata you would like to display.'),
);
- $form[$element .'_size_method'] = array(
+ $form['imageblock'][$element .'_size_method'] = array(
'#type' => 'select',
'#title' => t('Image size method'),
'#default_value' => variable_get($element .'_size_method', GALLERY_IMAGEBLOCK_SIZE_METHOD_DEFAULT),
@@ -238,7 +259,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
will be guaranteed to be the size defined below.'),
);
- $form[$element .'_size'] = array(
+ $form['imageblock'][$element .'_size'] = array(
'#type' => 'textfield',
'#title' => t('Image size'),
'#default_value' => variable_get($element .'_size', GALLERY_IMAGEBLOCK_SIZE_DEFAULT),
@@ -253,7 +274,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
$image_frames = gallery_get_image_frames();
- $form[$element .'_album_frame'] = array(
+ $form['imageblock'][$element .'_album_frame'] = array(
'#type' => 'select',
'#title' => t('Album frame'),
'#default_value' => variable_get($element .'_album_frame', 'none'),
@@ -261,7 +282,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
'#description' => $imageframe_desc,
);
- $form[$element .'_item_frame'] = array(
+ $form['imageblock'][$element .'_item_frame'] = array(
'#type' => 'select',
'#title' => t('Item frame'),
'#default_value' => variable_get($element .'_item_frame', 'none'),
@@ -269,7 +290,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
'#description' => $imageframe_desc,
);
- $form[$element .'_link_target'] = array(
+ $form['imageblock'][$element .'_link_target'] = array(
'#type' => 'textfield',
'#title' => t('Link target'),
'#default_value' => variable_get($element .'_link_target', ''),
@@ -278,7 +299,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
'#description' => t('Enter a link target (e.g. \'_blank\' to open in a new window).'),
);
- $form[$element .'_link'] = array(
+ $form['imageblock'][$element .'_link'] = array(
'#type' => 'textfield',
'#title' => t('Image Link'),
'#default_value' => variable_get($element .'_link', ''),
@@ -289,21 +310,27 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
to link somewhere else instead.'),
);
+ // Remove form elements that should not be available
+ if (isset($hide_options) && is_array($hide_options)) {
+ foreach ($hide_options as $option) {
+ unset($form['imageblock'][$element .'_'. $option]);
+ }
+ }
+
return $form;
}
/**
- * Function _gallery_block_admin_update().
+ * Function _gallery_block_admin_imageblock_submit().
*/
-function _gallery_block_admin_update($form, &$form_state) {
- _gallery_block_admin_save(0, $form_state['values']);
- db_query("UPDATE {blocks} SET title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
+function _gallery_block_admin_imageblock_submit($form, &$form_state) {
+ _gallery_block_admin_save($form_state['values']);
}
/**
- * Function _gallery_block_admin_save().
+ * Function _gallery_block_admin_imageblock_save().
*/
-function _gallery_block_admin_save($delta, $values) {
+function _gallery_block_admin_imageblock_save(&$values) {
$element = $values['element'];
unset($values['element']);
// Validate _size variable
@@ -314,7 +341,35 @@ function _gallery_block_admin_save($delta, $values) {
(The value has been updated to \'10\' for your convenience.)'), 'error');
}
}
+ // Save imageblock variables
+ foreach ($values['imageblock'] as $key => $value) {
+ if (is_array($value)) {
+ $value = array_values(array_filter($value));
+ }
+ variable_set($key, $value);
+ }
+ unset($values['imageblock']);
+}
+
+/**
+ * Function _gallery_block_admin_update().
+ */
+function _gallery_block_admin_update($form, &$form_state) {
+ _gallery_block_admin_save($form_state['values']);
+ db_query("UPDATE {blocks} SET title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
+}
+
+/**
+ * Function _gallery_block_admin_save().
+ */
+function _gallery_block_admin_save(&$values) {
+ // Save imageblock values (if present)
+ if (isset($values['imageblock'])) {
+ _gallery_block_admin_imageblock_save($values);
+ }
// Save variables
+ $element = $values['element'];
+ unset($values['element']);
foreach ($values as $key => $value) {
$pos = strpos($key, $element);
if ($pos !== FALSE && $pos == 0) {
diff --git a/gallery_profile/gallery_profile.module b/gallery_profile/gallery_profile.module
index d6723ea..ba1457f 100644
--- a/gallery_profile/gallery_profile.module
+++ b/gallery_profile/gallery_profile.module
@@ -9,22 +9,23 @@
* Implementation of hook_menu().
*/
function gallery_profile_menu() {
- $items['admin/user/gallery/settings/general'] = array(
- 'title' => 'General',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 0
- );
- $items['admin/user/gallery/settings/profile'] = array(
- 'title' => 'User Profile',
- 'access callback' => 'gallery_admin_access',
- 'access arguments' => array(array('administer users', 'administer gallery settings')),
- 'file' => 'gallery_settings.inc',
- 'file path' => drupal_get_path('module', 'gallery'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('_gallery_profile_settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1
- );
+ $items = array();
+ if (variable_get('gallery_valid', 0)) {
+ $items['admin/user/gallery/settings/general'] = array(
+ 'title' => 'General',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 0
+ );
+ $items['admin/user/gallery/settings/profile'] = array(
+ 'title' => 'User Profile',
+ 'access callback' => 'gallery_admin_access',
+ 'access arguments' => array(array('administer users', 'administer gallery settings')),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('_gallery_profile_settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1
+ );
+ }
return $items;
}
@@ -42,18 +43,18 @@ function gallery_profile_profile_alter(&$account) {
unset($profile['user_sync']);
}
// Useralbum link/gallery
- $gallery_mode = variable_get('gallery_user_profile_gallery', array('link'));
- if (in_array('gallery', $gallery_mode) && gallery_user_useralbum($account->uid, FALSE)) {
+ $profile_type = variable_get('gallery_user_profile_gallery', array('link'));
+ if (in_array('gallery', $profile_type) && gallery_user_useralbum($account->uid, FALSE)) {
$profile['useralbum_gallery'] = array(
'#type' => 'user_profile_item',
- '#title' => in_array('link', $gallery_mode) ?
+ '#title' => in_array('link', $profile_type) ?
$profile['useralbum_link']['#value'] : t('Album: %username', array('%username' => $account->name)),
'#value' => _gallery_profile_useralbum($account->uid),
'#attributes' => array('class' => 'gallery_profile_useralbum')
);
unset($profile['useralbum_link']);
}
- else if (!in_array('link', $gallery_mode)) {
+ else if (!in_array('link', $profile_type)) {
unset($profile['useralbum_link']);
}
// Hide section (if no items are available)
@@ -77,6 +78,9 @@ function gallery_profile_form_alter(&$form, $form_state, $form_id) {
* Function _gallery_profile_settings().
*/
function _gallery_profile_settings() {
+ require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc');
+ require_once(drupal_get_path('module', 'gallery') .'/gallery_block_admin.inc');
+
$form['profile'] = array(
'#type' => 'fieldset',
'#title' => t('User Profile'),
@@ -107,11 +111,11 @@ function _gallery_profile_settings() {
'#description' => t('Hide \'Gallery2-Drupal Sync Status\' message in the profile.'),
);
- $gallery_mode = variable_get('gallery_user_profile_gallery', array('link'));
+ $profile_type = variable_get('gallery_user_profile_gallery', array('link'));
$form['profile']['gallery_user_profile_gallery'] = array(
'#type' => 'checkboxes',
'#title' => t('Profile gallery mode'),
- '#default_value' => $gallery_mode,
+ '#default_value' => $profile_type,
'#options' => array(
'link' => t('Show link to useralbum'),
'gallery' => t('Show (useralbum) gallery/images')
@@ -119,154 +123,21 @@ function _gallery_profile_settings() {
'#description' => t('By default a link to the useralbum is shown. But you may also insert a gallery of
random/recent images from the useralbum into the user profile.'),
);
- // Useralbum settings
- if (in_array('gallery', $gallery_mode)) {
- $form['profile'][] = _gallery_profile_useralbum_settings();
- }
- $form['array_filter'] = array('#type' => 'value');
- return system_settings_form($form);
-}
-
-/**
- * Function _gallery_profile_useralbum_settings().
- */
-function _gallery_profile_useralbum_settings() {
- require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc');
-
- $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe'));
- $form['useralbum'] = array(
- '#type' => 'fieldset',
- '#title' => t('Useralbum'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#description' => t('The profile useralbum 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'])
- ))
- );
- if ($plugin_status['imageblock'] != GALLERY_PLUGIN_ENABLED) {
- $form['useralbum']['#description'] .= t(' However the Image Block plugin is unavailable.');
- return $form;
+ // Useralbum settings
+ if (in_array('gallery', $profile_type)) {
+ $form['profile']['useralbum'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Useralbum settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE
+ );
+ $element = 'gallery_user_profile_useralbum';
+ $form['profile']['useralbum'] += _gallery_block_admin_imageblock($element, t('profile useralbum'));
+ $form['#submit'][] = '_gallery_block_admin_imageblock_submit';
}
- $form['useralbum']['gallery_user_profile_useralbum_num_cols'] = array(
- '#type' => 'select',
- '#title' => t('Number of columns'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_num_cols', 2),
- '#options' => _gallery_range_array(1, 10),
- '#description' => t('Enter the number of columns in the useralbum.'),
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_num_rows'] = array(
- '#type' => 'select',
- '#title' => t('Number of rows'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_num_rows', 2),
- '#options' => _gallery_range_array(1, 10),
- '#description' => t('Enter the number of rows in the useralbum.'),
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_block_block'] = array(
- '#type' => 'select',
- '#title' => 'Image types',
- '#default_value' => variable_get('gallery_user_profile_useralbum_block_block', 'randomImage'),
- '#options' => array(
- 'randomImage' => t('Random image'),
- 'recentImage' => t('Recent image')
- ),
- '#description' => 'Pick the type of images you would like to see in the useralbum.',
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_item_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Album or Item ID'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_item_id', ''),
- '#size' => 20,
- '#maxlength' => 20,
- '#description' => t('Enter the Gallery image or album ID or leave blank for \'Useralbum\' (default).')
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_block_show'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Image data'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_block_show', array()),
- '#options' => array(
- 'title' => t('Title'),
- 'date' => t('Date'),
- 'views' => t('View Count'),
- 'owner' => t('Item owner'),
- 'heading' => t('Heading')
- ),
- '#description' => t('Choose the item metadata you would like to display.'),
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_size_method'] = array(
- '#type' => 'select',
- '#title' => t('Image size method'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT),
- '#options' => array(
- 'maxsize' => t('Max Size'),
- 'exactsize' => t('Exact Size'),
- ),
- '#description' => t('\'Max Size\' gives faster image downloading, but the image size
- may be smaller than the size defined below. <br />\'Exact Size\' may be slower
- (as a larger image is downloaded and then scaled by the browser) but the image
- will be guaranteed to be the size defined below. Only supported for G2.2+.'),
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_size'] = array(
- '#type' => 'textfield',
- '#title' => t('Image size'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_size', GALLERY_GRID_SIZE_DEFAULT),
- '#size' => 10,
- '#maxlength' => 10,
- '#description' => t('Sets the size (in pixels) of the longest side of the image according
- to the method defined above.'),
- );
-
- $imageframe_desc = ($plugin_status['imageframe'] != GALLERY_PLUGIN_ENABLED) ?
- t('Requires the Gallery2 Image Frame plugin (!imageframe_status).',
- array('!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']))) : '';
-
- $image_frames = gallery_get_image_frames();
-
- $form['useralbum']['gallery_user_profile_useralbum_album_frame'] = array(
- '#type' => 'select',
- '#title' => t('Album frame'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_album_frame', 'none'),
- '#options' => $image_frames,
- '#description' => $imageframe_desc,
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_item_frame'] = array(
- '#type' => 'select',
- '#title' => t('Item frame'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_item_frame', 'none'),
- '#options' => $image_frames,
- '#description' => $imageframe_desc,
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_link_target'] = array(
- '#type' => 'textfield',
- '#title' => t('Link target'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_link_target', ''),
- '#size' => 20,
- '#maxlength' => 20,
- '#description' => t('Enter a link target (e.g. \'_blank\' to open in a new window).'),
- );
-
- $form['useralbum']['gallery_user_profile_useralbum_link'] = array(
- '#type' => 'textfield',
- '#title' => t('Image Link'),
- '#default_value' => variable_get('gallery_user_profile_useralbum_link', ''),
- '#size' => 60,
- '#maxlength' => 255,
- '#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.'),
- );
-
+ $form = system_settings_form($form);
return $form;
}
@@ -277,13 +148,18 @@ function _gallery_profile_useralbum($uid) {
$num_cols = variable_get('gallery_user_profile_useralbum_num_cols', 2);
$num_rows = variable_get('gallery_user_profile_useralbum_num_rows', 2);
$num_images = $num_cols * $num_rows;
-
- $param_blocks_array = array_fill(0, $num_images, variable_get('gallery_user_profile_useralbum_block_block', 'randomImage'));
- $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : '';
+
+ $param_blocks_array = array_filter(variable_get('gallery_user_profile_useralbum_block_block', array('randomImage')));
+ // Ensure $param_blocks_array contains $num_images elements (auto-append if necessary)
+ $count = count($param_blocks_array);
+ if (($num = $num_images - $count) > 0) {
+ $param_blocks_array += array_fill($count, $num, end($param_blocks_array));
+ }
+ $params['blocks'] = implode('|', $param_blocks_array);
$item_id = trim(variable_get('gallery_user_profile_useralbum_item_id', ''));
$params['itemId'] = empty($item_id) ? ('user:'. $uid) : $item_id;
$param_show_array = variable_get('gallery_user_profile_useralbum_block_show', array());
- $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : '';
+ $params['show'] = empty($param_show_array) ? 'none' : implode('|', $param_show_array);
if (variable_get('gallery_user_profile_useralbum_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT) == 'maxsize') {
$params['maxSize'] = variable_get('gallery_user_profile_useralbum_size', GALLERY_GRID_SIZE_DEFAULT);
}
@@ -294,7 +170,7 @@ function _gallery_profile_useralbum($uid) {
$params['itemFrame'] = variable_get('gallery_user_profile_useralbum_item_frame', 'none');
$params['linkTarget'] = variable_get('gallery_user_profile_useralbum_link_target', '');
$params['link'] = variable_get('gallery_user_profile_useralbum_link', '');
-
+
$block = gallery_get_block($params, 'ImageBlock', array('num_cols' => $num_cols));
return $block['content'];
}