2140 { |
2140 { |
2141 $list[] = $lower + $i; |
2141 $list[] = $lower + $i; |
2142 } |
2142 } |
2143 } |
2143 } |
2144 $url = sprintf($result_url, '0'); |
2144 $url = sprintf($result_url, '0'); |
2145 $link = ( 0 == $start ) ? "<b>" . $lang->get('pagination_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('pagination_btn_first') . "</a>"; |
2145 $link = ( 0 == $start ) ? "<b>" . $lang->get('paginate_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_first') . "</a>"; |
2146 $blk->assign_vars(array( |
2146 $blk->assign_vars(array( |
2147 'CLASS'=>$cls, |
2147 'CLASS'=>$cls, |
2148 'LINK'=>$link |
2148 'LINK'=>$link |
2149 )); |
2149 )); |
2150 $inner .= $blk->run(); |
2150 $inner .= $blk->run(); |
2182 |
2182 |
2183 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2183 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2184 $offset = strval($total); |
2184 $offset = strval($total); |
2185 $url = sprintf($result_url, $offset); |
2185 $url = sprintf($result_url, $offset); |
2186 $j = $i + 1; |
2186 $j = $i + 1; |
2187 $link = ( $offset == strval($start) ) ? "<b>" . $lang->get('pagination_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('pagination_btn_last') . " »</a>"; |
2187 $link = ( $offset == strval($start) ) ? "<b>" . $lang->get('paginate_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_last') . " »</a>"; |
2188 $blk->assign_vars(array( |
2188 $blk->assign_vars(array( |
2189 'CLASS'=>$cls, |
2189 'CLASS'=>$cls, |
2190 'LINK'=>$link |
2190 'LINK'=>$link |
2191 )); |
2191 )); |
2192 $inner .= $blk->run(); |
2192 $inner .= $blk->run(); |
2253 */ |
2253 */ |
2254 |
2254 |
2255 function paginate_array($q, $num_results, $result_url, $start = 0, $perpage = 10, $header = '', $footer = '') |
2255 function paginate_array($q, $num_results, $result_url, $start = 0, $perpage = 10, $header = '', $footer = '') |
2256 { |
2256 { |
2257 global $db, $session, $paths, $template, $plugins; // Common objects |
2257 global $db, $session, $paths, $template, $plugins; // Common objects |
|
2258 global $lang; |
|
2259 |
2258 $num_pages = ceil ( $num_results / $perpage ); |
2260 $num_pages = ceil ( $num_results / $perpage ); |
2259 $out = ''; |
2261 $out = ''; |
2260 $i = 0; |
2262 $i = 0; |
2261 $this_page = ceil ( $start / $perpage ); |
2263 $this_page = ceil ( $start / $perpage ); |
2262 |
2264 |
2263 // Build paginator |
2265 // Build paginator |
2264 $begin = '<div class="tblholder" style="display: table; margin: 10px 0 0 auto;"> |
2266 $begin = '<div class="tblholder" style="display: table; margin: 10px 0 0 auto;"> |
2265 <table border="0" cellspacing="1" cellpadding="4"> |
2267 <table border="0" cellspacing="1" cellpadding="4"> |
2266 <tr><th>Page:</th>'; |
2268 <tr><th>' . $lang->get('paginate_lbl_page') . '</th>'; |
2267 $block = '<td class="row1" style="text-align: center;">{LINK}</td>'; |
2269 $block = '<td class="row1" style="text-align: center;">{LINK}</td>'; |
2268 $end = '</tr></table></div>'; |
2270 $end = '</tr></table></div>'; |
2269 $blk = $template->makeParserText($block); |
2271 $blk = $template->makeParserText($block); |
2270 $inner = ''; |
2272 $inner = ''; |
2271 $cls = 'row2'; |
2273 $cls = 'row2'; |
2272 $total = $num_pages * $perpage - $perpage; |
2274 $total = $num_pages * $perpage - $perpage; |
|
2275 /* |
2273 if ( $start > 0 ) |
2276 if ( $start > 0 ) |
2274 { |
2277 { |
2275 $url = sprintf($result_url, abs($start - $perpage)); |
2278 $url = sprintf($result_url, abs($start - $perpage)); |
2276 $link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_prev') . "</a>"; |
2279 $link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_prev') . "</a>"; |
2277 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2280 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2320 { |
2324 { |
2321 $list[] = $lower + $i; |
2325 $list[] = $lower + $i; |
2322 } |
2326 } |
2323 } |
2327 } |
2324 $url = sprintf($result_url, '0'); |
2328 $url = sprintf($result_url, '0'); |
2325 $link = ( 0 == $start ) ? "<b>" . $lang->get('pagination_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('pagination_btn_first') . "</a>"; |
2329 $link = ( 0 == $start ) ? "<b>" . $lang->get('paginate_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_first') . "</a>"; |
2326 $blk->assign_vars(array( |
2330 $blk->assign_vars(array( |
2327 'CLASS'=>$cls, |
2331 'CLASS'=>$cls, |
2328 'LINK'=>$link |
2332 'LINK'=>$link |
2329 )); |
2333 )); |
2330 $inner .= $blk->run(); |
2334 $inner .= $blk->run(); |
2360 |
2364 |
2361 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2365 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2362 $offset = strval($total); |
2366 $offset = strval($total); |
2363 $url = sprintf($result_url, $offset); |
2367 $url = sprintf($result_url, $offset); |
2364 $j = $i + 1; |
2368 $j = $i + 1; |
2365 $link = ( $offset == strval($start) ) ? "<b>" . $lang->get('pagination_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('pagination_btn_last') . " »</a>"; |
2369 $link = ( $offset == strval($start) ) ? "<b>" . $lang->get('paginate_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_last') . " »</a>"; |
2366 $blk->assign_vars(array( |
2370 $blk->assign_vars(array( |
2367 'CLASS'=>$cls, |
2371 'CLASS'=>$cls, |
2368 'LINK'=>$link |
2372 'LINK'=>$link |
2369 )); |
2373 )); |
2370 $inner .= $blk->run(); |
2374 $inner .= $blk->run(); |
2371 } |
2375 } |
2372 |
2376 |
2373 } |
2377 } |
2374 |
2378 |
|
2379 /* |
2375 if ( $start < $total ) |
2380 if ( $start < $total ) |
2376 { |
2381 { |
2377 $link_offset = abs($start + $perpage); |
2382 $link_offset = abs($start + $perpage); |
2378 $url = htmlspecialchars(sprintf($result_url, strval($link_offset))); |
2383 $url = htmlspecialchars(sprintf($result_url, strval($link_offset))); |
2379 $link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_next') . " »</a>"; |
2384 $link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_next') . " »</a>"; |
2382 'CLASS'=>$cls, |
2387 'CLASS'=>$cls, |
2383 'LINK'=>$link |
2388 'LINK'=>$link |
2384 )); |
2389 )); |
2385 $inner .= $blk->run(); |
2390 $inner .= $blk->run(); |
2386 } |
2391 } |
|
2392 */ |
2387 |
2393 |
2388 $inner .= '<td class="row2" style="cursor: pointer;" onclick="paginator_goto(this, '.$this_page.', '.$num_pages.', '.$perpage.', unescape(\'' . rawurlencode($result_url) . '\'));">↓</td>'; |
2394 $inner .= '<td class="row2" style="cursor: pointer;" onclick="paginator_goto(this, '.$this_page.', '.$num_pages.', '.$perpage.', unescape(\'' . rawurlencode($result_url) . '\'));">↓</td>'; |
2389 |
2395 |
2390 $paginator = "\n$begin$inner$end\n"; |
2396 $paginator = "\n$begin$inner$end\n"; |
2391 if ( $total > 1 ) |
2397 if ( $total > 1 ) |