class GalleryAssistPager in Gallery Assist 7
Same name in this branch
- 7 libs/classes/GalleryAssistPager.php \GalleryAssistPager
- 7 libs/classes/GalleryAssistPager.inc \GalleryAssistPager
- 7 libs/classes/GalleryAssistPager_ORIG.inc \GalleryAssistPager
Hierarchy
- class \GalleryAssistPager
Expanded class hierarchy of GalleryAssistPager
File
- libs/
classes/ GalleryAssistPager_ORIG.inc, line 5
View source
class GalleryAssistPager {
public function __construct($node) {
#global $_DB, $_CONFIG;
$this->node = $node;
$this->total = count($node->ga_items_ids);
$this->ids = $node->ga_items_ids;
$this->conf = $node->ga_conf[$node->type];
// dsm($this->ids);
}
public function getPager($node, $extras = NULL) {
$conf = $node->ga_conf[$node->type];
$my_quantity = $conf['pager_quantity'];
$my_total = count($node->ga_items_ids);
if (count($node->ga_items_ids) <= 1) {
return '';
}
$data = array();
$i = 0;
foreach ($node->ga_items_ids as $k => $v) {
++$i;
$data[$i] = $node->ga_items_ids[$k];
$data[$i]->opath = $node->ga_items_ids[$k]->opath;
$node->ga_items_ids[$k]->counter = $i;
}
$my_page = isset($node->ga_items_ids[$node->pid]->counter) ? $node->ga_items_ids[$node->pid]->counter : 1;
$max_vis = $conf['pager_quantity'] < $my_total ? $conf['pager_quantity'] : $my_total + 2;
$my_quantity = $my_total > $my_quantity ? $max_vis : $my_total;
$my_short = $my_total > $my_quantity - 2 ? 1 : 0;
$my_odd = $my_quantity & 1;
$my_n = $my_odd == 1 ? 0 : 1;
$my_middle = ceil($my_quantity / 2);
$my_attributes = array(
'class' => array(
$node->type,
'pager',
),
);
// if ($conf['gap_align'] !== 'node') {
// switch ($conf['gap_align']) {
// case 'left' :
// $my_attributes['style'] = $conf['pager_align'] == 'left' ? 'text-align:left;' : 'text-align:'. $conf['pager_align'];
// break;
//
// case 'center' :
// $my_attributes['style'] = $conf['pager_align'] == 'center' ? 'text-align:center;' : 'text-align:'. $conf['pager_align'];
// break;
//
// case 'right' :
// $my_attributes['style'] = $conf['pager_align'] == 'right' ? 'text-align:right;' : 'text-align:'. $conf['pager_align'];
// break;
// }
// }
$my_active_opts = array(
'attributes' => array(
'class' => array(
$node->type,
'active',
),
),
'html' => TRUE,
);
$theme = variable_get('theme_default', FALSE);
$my_pager_layout = $conf['pager_theme'];
$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', array(
'path' => file_create_filename($my_grafic_previous_path, NULL),
'title' => t('go to the previous'),
'getsize' => TRUE,
));
$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', array(
'path' => file_create_filename($my_grafic_next_path, NULL),
'title' => t('go to the next'),
'getsize' => TRUE,
));
if ($conf['pager_format'] == 0) {
$my_grafic_first_path = file_exists(drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/first.png') ? drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/first.png' : drupal_get_path('module', 'gallery_assist') . '/ga_pager/default/first.png';
$my_grafic_first = theme('image', array(
'path' => file_create_filename($my_grafic_first_path, NULL),
'title' => t('go to the first'),
'getsize' => TRUE,
));
$my_grafic_hellip_path = file_exists(drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/hellip.png') ? drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/hellip.png' : drupal_get_path('module', 'gallery_assist') . '/ga_pager/default/hellip.png';
$my_grafic_hellip = theme('image', array(
'path' => file_create_filename($my_grafic_hellip_path, NULL),
'getsize' => TRUE,
));
$my_grafic_last_path = file_exists(drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/last.png') ? drupal_get_path('theme', $theme) . '/ga_pager/' . $my_pager_layout . '/last.png' : drupal_get_path('module', 'gallery_assist') . '/ga_pager/default/last.png';
$my_grafic_last = theme('image', array(
'path' => file_create_filename($my_grafic_last_path, NULL),
'title' => t('go to the last'),
'getsize' => TRUE,
));
$my_first = $conf['pager_type'] == 0 ? t('« first') : $my_grafic_first;
$my_last = $conf['pager_type'] == 0 ? t('last »') : $my_grafic_last;
$my_hellip = $conf['pager_type'] == 0 ? '…' : $my_grafic_hellip;
}
dsm($conf);
$my_previous = $conf['pager_type'] == 0 || $my_quantity == 0 ? t('‹ previous') : $my_grafic_previous;
$my_next = $conf['pager_type'] == 0 || $my_quantity == 0 ? t('next ›') : $my_grafic_next;
$link_helper = $node->type == 'gallery_assist' ? '' : '_' . $node->type;
$my_pager_paths = $extras == 'edit-one' ? 'node/ga_edit_one' . $link_helper . '/' . $node->nid . '/item/' : 'node/' . $node->nid . '/item/';
$get_values = array();
$get_values = $_GET;
unset($get_values['q']);
$my_active_opts['query'] = $get_values;
// $link = l('[edit]', 'node/ga_edit_one/'. $item->nid .'/'. $item->pid, array('query' => $get_values));
if ($my_quantity > 0) {
$before[] = array(
'class' => array(
$node->type,
'pager-first',
),
'data' => $my_page > 1 ? l($my_first, $my_pager_paths . $data[1]->pid, $my_active_opts) : $my_first,
);
}
$before[] = array(
'class' => array(
$node->type,
'pager-previous',
),
'data' => $my_page == 1 ? l($my_previous, $my_pager_paths . $data[$my_total]->pid, $my_active_opts) : l($my_previous, $my_pager_paths . $data[$my_page - 1]->pid, $my_active_opts),
);
if ($my_quantity > 0 && $conf['pager_format'] == 0) {
$before[] = array(
'class' => array(
$node->type,
'pager-ellipsis',
),
'data' => $my_short == 1 && $my_page > $my_middle ? $my_hellip : ' ',
);
}
$c = 1;
$links = array();
foreach ($data as $k => $v) {
if ($c == $my_page) {
$my_clss = 'pager-current';
if (module_exists('imagecache') && is_numeric($conf['pager_presetid'])) {
$my_mini = theme('imagecache', $conf['pager_presetname'], $data[$c]->opath, '', $c . ' / ' . $my_total, array(
'class' => array(
$node->type,
'pager-thumbnail ic-on',
),
), FALSE);
}
else {
#$my_mini = theme('image', file_create_url($data[$c]->thmb_path), '', $c .' / '. $my_total, array('height' => $conf['pager_t_active_height'], 'class' => array($node->type, 'gallery-assist-thumbnail')), FALSE);
$variables = array(
'path' => $data[$c]->opath,
#'alt' => $data[$c]->palt,
'title' => $c . ' / ' . $my_total,
'getsize' => FALSE,
'style_name' => $node->ga_conf[$node->type]['icon_image_style'],
'attributes' => array(
'class' => array(
'ga-pager-active-image',
),
'height' => $conf['pager_thm_active_height'],
),
);
$my_mini = theme('image_style', $variables);
}
$my_pager_layout_def = $extras == 'edit-one' ? 1 : $conf['pager_type'];
$my_data = $my_pager_layout_def == 1 ? $my_mini : $c;
}
else {
$my_clss = 'pager-item';
if (module_exists('imagecache') && is_numeric($conf['pager_presetid'])) {
$my_mini = theme('imagecache', $conf['pager_presetname'], $data[$c]->opath, '', $c . ' / ' . $my_total, array(
'class' => array(
$node->type,
'pager-thumbnail ic-off',
),
), FALSE);
}
else {
#$my_mini = theme('image', file_create_url($data[$c]->thmb_path), '', $c .' / '. $my_total, array('height' => $conf['pager_t_height'], 'id' => 'pager-icon', 'class' => array($node->type, ' gallery-assist-thumbnail')), FALSE);
$variables = array(
'path' => $data[$c]->opath,
#'alt' => $data[$c]->palt,
'title' => $c . ' / ' . $my_total,
'getsize' => FALSE,
'style_name' => $node->ga_conf[$node->type]['icon_image_style'],
'attributes' => array(
'class' => array(
'ga-pager-image',
),
'height' => $conf['pager_thm_height'],
),
);
$my_mini = theme('image_style', $variables);
}
$my_pager_layout_def = $extras == 'edit-one' ? 1 : $conf['pager_type'];
$my_symbol = $my_pager_layout_def == 1 ? $my_mini : $c;
$my_data = l($my_symbol, $my_pager_paths . $data[$c]->pid, $my_active_opts);
}
$links[] = array(
'class' => array(
$node->type,
$my_clss,
),
'data' => $my_data,
);
$c++;
}
$mylinks = $links;
if ($my_short == 1 && $my_total > $my_quantity) {
if ($my_page > $my_total - $my_quantity) {
if ($my_page + $my_middle - $my_odd < $my_total) {
$mysmall = array_slice($links, $my_page - $my_middle, $my_quantity, TRUE);
}
else {
$mysmall = array_slice($links, $my_total - $my_quantity, $my_quantity, TRUE);
}
}
elseif ($my_page <= $my_quantity) {
if ($my_page >= $my_middle) {
$mysmall = array_slice($links, $my_page - $my_middle, $my_quantity, TRUE);
}
else {
$mysmall = array_slice($links, 0, $my_quantity, TRUE);
}
}
else {
$mysmall = array_slice($links, $my_page - $my_middle, $my_middle + $my_middle - $my_odd, TRUE);
}
}
else {
$mysmall = array(
'',
);
}
$my_after_data = $my_short == 1 && $my_page + $my_middle + $my_n <= $my_total ? $my_hellip : ' ';
if ($my_quantity > 0 && $conf['pager_format'] == 0) {
$after[] = array(
'class' => array(
$node->type,
'pager-ellipsis',
),
'data' => $my_after_data,
);
}
$after[] = array(
'class' => array(
$node->type,
'pager-next',
),
'data' => $my_page == $my_total ? l($my_next, $my_pager_paths . $data[1]->pid, $my_active_opts) : l($my_next, $my_pager_paths . $data[$my_page + 1]->pid, $my_active_opts),
);
if ($my_quantity > 0 && $conf['pager_format'] == 0) {
$after[] = array(
'class' => array(
$node->type,
'pager-last',
),
'data' => $my_page == count($node->ga_items_ids) ? $my_last : l($my_last, $my_pager_paths . $data[$my_total]->pid, $my_active_opts),
);
}
if ($my_short == 1) {
$mylinks = $mysmall;
}
else {
$mylinks = $links;
}
$olinks = array_merge($before, $mylinks, $after);
$variables = array(
'items' => $olinks,
'title' => NULL,
'type' => 'ul',
'attributes' => array(
'id' => "gallery-assist-pager-{$node->nid}",
'class' => array(
'gallery-assist-pager',
),
),
);
$output = theme('item_list', $variables);
return $output;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GalleryAssistPager:: |
public | function | ||
GalleryAssistPager:: |
public | function |