PDA

View Full Version : calendar addon: months changing...


-okapi-
04-26-2005, 01:56 PM
a feature that would be very nice and useful:

the calendar months changing according to the month of the image that is displayed.

visitors are missing something, when they browse the images while the calendar always shows just the current month.

i think, an update of the calendar addon would be great for everyone!

steff
04-26-2005, 03:31 PM
yeah, and even better, the day of post could be evidenced ... :)

-okapi-
04-26-2005, 03:40 PM
oh yeah!!

this would be a fantastic update of the calendar addon!
but WHO would be kind enough, skilled enough, willing enough, and has a big heart for us, ever demanding people, to do that???

:wink: :wink: :wink:

-okapi-
05-03-2005, 10:53 AM
is this very hard to do...?

amalydia
05-26-2005, 03:04 PM
i've edited my index.php to get month and year from sql and add the curr_month and curr_year vars to the link.. works very fine right now... hope so

sorry for my bad english... i'll try my best


if(function_exists(gd_info)) {
$gd_info = gd_info();
if($gd_info != "") { // check that gd is here before this
$aheadnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate')");
$aheadnumb = $aheadnumb['count'];
$behindnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate')");
$behindnumb = $behindnumb['count'];
$aheadlimit = round(($cfgrow['thumbnumber']-1)/2);
$behindlimit = round(($cfgrow['thumbnumber']-1)/2);
if($aheadnumb <= $aheadlimit) {
$behindlimit = ($cfgrow['thumbnumber']-1)-$aheadnumb;
$aheadlimit = $aheadnumb;
}
if($behindnumb <= $behindlimit) {
$aheadlimit = ($cfgrow['thumbnumber']-1)-$behindnumb;
$behindlimit = $behindnumb;
}
$totalthumbcounter = 1;
$ahead_thumbs = "";
$ahead_thumbs_reverse ="";
$thumbs_ahead = mysql_query("select id,headline,image,datetime from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate') order by datetime asc limit 0,$aheadlimit");
while(list($id,$headline,$image,$datetime) = mysql_fetch_row($thumbs_ahead)) {
$thumbs_datetime = $row['datetime'];
$thumbs_date_year_full = substr($row['datetime'],0,4);
//$image_date_year = substr($row['datetime'],2,2);
$thumbs_date_month = substr($row['datetime'],5,2);
if ($thumbs_date_month != '10') {$thumbs_date_month = str_replace('0','',$thumbs_date_month);}
$headline = pullout($headline);
$headline = htmlspecialchars($headline,ENT_QUOTES);
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$ahead_thumbs .= "<a href='$showprefix$id&curr_month=$thumbs_date_month &curr_year=$thumbs_date_year_full'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>";
$ahead_thumbs_reverse = "<a href='$showprefix$id&curr_month=$thumbs_date_month &curr_year=$thumbs_date_year_full'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>" .$ahead_thumbs_reverse ;
$totalthumbcounter++;
}
$behind_thumbs = "";
$behind_thumbs_reverse ="";
$thumbs_behind = mysql_query("select id,headline,image,datetime from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate') order by datetime desc limit 0,$behindlimit");
while(list($id,$headline,$image,$datetime) = mysql_fetch_row($thumbs_behind)) {
$thumbs_datetime = $row['datetime'];
$thumbs_date_year_full = substr($row['datetime'],0,4);
//$image_date_year = substr($row['datetime'],2,2);
$thumbs_date_month = substr($row['datetime'],5,2);
if ($thumbs_date_month != '10') {$thumbs_date_month = str_replace('0','',$thumbs_date_month);}
$headline = pullout($headline);
$headline = htmlspecialchars($headline,ENT_QUOTES);
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$behind_thumbs = "<a href='$showprefix$id&curr_month=$thumbs_date_month &curr_year=$thumbs_date_year_full'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>$behind_thumbs";
$behind_thumbs_reverse .= "<a href='$showprefix$id&curr_month=$thumbs_date_month &curr_year=$thumbs_date_year_full'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>";
$totalthumbcounter++;
}

-okapi-
05-26-2005, 03:11 PM
very interesting,
thank you, amalydia!

but for me, there's still a function missing:
when browsing the images, the calendar still doesn't change the month according to the date of the image that is currently displayed.

the best would be a modification or a new version of the calendar addon, keeping the index.php untouched.

amalydia
05-26-2005, 07:11 PM
ok you are right.. leave the index.php clean and make some changes at the calendar.php in addons..

replace the outquoted source by this:


if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
}
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/

amalydia
05-26-2005, 07:12 PM
i forgot to say: in both sections - the normal and the horizontal function

Connie
05-26-2005, 07:16 PM
amalydia,

would you like to make an addon out of this?
That would be really great!

And welcome here!

amalydia
05-26-2005, 07:19 PM
schould i post my complete calendar.php as code?

raminia
05-26-2005, 07:48 PM
YES!

amalydia
05-26-2005, 08:00 PM
ok.. here we go again:


<?php

/*

Pixelpost version 1.4.1
Calendar addon version 1.0.2

Pixelpost www: http://www.pixelpost.org/

Version 1.4:
Developer Team:
Ramin Mehran, Connie Mueller-Goedecke and Robert Prouse
Version 1.1 to Version 1.3: Linus

Contact: pixelpost@pixelpunk.se
Copyright (c) 2004 shapestyle graphic design + code <http://www.shapestyle.se>
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.

*/

$addon_name = "Pixelpost Calendar";
$addon_description = "A standard calendar. Highlights days on which images are posted.<br />
Will return either a horizontal looking calendar, or a \"normal\" display.<br>
Uses the language-files for months and weekdays
";
$addon_version = "1.0.1";

if($_GET['x'] == "") {

// use the language-variables from the active language file
$days = array("$lang_monday","$lang_tuesday","$lang_wednesday","$lang_thursday","$lang_friday","$lang_saturday","$lang_sunday");
$months = array("","$lang_january","$lang_february","$lang_march","$lang_april","$lang_may","$lang_june","$lang_july","$lang_august","$lang_september","$lang_october","$lang_november","$lang_december");

// calendar in "normal" output

if($cfgrow['calendar'] == "Normal") {
$cal_vz = "";


$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);
// february is one day longer anyway
if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_vz .= "
<table class='table-calendar-vz' cellspacing='0'>
<tr>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year'>«</a></td>
<td colspan='5' class='td-calendar-navi-vz'>
$asc_mon $curr_year
</td>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year'>»</a></td>
</tr>
<tr>";
for ($x=0; $x<7; $x++) {
$day = substr($days[$x],0,3);
// here encoding ASCII to UTF:
$day= preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $day);
$cal_vz .= "<td class='td-calendar-days-vz'>$day</td>";
}
$cal_vz .= "</tr><tr>";
for($x=2; $x<=$first_day_month; $x++) {
$row_count++;
$cal_vz .= "<td class='td-calendar-days-vz'> </td>";
}
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($row_count % 7 == 0) { $cal_vz .= "</tr><tr>"; }
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days-vz";
} else {
$class = "td-calendar-days-vz";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = ""; // forgot, dare not delete yet
$link2 = ""; // forgot, dare not delete yet
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_vz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$cal_vz .= "
</tr>
</table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_vz,$tpl);
} // normal cal end

