function imagepicker_display_block in Image Picker 6.2
Same name and namespace in other branches
- 7 imagepicker.module \imagepicker_display_block()
Function to display the contents of a block.
1 call to imagepicker_display_block()
- imagepicker_block in ./
imagepicker.module - Implementation of hook_block().
File
- ./
imagepicker.module, line 581 - Enables permitted roles to upload images for insertion into configured nodes.
Code
function imagepicker_display_block($i) {
// fetch all the images for the group
$boxtype = 'colorbox';
$gid = variable_get('imagepicker_galleryblocks_group_' . $i, '');
$clickon = variable_get('imagepicker_galleryblocks_link_' . $i, t('Photo Gallery !i', array(
'!i' => $i,
)));
$textarea = variable_get('imagepicker_galleryblocks_text_' . $i, '');
$group = imagepicker_get_user_group($gid);
$gal = $group->group_name;
$sql = "SELECT DISTINCT i.img_id, i.uid, i.img_name, i.img_title, img_description\n FROM {imagepicker} AS i JOIN {users} AS n USING (uid),\n {imagepicker_user_groups} AS u JOIN {imagepicker_group_images} AS g USING (gid)\n WHERE g.img_id=i.img_id AND u.group_name = '{$gal}'";
$result = db_query($sql);
$ct = 0;
$content = "";
$class = '';
while ($img = db_fetch_object($result)) {
$name = $img->img_name;
$t = $img->img_title;
$d = $img->img_description;
$title = $d ? $d : $t;
if (variable_get('file_downloads', '1') == 2) {
$full = imagepicker_get_image_path($img, 'full', array(
'uid' => $img->uid,
));
}
else {
$full = file_directory_path() . DIRECTORY_SEPARATOR . IMAGEPICKER_FILES_DIR . DIRECTORY_SEPARATOR . $img->uid . DIRECTORY_SEPARATOR . $name;
}
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', $content);
}