07d8996d by Kevin Burton

made a super pagination function

1 parent b799f85c
...@@ -144,7 +144,22 @@ function add_settings_fields($class, $page = 'general', $section = 'default') { ...@@ -144,7 +144,22 @@ function add_settings_fields($class, $page = 'general', $section = 'default') {
144 } 144 }
145 } 145 }
146 146
147 function pagination($pages = null, $range = 2, $before = '', $after = '') { 147 function TzSuperPaginationBar($pages = null, $range = 2, $before = "", $after = "",$show_search = false, $show_advanced = false) {
148
149 $bar = '<div class="TzSuperPaginationBar">';
150 if ($show_search) { $bar .= '<div class="pagination-search"><form><input type="input" style="width:120px;" /></form></div>'; }
151 if ($show_advanced) { $bar .= '<div class="pagination-advanced"><a href="">Advanced</a></div>'; }
152 $bar .= '<div class="pagination-paging">'.pagination($pages,$range,$before,$after,false).'</div>';
153 $bar .= '<div style="clear:both;"></div>';
154 $bar .= '</div>';
155
156 return $bar;
157 }
158
159 function pagination($pages = null, $range = 2, $before = '', $after = '', $echo = true) {
160
161 $p = "";
162
148 $showitems = ($range * 2) + 1; 163 $showitems = ($range * 2) + 1;
149 164
150 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 165 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
...@@ -158,22 +173,26 @@ function pagination($pages = null, $range = 2, $before = '', $after = '') { ...@@ -158,22 +173,26 @@ function pagination($pages = null, $range = 2, $before = '', $after = '') {
158 } 173 }
159 174
160 if (1 != $pages) { 175 if (1 != $pages) {
161 echo $before; 176 $p .= $before;
162 177
163 if ($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='" . get_pagenum_link(1)."'>&laquo;</a>"; 178 if ($paged > 2 && $paged > $range+1 && $showitems < $pages) $p .= "<a href='" . get_pagenum_link(1)."'>&laquo;</a>";
164 if ($paged > 1 && $showitems < $pages) echo "<a href='" . get_pagenum_link($paged - 1) . "'>&lsaquo;</a>"; 179 if ($paged > 1 && $showitems < $pages) $p .= "<a href='" . get_pagenum_link($paged - 1) . "'>&lsaquo;</a>";
165 180
166 for ($i = 1; $i <= $pages; $i++) { 181 for ($i = 1; $i <= $pages; $i++) {
167 if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged-$range-1) || $pages <= $showitems)) { 182 if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged-$range-1) || $pages <= $showitems)) {
168 echo ($paged == $i) ? "<span class='current'>" . $i . "</span>":"<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>"; 183 $p .= ($paged == $i) ? "<span class='current'>" . $i . "</span>":"<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>";
169 } 184 }
170 } 185 }
171 186
172 if ($paged < $pages && $showitems < $pages) echo "<a href='" . get_pagenum_link($paged + 1) . "'>&rsaquo;</a>"; 187 if ($paged < $pages && $showitems < $pages) $p .= "<a href='" . get_pagenum_link($paged + 1) . "'>&rsaquo;</a>";
173 if ($paged < $pages-1 && $paged+$range - 1 < $pages && $showitems < $pages) echo "<a href='" . get_pagenum_link($pages) . "'>&raquo;</a>"; 188 if ($paged < $pages-1 && $paged+$range - 1 < $pages && $showitems < $pages) $p .= "<a href='" . get_pagenum_link($pages) . "'>&raquo;</a>";
174 189
175 echo $after; 190 $p .= $after;
176 } 191 }
192
193 if ($echo) { echo $p; } else { return $p; }
194
195
177 } 196 }
178 197
179 class Vars { 198 class Vars {
......