if($cfgrow['calendar'] == "Horizontal") {
// horizontal
$cal_hz = "";

if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);

if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day of month
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$cal_hz .= "<table class='table-calendar' cellspacing='0'><tr>";
// print the calendar days
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days";
} else {
$class = "td-calendar-days";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = "";
$link2 = "";
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_hz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$showimage = $_GET['showimage'];
// Convert month-name to UTF-8
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_hz .= "
</tr>
<tr>
<td colspan='31' class='td-calendar-navi'>
<a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year&showimage=$showimage'>«</a>
$asc_mon $curr_year
<a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year&showimage=$showimage'>»</a>
</td>
</tr></table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_hz,$tpl);
}
// end horizontal calendar
}

?>

amalydia
05-26-2005, 08:03 PM
perhaps you could read curr_day also from database and then you also have the day marked in calendar..

could be another improvement

-okapi-
05-27-2005, 05:50 AM
wow! that's really great.
thank you so much!
this has been on top of my wishlist for a long time!

yet there seems to be a small bug:

when clicking months << backward or forward >> i always get the current month

the syntax of the links is ok, but they don't work how they should:

http://www.a-visual-notebook.at/index.php?curr_month=3&curr_year=2005
doesn't get me march 2005, but may 2005

amalydia
05-27-2005, 08:50 AM
i forgot two lines of code. like in the horizontal section, you should add the if cause to the normal section:


if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
}

-okapi-
05-27-2005, 09:08 AM
the previous/next month links still don't work for me.
here's the code. maybe i have done something wrong...?

<?php

/*

Pixelpost version 1.4.1
Calendar addon version 1.0.2

Pixelpost www: http://www.pixelpost.org/

Version 1.4:
Developer Team:
Ramin Mehran, Connie Mueller-Goedecke and Robert Prouse
Version 1.1 to Version 1.3: Linus

Contact: pixelpost@pixelpunk.se
Copyright (c) 2004 shapestyle graphic design + code <http://www.shapestyle.se>
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.

*/

$addon_name = "Pixelpost Calendar";
$addon_description = "A standard calendar. Highlights days on which images are posted.<br />
Will return either a horizontal looking calendar, or a \"normal\" display.<br>
Uses the language-files for months and weekdays
";
$addon_version = "1.0.1";

