summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIneiev <ineiev@gnu.org>2024-10-28 06:22:09 +0000
committerIneiev <ineiev@gnu.org>2024-11-06 15:51:59 +0000
commitca90891f03d1e1eab4d356d8bceb23fb4109ed3a (patch)
tree03cb33ba996b4b8ab67544bf461a5a1781bc0447
parent1bddf8c5cd6c09ea40d308d8e93527120da3bf6b (diff)
downloadsavane-ca90891f03d1e1eab4d356d8bceb23fb4109ed3a.tar.gz
(html_nextprev): show matching items
-rw-r--r--frontend/php/bugs/dependencies.php15
-rw-r--r--frontend/php/include/html.php80
-rw-r--r--frontend/php/include/trackers/general.php7
-rw-r--r--frontend/php/include/trackers/view-dependencies.php23
-rw-r--r--frontend/php/search/index.php19
-rw-r--r--frontend/php/siteadmin/grouplist.php14
-rw-r--r--frontend/php/siteadmin/spamlist.php2
-rw-r--r--frontend/php/siteadmin/usergroup.php10
-rw-r--r--frontend/php/siteadmin/userlist.php12
9 files changed, 89 insertions, 93 deletions
diff --git a/frontend/php/bugs/dependencies.php b/frontend/php/bugs/dependencies.php
index 5c6bb7c2..4aa3e2d4 100644
--- a/frontend/php/bugs/dependencies.php
+++ b/frontend/php/bugs/dependencies.php
@@ -59,20 +59,13 @@ foreach ($includes as $i)
extract (sane_import ('request',
[
'true' => 'include_closed',
- 'digits' => ['chunksz', ['offset', [0, 410338673]]]
+ 'digits' => ['max_rows', ['offset', [0, 410338673]]]
]
));
-extract (sane_import ('get', ['digits' => [['max_rows', [1, 4913]]]]));
-if (!empty ($max_rows))
- $chunksz = $max_rows;
-
-$default_chunksz = 10;
-if (empty ($chunksz))
- $chunksz = $default_chunksz;
-$chunksz = intval ($chunksz);
-if ($chunksz <= 0)
- $chunksz = $default_chunksz;
+if (empty ($max_rows))
+ $max_rows = 10;
+$max_rows = intval ($max_rows);
trackers_view_dependencies ($list_format);
?>
diff --git a/frontend/php/include/html.php b/frontend/php/include/html.php
index abafff3a..899e2821 100644
--- a/frontend/php/include/html.php
+++ b/frontend/php/include/html.php
@@ -165,62 +165,68 @@ function html_image_dir ($theme, $suffix = null)
function html_nextprev_link ($url, $offset, $max_rows)
{
- print "<a href=\"$url&amp;offset="
+ return "<a href=\"$url&amp;offset="
. "$offset&amp;max_rows=" . utils_specialchars ($max_rows) . "#results\">";
}
-function html_print_prev ($url, $offset, $max_rows)
+function html_prev ($url, $offset, $max_rows, $total_rows)
{
- $prev_msg = _("Previous");
- $begin_msg = _("Begin");
+ if ($total_rows < $max_rows)
+ return '';
+ $begin_msg = _("Begin"); $prev_msg = _("Previous");
$sep = '&nbsp;&nbsp;&nbsp;&nbsp;';
if (!$offset)
- {
- print html_image ('arrows/firstgrey.png') . " <i>$begin_msg</i>$sep"
- . html_image ("arrows/previousgrey.png") . " <i>$prev_msg</i>";
- return;
- }
+ return html_image ('arrows/firstgrey.png') . " <i>$begin_msg</i>$sep"
+ . html_image ("arrows/previousgrey.png") . " <i>$prev_msg</i>";
$prev_offset = $offset - $max_rows;
if ($prev_offset < 0)
$prev_offset = 0;
- html_nextprev_link ($url, 0, $max_rows);
- print html_image ('arrows/first.png') . " $begin_msg</a>$sep";
- html_nextprev_link ($url, $prev_offset, $max_rows);
- print html_image ('arrows/previous.png') . " $prev_msg</a>";
+ $ret = html_nextprev_link ($url, 0, $max_rows);
+ $ret .= html_image ('arrows/first.png') . " $begin_msg</a>$sep";
+ $ret .= html_nextprev_link ($url, $prev_offset, $max_rows);
+ return $ret . html_image ('arrows/previous.png') . " $prev_msg</a>";
}
-function html_print_next ($url, $rows, $rows_returned, $total_rows)
+function html_next ($url, $offset, $max_rows, $total_rows)
{
- global $offset, $max_rows;
- $next_msg = _("Next");
- $end_msg = _("End");
- $sep = '&nbsp;&nbsp;&nbsp;&nbsp;';
- if ($rows_returned <= $rows)
- {
- print "<i>$next_msg</i> " . html_image ("arrows/nextgrey.png")
- . "$sep<i>$end_msg</i> " . html_image ('arrows/lastgrey.png');
- return;
- }
- html_nextprev_link ($url, $offset + $rows, $max_rows);
- print "$next_msg " . html_image ("arrows/next.png") . "</a>$sep";
+ if ($total_rows < $max_rows)
+ return '';
+ $next_msg = _("Next"); $end_msg = _("End");
+ $sep = '&nbsp; &nbsp;';
+ $rows = min ($max_rows, $total_rows - $offset);
+ if ($offset + $max_rows >= $total_rows)
+ return "<i>$next_msg</i> " . html_image ("arrows/nextgrey.png")
+ . "$sep<i>$end_msg</i> " . html_image ('arrows/lastgrey.png');
+ $ret = html_nextprev_link ($url, $offset + $rows, $max_rows);
+ $ret .= "$next_msg " . html_image ("arrows/next.png") . "</a>$sep";
$last_page = $total_rows - ($total_rows % $max_rows);
if ($last_page == $total_rows)
$last_page -= $max_rows;
- html_nextprev_link ($url, $last_page, $max_rows);
- print "$end_msg " . html_image ("arrows/last.png") . "</a>";
+ $ret .= html_nextprev_link ($url, $last_page, $max_rows);
+ return "$ret$end_msg " . html_image ("arrows/last.png") . "</a>";
}
-function html_nextprev ($url, $rows, $rows_returned, $total_rows)
+function html_nextprev_str ($url, $offset, $max_rows, $total_rows)
{
- global $offset, $max_rows;
- if ($rows_returned < $rows && !$offset)
- return;
+ if ($total_rows < $max_rows)
+ return '';
+ $ret = "<p class=\"nextprev\">\n";
+ $sep = "&nbsp; &nbsp; &nbsp;";
+ $ret .= html_prev ($url, $offset, $max_rows, $total_rows) . $sep;
+ $latest_item = min ($offset + $max_rows, $total_rows);
+ $ret .= sprintf (
+ # TRANSLATORS: The first argument is the number of the first item shown,
+ # the second argument is the number of the last item shown,
+ # the third argument is the total number of items.
+ _('%1$s&ndash;%2$s / %3$s'), $offset + 1, $latest_item, $total_rows
+ );
+ $ret .= $sep . html_next ($url, $offset, $max_rows, $total_rows);
+ return "$ret</p>\n";
+}
- print "\n<br /><p class=\"nextprev\">\n";
- html_print_prev ($url, $offset, $max_rows);
- print "&nbsp; &nbsp; &nbsp;";
- html_print_next ($url, $rows, $rows_returned, $total_rows);
- print "</p>\n";
+function html_nextprev ($url, $offset, $max_rows, $total_rows)
+{
+ print html_nextprev_str ($url, $offset, $max_rows, $total_rows);
}
function html_anchor ($content, $name)
diff --git a/frontend/php/include/trackers/general.php b/frontend/php/include/trackers/general.php
index ff847fae..31b17742 100644
--- a/frontend/php/include/trackers/general.php
+++ b/frontend/php/include/trackers/general.php
@@ -355,11 +355,10 @@ function trackers_field_date_operator ($field_name, $value = '', $ro = false)
. "\" name=\"{$field_name}_op\">$options</select>\n";
}
-function trackers_chunksz_control ()
+function trackers_chunksz_control ($var = 'chunksz')
{
- global $chunksz;
- return html_label ('chunksz', _("Items to show at once:")) . '&nbsp;'
- . form_input ('text', 'chunksz', $chunksz, 'size="3" maxlength="5"');
+ return html_label ($var, _("Items to show at once:")) . '&nbsp;'
+ . form_input ('text', $var, $GLOBALS[$var], 'size="3" maxlength="5"');
}
function trackers_field_text (
diff --git a/frontend/php/include/trackers/view-dependencies.php b/frontend/php/include/trackers/view-dependencies.php
index 49be702e..fbe558e4 100644
--- a/frontend/php/include/trackers/view-dependencies.php
+++ b/frontend/php/include/trackers/view-dependencies.php
@@ -152,7 +152,7 @@ function trackers_warn_about_hidden ($html_format = true)
# Drop unaccessible, unlinked and other unappropriate items.
function trackers_filter_out_items (&$items_for_digest, $items, $dependencies)
{
- global $include_closed, $chunksz, $offset;
+ global $include_closed, $max_rows, $offset;
$filtered = [];
$i = $total = 0;
foreach ($items_for_digest as $it)
@@ -167,7 +167,7 @@ function trackers_filter_out_items (&$items_for_digest, $items, $dependencies)
$total++;
if ($i++ < $offset)
continue;
- if ($i > $offset + $chunksz)
+ if ($i > $offset + $max_rows)
continue;
$filtered[] = $it;
}
@@ -238,22 +238,22 @@ function trackers_print_item_list_img ($items, $dependencies)
return;
$url = "$sys_home" . ARTIFACT . "/dependencies.php?";
$args = ['list_format=svg'];
- foreach (['group', 'include_closed', 'offset', 'chunksz'] as $var)
+ foreach (['group', 'include_closed', 'offset', 'max_rows'] as $var)
{
if (empty ($GLOBALS[$var]))
continue;
$args[] = "$var={$GLOBALS[$var]}";
}
$url .= join ('&', $args);
- print "<img width='100%' src=\"$url\" alt=\""
- . _('Dependency graph') . "\" />\n";
+ print "<img src=\"$url\" alt=\"" . _('Dependency graph')
+ . " width='100%'\" />\n";
}
function trackers_print_view_deps_controls ()
{
- global $include_closed, $chunksz, $offset, $group;
+ global $include_closed, $group;
print form_tag (['method' => 'get']);
print form_hidden (['func' => 'view-dependencies', 'group' => $group]);
- print trackers_chunksz_control ();
+ print trackers_chunksz_control ('max_rows');
print "&nbsp; &nbsp;\n";
print form_checkbox ('include_closed', !empty ($include_closed),
['label' => _('Include closed items')]);
@@ -323,15 +323,14 @@ function trackers_print_item_list_html (
}
function trackers_viewdep_nextprev ($total)
{
- global $sys_home, $max_rows, $chunksz, $offset, $group, $item_no;
- global $include_closed;
- $max_rows = $chunksz;
- if (empty ($offset) && $item_no <= $chunksz)
+ global $sys_home, $group, $item_no, $include_closed;
+ global $max_rows, $offset;
+ if (empty ($offset) && $item_no <= $max_rows)
return;
$url = $sys_home . ARTIFACT . "/dependencies.php?group=$group";
if (!empty ($include_closed))
$url .= "&amp;include_closed";
- html_nextprev ($url, $chunksz, $item_no - $offset, $total);
+ html_nextprev ($url, $offset, $max_rows, $total);
}
function trackers_output_list_html (
$items_for_digest, $items, $dependencies, $total
diff --git a/frontend/php/search/index.php b/frontend/php/search/index.php
index a0c1f5b0..e00fb6df 100644
--- a/frontend/php/search/index.php
+++ b/frontend/php/search/index.php
@@ -75,12 +75,10 @@ if (!$words || !is_scalar ($words))
exit;
}
-$result = search_run ($words, $type_of_search);
-
function finish_page ()
{
global $sys_home, $only_group_id, $words, $type_of_search;
- global $type, $exact, $rows, $rows_returned, $search_total_rows;
+ global $type, $exact, $search_total_rows, $offset, $max_rows;
$nextprev_url =
"{$sys_home}search/?type_of_search=$type_of_search&amp;words="
@@ -92,24 +90,27 @@ function finish_page ()
if (isset ($exact))
$nextprev_url .= "&amp;exact=$exact";
- html_nextprev ($nextprev_url, $rows, $rows_returned, $search_total_rows);
+ html_nextprev ($nextprev_url, $offset, $max_rows, $search_total_rows);
site_footer ([]);
exit (0);
}
-function check_search_fail ($result)
+function check_search_fail ($result, $max_rows)
{
$rows = db_numrows ($result);
if ($rows)
- return $rows;
+ {
+ if ($rows > $max_rows)
+ $rows = $max_rows;
+ return $rows;
+ }
search_failed ();
finish_page ();
return 0;
}
-$rows = $rows_returned = check_search_fail ($result);
-if ($rows_returned > $max_rows)
- $rows = $max_rows;
+$result = search_run ($words, $type_of_search);
+$rows = check_search_fail ($result, $max_rows);
if ($type_of_search == 'soft')
{
diff --git a/frontend/php/siteadmin/grouplist.php b/frontend/php/siteadmin/grouplist.php
index d3399e73..83ae1a72 100644
--- a/frontend/php/siteadmin/grouplist.php
+++ b/frontend/php/siteadmin/grouplist.php
@@ -172,7 +172,7 @@ print '<td><a href="grouplist.php?status=D">'
print "</tr>\n";
print "</table>\n";
-$MAX_ROW = !empty ($max_rows)? $max_rows: 100;
+$max_rows = !empty ($max_rows)? $max_rows: 100;
$abc_array = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
@@ -248,13 +248,13 @@ $res = db_execute ("
SELECT `group_name`, `unix_group_name`, `group_id`, `is_public`, `status`,
`license`, `gidNumber`
FROM `groups` WHERE $where ORDER BY `group_name` LIMIT ?, ?",
- [$offset, $MAX_ROW + 1]
+ [$offset, $max_rows + 1]
);
if (!$res)
$feedback = db_error ();
print "<p><strong>$msg</strong></p>\n";
-$rows = $rows_returned = db_numrows ($res);
+$rows = db_numrows ($res);
$title_arr = [
no_i18n ("Group Name"), no_i18n ("System Name"), no_i18n ('gidNumber'),
@@ -264,7 +264,7 @@ $title_arr = [
print html_build_list_table_top ($title_arr);
-if ($rows_returned < 1)
+if ($rows < 1)
{
print '<tr class="' . utils_altrow ($inc++) . '"><td colspan="7">';
print no_i18n ("No matches.");
@@ -272,8 +272,8 @@ if ($rows_returned < 1)
}
else
{
- if ($rows_returned > $MAX_ROW)
- $rows = $MAX_ROW;
+ if ($rows > $max_rows)
+ $rows = $max_rows;
$data = [];
for ($i = 0; $i < $rows; $i++)
$data[$i] = db_fetch_array ($res);
@@ -286,7 +286,7 @@ print "</table>\n";
html_nextprev (
'?groupsearch=1&amp;group_name_search=' . utils_urlencode ($group_name_search)
. '&amp;search=' . utils_urlencode ($search),
- $rows, $rows_returned, $total_rows
+ $offset, $max_rows, $total_rows
);
site_admin_footer ([]);
diff --git a/frontend/php/siteadmin/spamlist.php b/frontend/php/siteadmin/spamlist.php
index d722ee76..719a596f 100644
--- a/frontend/php/siteadmin/spamlist.php
+++ b/frontend/php/siteadmin/spamlist.php
@@ -191,6 +191,6 @@ while ($entry = db_fetch_array ($result))
}
print "</table>\n";
-html_nextprev ("$php_self?", $max_rows, $i, $cnt);
+html_nextprev ("$php_self?", $offset, $max_rows, $cnt);
$HTML->footer ([]);
?>
diff --git a/frontend/php/siteadmin/usergroup.php b/frontend/php/siteadmin/usergroup.php
index 58a6e264..745fee47 100644
--- a/frontend/php/siteadmin/usergroup.php
+++ b/frontend/php/siteadmin/usergroup.php
@@ -81,12 +81,10 @@ if (empty ($max_rows))
$max_rows = intval ($max_rows);
$offset = intval ($offset);
-function contribution_nextprev ($user_id, $max_rows, $result, $total_rows)
+function contribution_nextprev ($uid, $offset, $max_rows, $total_rows)
{
global $php_self;
- html_nextprev (
- "$php_self?user_id=$user_id", $max_rows, db_numrows ($result), $total_rows
- );
+ html_nextprev ("$php_self?user_id=$uid", $offset, $max_rows, $total_rows);
}
function print_contribution_heading ($user_id)
@@ -222,11 +220,11 @@ function list_user_contributions ($user_id, $user_name, $offset, $max_rows)
print '<p>' . no_i18n ('No contributions found.') . "</p>\n";
return;
}
- contribution_nextprev ($user_id, $max_rows, $result, $total_rows);
+ contribution_nextprev ($user_id, $offset, $max_rows, $total_rows);
print html_dl (
output_contributions ($result, $offset, $max_rows), 'comment_results'
);
- contribution_nextprev ($user_id, $max_rows, $result, $total_rows);
+ contribution_nextprev ($user_id, $offset, $max_rows, $total_rows);
}
function report_db_result ($result, $msg_err, $msg_ok)
diff --git a/frontend/php/siteadmin/userlist.php b/frontend/php/siteadmin/userlist.php
index 2b7f3868..18a0d8d8 100644
--- a/frontend/php/siteadmin/userlist.php
+++ b/frontend/php/siteadmin/userlist.php
@@ -123,7 +123,7 @@ print html_h (2,
sprintf (no_i18n ("User list for %s"), "<strong>$group_listed</strong>")
);
-$rows = $rows_returned = db_numrows ($result);
+$rows = db_numrows ($result);
print html_build_list_table_top (
[no_i18n ("Id"), no_i18n ("User"), no_i18n ("Status"), no_i18n ("Profile")]
@@ -131,28 +131,28 @@ print html_build_list_table_top (
function finish_page ()
{
- global $user_name_search, $search, $text_search, $rows, $rows_returned;
- global $total_rows, $HTML, $php_self;
+ global $user_name_search, $search, $text_search;
+ global $offset, $max_rows, $total_rows, $HTML, $php_self;
print "</table>\n";
html_nextprev (
"$php_self?user_name_search=$user_name_search"
. '&amp;usersearch=1&amp;search=' . utils_urlencode ($search)
. "&amp;text_search=$text_search",
- $rows, $rows_returned, $total_rows
+ $offset, $max_rows, $total_rows
);
$HTML->footer ([]);
exit (0);
}
$inc = 0;
-if ($rows_returned < 1)
+if ($rows < 1)
{
print '<tr class="' . utils_altrow ($inc++)
. '"><td colspan="7">'. no_i18n ("No matches") . ".</td></tr>\n";
finish_page ();
}
-if ($rows_returned > $max_rows)
+if ($rows > $max_rows)
$rows = $max_rows;
for ($i = 0; $i < $rows; $i++)