You are here

function gallery_assist_image_box in Gallery Assist 6

Build and return the image box.

1 call to gallery_assist_image_box()
gallery_assist_item_box in ./gallery_assist_display.inc
Build and return the gallery item box.

File

./gallery_assist_display.inc, line 344
Build and display the Gallery Assist Container. This file will be included if the parameter "show_layout" is setted to "grid"

Code

function gallery_assist_image_box($type, $item, $conf, $img) {
  global $user;
  if ($conf['shadow'] == 1) {
    $withshadow = ' shadow3';
    drupal_add_css(drupal_get_path('module', 'gallery_assist') . '/css/gallery_assist_shadow.css', 'module', 'all', FALSE);
  }
  if (variable_get('gallery_assist_use_imagecache', 0) == 1 && $conf['force_image_height'] == 1) {
    $my_image_height = $conf['thumbnail_height_size'];
    $my_box_attr = array(
      'id' => 'image-box-' . $item->pid,
      'class' => $type . ' image-box' . $withshadow,
      'style' => 'height:' . $my_image_height . 'px;' . 'width:' . $conf['thumbnail_size'] + $conf['item_padding'] * 2 . 'px;',
    );
    if ($conf['item_padding'] > 0) {
      $my_box_attr['style'] .= 'padding:' . $conf['item_padding'] . 'px;';
    }
    if ($conf['item_border'] > 0) {
      $my_box_attr['style'] .= 'border:' . $conf['item_border'] . 'px solid ' . $conf['item_border_color'] . ';';
    }
    $my_sheet_attr = array(
      'id' => 'image-sheet-' . $item->pid,
      'class' => $type . ' image-sheet' . $my_img_behavior,
      'style' => 'height:' . $my_image_height . 'px;' . 'width:' . $conf['thumbnail_size'] . 'px;',
    );
    $img = gallery_assist_image_more_info($type, $img, $conf, $my_image_height);
    $my_layout = $img['pos'] == 'v' ? 'height' : 'width';
    $my_img_attr = array(
      $my_layout => $conf['thumbnail_size'],
      'style' => 'margin-top:' . $img['top'] . 'px;',
    );
  }
  else {
    $my_box_attr = array(
      'id' => 'image-box-' . $item->pid,
      'class' => $type . ' image-box' . $withshadow,
      'style' => 'height:' . $conf['thumbnail_size'] + $conf['item_padding'] * 2 . 'px;' . 'width:' . $conf['thumbnail_size'] + $conf['item_padding'] * 2 . 'px;',
    );
    if ($conf['item_padding'] > 0) {
      $my_box_attr['style'] .= 'padding:' . $conf['item_padding'] . 'px;';
    }
    if ($conf['item_border'] > 0) {
      $my_box_attr['style'] .= 'border:' . $conf['item_border'] . 'px solid ' . $conf['item_border_color'] . ';';
    }

    //$my_box_attr['style'] .= 'position:relative;';
    $my_sheet_attr = array(
      'id' => 'image-sheet-' . $item->pid,
      'class' => $type . ' image-sheet' . $my_img_behavior,
      'style' => 'height:' . $conf['thumbnail_size'] . 'px;' . 'width:' . $conf['thumbnail_size'] . 'px;',
    );
    $img = gallery_assist_image_more_info($type, $img, $conf);
    $my_layout = $img['pos'] == 'v' ? 'height' : 'width';
    $my_img_attr = array(
      $my_layout => $conf['thumbnail_size'],
      'style' => 'margin-top:' . $img['top'] . 'px;',
    );
  }

  // without
  $edit_link_attr = array(
    'class' => $type . ' ga-item-edit-link',
    'style' => 'position:absolute;top:0px;left:0px;width:100%;',
  );
  $item->my_img_attr = $my_img_attr;
  $my_img = gallery_assist_prepare_thms($item, $conf);
  $get_values = $_GET;
  unset($get_values['q']);
  $edit_text = t('[edit]');
  $delete_text = t('[delete]');
  $cover_text = t('[cover]');
  $elink = l($edit_text, 'node/ga_edit_one/' . $item->my_nid . '/' . $item->pid, array(
    'query' => $get_values,
  ));
  $elink .= l($delete_text, 'node/ga_del_one/' . $item->my_nid . '/' . $item->pid, array(
    'query' => $get_values,
  ));
  $elink .= $item->cover == 1 ? '' : l($cover_text, 'ga_item_to_cover/' . $item->my_nid . '/' . $item->pid, array(
    'query' => $get_values,
  ));
  $node = new stdClass();
  $node->nid = $item->my_nid;
  $node->uid = $item->uid;
  $node->type = $type;
  $edit_link = $user->uid == 1 || $user->uid == $item->uid || gallery_assist_check_access($node, 'edit') ? $elink : '';
  $link_query = array();
  if (isset($_GET['page'])) {
    $link_query['page'] = $_GET['page'];
  }
  if (isset($_GET['titles'])) {
    $link_query['titles'] = $_GET['titles'];
  }
  $lb_item_link = gallery_assist_build_item_hyperlink($my_img, $item, $link_query, $conf);
  $output = '<div' . drupal_attributes($my_box_attr) . '>' . "\n";
  $output .= '<div' . drupal_attributes($my_sheet_attr) . '>' . "\n";
  $output .= '    ' . $lb_item_link;
  $output .= '</div>' . "\n";
  $output .= '</div>' . "\n";
  $output .= '<div' . drupal_attributes($edit_link_attr) . '>' . $edit_link . '</div>' . "\n";
  return $output;
}