if($_GET['x'] == "") {

// use the language-variables from the active language file
$days = array("$lang_monday","$lang_tuesday","$lang_wednesday","$lang_thursday","$lang_friday","$lang_saturday","$lang_sunday");
$months = array("","$lang_january","$lang_february","$lang_march","$lang_april","$lang_may","$lang_june","$lang_july","$lang_august","$lang_september","$lang_october","$lang_november","$lang_december");

// calendar in "normal" output

if($cfgrow['calendar'] == "Normal") {
$cal_vz = "";

if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
}

$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);
// february is one day longer anyway
if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_vz .= "
<table class='table-calendar-vz' cellspacing='0'>
<tr>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year'>«</a></td>
<td colspan='5' class='td-calendar-navi-vz'>
$asc_mon $curr_year
</td>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year'>»</a></td>
</tr>
<tr>";
for ($x=0; $x<7; $x++) {
$day = substr($days[$x],0,2);
// here encoding ASCII to UTF:
$day= preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $day);
$cal_vz .= "<td class='td-calendar-days-vz'>$day</td>";
}
$cal_vz .= "</tr><tr>";
for($x=2; $x<=$first_day_month; $x++) {
$row_count++;
$cal_vz .= "<td class='td-calendar-days-vz'> </td>";
}
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($row_count % 7 == 0) { $cal_vz .= "</tr><tr>"; }
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days-vz";
} else {
$class = "td-calendar-days-vz";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = ""; // forgot, dare not delete yet
$link2 = ""; // forgot, dare not delete yet
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_vz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$cal_vz .= "
</tr>
</table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_vz,$tpl);
} // normal cal end

if($cfgrow['calendar'] == "Horizontal") {
// horizontal
$cal_hz = "";

if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
// $hmpf = mysql_fetch_row($img_dates);
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
//echo $curr_month.'-'.$curr_year;
}
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);

if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day of month
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$cal_hz .= "<table class='table-calendar' cellspacing='0'><tr>";
// print the calendar days
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days";
} else {
$class = "td-calendar-days";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = "";
$link2 = "";
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_hz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$showimage = $_GET['showimage'];
// Convert month-name to UTF-8
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_hz .= "
</tr>
<tr>
<td colspan='31' class='td-calendar-navi'>
<a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year&showimage=$showimage'>«</a>
$asc_mon $curr_year
<a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year&showimage=$showimage'>»</a>
</td>
</tr></table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_hz,$tpl);
}
// end horizontal calendar
}

?>

amalydia
05-27-2005, 09:46 AM
as it schould be:



<?php

/*

Pixelpost version 1.4.1
Calendar addon version 1.0.3
edited by amalYdia.de

Pixelpost www: http://www.pixelpost.org/

Version 1.4:
Developer Team:
Ramin Mehran, Connie Mueller-Goedecke and Robert Prouse
Version 1.1 to Version 1.3: Linus

Contact: pixelpost@pixelpunk.se
Copyright (c) 2004 shapestyle graphic design + code <http://www.shapestyle.se>
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.

*/

$addon_name = "Pixelpost Calendar";
$addon_description = "A standard calendar. Highlights days on which images are posted.<br />
Will return either a horizontal looking calendar, or a \"normal\" display.<br>
Uses the language-files for months and weekdays
";
$addon_version = "1.0.3";

if($_GET['x'] == "") {

// use the language-variables from the active language file
$days = array("$lang_monday","$lang_tuesday","$lang_wednesday","$lang_thursday","$lang_friday","$lang_saturday","$lang_sunday");
$months = array("","$lang_january","$lang_february","$lang_march","$lang_april","$lang_may","$lang_june","$lang_july","$lang_august","$lang_september","$lang_october","$lang_november","$lang_december");

// calendar in "normal" output

if($cfgrow['calendar'] == "Normal") {
$cal_vz = "";

if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
}
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);
// february is one day longer anyway
if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_vz .= "
<table class='table-calendar-vz' cellspacing='0'>
<tr>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year'>«</a></td>
<td colspan='5' class='td-calendar-navi-vz'>
$asc_mon $curr_year
</td>
<td class='td-calendar-navi-vz'><a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year'>»</a></td>
</tr>
<tr>";
for ($x=0; $x<7; $x++) {
$day = substr($days[$x],0,3);
// here encoding ASCII to UTF:
$day= preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $day);
$cal_vz .= "<td class='td-calendar-days-vz'>$day</td>";
}
$cal_vz .= "</tr><tr>";
for($x=2; $x<=$first_day_month; $x++) {
$row_count++;
$cal_vz .= "<td class='td-calendar-days-vz'> </td>";
}
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($row_count % 7 == 0) { $cal_vz .= "</tr><tr>"; }
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days-vz";
} else {
$class = "td-calendar-days-vz";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = ""; // forgot, dare not delete yet
$link2 = ""; // forgot, dare not delete yet
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_vz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$cal_vz .= "
</tr>
</table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_vz,$tpl);
} // normal cal end

