histogram: Make histograms crash less
[ninja.git] / application / views / pagination / digg.php
blobe60bc7ca466d6cafea4e97caeb3ea418b73ea1c9
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 if (!isset($_SESSION['_pagination_id_'])) {
3 $_SESSION['_pagination_id_'] = 1;
4 } else {
5 switch ($_SESSION['_pagination_id_']) {
6 case 1:
7 $_SESSION['_pagination_id_'] = 2;
8 break;
9 case 2:
10 $_SESSION['_pagination_id_'] = 1;
11 break;
12 default:
13 $_SESSION['_pagination_id_'] = 1;
18 /**
19 * Digg pagination style
21 * @preview « Previous 1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26 Next »
23 if (!empty($total_items)) {
24 $label_previous = '<span class="icon-16 x16-arrow-left" title="'._('Previous').'"></span>';
25 $label_next = '<span class="icon-16 x16-arrow-right" title="'._('Next').'"></span>';
28 <div class="pagination_container">
29 <?php
30 $paging_step = config::get('pagination.paging_step', '*'); # step used below to print nr of items per page
31 $max_items_per_page = config::get('pagination.max_items_per_page', '*'); # maximum items per page to show
32 $entries = _('entries');
33 if (!isset($items_per_page)) {
34 $items_per_page = config::get('pagination.items_per_page', '*');
37 $other_get_params = $_GET;
38 unset( $other_get_params['page'] );
39 unset( $other_get_params['items_per_page'] );
40 unset( $other_get_params['custom_pagination_field'] );
41 unset( $other_get_params['show_pagination'] );
44 <span class="pagination_entries_str" style="display:none"><?php echo $entries ?></span>
46 <div class="pagination_form">
47 <form action="<?php echo basename($_SERVER['PHP_SELF']) ?>" method="get">
48 <fieldset>
49 <?php foreach( $other_get_params as $key => $val ) { ?>
50 <input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val) ?>" />
51 <?php } ?>
52 <select class="auto" id="sel_items_<?php echo $_SESSION['_pagination_id_'] ?>" class="items_per_page" name="items_per_page" onchange="preserve_get_params('sel', $(this).attr('id'));this.form.submit()">
53 <?php
54 if ($total_items < $paging_step) {
56 <option value="<?php echo $total_items ?>" selected="selected"><?php echo $total_items ?> <?php echo $entries ?></option>
57 <?php
58 } else {
60 <option value="<?php echo $total_items ?>"<?php if ($items_per_page == $total_items) { ?> selected='selected'<?php } ?>><?php echo _('All').' '.$entries ?></option>
61 <?php
63 if( $items_per_page < $paging_step ) {
64 ?><option value="<?php echo $items_per_page; ?>" selected='selected'><?php echo $items_per_page; ?> <?php echo $entries ?></option><?php
66 for ($i=$paging_step ; $i<$total_items && $i<=$max_items_per_page; $i+=$paging_step ) {
67 ?><option value="<?php echo $i ?>"<?php if ($items_per_page == $i) { ?> selected='selected'<?php } ?>><?php echo $i ?> <?php echo $entries ?></option><?php
68 if( $items_per_page > $i && $items_per_page < ($i+$paging_step) ) {
69 ?><option value="<?php echo $items_per_page; ?>" selected='selected'><?php echo $items_per_page; ?> <?php echo $entries ?></option><?php
73 </select>
75 <input
76 type="text" size="4" name="custom_pagination_field" id="pagination_id_<?php echo $_SESSION['_pagination_id_'] ?>" class="custom_pagination_field"
77 title="<?php echo _('Enter number of items to show on each page or select from the drop-down on the left') ?>"
78 value="<?php echo $total_items < $items_per_page ? $total_items : $items_per_page ?>" />
79 <input type="submit" name="show_pagination" class="show_pagination" value="<?php echo _('Go') ?>" />
80 </fieldset>
81 </form>
82 </div>
84 <div class="pagination">
85 <?php $url = str_replace('&','&amp;',$url); ?>
86 <?php if ($previous_page): ?>
87 <a href="<?php echo str_replace('{page}', $previous_page, $url) ?>" class="img prevpage"><?php echo $label_previous ?></a>
88 <?php else: ?>
89 <?php echo $label_previous ?>
90 <?php endif ?>
93 <?php if ($total_pages < 13): /* « Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next » */ ?>
95 <?php for ($i = 1; $i <= $total_pages; $i++): ?>
96 <?php if ($i == $current_page): ?>
97 <strong><?php echo $i ?></strong>
98 <?php else: ?>
99 <a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
100 <?php endif ?>
101 <?php endfor ?>
103 <?php elseif ($current_page < 9): /* « Previous 1 2 3 4 5 6 7 8 9 10 … 25 26 Next » */ ?>
105 <?php for ($i = 1; $i <= 10; $i++): ?>
106 <?php if ($i == $current_page): ?>
107 <strong><?php echo $i ?></strong>
108 <?php else: ?>
109 <a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
110 <?php endif ?>
111 <?php endfor ?>
113 &hellip;
114 <a href="<?php echo str_replace('{page}', $total_pages - 1, $url) ?>"><?php echo $total_pages - 1 ?></a>
115 <a href="<?php echo str_replace('{page}', $total_pages, $url) ?>"><?php echo $total_pages ?></a>
117 <?php elseif ($current_page > $total_pages - 8): /* « Previous 1 2 … 17 18 19 20 21 22 23 24 25 26 Next » */ ?>
119 <a href="<?php echo str_replace('{page}', 1, $url) ?>">1</a>
120 <a href="<?php echo str_replace('{page}', 2, $url) ?>">2</a>
121 &hellip;
123 <?php for ($i = $total_pages - 9; $i <= $total_pages; $i++): ?>
124 <?php if ($i == $current_page): ?>
125 <strong><?php echo $i ?></strong>
126 <?php else: ?>
127 <a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
128 <?php endif ?>
129 <?php endfor ?>
131 <?php else: /* « Previous 1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26 Next » */ ?>
133 <a href="<?php echo str_replace('{page}', 1, $url) ?>">1</a>
134 <a href="<?php echo str_replace('{page}', 2, $url) ?>">2</a>
135 &hellip;
137 <?php for ($i = $current_page - 5; $i <= $current_page + 5; $i++): ?>
138 <?php if ($i == $current_page): ?>
139 <strong><?php echo $i ?></strong>
140 <?php else: ?>
141 <a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
142 <?php endif ?>
143 <?php endfor ?>
145 &hellip;
146 <a href="<?php echo str_replace('{page}', $total_pages - 1, $url) ?>"><?php echo $total_pages - 1 ?></a>
147 <a href="<?php echo str_replace('{page}', $total_pages, $url) ?>"><?php echo $total_pages ?></a>
149 <?php endif ?>
152 <?php if ($next_page): ?>
153 <a href="<?php echo str_replace('{page}', $next_page, $url) ?>" class="img nextpage"><?php echo $label_next ?></a>
154 <?php else: ?>
155 <?php echo $label_next ?>
156 <?php endif ?>
157 <?php //echo '&nbsp; (' . _('total') . ': ' . $total_items . ' ' . _('entries') . ')' ?>
161 </div>
162 </div>
163 <?php } ?>