Commit 9e95ee77 authored by walkah's avatar walkah
Browse files

fix #31412 - now allow multiple images in the image block

parent 06e78013
...@@ -151,18 +151,18 @@ function gallery_user($op, &$edit, &$user, $category = NULL) { ...@@ -151,18 +151,18 @@ function gallery_user($op, &$edit, &$user, $category = NULL) {
* - gallery imageblock (random, most viewed, etc) * - gallery imageblock (random, most viewed, etc)
*/ */
function gallery_block($op = 'list', $delta = 0, $edit = array()) { function gallery_block($op = 'list', $delta = 0, $edit = array()) {
$typeMap = array('randomImage' => t('Random image'), $typeMap = array('randomImage' => t('Random Image'),
'recentImage' => t('Recent image'), 'recentImage' => t('Newest Image'),
'viewedImage' => t('Viewed image'), 'viewedImage' => t('Most Viewed Image'),
'randomAlbum' => t('Random album'), 'randomAlbum' => t('Random Album'),
'recentAlbum' => t('Recent album'), 'recentAlbum' => t('Newest Album'),
'viewedAlbum' => t('Viewed album'), 'viewedAlbum' => t('Most Viewed Album'),
'dailyImage' => t('Daily image'), 'dailyImage' => t('Picture of the Day'),
'weeklyImage' => t('Weekly image'), 'weeklyImage' => t('Picture of the Week'),
'monthlyImage' => t('Monthly image'), 'monthlyImage' => t('Picture of the Month'),
'dailyAlbum' => t('Daily album'), 'dailyAlbum' => t('Album of the Day'),
'weeklyAlbum' => t('Weekly album'), 'weeklyAlbum' => t('Album of the Week'),
'monthlyAlbum' => t('Monthly album')); 'monthlyAlbum' => t('Album of the Month'));
switch ($op) { switch ($op) {
case 'list': case 'list':
...@@ -171,9 +171,9 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -171,9 +171,9 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
case 'configure': case 'configure':
$form['gallery_block_block_'. $delta] = array( $form['gallery_block_block_'. $delta] = array(
'#type' => 'select', '#type' => 'checkboxes',
'#title' => t('Image type'), '#title' => t('Image type'),
'#default_value' => variable_get('gallery_block_block_' . $delta, 'randomImage'), '#default_value' => variable_get('gallery_block_block_' . $delta, array('randomImage')),
'#options' => $typeMap, '#options' => $typeMap,
'#description' => t("Pick the type of image you'd like to see"), '#description' => t("Pick the type of image you'd like to see"),
); );
...@@ -186,8 +186,14 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -186,8 +186,14 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
); );
return $form; return $form;
case 'save': case 'save':
variable_set('gallery_block_block_' . $delta, $edit['gallery_block_block_' . $delta]); // if no image types selected, assume randomImage
variable_set('gallery_block_show_' . $delta, $edit['gallery_block_show_' . $delta]); if (count($edit['gallery_block_block_' . $delta])) {
variable_set('gallery_block_block_' . $delta, array_keys($edit['gallery_block_block_' . $delta], 1));
}
else {
variable_set('gallery_block_block_' . $delta, array('randomImage'));
}
variable_set('gallery_block_show_' . $delta, array_keys($edit['gallery_block_show_' . $delta], 1));
break; break;
case 'view': case 'view':
...@@ -197,21 +203,29 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -197,21 +203,29 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
return; return;
} }
$params['blocks'] = variable_get('gallery_block_block_' . $delta, 'randomImage'); $params['blocks'] = implode('|', variable_get('gallery_block_block_' . $delta, array('randomImage')));
$params['show'] = implode('|', array_keys(variable_get('gallery_block_show_' . $delta, array()))); $params['show'] = implode('|', variable_get('gallery_block_show_' . $delta, array()));
// TODO: parameterize this // TODO: parameterize this
$params['maxSize'] = 160; $params['maxSize'] = 160;
$block = array(); $block = array();
list($ret, $content) = GalleryEmbed::getImageBlock($params); list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
if ($ret->isError()) { if ($ret->isError()) {
gallery_error(t('Unable to get Gallery image block'), $ret); gallery_error(t('Unable to get Gallery image block'), $ret);
return; return;
} else { } else {
if ($content) { if ($content) {
$block['subject'] = $typeMap[$params['blocks']]; if (count(variable_get('gallery_block_block_' . $delta, 'randomImage')) > 1) {
$block['content'] = '<center>' . $content . '</center>'; $block['subject'] = t('Gallery');
}
else {
$block['subject'] = $typeMap[$params['blocks']];
}
$block['content'] = '<center>'. $content . '</center>';
}
if ($head) {
drupal_set_html_head($head);
} }
} }
......
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