if($cfgrow['calendar'] == "Horizontal") {
// horizontal
$cal_hz = "";

if (!$curr_year) {
$img_dates = mysql_query("select datetime from ".$pixelpost_db_prefix."pixelpost where (id = '$image_id')");
while(list($datetime) = mysql_fetch_row($img_dates)) {
$curr_year = substr($row['datetime'],0,4);
$curr_month = substr($row['datetime'],5,2);
if ($curr_month != '10') {$curr_month = str_replace('0','',$curr_month);}
}
}
/*
$curr_month = $_GET['curr_month'];
$curr_year = $_GET['curr_year'];
if(!$curr_year) { $curr_year = date("Y"); }
if(!$curr_month) { $curr_month = date("n"); }
if(!$curr_day) { $curr_day = date("j"); }
*/
$total_days = array(0,31,28,31,30,31,30,31,31,30,31,30,31);

if(date("L", mktime(0,0,0,$curr_month,1,$curr_year))) {
$total_days[2] = 29;
}
$prev_month = $curr_month-1;
$prev_year = $curr_year;
if($prev_month < 1) {
$prev_month=12;
$prev_year--;
}
$next_month = $curr_month+1;
$next_year = $curr_year;
if($next_month > 12) {
$next_month=1;
$next_year++;
}
// first day of month
$first_day_month = date("w", mktime(0,0,0,$curr_month,1,$curr_year));
$cal_hz .= "<table class='table-calendar' cellspacing='0'><tr>";
// print the calendar days
$day_count=1;
while($day_count <= $total_days[$curr_month]) {
if($day_count <= 9) { $day_count = "0$day_count"; }
$thismonth = $curr_month;
if($curr_month <= 9) { $thismonth = "0$curr_month"; }
if($day_count <= date("j") && $curr_year == date("Y") && $curr_month == date("n") OR ($curr_month < date("m") AND $curr_year <= date("Y"))) {
$class = "td-calendar-days";
} else {
$class = "td-calendar-days";
}
$image_search = "$curr_year-$thismonth-$day_count"; // correct queryformat to check if any image are present the current day
$link = "";
$link2 = "";
// search for image for this day
$dayimage = "false";
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (datetime like '$image_search%') and (datetime<='$cdate')");
while(list($img_id, $img_datetime, $img_headline, $img_body, $img_image) = mysql_fetch_row($query)) {
$dayimage = "true";
$curr_image_id = $img_id;
}
if($dayimage == "true") {
$class = "td-calendar-days-imagefound";
$link = "<a href='$PHP_SELF?curr_month=$curr_month&curr_ye ar=$curr_year&showimage=$curr_image_id' title='An Image Was Posted This Day'>";
$link2 = "</a>";
}
$cal_hz .= "<td class='$class'>$link$day_count$link2</td>";
$day_count++;
$row_count++;
}
$showimage = $_GET['showimage'];
// Convert month-name to UTF-8
$asc_mon = $months[$curr_month];
$asc_mon = preg_replace ('/([\x80-\xff])/se', "pack (\"C*\", (ord ($1) >> 6) | 0xc0, (ord ($1) & 0x3f) | 0x80)", $asc_mon);
$cal_hz .= "
</tr>
<tr>
<td colspan='31' class='td-calendar-navi'>
<a href='$PHP_SELF?curr_month=$prev_month&curr_ye ar=$prev_year&showimage=$showimage'>«</a>
$asc_mon $curr_year
<a href='$PHP_SELF?curr_month=$next_month&curr_ye ar=$next_year&showimage=$showimage'>»</a>
</td>
</tr></table>
";
$tpl = ereg_replace("<SITE_CALENDAR>",$cal_hz,$tpl);
}
// end horizontal calendar
}

?>

-okapi-
05-27-2005, 09:55 AM
thank you very much, amalydia!
now it works perfectly!
:D

raminia
05-27-2005, 04:21 PM
I updated my calander addon but when I choose previous months the shown image does not change. BTW, the reverse is working. when selecting an image of the past the calander shows the dates of the past.

-okapi-
05-27-2005, 04:29 PM
ramin,
the last code that amalydia provided (Fri May 27, 2005 10:46 am) does work!

steff
05-27-2005, 08:20 PM
for my horizontal calendar, it does not work, the image remains the same :(

raminia
05-27-2005, 08:29 PM
yes me 2. horizontal.

amalydia
05-27-2005, 09:10 PM
yes.. ramina is right, but the calendar addon before didn't provided this feature at all (or shoul i say also?)

let's give it a try when my site is working and i have more time for such improvements :-)

i got a lot of things to do..

please have a look: http://amalydia.de