| 182 | | $this->content_tag("ul", array_reduce($object->errors, create_function('$v,$w', 'return ($v ? $v : "") . content_tag("li", $w);'), '')), |
| | 182 | $this->content_tag("ul", array_reduce($errors, create_function('$v,$w', 'return ($v ? $v : "") . content_tag("li", $w);'), '')), |
| | 497 | $base_url = isset($options['base_url']) ? $options['base_url'] : ''; |
| | 498 | $update = isset($options['update']) ? $options['update'] : ''; |
| | 499 | $extra_params = isset($options['extra_params']) ? "&".$options['extra_params'] : |
| | 500 | ($object->paging_extra_params ? "&".$object->paging_extra_params : ''); |
| | 501 | $default_text = isset($options['default_text']) ? $options['default_text'] : "per page:"; |
| | 502 | if($update && $base_url) { |
| | 503 | $on_change = remote_function(array( |
| | 504 | "update" => $update, |
| | 505 | "url" => "{$base_url}?per_page=' + this.options[this.selectedIndex].value + '".escape_javascript($extra_params)."'" |
| | 506 | )); |
| | 507 | } else { |
| | 508 | $on_change = "document.location = '{$base_url}?per_page=' + this.options[this.selectedIndex].value + '".escape_javascript($extra_params)."'"; |
| | 509 | } |
| | 545 | |
| | 546 | $first_text = isset($options['first_text']) ? $options['first_text'] : "<<"; |
| | 547 | $last_text = isset($options['last_text']) ? $options['last_text'] : ">>"; |
| | 548 | $prev_text = isset($options['prev_text']) ? $options['prev_text'] : "<"; |
| | 549 | $next_text = isset($options['next_text']) ? $options['next_text'] : ">"; |
| | 550 | $link_class = isset($options['link_class']) ? $options['link_class'] : "pagingLink"; |
| | 551 | $selected_class = isset($options['selected_class']) ? $options['selected_class'] : "pagingSelected"; |
| | 552 | $base_url = isset($options['base_url']) ? $options['base_url'] : ''; |
| | 553 | $update = isset($options['update']) ? $options['update'] : ''; |
| | 554 | $extra_params = isset($options['extra_params']) ? "&".$options['extra_params'] : |
| | 555 | ($object->paging_extra_params ? "&".$object->paging_extra_params : ''); |
| | 556 | |
| | 557 | $first_width = "width:".(isset($options['first_width']) ? $options['first_width'] : '20')."px;"; # size in pixels |
| | 558 | $first_width = ( |
| | 559 | ( isset($options['first_text']) && isset($options['first_width']) ) || |
| | 560 | ( !isset($options['first_text']) && !isset($options['first_width']) ) |
| | 561 | ) ? $first_width : ''; |
| | 562 | $last_width = "width:".(isset($options['last_width']) ? $options['last_width'] : '20')."px;"; # size in pixels |
| | 563 | $last_width = ( |
| | 564 | ( isset($options['last_text']) && isset($options['last_width']) ) || |
| | 565 | ( !isset($options['last_text']) && !isset($options['last_width']) ) |
| | 566 | ) ? $last_width : ''; |
| | 567 | $prev_width = "width:".(isset($options['prev_width']) ? $options['prev_width'] : '10')."px;"; # size in pixels |
| | 568 | $prev_width = ( |
| | 569 | ( isset($options['prev_text']) && isset($options['prev_width']) ) || |
| | 570 | ( !isset($options['prev_text']) && !isset($options['prev_width']) ) |
| | 571 | ) ? $prev_width : ''; |
| | 572 | $next_width = "width:".(isset($options['next_width']) ? $options['next_width'] : '10')."px;"; # size in pixels |
| | 573 | $next_width = ( |
| | 574 | ( isset($options['next_text']) && isset($options['next_width']) ) || |
| | 575 | ( !isset($options['next_text']) && !isset($options['next_width']) ) |
| | 576 | ) ? $next_width : ''; |
| | 577 | $pages_width = isset($options['fixed_pages']) ? "width:".$options['fixed_pages']."px;" : ''; # size in pixels |
| 535 | | if(($object->page != 1) && ($object->page)) { |
| 536 | | $html .= link_to("<<", |
| 537 | | "?$object->paging_extra_params&page=1&per_page=$object->rows_per_page", |
| 538 | | array( |
| 539 | | "class" => "pageList", |
| 540 | | "title" => "First page" |
| 541 | | ))." "; |
| 542 | | } |
| 543 | | if(($object->page-1) > 0) { |
| 544 | | $html .= link_to("<", |
| 545 | | "?$object->paging_extra_params&page=".($object->page-1)."&per_page=$object->rows_per_page", |
| 546 | | array( |
| 547 | | "class" => "pageList", |
| 548 | | "title" => "Previous Page" |
| 549 | | )); |
| 550 | | } |
| 551 | | |
| | 583 | if(($object->page != 1) && ($object->page) && $first_text) { |
| | 584 | if($update && $base_url) { |
| | 585 | $html .= link_to_remote($first_text, array( |
| | 586 | "update" => $update, |
| | 587 | "url" => "{$base_url}?page=1&per_page={$object->rows_per_page}{$extra_params}" |
| | 588 | ), array( |
| | 589 | "class" => $link_class, |
| | 590 | "title" => "First page" |
| | 591 | ))." "; |
| | 592 | } else { |
| | 593 | $html .= link_to($first_text, "{$base_url}?page=1&per_page={$object->rows_per_page}{$extra_params}", array( |
| | 594 | "class" => $link_class, |
| | 595 | "title" => "First page" |
| | 596 | ))." "; |
| | 597 | } |
| | 598 | } else { |
| | 599 | $html .= " "; |
| | 600 | } |
| | 601 | $html .= "</div>"; |
| | 602 | $html .= "<div class=\"pagingPrev\" style=\"{$prev_width}text-align:left;display:inline;float:left\">"; |
| | 603 | if(($object->page-1) > 0 && $prev_text) { |
| | 604 | if($update && $base_url) { |
| | 605 | $html .= link_to_remote($prev_text, array( |
| | 606 | "update" => $update, |
| | 607 | "url" => "{$base_url}?page=".($object->page-1)."&per_page={$object->rows_per_page}{$extra_params}" |
| | 608 | ), array( |
| | 609 | "class" => $link_class, |
| | 610 | "title" => "Previous page" |
| | 611 | )); |
| | 612 | } else { |
| | 613 | $html .= link_to($prev_text, "{$base_url}?page=".($object->page-1)."&per_page={$object->rows_per_page}{$extra_params}", array( |
| | 614 | "class" => $link_class, |
| | 615 | "title" => "Previous page" |
| | 616 | )); |
| | 617 | } |
| | 618 | } else { |
| | 619 | $html .= " "; |
| | 620 | } |
| | 621 | $html .= "</div>"; |
| 593 | | |
| 594 | | /* Print the Next and Last page links if necessary */ |
| 595 | | if(($object->page+1) <= $object->pages) { |
| 596 | | $html .= link_to(">", |
| 597 | | "?$object->paging_extra_params&page=".($object->page+1)."&per_page=$object->rows_per_page", |
| 598 | | array( |
| 599 | | "class" => "pageList", |
| 600 | | "title" => "Next Page" |
| 601 | | )); |
| 602 | | } |
| 603 | | if(($object->page != $object->pages) && ($object->pages != 0)) { |
| 604 | | $html .= link_to(">>", |
| 605 | | "?$object->paging_extra_params&page=".$object->pages."&per_page=$object->rows_per_page", |
| 606 | | array( |
| 607 | | "class" => "pageList", |
| 608 | | "title" => "Last Page" |
| 609 | | )); |
| 610 | | } |
| 611 | | $html .= "\n"; |
| | 673 | $html .= "</div>"; |
| | 674 | $html .= "<div class=\"pagingNext\" style=\"{$next_width}text-align:right;display:inline;float:left\">"; |
| | 675 | # Print the Next and Last page links if necessary |
| | 676 | if(($object->page+1) <= $object->pages && $next_text) { |
| | 677 | if($update && $base_url) { |
| | 678 | $html .= link_to_remote($next_text, array( |
| | 679 | "update" => $update, |
| | 680 | "url" => "{$base_url}?page=".($object->page+1)."&per_page={$object->rows_per_page}{$extra_params}" |
| | 681 | ), array( |
| | 682 | "class" => $link_class, |
| | 683 | "title" => "Next Page" |
| | 684 | )); |
| | 685 | } else { |
| | 686 | $html .= link_to($next_text, "{$base_url}?page=".($object->page+1)."&per_page={$object->rows_per_page}{$extra_params}", array( |
| | 687 | "class" => $link_class, |
| | 688 | "title" => "Next Page" |
| | 689 | )); |
| | 690 | } |
| | 691 | } else { |
| | 692 | $html .= " "; |
| | 693 | } |
| | 694 | $html .= "</div>"; |
| | 695 | $html .= "<div class=\"pagingLast\" style=\"{$last_width}text-align:right;display:inline;float:left\">"; |
| | 696 | if(($object->page != $object->pages) && ($object->pages != 0) && $last_text) { |
| | 697 | if($update && $base_url) { |
| | 698 | $html .= link_to_remote($last_text, array( |
| | 699 | "update" => $update, |
| | 700 | "url" => "{$base_url}?page=".$object->pages."&per_page={$object->rows_per_page}{$extra_params}" |
| | 701 | ), array( |
| | 702 | "class" => $link_class, |
| | 703 | "title" => "Last Page" |
| | 704 | )); |
| | 705 | } else { |
| | 706 | $html .= link_to($last_text, "{$base_url}?page=".$object->pages."&per_page={$object->rows_per_page}{$extra_params}", array( |
| | 707 | "class" => $link_class, |
| | 708 | "title" => "Last Page" |
| | 709 | )); |
| | 710 | } |
| | 711 | } else { |
| | 712 | $html .= " "; |
| | 713 | } |
| | 714 | $html .= "</div>"; |
| | 715 | $html .= "</div>\n"; |