function gallery_assist_display_item_default in Gallery Assist 6
Build the output to display each gallery image. Call the own pager and the theme.
1 call to gallery_assist_display_item_default()
- gallery_assist_display_item in ./
gallery_assist.module - Allow to use jquery effects on the image view such as flash, slideshow, zoom viewer, galleria.
File
- ./
gallery_assist.module, line 3830 - Drupal content type with gallery functionality.
Code
function gallery_assist_display_item_default($node, $pid, $global_node_type_settings = array()) {
global $user, $base_url;
if (gallery_assist_check_access($node)) {
if (gallery_assist_check_public_status($node, $user)) {
$item = new \stdClass();
$node->galltemp['active_item'] = $pid;
$node->galltemp['class_active'] = '';
$node->galltemp['path'] = '';
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l($node->title, 'node/' . $node->nid);
$breadcrumb[] = $node->gallitems[$pid]->ptitle;
drupal_set_breadcrumb($breadcrumb);
$node->file_created = db_result(db_query("SELECT timestamp FROM {files} WHERE fid=%d", $node->gallitems[$pid]->fid));
$node->dateformate = t('D, m/d/Y - h:i');
$item->nid = $node->nid;
$item->nodetype = $node->type;
$item->title = $node->title;
$theme_settings = theme_get_settings();
// $item->submitted = $theme_settings["toggle_node_info_{$node->type}_item"] ? theme('gallery_assist_item_submitted', $node) : '';
$node->created = $node->file_created;
$item->submitted = $theme_settings["toggle_node_info_{$node->type}_item"] ? theme('node_submitted', $node) : '';
$conf = $node->gallconf[$node->type];
$item->preview_size = $node->gallconf[$node->type]['preview_size'];
if (variable_get('gallery_assist_imagecache_uninstalled', FALSE) == 1 && !file_exists(file_create_path($node->gallitems[$pid]->ppath)) && file_exists($node->gallitems[$pid]->opath)) {
// drupal_set_message($additions->gallitems[$item->pid]->ptitle .' wurde nicht gefunden', 'warning');
$h_imageinfo = image_get_info($node->gallitems[$pid]->opath);
$my_dim_ref = $h_imageinfo['width'] > $h_imageinfo['height'] ? $h_imageinfo['width'] : $h_imageinfo['height'];
$item->h_prev_size = $h_prev_size = $node->gallconf[$node->type]['upload_prev'];
if ($h_prev_size < $my_dim_ref) {
@image_scale($node->gallitems[$pid]->opath, $node->gallitems[$pid]->ppath, $h_prev_size, $h_prev_size);
}
else {
@copy($node->gallitems[$pid]->opath, $node->gallitems[$pid]->ppath);
}
@chmod($node->gallitems[$pid]->tpath, 0664);
// drupal_set_message('The preview image from '. $node->gallitems[$pid]->ptitle .' was recreated sucessfull.');
}
//-------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------//
// We use the if to avoid division by zero if the image path is wrong
// $img = image_get_info($node->gallitems[$pid]->ppath);
// if (count($img) && !empty($img['width'])) {
// $size_param = $img['width'] >= $img['height'] ? 'width' : 'height';
// $contraer = $size_param == 'width' ? 'max-height:'. $img['height'] .'px' : 'max-width:'. $img['width'] .'px';
// $size_param_ie6 = $img['width'] >= $img['height'] ? '_width' : '_height';
// $size_param_ie7 = $img['width'] >= $img['height'] ? '>width' : '>height';
// $size_param_max = $img['width'] >= $img['height'] ? 'max-width' : 'max-height';
// if ($img[$size_param] < $item->preview_size) {
// $item->preview_size = $img[$size_param];
// }
// $style_str = array(
// $contraer,
// $size_param .': 100%',
// $size_param_max .':'. $item->preview_size .'px',
// $size_param_ie6 .':'. $item->preview_size .'px',
// $size_param_ie7 .':'. $item->preview_size .'px',
// );
// $size_parameter = implode(';', $style_str);
// }
// else {
// $img = image_get_info($node->gallitems[$pid]->opath);
// $size_param = $img['width'] >= $img['height'] ? 'width' : 'height';
// $size_param_ie6 = $img['width'] >= $img['height'] ? '_width' : '_height';
// $size_param_ie7 = $img['width'] >= $img['height'] ? '>width' : '>height';
// $size_param_max = $img['width'] >= $img['height'] ? 'max-width' : 'max-height';
// if ($img[$size_param] < $item->preview_size) {
// $item->preview_size = $img[$size_param];
// }
// $style_str = array(
// $contraer,
// $size_param .': 100%',
// $size_param_max .':'. $item->preview_size .'px',
// $size_param_ie6 .':'. $item->preview_size .'px',
// $size_param_ie7 .':'. $item->preview_size .'px',
// );
// $size_parameter = implode(';', $style_str);
// }
//-------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------//
if (file_exists($node->gallitems[$pid]->ppath)) {
$info = image_get_info($node->gallitems[$pid]->ppath);
$img['width'] = $info['width'];
$img['height'] = $info['height'];
}
else {
$info = image_get_info($node->gallitems[$pid]->opath);
$info = gallery_assist_image_prev_more_info($info, $conf);
$img['width'] = $info['new_width'];
$img['height'] = $info['new_height'];
}
$node->pid = $pid;
$links = gallery_assist_item_pager($node);
if (function_exists('imagecache_preset') && variable_get('gallery_assist_use_imagecache', 0) == 1) {
$item->img = theme('imagecache', $node->gallconf[$node->type]['prev_presetname'], $node->gallitems[$pid]->opath, $node->gallitems[$pid]->palt, $node->gallitems[$pid]->ptitle, array(), TRUE);
$item->img = l($item->img, "node/{$node->nid}/{$links['next']}", array(
'html' => TRUE,
'fragment' => 'ga-item-top',
'attributes' => array(
'fragment' => 'ga-item-top',
),
));
}
else {
$prev_attr = array(
'id' => 'prev-img-box',
'style' => 'width:' . $img['width'] . 'px;height:' . $img['height'] . 'px;',
);
$item->img = '<div ' . drupal_attributes($prev_attr) . '>' . theme('image', file_create_url($node->gallitems[$pid]->ppath), $node->gallitems[$pid]->palt, $node->gallitems[$pid]->ptitle, array(
'style' => isset($size_parameter) ? $size_parameter : '',
), FALSE) . '</div>';
$item->img = l($item->img, "node/{$node->nid}/{$links['next']}", array(
'html' => TRUE,
'fragment' => 'ga-item-top',
'attributes' => array(
'fragment' => 'ga-item-top',
),
));
$prev = image_get_info($node->gallitems[$pid]->ppath);
}
$item->ppath = $node->gallitems[$pid]->ppath;
$item->boxes_width = 'width:' . $item->preview_size . 'px;max-width:' . $item->preview_size . 'px;_width:' . $item->preview_size . 'px;>width:' . $item->preview_size . 'px;';
$item->ptitle = drupal_set_title(check_plain($node->gallitems[$pid]->ptitle));
$item->pdescription = check_markup($node->gallitems[$pid]->pdescription, $node->gallitems[$pid]->format);
$build_copyright_string = _filter_html(_filter_url($node->gallitems[$pid]->copyright, 1), 1);
$item->copyright = $build_copyright_string;
if ($conf['pager_position'] == 'top') {
$item->top = 1;
}
elseif ($conf['pager_position'] == 'bottom') {
$item->top = 0;
}
else {
$item->top = 3;
}
$node->pid = $pid;
$node_light = new \stdClass();
$node_light->nodetype = $node->type;
$node_light->pager_style = $node->gallconf[$node->type]['xx'];
$extras['pager_position'] = $conf['pager_position'];
$item->pager = count($node->gallitems) > 1 ? theme('gallery_assist_pager', $node_light, $links['all'], $extras) : '';
$link_helper = $node->type == 'gallery_assist' ? '' : '_' . $node->type;
$link = l('edit', 'node/ga_edit_one' . $link_helper . '/' . $item->nid . '/' . $pid);
$adm_link = '<div id="image-box-links"> [ ' . $link . ' ] </div>' . "\n";
$item->adm_link = $user->uid == $node->gallitems[$pid]->uid ? $adm_link : '';
if ($global_node_type_settings['show_download_link'] == 0) {
$item->allow_download = 0;
}
else {
if ($node->gallitems[$pid]->sid != $node->gallconf[$node->type]['show_download_link']) {
$item->allow_download = $node->gallitems[$pid]->sid;
}
else {
$item->allow_download = $node->gallconf[$node->type]['show_download_link'];
}
$item->download_path = file_create_url($node->gallitems[$pid]->opath);
}
$links_graf = $node->gallconf[$node->type]['graphlinks'];
$separator = isset($links_graf) && $links_graf ? '' : ' - ';
$item->link = array();
if ($conf['show_backlink'] == 1) {
$item->link['back'] = $links_graf ? gallery_assist_build_div(l('« ' . t('Back to the gallery'), 'node/' . $node->nid, array(
'attributes' => array(
'title' => t('Back to the gallery'),
'class' => 'ga-back-link',
),
)), 'back-link') : l('« ' . t('Back to the gallery'), 'node/' . $node->nid, array(
'attributes' => array(
'title' => t('Back to the gallery'),
'class' => 'ga-back-link',
),
));
}
if ($conf['gallery_call_type'] > 0) {
$item->link['back'] = gallery_assist_build_div(l('« ' . t('Edit the gallery'), 'node/' . $node->nid . '/edit', array(
'attributes' => array(
'title' => t('Edit the gallery'),
'class' => 'ga-node-edit-link',
),
)), 'node-edit-link');
}
$edit_link_query = array();
if (isset($_GET['page'])) {
$edit_link_query['page'] = $_GET['page'];
}
if (isset($_GET['titles'])) {
$edit_link_query['titles'] = $_GET['titles'];
}
// if (gallery_assist_check_access($node, 'edit')) {
// $item->link['edit'] = $links_graf ? gallery_assist_build_div(l(t('Edit this item'), 'node/ga_edit_one'. $link_helper .'/'. $node->nid .'/'. $pid, array('attributes' => array('title' => t('Edit this item'), 'class' => 'ga-edit-item-link'))), 'edit-item-link') : l(t('Edit this item'), 'node/ga_edit_one'. $link_helper .'/'. $node->nid .'/'. $pid, array('query' => $edit_link_query, 'attributes' => array('title' => t('Edit this item'), 'class' => 'ga-edit-item-link')));
// }
if ($links_graf) {
$item->links = !empty($item->link['back']) ? $item->link['back'] : '';
$item->links .= !empty($item->link['edit']) ? $item->link['edit'] : '';
}
else {
$values = array_values($item->link);
$item->links = gallery_assist_build_div(implode(' - ', $values), 'nav-links');
}
if ($node->gallconf[$node->type]['gap_align'] !== 'node') {
$item->extra_styles = array();
switch ($conf['gap_align']) {
case 'left':
$item->extra_styles = 'margin-right:auto;';
$item->img_extra_styles = 'text-align:left;';
break;
case 'center':
$item->extra_styles = 'margin-left:auto;margin-right:auto;';
$item->img_extra_styles = 'text-align:center;';
break;
case 'right':
$item->extra_styles = 'margin-left:auto;';
$item->img_extra_styles = 'text-align:right;';
break;
}
}
//gallery_assist_add_css('gallery_assist');
$results = array();
$results[] = array(
'#value' => theme('gallery_assist_item', $item),
'#weight' => -20,
);
$output = drupal_render($preview_display);
$node_light = new stdClass();
$node_light->uid = $node->uid;
$node_light->nodetype = $item->nodetype;
$node_light->nid = $node->nid;
$node_light->ref = $node->ref;
$node_light->gid = $node->gid;
$node_light->gref = $node->gref;
$node_light->pid = $pid;
$node_light->preview_size = $item->preview_size;
$node_light->container_width = $item->boxes_width;
$node_light->extra_styles = $item->extra_styles;
$node_light->opath = $node->gallitems[$pid]->opath;
$node_light->info = $img;
foreach (module_implements('gallery_assist_api') as $name) {
$function = $name . '_gallery_assist_api';
$node_light->node_settings = unserialize($node->gallconf[$node->type]['modules'][$name]['data']);
$result = $function('view', $pid, $node_light);
if (is_string($result)) {
$results[$name] = array(
'#value' => $result,
'#weight' => 2000,
);
}
elseif (is_array($result) && count($result) > 0) {
$results[$name] = $result;
if (isset($result['#weight'])) {
$results[$name]['#weight'] = $result['#weight'];
}
}
}
$output .= drupal_render($results);
}
else {
drupal_goto($base_url);
}
return $output;
}
}