function gallery_assist_display in Gallery Assist 6
Display the Gallery Assist Container as grid.
1 call to gallery_assist_display()
- gallery_assist_include_display in ./
gallery_assist.module - Display gallery assist container.
1 string reference to 'gallery_assist_display'
- gallery_assist_include_display in ./
gallery_assist.module - Display gallery assist container.
File
- ./
gallery_assist_display.inc, line 15 - 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_display($node, $opt = '', $owner = '') {
global $user;
$conf = $node->gallconf[$node->type];
$conf['opt'] = $opt;
//$my_teaser_count = $conf['items_per_row'];
$my_teaser_count = $conf['t_items_per_row'] > 0 ? $conf['t_items_per_row'] : $conf['items_per_row'];
$my_page_count = $conf['items_per_row'] == 'unlimited' ? count($node->gallitems) : $conf['items_per_row'] * $conf['rows_per_page'];
if ($conf['items_per_row'] == 'unlimited' && $opt == 'teaser') {
//$my_teaser_count = 3;
$my_teaser_count = $conf['t_items_per_row'] > 0 ? $conf['t_items_per_row'] : 3;
}
$my_previous = '‹ previous';
$my_next = 'next ›';
if (count($node->gallitems) == 0) {
return;
}
foreach ($node->gallitems as $pid => $item) {
$img_obj = image_get_info($item->tpath);
if ($img_obj['width'] > $img_obj['height']) {
$img_obj['layout'] = 'h';
}
else {
$img_obj['layout'] = 'v';
}
foreach ($img_obj as $k => $v) {
$node->gallitems[$pid]->{$k} = $v;
$node->gallitems[$pid]->show_title = $node->show_title;
}
$node->gallitems[$pid]->my_nid = $node->nid;
$my_item_box = gallery_assist_item_box($node->type, $node->gallitems[$pid], $conf, $img_obj);
$my_boxes[] = $my_item_box;
$block_boxes[] = $my_item_box;
}
// Prepare the pager OLD VARIANT OF gallery_assist.
$node->gall_pager = new stdClass();
$node->gall_pager->show = $my_page_count;
$node->gall_pager->cshow = $node->gall_pager->show;
$theme = $user->theme ? $user->theme : variable_get('theme_default', FALSE);
$my_pager_layout = $conf['pager_layout'];
$my_grafic_next_path = file_exists(drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/next.png') ? drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/next.png' : drupal_get_path('module', 'gallery_assist') . '/ga_pager/default/next.png';
$my_grafic_next = theme('image', $my_grafic_next_path, '', 'go to the next');
$my_next = $conf['pager_symbol'] == 0 ? t('next ›') : $my_grafic_next;
$my_grafic_previous_path = file_exists(drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/previous.png') ? drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/previous.png' : drupal_get_path('module', 'gallery_assist') . '/ga_pager/default/previous.png';
$my_grafic_previous = theme('image', $my_grafic_previous_path, '', 'go to the previous');
$my_previous = $conf['pager_symbol'] == 0 ? t('‹ previous') : $my_grafic_previous;
$my_separator = $conf['pager_symbol'] == 0 ? ' | ' : ' ';
if ($_GET['page'] == '' || $_GET['page'] == 1) {
$pages = 0;
$page = 2;
$preview = '';
if (count($my_boxes) <= $node->gall_pager->show) {
$next = "";
}
else {
$link_query['page'] = $page;
if (isset($_GET['titles'])) {
$link_query['titles'] = $_GET['titles'];
}
$next = l($my_next, $_GET['q'], array(
'html' => TRUE,
'attributes' => array(
'class' => $node->type . ' pager-next',
),
'query' => $link_query,
));
}
}
else {
$pages = $node->gall_pager->show * ($_GET['page'] - 1);
$page = $_GET['page'];
$node->gall_pager->cshow = $node->gall_pager->show * $_GET['page'];
$link_query['page'] = $_GET['page'] - 1;
if (isset($_GET['titles'])) {
$link_query['titles'] = $_GET['titles'];
}
$preview = l($my_previous, $_GET['q'], array(
'html' => TRUE,
'attributes' => array(
'class' => $node->type . ' pager-previous',
),
'query' => $link_query,
));
if ($node->gall_pager->cshow < count($my_boxes)) {
$link_query['page'] = $_GET['page'] + 1;
if (isset($_GET['titles'])) {
$link_query['titles'] = $_GET['titles'];
}
$next = l($my_next, $_GET['q'], array(
'html' => TRUE,
'query' => $link_query,
));
}
else {
$next = "";
}
}
if (!empty($preview)) {
$link[] = $preview;
}
if (!empty($next)) {
$link[] = $next;
}
// Atrr.
$c_w = $opt == 'teaser' && $node->gallconf[$node->type]['t_items_per_row'] > 0 ? $node->gallconf[$node->type]['t_container_width'] : $node->gallconf[$node->type]['container_width'];
$my_attr_array = array(
//'style' => 'max-width:'. $node->gallconf[$node->type]['container_width'] .'px;',
'style' => 'max-width:' . $c_w . 'px;',
);
$stl = array();
$pstl = array();
switch ($opt) {
case 'teaser':
for ($i = 0; $i < $my_teaser_count; $i++) {
$boxes .= $my_boxes[$i];
}
$node->gallconf[$node->type]['op'] = 'teaser';
if ($conf['ga_align'] != 'none' || $conf['t_ga_float'] != 'none') {
//ALIGN TEASER
switch ($conf['ga_align']) {
case 'left':
$stl['l'] = 'margin-right:auto';
break;
case 'center':
$stl['ml'] = 'margin-left:auto';
$stl['mr'] = 'margin-right:auto';
break;
case 'right':
$stl['r'] = 'margin-left:auto';
break;
}
//FLOAT TEASER
switch ($conf['t_ga_float']) {
case 'left':
$stl['l'] = 'float:left';
$stl['mr'] = 'margin-right:10px';
unset($stl['ml']);
break;
case 'right':
$stl['l'] = 'float:right';
$stl['ml'] = 'margin-left:10px';
unset($stl['mr']);
break;
}
}
// end (styles)
break;
case 'page':
for ($i = $pages; $i < $node->gall_pager->cshow; $i++) {
if (drupal_strlen($my_boxes[$i]) > 0) {
$count[] = 1;
}
$boxes .= $my_boxes[$i];
}
$node->gallconf[$node->type]['op'] = 'page';
if ($conf['gap_align'] != 'none' || $conf['p_ga_float'] != 'none') {
//(styles)
//ALIGN PAGE
$pstlx = $conf['pager_align'] == 'center' ? 'padding-right:10px;' : '';
switch ($conf['gap_align']) {
case 'left':
$stl['l'] = 'margin-right:auto';
$pstl['pl'] = $conf['pager_align'] == 'left' ? 'text-align:left;' : $pstlx . 'text-align:' . $conf['pager_align'];
break;
case 'center':
$stl['ml'] = 'margin-left:auto';
$stl['mr'] = 'margin-right:auto';
$pstlx = 'padding-right:10px;';
$pstl['pl'] = $conf['pager_align'] == 'center' ? 'text-align:center;' . $pstlx : 'text-align:' . $conf['pager_align'];
break;
case 'right':
$stl['r'] = 'margin-left:auto';
$pstl['pl'] = $conf['pager_align'] == 'right' ? 'text-align:right;' : $pstlx . 'text-align:' . $conf['pager_align'];
break;
}
//FLOAT PAGE
switch ($conf['p_ga_float']) {
case 'left':
$stl['l'] = 'float:left';
$stl['mr'] = 'margin-right:10px';
unset($stl['ml']);
break;
case 'right':
$stl['l'] = 'float:right';
$stl['ml'] = 'margin-left:10px';
unset($stl['mr']);
break;
}
}
// end (styles)
break;
}
$my_attr_array['style'] .= implode(';', $stl);
//$extras['container_width'] = $conf['container_width'];
$extras['container_width'] = $opt == 'teaser' ? $conf['t_container_width'] : $conf['container_width'];
$extras['pager_position'] = $conf['pager_position'];
$extras['pager_style'] = implode(';', $pstl);
if (count($my_boxes) > $node->gall_pager->show && $opt == 'page') {
// ericpai implementation to emulate the drupal pager.
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$pages = ceil(count($node->gallitems) / $my_page_count);
if ($conf['ga_pager_show_pages']) {
$links = gallery_assist_emulate_pager_pages($node, $page, $pages, $link);
}
else {
$links = implode($my_separator, $link);
}
$node_light = new stdClass();
$pager = theme('gallery_assist_pager', $node_light, $links, $extras);
}
$node->gallconf[$node->type]['my_attr'] = $node->gallconf[$node->type]['items_per_row'] == 'unlimited' ? '' : drupal_attributes($my_attr_array);
$node->gallconf[$node->type]['nid'] = $node->nid;
if ($owner == 'block') {
$num = count($block_boxes) < $conf['block_gallery_visibles'] ? count($block_boxes) : $conf['block_gallery_visibles'];
$rand_boxes = array_rand($block_boxes, $num);
if (count($rand_boxes) > 1) {
foreach ($rand_boxes as $ks => $divs) {
$bboxes .= $block_boxes[$ks];
unset($block_boxes[$ks]);
}
}
else {
$bboxes .= $block_boxes[0];
}
return theme('gallery_assist_block_display', $bboxes, $node->gallconf[$node->type], $node->type);
}
else {
return theme('gallery_assist_display', $pager, $boxes, $node->gallconf[$node->type], $node->type);
}
}