- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
function box_navigation($gc, $num, $id, $function, $act){
global $tpl, $page;
$gcount = $gc;
$cnt = $num;
$items_count = $cnt;
$items_per_page = $gcount;
$page_refers_per_page = 5;
$pages = '';
$pages_count = ( ( $items_count % $items_per_page != 0 ) ) ? floor( $items_count / $items_per_page ) + 1 : floor( $items_count / $items_per_page );
$start_page = ( $page - $page_refers_per_page <= 0 ) ? 1 : $page - $page_refers_per_page + 1;
$page_refers_per_page_count = ( ( $page - $page_refers_per_page < 0 ) ? $page : $page_refers_per_page ) + ( ( $page + $page_refers_per_page > $pages_count ) ? ( $pages_count - $page ) : $page_refers_per_page - 1 );
if(!$act)
$act = "''";
else
$act = "'{$act}'";
if($page > 1)
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($page-1).', '.$act.'); return false">«</a>';
else
$pages .= '';
if ( $start_page > 1 ) {
$pages .= '<a href="" onClick="'.$function.'('.$id.', 1, '.$act.'); return false">1</a>';
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page-1).', '.$act.'); return false">...</a>';
}
for ( $index = -1; ++$index <= $page_refers_per_page_count-1; ) {
if ( $index + $start_page == $page )
$pages .= '<span>' . ( $start_page + $index ) . '</span>';
else
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page+$index).', '.$act.'); return false">'.($start_page+$index).'</a>';
}
if ( $page + $page_refers_per_page <= $pages_count ) {
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page + $page_refers_per_page_count).', '.$act.'); return false">...</a>';
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.$pages_count.', '.$act.'); return false">'.$pages_count.'</a>';
}
$resif = $cnt/$gcount;
if(ceil($resif) == $page)
$pages .= '';
else
$pages .= '<a href="/" onClick="'.$function.'('.$id.', '.($page+1).', '.$act.'); return false">»</a>';
if ( $pages_count <= 1 )
$pages = '';
$tpl_2 = new mozg_template();
$tpl_2->dir = TEMPLATE_DIR;
$tpl_2->load_template('nav.tpl');
$tpl_2->set('{pages}', $pages);
$tpl_2->compile('content');
$tpl_2->clear();
$tpl->result['content'] .= $tpl_2->result['content'];
}
Zuzik 21.05.2014 14:44 # +2
Vasiliy 21.05.2014 18:41 # +1
dunmaksim 21.05.2014 21:56 # +1