Commit 9e95ee77 authored by walkah's avatar walkah

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

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