function imagepicker_display_block in Image Picker 7
Same name and namespace in other branches
- 6.2 imagepicker.module \imagepicker_display_block()
Function to display the contents of a block.
1 call to imagepicker_display_block()
- imagepicker_block_view in ./
imagepicker.module - Implements hook_block_view().
File
- ./
imagepicker.module, line 655 - @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function imagepicker_display_block($i) {
// fetch all the images for the group
$boxtype = 'colorbox';
$gid = imagepicker_variable_get('imagepicker_galleryblocks_group_' . $i, '');
$clickon = imagepicker_variable_get('imagepicker_galleryblocks_link_' . $i, t('Photo Gallery !i', array(
'!i' => $i,
)));
$textarea = imagepicker_variable_get('imagepicker_galleryblocks_text_' . $i, '');
$group = imagepicker_get_user_group($gid);
if ($group) {
$gal = $group->group_name;
}
else {
return;
}
$query = db_select('users', 'u');
$query
->fields('i', array(
'img_id',
'uid',
'img_name',
'img_title',
'img_description',
));
$query
->join('imagepicker', 'i');
$query
->leftjoin('imagepicker_group_images', 'g', 'g.img_id = i.img_id');
$query
->leftjoin('imagepicker_user_groups', 'iug', 'iug.gid = g.gid');
$query
->condition('u.uid', 'iug.uid');
$query
->condition('iug.group_name', $gal);
$rows = $query
->execute();
$ct = 0;
$content = "";
$class = '';
foreach ($rows as $img) {
$name = $img->img_name;
$t = $img->img_title;
$d = $img->img_description;
$title = $d ? $d : $t;
$full = imagepicker_get_image_path($img, 'full', array(
'uid' => $img->uid,
));
// munge this so that it can go through l() when using relative url setting
$full = preg_replace("#^" . base_path() . "#", '', $full);
if ($ct) {
$class = "js-hide";
$content .= l($name, $full, array(
'html' => $ct ? FALSE : TRUE,
'attributes' => array(
'class' => "{$boxtype} {$class}",
'rel' => $gal,
'title' => $title,
),
));
}
else {
// first one is visible
$link = l($clickon, $full, array(
'html' => $ct ? FALSE : TRUE,
'attributes' => array(
'class' => "{$boxtype} {$class}",
'rel' => $gal,
'title' => $title,
),
));
if ($textarea && preg_match("/\\[link\\]/", $textarea)) {
$content .= preg_replace("/\\[link\\]/", $link, $textarea);
}
else {
$content .= $textarea . $link;
}
}
$ct++;
}
return theme('imagepicker_display_block', array(
'content' => $content,
));
}