Menu

#1 # of thumbnails per page user changeable

open
nobody
None
5
2002-02-03
2002-02-03
Anonymous
No

This patch allows users to change the number of
thumbnails per page.

The config.inc sports 3 new settings,
items_per_page_min/max/default. And items_per_age has
been retired =)

To see it in action visit http://www.quakeconpics.com/

Discussion

  • DocWilco

    DocWilco - 2002-02-03

    Logged In: YES
    user_id=447148

    The file upload failed so here's the patch in txt format:

    --- functions.inc.orig Sun Jan 27 15:22:25 2002
    +++ functions.inc Sat Feb 2 15:16:09 2002
    @@ -37,10 +37,11 @@
    global $realbase;
    global $dispsize;
    global $sitehome;
    +
    global $perpage;
    if ($sitehome != '') {
    -
    print "<A HREF=\"$sitehome\">Home</a> -> \n";
    +
    print "<A HREF=\"$sitehome?perpage=$perpage\">Home</a> -> \n";
    }
    -
    print "<A HREF=" . dirname($SCRIPT_NAME) .
    "?dispsize=$dispsize>Albums</a>\n";
    +
    print "<A HREF=" . dirname($SCRIPT_NAME) .
    "?dispsize=$dispsize&perpage=$perpage>Albums</a>\n";
    $doo = split("/",$path);
    $prepath = '';
    while (list($foo,$filename) = each($doo)) {
    @@ -52,7 +53,7 @@

    if \($filename == $endpoint\) \{
    
        print " -> <b>$filename</b>\n";
    
    \} else \{
    

    -
    print " -> <A HREF=?mode=album&album=" . urlencode($fullname)
    . "&dispsize=$dispsize&start=$start>$filename</a>\n";
    +
    print " -> <A HREF=?mode=album&album=" . urlencode($fullname)
    .
    "&dispsize=$dispsize&start=$start&perpage=$perpage>$filename</a>\n";

    \}
    
    $prepath = $fullname;
    \}
    

    --- index.phtml.orig Sun Jan 27 13:32:42 2002
    +++ index.phtml Sat Feb 2 15:37:18 2002
    @@ -4,6 +4,19 @@

    $version = "2.0.2";

    +if (is_numeric($perpage)) {
    + $items_per_page = $perpage;
    + if ($items_per_page > $items_per_page_max) {
    + $items_per_page = $items_per_page_max;
    + }
    + if ($items_per_page < $items_per_page_min) {
    + $items_per_page = $items_per_page_min;
    + }
    +} else {
    + $items_per_page = $items_per_page_default;
    +}
    +$perpage = $items_per_page;
    +
    print "<HTML>\n";
    print "<HEAD>\n";
    if ($mode == "album" or $mode == "view") {
    @@ -42,7 +55,7 @@
    }
    is_array($alblist) and sort($alblist);
    for ($i = 0 ; $i < sizeof($alblist) ; $i++) {
    -
    print "<A HREF=?mode=album&album=" . urlencode($alblist[$i])
    . "&dispsize=$dispsize>";
    +
    print "<A HREF=?mode=album&album=" . urlencode($alblist[$i])
    . "&dispsize=$dispsize&perpage=$perpage>";

    print "<b>$alblist\[$i\]</b>\n";
    
    print "</a><br>\n";
    \}
    

    @@ -84,7 +97,7 @@

        print "</tr><tr bgcolor=white>\n";
    
        $colcounter = 0;
    
    \}
    

    -
    print "<td align=center><A
    HREF=?mode=album&album=".urlencode("$album/$dirname") . ">";
    +
    print "<td align=center><A
    HREF=?mode=album&album=".urlencode("$album/$dirname") .
    "&perpage=$perpage>";

    print "<b>$dirname</b>\n";
    
    print "</a><br><IMG width=$thumb\_size height=1 src=\"" .
    

    $imgbase . "/blank.gif\"></td>\n";

    $colcounter++;
    

    @@ -97,7 +110,7 @@

        $colcounter = 0;
    
    \}
    
    if \(is\_dir\($realbase . "/$album/" . $file\)\) \{
    

    -
    print "<td><A HREF=?mode=album&album=$album/$file>";
    +
    print "<td><A
    HREF=?mode=album&album=$album/$file&perpage=$perpage>";

        print "<b>$file</b>\n";
    
        print "</a></td>\n";
    
        $colcounter++;
    

    @@ -115,7 +128,7 @@

        \#\}
    
        $thumbsize = GetImageSize\($thumbfile\);
    
        $imgsrc = preg\_replace\('/ /',"%20","/$dyn\_base/$album/$thumbpic"\);
    

    -
    print "<td align=center><A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($file)."&dispsize=$dispsize&start=$start>";
    +
    print "<td align=center><A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($file)."&dispsize=$dispsize&start=$start&perpage=$perpage>";

        print "<IMG hspace=3 vspace=3 $thumbsize\[3\] BORDER=0 SRC=\"" .
    

    $imgbase . "$imgsrc\"><br>$file\n";

        print "</a></td>\n";
    
        $colcounter++;
    

    @@ -126,7 +139,7 @@
    }
    print "</tr>\n";
    print "<tr bgcolor=white><td colspan=$display_cols><table
    border=0 width=100%><tr><td>";
    -
    print "<A HREF=?mode=album&album=" . urlencode($album) .
    "&start=0>Start</a> | ";
    +
    print "<A HREF=?mode=album&album=" . urlencode($album) .
    "&start=0&perpage=$perpage>Start</a> | ";
    if ($start > 0) {

    print "<A HREF=?mode=album&album=" . urlencode\($album\) .
    

    "&start=";

    if \($start-$items\_per\_page < 0\) \{
    

    @@ -134,15 +147,26 @@

    \} else \{
    
        print \($start-$items\_per\_page\);
    
    \}
    

    -
    print ">Prev $items_per_page</a> | ";
    +
    print "&perpage=$perpage>Prev $items_per_page</a> | ";
    } else {

    print "Prev $items\_per\_page | ";
    \}
    if \($totalfiles > $x\) \{
    

    -
    print "<A HREF=?mode=album&album=" . urlencode($album) .
    "&start=$x>Next $items_per_page</a> | ";
    +
    print "<A HREF=?mode=album&album=" . urlencode($album) .
    "&start=$x&perpage=$perpage>Next $items_per_page</a> | ";
    } else {

    print "Next $items\_per\_page | ";
    \}
    

    +
    print "<FORM>\n";
    +
    while (list($key, $val) = each($HTTP_GET_VARS)) {
    +
    print "<input type=hidden name=\"$key\" value=\"$val\">\n";
    +
    }
    +
    print "<SELECT name=perpage>\n";
    +
    for ($i = $items_per_page_min; $i <= $items_per_page_max;
    $i++) {
    +
    print "<OPTION value=\"$i\"". ($i == $items_per_page ? "
    selected" : "") . ">$i</OPTION>\n";
    +
    }
    +
    print "</SELECT>\n";
    +
    print "Pics per page<input type=submit value=change>";
    +
    print "</FORM>\n";
    print "</td><td align=right>";
    if ($totalfiles > 0) {

    print "Images " . \($start+1\) . " to $x of $totalfiles<br>\n";
    

    @@ -217,7 +241,7 @@

    \#\}
    
    $thumbsize = GetImageSize\($thumbfile\);
    
    $imgsrc = preg\_replace\('/
    

    /',"%20","/$dyn_base/$album/$thumbpic");
    -
    print "<A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($prevfile)."&dispsize=$dlinksize&start=$start>";
    +
    print "<A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($prevfile)."&dispsize=$dlinksize&start=$start&perpage=$perpage>";

    print "<-Prev<br><IMG align=center hspace=2 vspace=2
    

    $thumbsize[3] BORDER=0 SRC=\"" . $imgbase . "$imgsrc\"></a>";
    } else {

    print "<td><IMG width=$thumb\_size height=1 src=\"" . $imgbase
    

    . "/blank.gif\"></td>\n";
    @@ -265,7 +289,7 @@

    \#\}
    
    $thumbsize = GetImageSize\($thumbfile\);
    
    $imgsrc = preg\_replace\('/
    

    /',"%20","/$dyn_base/$album/$thumbpic");
    -
    print "<A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($nextfile)."&dispsize=$dlinksize&start=$start>";
    +
    print "<A
    HREF=?mode=view&album=".urlencode($album)."&pic=".urlencode($nextfile)."&dispsize=$dlinksize&start=$start&perpage=$perpage>";

    print "Next -><br>";
    
    print "<IMG align=center hspace=2 vspace=2 $thumbsize\[3\]
    

    BORDER=0 SRC=\"" . $imgbase . "$imgsrc\"></a>";
    } else {
    @@ -273,9 +297,9 @@
    }

    $totalfiles = sizeof\($filelist\);
    

    -
    #print "<A HREF=convert.phtml?effect=charcoal&file=" .
    urlencode($viewfile) . ">Charcoal</a>\n";
    -
    #print " | <A HREF=convert.phtml?effect=paint&file=" .
    urlencode($viewfile) . ">Paint</a>\n";
    -
    #print " | <A HREF=convert.phtml?effect=shade&file=" .
    urlencode($viewfile) . ">Shade</a>\n";
    +
    #print "<A HREF=convert.phtml?effect=charcoal&file=" .
    urlencode($viewfile) . "&perpage=$perpage>Charcoal</a>\n";
    +
    #print " | <A HREF=convert.phtml?effect=paint&file=" .
    urlencode($viewfile) . "&perpage=$perpage>Paint</a>\n";
    +
    #print " | <A HREF=convert.phtml?effect=shade&file=" .
    urlencode($viewfile) . "&perpage=$perpage>Shade</a>\n";
    #print "<br>\n";
    print "</td></tr></table></td></tr>\n";
    #if ($show_exif) {
    --- config.inc.orig Sun Jan 27 14:06:28 2002
    +++ config.inc Sun Jan 27 14:11:57 2002
    @@ -11,7 +11,9 @@
    $sitehome
    = "http://phpix.org";
    ## EXIF Support requires PHP4 with exif support compiled
    $show_exif
    = 0;
    -$items_per_page
    = 6;
    +$items_per_page_default
    = 6;
    +$items_per_page_min = 3;
    +$items_per_page_max = 21;
    $display_cols = 4;
    $default_size = 640;
    $thumb_size
    = 120;

     
  • DocWilco

    DocWilco - 2002-02-03

    Logged In: YES
    user_id=447148

    OK that was ugly... so here it is in the form of a URL =)

    <A
    href="http://www.bsdchicks.com/perpage.patch">http://www.bsdchicks.com/perpage.patch</a>

     
  • Robert

    Robert - 2003-02-06

    Logged In: YES
    user_id=10577

    You can also attach the patch as a file... look at the
    bottom of this page.
    Much easier to download/keep track of.

     

Log in to post a comment.