[Home]WikiPatches/SearchResultsLimitVariant

UseModWiki | WikiPatches | RecentChanges | Preferences

Based on WikiPatches/SearchResultsLimit.

Restricted to the action "node", but it can extended, wherever an action of some list of elements.

Ununordered lists here can be converted to numbered lists with minor tweak of patch and CSS help.

  1. useful for large lists.
  2. $PageCountLimit? defined in config file
  3. simultaneously, set of links (ala RecentChanges) from where to change interval of PageCountLimit?, defined by @PageCountLimit? in config file
  4. No javascript

+ use vars qw( ... $PageCountLimit @LimitNodes);
...
@RcDays      = qw(1 3 7 30 90); # Days for links on RecentChanges
+ @PageCountLimit  = qw(0 25 50 100 200 500 1000); # Intervals for links on Node
sub DoOtherRequest {
...
  } elsif ($action eq "index") {
    &DoIndex();
  } elsif ($action eq "node") {
    &DoNodes();
  }
...
}

sub DoIndex {
  print &GetHeader('', T('Index of all pages'), '');
  &PrintPageList(&AllPagesList());
  print &GetCommonFooter();
}

+ sub DoNodes {
+  print &GetHeader('', T('Index of all pages (by interval)'), '');
+  &PrintPageIndexList(&AllPagesList());
+  print &GetCommonFooter();
+}
sub PrintPageList {
...
}

+ sub PrintPageIndexList {
+  my ($pagename, $spacer, $pagecount, $printcount, $pagenumber, $from, $limit , $action);
+  my @pagename  = @_;
+  my $status;
+  my ($i, $j, $k, $l);
+
+  $action = &GetParam('action','');
+  $limit = &GetParam('limit', $PageCountLimit);
+  if ($limit) { 
+    $PageCountLimit = $limit;
+  } else {
+    $PageCountLimit = @_;
+  }
+  $from = &GetParam('from','1');
+  $pagecount = $#_ + 1;
+  print T('Default limit to display') . '<br>';
+  foreach $j (@PageCountLimits) {
+    $k++;
+    if ($k > 1) {print ' : '};
+    if (not $j) {print  &ScriptLink("action=node&limit=$j", T('All pages'))} 
+    else {print  &ScriptLink("action=node&limit=$j", $j)}
+  }
+  if ($action eq "node") {
+    print  '<br>';
+    if (($limit ne '' and $limit ne 0) and $limit < $pagecount) {
+      print Tss('Node shown by %1, starting from %2 or', $limit, $from) . ' ...';
+    } else {
+       print T('Node shown by whole') . '<br>';
+      if ($limit eq 0) {
+        print '(' . T('There\'s no limit') . ')';
+      }
+     if ($limit > 0 and $limit >= $pagecount) {
+       print '(' . Tss('limit %1 is => to number of nodes %2', $limit, $pagecount) . ')';
+      }
+    }
+    if ($limit and $limit < $pagecount) {
+      my ($prev, $next);
+
+      print '<br>';
+      $prev = $from - $limit;
+      if ($prev >= 0) {
+        print "<a href=\"$ScriptName?action=$action&from=$prev&limit=$limit" ."\">"
+             . T('prev') . "</a>";
+      }
+      $next = $from + $limit;
+      if ($next <= $pagecount) {
+        if (($prev >=0) and $next) { print ' : ';}
+        print "<a href=\"$ScriptName?action=$action&from=$next&limit=$limit" ."\">"
+              . T('next') . "</a>" . ' | ';
+      } else {
+        print ' : ' . T('next') . ' | ';
+      }
+    }
+    $pagenumber = 0;
+    my $interval = ((int ($pagecount / $PageCountLimit))*$PageCountLimit);
+    
+    for (my $i=1; $i < $pagecount; $i +=$PageCountLimit) {
+      if (($limit ne '' and $limit ne 0) and $limit < $pagecount) {
+        $l++;
+        if ($l > 1) {print ' : '};
+          print '' . "<a href=\"$ScriptName?action=$action&from=$i&limit=$limit" ."\">$i</a>";
+      }
+    }
+  }
+  print '<ul>';
+  foreach $pagename (@_) {
+  $pagenumber++;
+
+  if ($pagenumber >= "$from") {
+    $printcount++;
+    @pagename = split (/\//,$pagename);
+      print '<li>';
+      for (1 .. $#pagename) {print ' . ',}
+         print ' ' . &GetPageOrEditLink($pagename) . '<br>';
+    if ($printcount >= $PageCountLimit) { last; }
+    }
+  }
+  print '</ul>';
+ }
--JuanmaMP

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited August 8, 2012 4:15 am by JuanmaMP (diff)
Search: