View Full Version : Page-By-Page-Archive addon bug
posefius
06-09-2005, 08:39 PM
The Page-By-Page-Archive for category and month (for PP v1.4) (paged_archive.php - version 0.6) has a bug. When You have categories that span multiple pages, only the first index page is displayed. The number of the second page is displayed but does not display the next index page. The number of the first page is missing. Please check my photolog to see the problem. I have set the treshold to 40 thumbs, the category "Objects" contains 42 at the moment. The problem doesnt occur with "All".
Piet Osefius
Joe[y]
06-09-2005, 09:00 PM
i'll look into the difference between the ALL and categories setting now!
posefius
06-16-2005, 02:50 PM
Can you tell me if this addon is fixed? Maybe I need to contact Ramin Mehran about this problem, because I see he made the Page-By-Page-Archive addon.
Piet Osefius
raminia
06-16-2005, 07:31 PM
it works!
raminia
06-16-2005, 07:44 PM
1- make sure you use the latest version.
2- make sure abou the tags in html
3- re-upload the addon.
4- it works perfectly here I paste the latest version again here.
<?php
/*
Requires Pixelpost version 1.4 or newer
Page-By-Page-Archive
ADDON-Version 0.6
Written by: Ramin Mehran
Contact: raminia@yahoo.com
Pixelpost www: http://www.pixelpost.org/
License: http://www.gnu.org/copyleft/gpl.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
================================================== ==========================
NEW TAGS:
<CATEGORY_LINKS_AS_LIST> // Category links as a text list for default PP's archive page
<CATEGORY_LINKS_AS_LIST_PAGED> // Category links as a text list for page-by-page archive
<BROWSE_MONTHLY_ARCHIVE_PAGED> // Monthly drop box for default PP's archive page
<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED> // Monthly links as a text list for page-by-page archive
<BROWSE_CATEGORIES_PAGED> // Category drop box for page-by-page archive
<THUMBNAILS_WHOLE_PAGED> // Thumbnails in this page
<THUMBNAILS_PAGES_LINKS> // Link to the pages of thumbnail in the selected category
<ARCHIVE_PAGES_NUM> // Page number you are viewing
<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE> // Name of the category or Month you select
<LINK_TO_PAGED_ARCHIVE> // Link to Paged-by-page archive page as <a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
*/
$addon_name = "Page-By-Page-Archive for category and month (for PP v1.4)";
$addon_version = "0.6";
$maxpthumb = $cfgrow['maxpthumb'];
if ($_GET['updatedflagp']=="1")
{$isupdated = "<font color='#FF0000'>Updated!</font>";}
else
{$isupdated = ""; }
// FIELD_EXISTS
// Checks whether specified field exists in current or specified table.
$fieldname = "maxpthumb";
$table = $pixelpost_db_prefix ."config";
$fieldexists = 0;
$t = 0;
$attention_call = "";
if ($table != "") {
if ($table_name != "") $current_table = $table;
$result_id = mysql_list_fields( $pixelpost_db_pixelpost, $table );
for ($t = 0; $t < mysql_num_fields($result_id); $t++) {
if (strtolower( $fieldname) == strtolower(mysql_field_name($result_id, $t))) {
$fieldexists = 1;
break;
}
}
}
// if the field does not exit: Create it!
if ($fieldexists==0) {
$result = mysql_query("ALTER TABLE $table ADD `maxpthumb` VARCHAR( 5 ) DEFAULT '100' NOT NULL ");
}
// if the maximum number of thumbnails in the admin section is updated
if($_GET['x'] == "maxpthumb") {
$newmaxpthumb = $_POST['newmaxpthumb'];
$query = "update ".$pixelpost_db_prefix."config set maxpthumb='" .$newmaxpthumb ."'" ;
$update = mysql_query($query );
$to = './admin/?view=addons&amp;updatedflagp=1';
header('Location: '. $to);
exit;
};
// description
$addon_description = "$attention_call Page by page category and month archive. Usefull when you have
plenty of photos in archive and you want to show them in few pages and not just as a whole. Compatible with Pixelpost version 1.3 with multi category mod and version 1.4.
Many new tags is added to handle the archives. Open the archive_page.php file to see the new tags.<p />
Enter the maximum number of thumbnails in each page of the archive page:
<form method='post' action='../index.php?x=maxpthumb'>
<input type='text' name='newmaxpthumb' value='".$maxpthumb ."' style='width:40px'>
<input type='submit' value='update'>
</form> $isupdated
";
// date time of now!
$tz = $cfgrow['timezone'];
$datetime = gmdate("Y-m-d H:i:s",gmdate("U")+(3600 * $tz));
// get maximum number of thumbnails in each browse page from db
$maxnumber_thumbs = $cfgrow['maxpthumb'];
// number of all photos
$photonumb = mysql_query("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" );
$row = mysql_fetch_array($photonumb);
// number of photos in the database
$pixelpost_all_photonumb = $row['count'] ;
//-------------------------------- Category Browse Menu (paged and original)
/*---------------------------------**********************---------------------------------------*/
$count= $pixelpost_all_photonumb;
$category_Link_List = " <a href='index.php?x=browse'> $lang_browse_all (" .$count .") </a><br />";
$category_Link_List_paged = " <a href='index.php?x=browse&amp;pagenum=1'> $lang_browse_all (" .$count .") </a><br />";
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
$name = pullout($name);
$catname_count = $name ." (" .$count .")";
$category_Link_List .= "<a href='index.php?x=browse&amp;category=$id'>$catname_count</a><br />";
// paged version of the browse archive
$category_Link_List_paged .= "<a href='index.php?x=browse&amp;category=$id&amp;page num=1'>$catname_count</a><br />";
}
// tags of Category List Of Links (default version)
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST>",$category_Link_List,$tpl);
// paged version tages
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST_PAGED>",$category_Link_List_paged,$tpl);
//----------- Monthly Archive Menu and List
if ($_GET['pagenum'] != "") {
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive: <br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = "select distinct DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m') <= '$thismonth'
order by datetime desc";
$query = mysql_query($query);
while(list($thedate) = mysql_fetch_row($query)) {
$query2 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query2);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate &amp;monthname=$select_display_date&amp;pagenum =1'>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;monthname=$select_display_date&amp;pagenum=1'>$name (" .$select_display_date .") (" .$count .")</a>";
};// end while
$archive_select .= "</select>";
} // end $_GET['pagenum'] != "")
ELSE
{
// does not use page number
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse'
onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive:<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = mysql_query("select DISTINCT DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost order by datetime desc");
while(list($thedate) = mysql_fetch_row($query)) {
$query3 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query3);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate '>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate'>$name (" .$select_display_date .") (" .$count .")</a>";
}; // end while
$archive_select .= "</select>";
} // end else
// bulid the new tag
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_PAGED>",$archive_select,$tpl);
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED>",$archive_select_links,$tpl);
//--------------- check if it should be the browse page
if($_GET['x'] == "browse") {
// initialize variables
$thumb_output = "";
$where = "";
$limit = "";
$pagenum = $_GET['pagenum'];
// did user select a category?
if($_GET['category'] != "") { $where = "and (t2.cat_id ='".$_GET['category']."')"; }
// do you use links with page number?
if ($_GET['pagenum'] != "") {
$start = $maxnumber_thumbs*($_GET['pagenum']-1);// calculate start and end of the thumbs in the selected page
$limit = " limit $start , $maxnumber_thumbs "; // create the limit command (in MS-SQL this should be TOP)
}// end if ($_GET['pagenum'] != "")
// build query
if ($_GET['archivedate']=="")
{
// no archive date
$query = "select t1.id,t1.headline,t1.image from {$pixelpost_db_prefix}pixelpost as t1
inner join {$pixelpost_db_prefix}catassoc as t2
where (t1.datetime<='$cdate')
$where
and t1.id = t2.image_id
group by t1.id
order by t1.datetime desc" .$limit;
} // if ($_GET['archivedate']=="")
else
{ // archive date is available
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$query = "select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate' and datetime >='$archivedate_start' and datetime <= '$archivedate_end') $where order by datetime desc" .$limit;
}// end else if ($_GET['archivedate']=="")
$query = mysql_query($query);
//---------------------------- Making thumbs row
// for each record ...
while(list($id,$title,$name) = mysql_fetch_row($query)) {
// from the thumbnail row. This could be build by tables too.
$title = pullout($title);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
} //end while
// initialize page counter
$pagecounter=0;
//---------------- Get number of photos in database in the selected category
// initialize where command
$where = "";
// check if user selects a category
if($_GET['category'] != "") {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$_GET['category']."' AND datetime<='$datetime')";
$queryr .= " group by t1.cat_id ";
}// end if
else // not cat selected return all images in the DB
{
$queryr = "select count(*) as count
from {$pixelpost_db_prefix}pixelpost
where ( datetime<='$datetime')";
} //end else
$monthname = "";
if($_GET['archivedate'] != "") {
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$where = " and datetime >='$archivedate_start' and datetime <= '$archivedate_end' ";
$monthname = $_GET['monthname'];
$queryr = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" .$where;
} // end if($_GET['archivedate'] != "")
$photonumb = mysql_query($queryr);
$row = mysql_fetch_array($photonumb);
// number of photos in the database in the same category
$pixelpost_photonumb = $row['count'];
// calculate the number of pages
$num_browse_pages = ceil($pixelpost_photonumb/$maxnumber_thumbs);
// initialize archive links
$Archive_pages_Links = "";
// selected category id
$cat_id = $_GET['category'];
//-------- Make page number to archive as links (for the selected category)
if ($_GET['category']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=$cat_id&amp; pagenum=$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
else
{
if ($_GET['pagenum']!=""&$_GET['archivedate']=="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=&amp;pagenum =$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
if ($_GET['archivedate']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$monthname=str_replace(" ","%20",$monthname);
$pagecounter++;
$archivedate=$_GET['archivedate'];
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;archivedate=$archived ate&amp;monthname=$monthname&amp;pagenum=$pagecoun ter'>$pagecounter</a> ";
}// whilte
}// end if $_GET['archivedate']!=""
}// end else
// selected category name
if($cat_id != "") {
$query = mysql_query("select name from ".$pixelpost_db_prefix."categories where id='$cat_id'");
$images_category_or_date = mysql_fetch_array($query);
$images_category_or_date = pullout($images_category_or_date['name']);
}
else
{
if ($_GET['archivedate']=="")
{$images_category_or_date = $lang_browse_all;}
else
{$images_category_or_date = $_GET['monthname'];}
}
} // end if ($_GET['x'] == "browse")
//------------- Make Archive browse menu with link to paged archive
// build browse menu
$browse_select = "";
// do you use links with page number?
if ($maxpthumb>0) {
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category=&amp;pa genum=$pagenum'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
else{
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category='>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$name = pullout($name);
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
// check if you are using this addon
if ($maxpthumb>0) {
// u r using
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id&amp ;pagenum=1'>$name (" .$count .")</option>";
} // end if pagenum!=""
else {
// use the original browse category menu
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id'>$name (" .$count .")</option>";};
} // end while
// finilize the tag
$browse_select .= "</select>";
$tpl = str_replace("<BROWSE_CATEGORIES_PAGED>",$browse_select,$tpl); //Browse menu for paged archive
//----------------- Build the additional new tages
//-- If you use paged archive
if ($pagenum!=""){
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); //thumbnails in this page
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>",$Archive_pages_Links,$tpl); // link to the pages of thumbnail in the selected category
$tpl = str_replace("<ARCHIVE_PAGES_NUM>",$pagenum,$tpl);// page number you are viewing
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
} //end if
//-- If you do not use page archive
else {
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>","",$tpl); // this does not use paged archive so there should be no links
$tpl = str_replace("<ARCHIVE_PAGES_NUM>","",$tpl); // page number you are viewing (it's empty for this case)
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); // the original thumb row in the archive
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
}// end else
$tpl = str_replace("<LINK_TO_PAGED_ARCHIVE>",'<a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
?>
posefius
06-17-2005, 06:54 AM
Thank You! I uploaded the addon and its working fine for the category multiple page display.
There is still only one minor problem concerning the current month image counting. I have posted images in advance for the whole month of june. When I look at the archive I see that all the images are counted and not the ones until today.
I hope You can fix this also.
Piet Osefius
raminia
06-17-2005, 07:54 PM
it should be fixed... ummmm I'm getting paranoia with this addon ;)
I'll check it later.
raminia
06-26-2005, 05:48 PM
Try this one and let me know if it works ok.
<?php
/*
Requires Pixelpost version 1.4 or newer
Page-By-Page-Archive
ADDON-Version 0.6
Written by: Ramin Mehran
Contact: raminia@yahoo.com
Pixelpost www: http://www.pixelpost.org/
License: http://www.gnu.org/copyleft/gpl.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
================================================== ==========================
NEW TAGS:
<CATEGORY_LINKS_AS_LIST> // Category links as a text list for default PP's archive page
<CATEGORY_LINKS_AS_LIST_PAGED> // Category links as a text list for page-by-page archive
<BROWSE_MONTHLY_ARCHIVE_PAGED> // Monthly drop box for default PP's archive page
<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED> // Monthly links as a text list for page-by-page archive
<BROWSE_CATEGORIES_PAGED> // Category drop box for page-by-page archive
<THUMBNAILS_WHOLE_PAGED> // Thumbnails in this page
<THUMBNAILS_PAGES_LINKS> // Link to the pages of thumbnail in the selected category
<ARCHIVE_PAGES_NUM> // Page number you are viewing
<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE> // Name of the category or Month you select
<LINK_TO_PAGED_ARCHIVE> // Link to Paged-by-page archive page as <a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
*/
$addon_name = "Page-By-Page-Archive for category and month (for PP v1.4)";
$addon_version = "0.6";
$maxpthumb = $cfgrow['maxpthumb'];
if ($_GET['updatedflagp']=="1")
{$isupdated = "<font color='#FF0000'>Updated!</font>";}
else
{$isupdated = ""; }
// FIELD_EXISTS
// Checks whether specified field exists in current or specified table.
$fieldname = "maxpthumb";
$table = $pixelpost_db_prefix ."config";
$fieldexists = 0;
$t = 0;
$attention_call = "";
if ($table != "") {
if ($table_name != "") $current_table = $table;
$result_id = mysql_list_fields( $pixelpost_db_pixelpost, $table );
for ($t = 0; $t < mysql_num_fields($result_id); $t++) {
if (strtolower( $fieldname) == strtolower(mysql_field_name($result_id, $t))) {
$fieldexists = 1;
break;
}
}
}
// if the field does not exit: Create it!
if ($fieldexists==0) {
$result = mysql_query("ALTER TABLE $table ADD `maxpthumb` VARCHAR( 5 ) DEFAULT '100' NOT NULL ");
}
// if the maximum number of thumbnails in the admin section is updated
if($_GET['x'] == "maxpthumb") {
$newmaxpthumb = $_POST['newmaxpthumb'];
$query = "update ".$pixelpost_db_prefix."config set maxpthumb='" .$newmaxpthumb ."'" ;
$update = mysql_query($query );
$to = './admin/?view=addons&amp;updatedflagp=1';
header('Location: '. $to);
exit;
};
// description
$addon_description = "$attention_call Page by page category and month archive. Usefull when you have
plenty of photos in archive and you want to show them in few pages and not just as a whole. Compatible with Pixelpost version 1.3 with multi category mod and version 1.4.
Many new tags is added to handle the archives. Open the archive_page.php file to see the new tags.<p />
Enter the maximum number of thumbnails in each page of the archive page:
<form method='post' action='../index.php?x=maxpthumb'>
<input type='text' name='newmaxpthumb' value='".$maxpthumb ."' style='width:40px'>
<input type='submit' value='update'>
</form> $isupdated
";
// date time of now!
$tz = $cfgrow['timezone'];
$datetime = gmdate("Y-m-d H:i:s",gmdate("U")+(3600 * $tz));
// get maximum number of thumbnails in each browse page from db
$maxnumber_thumbs = $cfgrow['maxpthumb'];
// number of all photos
$photonumb = mysql_query("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" );
$row = mysql_fetch_array($photonumb);
// number of photos in the database
$pixelpost_all_photonumb = $row['count'] ;
//-------------------------------- Category Browse Menu (paged and original)
/*---------------------------------**********************---------------------------------------*/
$count= $pixelpost_all_photonumb;
$category_Link_List = " <a href='index.php?x=browse'> $lang_browse_all (" .$count .") </a><br />";
$category_Link_List_paged = " <a href='index.php?x=browse&amp;pagenum=1'> $lang_browse_all (" .$count .") </a><br />";
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
$name = pullout($name);
$catname_count = $name ." (" .$count .")";
$category_Link_List .= "<a href='index.php?x=browse&amp;category=$id'>$catname_count</a><br />";
// paged version of the browse archive
$category_Link_List_paged .= "<a href='index.php?x=browse&amp;category=$id&amp;page num=1'>$catname_count</a><br />";
}
// tags of Category List Of Links (default version)
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST>",$category_Link_List,$tpl);
// paged version tages
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST_PAGED>",$category_Link_List_paged,$tpl);
//----------- Monthly Archive Menu and List
if ($_GET['pagenum'] != "") {
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive: <br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = "select distinct DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m') <= '$thismonth' and datetime<='$datetime'
order by datetime desc";
$query = mysql_query($query);
while(list($thedate) = mysql_fetch_row($query)) {
$query2 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query2);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate &amp;monthname=$select_display_date&amp;pagenum =1'>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;monthname=$select_display_date&amp;pagenum=1'>$name (" .$select_display_date .") (" .$count .")</a>";
};// end while
$archive_select .= "</select>";
} // end $_GET['pagenum'] != "")
ELSE
{
// does not use page number
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse'
onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive:<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = mysql_query("select DISTINCT DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost order by datetime desc");
while(list($thedate) = mysql_fetch_row($query)) {
$query3 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query3);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate '>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate'>$name (" .$select_display_date .") (" .$count .")</a>";
}; // end while
$archive_select .= "</select>";
} // end else
// bulid the new tag
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_PAGED>",$archive_select,$tpl);
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED>",$archive_select_links,$tpl);
//--------------- check if it should be the browse page
if($_GET['x'] == "browse") {
// initialize variables
$thumb_output = "";
$where = "";
$limit = "";
$pagenum = $_GET['pagenum'];
// did user select a category?
if($_GET['category'] != "") { $where = "and (t2.cat_id ='".$_GET['category']."')"; }
// do you use links with page number?
if ($_GET['pagenum'] != "") {
$start = $maxnumber_thumbs*($_GET['pagenum']-1);// calculate start and end of the thumbs in the selected page
$limit = " limit $start , $maxnumber_thumbs "; // create the limit command (in MS-SQL this should be TOP)
}// end if ($_GET['pagenum'] != "")
// build query
if ($_GET['archivedate']=="")
{
// no archive date
$query = "select t1.id,t1.headline,t1.image from {$pixelpost_db_prefix}pixelpost as t1
inner join {$pixelpost_db_prefix}catassoc as t2
where (t1.datetime<='$cdate')
$where
and t1.id = t2.image_id
group by t1.id
order by t1.datetime desc" .$limit;
} // if ($_GET['archivedate']=="")
else
{ // archive date is available
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$query = "select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate' and datetime >='$archivedate_start' and datetime <= '$archivedate_end') $where order by datetime desc" .$limit;
}// end else if ($_GET['archivedate']=="")
$query = mysql_query($query);
//---------------------------- Making thumbs row
// for each record ...
while(list($id,$title,$name) = mysql_fetch_row($query)) {
// from the thumbnail row. This could be build by tables too.
$title = pullout($title);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
} //end while
// initialize page counter
$pagecounter=0;
//---------------- Get number of photos in database in the selected category
// initialize where command
$where = "";
// check if user selects a category
if($_GET['category'] != "") {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$_GET['category']."' AND datetime<='$datetime')";
$queryr .= " group by t1.cat_id ";
}// end if
else // not cat selected return all images in the DB
{
$queryr = "select count(*) as count
from {$pixelpost_db_prefix}pixelpost
where ( datetime<='$datetime')";
} //end else
$monthname = "";
if($_GET['archivedate'] != "") {
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$where = " and datetime >='$archivedate_start' and datetime <= '$archivedate_end' ";
$monthname = $_GET['monthname'];
$queryr = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" .$where;
} // end if($_GET['archivedate'] != "")
$photonumb = mysql_query($queryr);
$row = mysql_fetch_array($photonumb);
// number of photos in the database in the same category
$pixelpost_photonumb = $row['count'];
// calculate the number of pages
$num_browse_pages = ceil($pixelpost_photonumb/$maxnumber_thumbs);
// initialize archive links
$Archive_pages_Links = "";
// selected category id
$cat_id = $_GET['category'];
//-------- Make page number to archive as links (for the selected category)
if ($_GET['category']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=$cat_id&amp; pagenum=$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
else
{
if ($_GET['pagenum']!=""&$_GET['archivedate']=="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=&amp;pagenum =$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
if ($_GET['archivedate']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$monthname=str_replace(" ","%20",$monthname);
$pagecounter++;
$archivedate=$_GET['archivedate'];
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;archivedate=$archived ate&amp;monthname=$monthname&amp;pagenum=$pagecoun ter'>$pagecounter</a> ";
}// whilte
}// end if $_GET['archivedate']!=""
}// end else
// selected category name
if($cat_id != "") {
$query = mysql_query("select name from ".$pixelpost_db_prefix."categories where id='$cat_id'");
$images_category_or_date = mysql_fetch_array($query);
$images_category_or_date = pullout($images_category_or_date['name']);
}
else
{
if ($_GET['archivedate']=="")
{$images_category_or_date = $lang_browse_all;}
else
{$images_category_or_date = $_GET['monthname'];}
}
} // end if ($_GET['x'] == "browse")
//------------- Make Archive browse menu with link to paged archive
// build browse menu
$browse_select = "";
// do you use links with page number?
if ($maxpthumb>0) {
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category=&amp;pa genum=$pagenum'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
else{
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category='>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$name = pullout($name);
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
// check if you are using this addon
if ($maxpthumb>0) {
// u r using
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id&amp ;pagenum=1'>$name (" .$count .")</option>";
} // end if pagenum!=""
else {
// use the original browse category menu
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id'>$name (" .$count .")</option>";};
} // end while
// finilize the tag
$browse_select .= "</select>";
$tpl = str_replace("<BROWSE_CATEGORIES_PAGED>",$browse_select,$tpl); //Browse menu for paged archive
//----------------- Build the additional new tages
//-- If you use paged archive
if ($pagenum!=""){
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); //thumbnails in this page
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>",$Archive_pages_Links,$tpl); // link to the pages of thumbnail in the selected category
$tpl = str_replace("<ARCHIVE_PAGES_NUM>",$pagenum,$tpl);// page number you are viewing
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
} //end if
//-- If you do not use page archive
else {
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>","",$tpl); // this does not use paged archive so there should be no links
$tpl = str_replace("<ARCHIVE_PAGES_NUM>","",$tpl); // page number you are viewing (it's empty for this case)
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); // the original thumb row in the archive
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
}// end else
$tpl = str_replace("<LINK_TO_PAGED_ARCHIVE>",'<a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
?>
posefius
06-27-2005, 01:36 PM
Dear Ramin,
Sorry, It still doesnt work correct. I think the poblem is in the last line of the script part "Monthly Archive Menu and List" below. The query2 on the last line needs the following extra check: AND datetime<='$datetime'.
I have some programming background, but I never programmed in php, so I dont try to fix it. Maybe I forget some ; or ). I'm sorry if I'm wrong.
Bye the way: Thanks for the comment on my picture!
Best regards,
Piet
//----------- Monthly Archive Menu and List
if ($_GET['pagenum'] != "") {
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse' onChange='self.location.href=this.options[this.selectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive: <br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = "select distinct DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m') <= '$thismonth' and datetime<='$datetime'
order by datetime desc";
$query = mysql_query($query);
while(list($thedate) = mysql_fetch_row($query)) {
$query2 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
raminia
06-27-2005, 01:54 PM
<?php
/*
Requires Pixelpost version 1.4 or newer
Page-By-Page-Archive
ADDON-Version 1.0
Written by: Ramin Mehran
Contact: raminia@yahoo.com
Pixelpost www: http://www.pixelpost.org/
License: http://www.gnu.org/copyleft/gpl.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
================================================== ==========================
NEW TAGS:
<CATEGORY_LINKS_AS_LIST> // Category links as a text list for default PP's archive page
<CATEGORY_LINKS_AS_LIST_PAGED> // Category links as a text list for page-by-page archive
<BROWSE_MONTHLY_ARCHIVE_PAGED> // Monthly drop box for default PP's archive page
<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED> // Monthly links as a text list for page-by-page archive
<BROWSE_CATEGORIES_PAGED> // Category drop box for page-by-page archive
<THUMBNAILS_WHOLE_PAGED> // Thumbnails in this page
<THUMBNAILS_PAGES_LINKS> // Link to the pages of thumbnail in the selected category
<ARCHIVE_PAGES_NUM> // Page number you are viewing
<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE> // Name of the category or Month you select
<LINK_TO_PAGED_ARCHIVE> // Link to Paged-by-page archive page as <a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
*/
$addon_name = "Page-By-Page-Archive for category and month (for PP v1.4)";
$addon_version = "1.0";
$maxpthumb = $cfgrow['maxpthumb'];
if ($_GET['updatedflagp']=="1")
{$isupdated = "<font color='#FF0000'>Updated!</font>";}
else
{$isupdated = ""; }
// FIELD_EXISTS
// Checks whether specified field exists in current or specified table.
$fieldname = "maxpthumb";
$table = $pixelpost_db_prefix ."config";
$fieldexists = 0;
$t = 0;
$attention_call = "";
if ($table != "") {
if ($table_name != "") $current_table = $table;
$result_id = mysql_list_fields( $pixelpost_db_pixelpost, $table );
for ($t = 0; $t < mysql_num_fields($result_id); $t++) {
if (strtolower( $fieldname) == strtolower(mysql_field_name($result_id, $t))) {
$fieldexists = 1;
break;
}
}
}
// if the field does not exit: Create it!
if ($fieldexists==0) {
$result = mysql_query("ALTER TABLE $table ADD `maxpthumb` VARCHAR( 5 ) DEFAULT '100' NOT NULL ");
}
// if the maximum number of thumbnails in the admin section is updated
if($_GET['x'] == "maxpthumb") {
$newmaxpthumb = $_POST['newmaxpthumb'];
$query = "update ".$pixelpost_db_prefix."config set maxpthumb='" .$newmaxpthumb ."'" ;
$update = mysql_query($query );
$to = './admin/?view=addons&amp;updatedflagp=1';
header('Location: '. $to);
exit;
};
// description
$addon_description = "$attention_call Page by page category and month archive. Usefull when you have
plenty of photos in archive and you want to show them in few pages and not just as a whole. Compatible with Pixelpost version 1.3 with multi category mod and version 1.4.
Many new tags is added to handle the archives. Open the archive_page.php file to see the new tags.<p />
Enter the maximum number of thumbnails in each page of the archive page:
<form method='post' action='../index.php?x=maxpthumb'>
<input type='text' name='newmaxpthumb' value='".$maxpthumb ."' style='width:40px'>
<input type='submit' value='update'>
</form> $isupdated
";
// date time of now!
$tz = $cfgrow['timezone'];
$datetime = gmdate("Y-m-d H:i:s",gmdate("U")+(3600 * $tz));
// get maximum number of thumbnails in each browse page from db
$maxnumber_thumbs = $cfgrow['maxpthumb'];
// number of all photos
$photonumb = mysql_query("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" );
$row = mysql_fetch_array($photonumb);
// number of photos in the database
$pixelpost_all_photonumb = $row['count'] ;
//-------------------------------- Category Browse Menu (paged and original)
/*---------------------------------**********************---------------------------------------*/
$count= $pixelpost_all_photonumb;
$category_Link_List = " <a href='index.php?x=browse'> $lang_browse_all (" .$count .") </a><br />";
$category_Link_List_paged = " <a href='index.php?x=browse&amp;pagenum=1'> $lang_browse_all (" .$count .") </a><br />";
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
$name = pullout($name);
$catname_count = $name ." (" .$count .")";
$category_Link_List .= "<a href='index.php?x=browse&amp;category=$id'>$catname_count</a><br />";
// paged version of the browse archive
$category_Link_List_paged .= "<a href='index.php?x=browse&amp;category=$id&amp;page num=1'>$catname_count</a><br />";
}
// tags of Category List Of Links (default version)
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST>",$category_Link_List,$tpl);
// paged version tages
$tpl = str_replace("<CATEGORY_LINKS_AS_LIST_PAGED>",$category_Link_List_paged,$tpl);
//----------- Monthly Archive Menu and List
if ($_GET['pagenum'] != "") {
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive: <br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = "select distinct DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost
where DATE_FORMAT(datetime, '%Y-%m') <= '$thismonth' and datetime<='$datetime'
order by datetime desc";
$query = mysql_query($query);
while(list($thedate) = mysql_fetch_row($query)) {
$query2 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime' and DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query2);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate &amp;monthname=$select_display_date&amp;pagenum =1'>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;monthname=$select_display_date&amp;pagenum=1'>$name (" .$select_display_date .") (" .$count .")</a>";
};// end while
$archive_select .= "</select>";
} // end $_GET['pagenum'] != "")
ELSE
{
// does not use page number
$tz = $cfgrow['timezone'];
$thismonth = gmdate("Y-m",gmdate("U")+(3600 * $tz));
$select_display_thismonth=date("F, Y",strtotime($thismonth."-01"));
$archive_select = "<select name='browse'
onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>Monthly archive</option><option value='index.php?x=browse&amp;archivedate=$thedate &amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";
$archive_select_links = "Monthly archive:<br /><a href='index.php?x=browse&amp;archivedate=$thedate& amp;pagenum=1'>$lang_browse_all (" .$pixelpost_all_photonumb .")</a>";
$query = mysql_query("select DISTINCT DATE_FORMAT(datetime, '%Y-%m') from ".$pixelpost_db_prefix."pixelpost order by datetime desc");
while(list($thedate) = mysql_fetch_row($query)) {
$query3 = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where DATE_FORMAT(datetime, '%Y-%m')='".$thedate ."'";
$count = mysql_query($query3);
$count = mysql_fetch_array($count);
$count= $count['count'];
$select_display_date=date("F, Y",strtotime($thedate."-01"));
$thedate = pullout($thedate);
$archive_select .= "<option value='index.php?x=browse&amp;archivedate=$thedate '>$name (" .$select_display_date .") (" .$count .")</option>";
$archive_select_links .= "<br /><a href='index.php?x=browse&amp;archivedate=$thedate'>$name (" .$select_display_date .") (" .$count .")</a>";
}; // end while
$archive_select .= "</select>";
} // end else
// bulid the new tag
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_PAGED>",$archive_select,$tpl);
$tpl = str_replace("<BROWSE_MONTHLY_ARCHIVE_AS_LINK_PAGED>",$archive_select_links,$tpl);
//--------------- check if it should be the browse page
if($_GET['x'] == "browse") {
// initialize variables
$thumb_output = "";
$where = "";
$limit = "";
$pagenum = $_GET['pagenum'];
// did user select a category?
if($_GET['category'] != "") { $where = "and (t2.cat_id ='".$_GET['category']."')"; }
// do you use links with page number?
if ($_GET['pagenum'] != "") {
$start = $maxnumber_thumbs*($_GET['pagenum']-1);// calculate start and end of the thumbs in the selected page
$limit = " limit $start , $maxnumber_thumbs "; // create the limit command (in MS-SQL this should be TOP)
}// end if ($_GET['pagenum'] != "")
// build query
if ($_GET['archivedate']=="")
{
// no archive date
$query = "select t1.id,t1.headline,t1.image from {$pixelpost_db_prefix}pixelpost as t1
inner join {$pixelpost_db_prefix}catassoc as t2
where (t1.datetime<='$cdate')
$where
and t1.id = t2.image_id
group by t1.id
order by t1.datetime desc" .$limit;
} // if ($_GET['archivedate']=="")
else
{ // archive date is available
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$query = "select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate' and datetime >='$archivedate_start' and datetime <= '$archivedate_end') $where order by datetime desc" .$limit;
}// end else if ($_GET['archivedate']=="")
$query = mysql_query($query);
//---------------------------- Making thumbs row
// for each record ...
while(list($id,$title,$name) = mysql_fetch_row($query)) {
// from the thumbnail row. This could be build by tables too.
$title = pullout($title);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
} //end while
// initialize page counter
$pagecounter=0;
//---------------- Get number of photos in database in the selected category
// initialize where command
$where = "";
// check if user selects a category
if($_GET['category'] != "") {
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$_GET['category']."' AND datetime<='$datetime')";
$queryr .= " group by t1.cat_id ";
}// end if
else // not cat selected return all images in the DB
{
$queryr = "select count(*) as count
from {$pixelpost_db_prefix}pixelpost
where ( datetime<='$datetime')";
} //end else
$monthname = "";
if($_GET['archivedate'] != "") {
$archivedate_start = $_GET['archivedate'] ."-01 00:00:00";
$archivedate_end = $_GET['archivedate'] ."-31 23:59:59";
$where = " and datetime >='$archivedate_start' and datetime <= '$archivedate_end' ";
$monthname = $_GET['monthname'];
$queryr = "select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'" .$where;
} // end if($_GET['archivedate'] != "")
$photonumb = mysql_query($queryr);
$row = mysql_fetch_array($photonumb);
// number of photos in the database in the same category
$pixelpost_photonumb = $row['count'];
// calculate the number of pages
$num_browse_pages = ceil($pixelpost_photonumb/$maxnumber_thumbs);
// initialize archive links
$Archive_pages_Links = "";
// selected category id
$cat_id = $_GET['category'];
//-------- Make page number to archive as links (for the selected category)
if ($_GET['category']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=$cat_id&amp; pagenum=$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
else
{
if ($_GET['pagenum']!=""&$_GET['archivedate']=="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$pagecounter++;
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;category=&amp;pagenum =$pagecounter'>$pagecounter</a> ";
}// end while
}// end if
if ($_GET['archivedate']!="")
{
$pagecounter = 0;
while ($pagecounter < $num_browse_pages)
{
$monthname=str_replace(" ","%20",$monthname);
$pagecounter++;
$archivedate=$_GET['archivedate'];
$Archive_pages_Links .= "<a href='index.php?x=browse&amp;archivedate=$archived ate&amp;monthname=$monthname&amp;pagenum=$pagecoun ter'>$pagecounter</a> ";
}// whilte
}// end if $_GET['archivedate']!=""
}// end else
// selected category name
if($cat_id != "") {
$query = mysql_query("select name from ".$pixelpost_db_prefix."categories where id='$cat_id'");
$images_category_or_date = mysql_fetch_array($query);
$images_category_or_date = pullout($images_category_or_date['name']);
}
else
{
if ($_GET['archivedate']=="")
{$images_category_or_date = $lang_browse_all;}
else
{$images_category_or_date = $_GET['monthname'];}
}
} // end if ($_GET['x'] == "browse")
//------------- Make Archive browse menu with link to paged archive
// build browse menu
$browse_select = "";
// do you use links with page number?
if ($maxpthumb>0) {
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category=&amp;pa genum=$pagenum'>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
else{
$browse_select = "<select name='browse' onChange='self.location.href=this.options[this.sel ectedIndex].value;'><option value=''>$lang_browse_select_category</option><option value='index.php?x=browse&amp;amp;category='>$lang_browse_all (" .$pixelpost_all_photonumb .")</option>";}
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$name = pullout($name);
$queryr = "select count(*) as count,datetime
from {$pixelpost_db_prefix}catassoc as t1
inner join {$pixelpost_db_prefix}pixelpost t2 on t2.id = t1.image_id
where (t1.cat_id = '".$id."' AND datetime<='$datetime')
group by t1.cat_id ";
$count = mysql_query($queryr);
$count = mysql_fetch_array($count);
$count= $count['count'];
// check if you are using this addon
if ($maxpthumb>0) {
// u r using
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id&amp ;pagenum=1'>$name (" .$count .")</option>";
} // end if pagenum!=""
else {
// use the original browse category menu
$browse_select .= "<option value='index.php?x=browse&amp;amp;category=$id'>$name (" .$count .")</option>";};
} // end while
// finilize the tag
$browse_select .= "</select>";
$tpl = str_replace("<BROWSE_CATEGORIES_PAGED>",$browse_select,$tpl); //Browse menu for paged archive
//----------------- Build the additional new tages
//-- If you use paged archive
if ($pagenum!=""){
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); //thumbnails in this page
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>",$Archive_pages_Links,$tpl); // link to the pages of thumbnail in the selected category
$tpl = str_replace("<ARCHIVE_PAGES_NUM>",$pagenum,$tpl);// page number you are viewing
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
} //end if
//-- If you do not use page archive
else {
$tpl = str_replace("<THUMBNAILS_PAGES_LINKS>","",$tpl); // this does not use paged archive so there should be no links
$tpl = str_replace("<ARCHIVE_PAGES_NUM>","",$tpl); // page number you are viewing (it's empty for this case)
$tpl = str_replace("<THUMBNAILS_WHOLE_PAGED>",$thumb_output,$tpl); // the original thumb row in the archive
$tpl = str_replace("<CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE>",$images_category_or_date,$tpl); // Name of the category or Month you select
}// end else
$tpl = str_replace("<LINK_TO_PAGED_ARCHIVE>",'<a href="index.php?x=browse&pagenum=1">Archive</a>',$tpl);
?>
try this one.
Ignore the PM I made some minutes ago
raminia
06-27-2005, 05:33 PM
Ignore all these. download the latest from
http://www.pixelpost.org/v1/index.php?x=downloads&details=45
the bug is fixed there.
posefius
06-27-2005, 08:14 PM
Thank you Ramin. It is working fine now!
Piet Osefius
zjootsuite
06-28-2005, 08:25 PM
Ignore all these. download the latest from
http://www.pixelpost.org/v1/index.php?x=downloads&details=45.
Hi Raminia,
Today I fixed it too... but I can only view the first page. Wich Tag do I need for the second (and rest) page?
raminia
06-28-2005, 08:45 PM
Ignore all these. download the latest from
http://www.pixelpost.org/v1/index.php?x=downloads&details=45.
Hi Raminia,
Today I fixed it too... but I can only view the first page. Wich Tag do I need for the second (and rest) page?
<THUMBNAILS_PAGES_LINKS> // Link to the pages of thumbnail in the selected category
zjootsuite
06-28-2005, 08:50 PM
Thanks. It is working. Now only finetuning the css file.
btw It is a great addon.
oskarrr
01-15-2006, 11:35 AM
I must be stupid because i really don´t understand how to install this! I just downloaded the latest version of Pixelpost and in the admin-area i see that i can adjust this "add on" but i have no idea what so ever how to install it. I´ve opened the paged_archive.php but where should i upload this file? Or should i copy it to my ordinary archive page browse_template.html ? There is no info anywhere how to install it!
Would really appreciate a step-by-step idiot-proof guide how to do this. Thanks!
oskarrr
01-15-2006, 08:42 PM
Anyone?
I would like to have the archive sorted by month, and perhaps have the thumbnails with some info, like the title of the image and the date it was posted. Is that possible?
Joe[y]
01-15-2006, 08:48 PM
oskarr - perhaps you should look in your doc folder have a look at pixelpost-tags.txt - all the info you could want for the things you jsut described is there.
oskarrr
01-16-2006, 10:00 AM
']oskarr - perhaps you should look in your doc folder have a look at pixelpost-tags.txt - all the info you could want for the things you jsut described is there.
So since i have downloaded the latest version of Pixelpost i don't need to install the add-on:s they are allready there?
I found the "<BROWSE_MONTHLY_ARCHIVE_PAGED>"-tag but i can't find any tag that shows the title and date of every thumbnail, is there any such tag?
Joe[y]
01-16-2006, 05:30 PM
So since i have downloaded the latest version of Pixelpost i don't need to install the add-on:s they are allready there?
I found the "<BROWSE_MONTHLY_ARCHIVE_PAGED>"-tag but i can't find any tag that shows the title and date of every thumbnail, is there any such tag?
actually - these don't exist as standard tags.
have a look at this archive addon: http://pixelpost.org/v1/index.php?x=downloads&details=101
i use it at http://photos.jlspurling.com/archive
it works a treat!
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.