5 * Functions common to display
23 * Header text to display
25 function displayHeaderText($text) {
27 $ret = "<h2>" . $text . "</h2>
34 * displays header line
36 function displayLine() {
40 <div class='spacer'></div>
41 <div class='spacer'></div>
52 class DisplaySearch extends Display {
57 function DisplaySearch() {
61 * displays search controls
64 * where to align the control
68 * whether to focus control on this block
70 function displaySearchBlock($align,$m,$q,$url_opts,$focus) {
73 if ($align=='center') {
74 $alignText = "class='bar_center'";
77 $alignText = "class='bar_left'";
81 foreach ($url_opts as $key => $value) {
82 $option_text .= "<input type=hidden name=" . $key . " value=" . $value . ">";
86 $ret .= "<div " . $alignText . ">
87 <form class='bar' action='" . $_SESSION['ARI_ROOT'] . "' method='GET' name='search'>
88 <input type=hidden name=m value=" . $m . ">
89 <input type=text name=q size=40 value='" . $q . "' maxlength=256>
91 <input type=hidden name=start value=0>
92 <input type=submit name=btnS value='" . _("Search") . "'>
96 if ($focus=="true") { // search block loaded twice usually so only allow javascript to be loaded on the top block
97 $ret .= "<script type='text/javascript'>
99 if (document.search) {
100 document.search.q.focus();
113 * controls for the page on the bar
117 * start number of current page
119 * number of items on current page
121 * total number of records found by current search
123 function displayInfoBarBlock($controls,$q,$start,$span,$total) {
128 $start_count = ($total>0)?$start+1:$start;
129 $span_count = ($start+$span>$total)?$total:$start+$span;
132 $left_text = $controls;
134 elseif ($q != NULL) {
135 $left_text = "<small><small>" . _("Searched for") . " <u>" . $q . "</u></small></small>";
139 $right_text = "<small><small>" . sprintf(_("Results %d - %d of %d"),$start_count,$span_count,$total) . "</small></small>";
141 $right_text = "<small><small>" . sprintf(_("Results %d"),$total) . "</small></small>";
145 <table id='navbar' width='100%'>
160 * displays navigation bar
165 * start number of current page
167 * number of items on current page
169 * total number of records found by current search
171 function displayNavigationBlock($m,$q,$url_opts,$start,$span,$total) {
173 $start = $start=='' ? 0 : $start ;
174 $span = $span=='' ? 15 : $span ;
176 $total_pages = ceil($total/$span);
177 $start_page = floor($start/$span);
179 // if more than ten pages start at this page minus ten otherwise start at zero
180 $begin = ($start_page>10)?($start_page-10):0;
181 // if more than ten pages then stop at this page plus ten otherwise stop at last page
182 $end = ($start_page>8)?($start_page+10):10;
185 $unicode_q = urlencode($q); // encode search string
187 foreach ($url_opts as $key => $value) {
188 $option_text .= "&" . $key . "=" . $value;
191 $url = $_SESSION['ARI_ROOT'] . "?m=" . $m . "&q=" . $unicode_q . $option_text;
194 if ($start_page!=0) {
195 $start_page_text = "<a href='" . $url . "&start=0'><small>" . _("First") . "</a> </small>
196 <a href=" . $url . "&start=" . ($start-$span) . "><small><</a> </small>";
199 for($next_page=$begin;($next_page<$total_pages)&&($next_page<$end);$next_page++) {
200 if ($next_page == $start_page) {
201 $middle_page_text .= "<small>" . ($next_page+1) . " </small>";
203 $middle_page_text .= "<a href='" . $url . "&start=" . ($next_page*$span) . "'><small>" . ($next_page+1) . "</a> </small>";
206 if ( ($start_page != $total_pages-1) && ($total != 0) ) {
207 $end_page_text = "<a href='" . $url . "&start=" . ($start+$span) . "'><small>></a> </small>
208 <a href='" . $url . "&start=" . ($total_pages-1)*$span . "'><small>" . _("Last") . "</a> </small>";
211 $ret .= "<div class='bar_center'>
212 " . $start_page_text . "
213 " . $middle_page_text . "
214 " . $end_page_text . "