|
#1
|
|||
|
|||
|
calendar addon - now with day marking
now i've made it.. the posting day (of the shown image) is marked in the calendar.
to get this thing work you first have to add something to your style.css: Code:
.td-calendar-days-imagefound2 {
padding:1px;
text-align:center;
border-top:1px dotted #F00;
border-bottom:1px dotted #F00;
border-left:1px dotted #F00;
border-right:1px dotted #F00;
background:#f5f5f5;
}
Code:
<?php /* Pixelpost version 1.4.1 Calendar addon version 1.0.4 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&amp;curr_year=$prev_year'>&laquo;</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&amp;curr_year=$next_year'>&raquo;</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'>&nbsp;</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; } $post_day = substr($image_search,8,2); if ($post_day == $curr_day) { $check_var = "true"; } if($dayimage == "true") { if (($curr_image_id != $image_id) AND ($post_day != $curr_day)) { $class = "td-calendar-days-imagefound"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='An Image Was Posted This Day'>"; $link2 = "</a>"; } elseif ($curr_image_id == $image_id) { $class = "td-calendar-days-imagefound2"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='The Shown Image Was Posted This Day'>"; $link2 = "</a>"; } elseif (($curr_image_id != $image_id) AND ($check_var == "true")) { $class = "td-calendar-days-imagefound2"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='The Shown 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); $curr_day = substr($row['datetime'],8,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; } $post_day = substr($image_search,8,2); if ($post_day == $curr_day) { $check_var = "true"; } if($dayimage == "true") { if (($curr_image_id != $image_id) AND ($post_day != $curr_day)) { $class = "td-calendar-days-imagefound"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='An Image Was Posted This Day'>"; $link2 = "</a>"; } elseif ($curr_image_id == $image_id) { $class = "td-calendar-days-imagefound2"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='The Shown Image Was Posted This Day'>"; $link2 = "</a>"; } elseif (($curr_image_id != $image_id) AND ($check_var == "true")) { $class = "td-calendar-days-imagefound2"; $link = "<a href='$PHP_SELF?curr_month=$curr_month&amp;curr_year=$curr_year&amp;showimage=$curr_image_id' title='The Shown 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&amp;curr_year=$prev_year&amp;showimage=$showimage'>&laquo;</a> $asc_mon $curr_year <a href='$PHP_SELF?curr_month=$next_month&amp;curr_year=$next_year&amp;showimage=$showimage'>&raquo;</a> </td> </tr></table> "; $tpl = ereg_replace("<SITE_CALENDAR>",$cal_hz,$tpl); } // end horizontal calendar } ?>
__________________
Wer das Internet zu nutzen weiß, dem gehört die Gegenwart, wer es jedoch zu verändern weiß, dem gehört die Zukunft. for sale: madcity.de |
|
#2
|
|||
|
|||
|
the posting day is not shown correctly: it seems some css are missing, as you can see in my blog http://steff.altervista.org
(of course I modified my css style sheet as you stated) edit the calendar has disappeared... I revert to the original calendar
|
|
#3
|
|||
|
|||
|
for me it's working: http://amalydia.de
__________________
Wer das Internet zu nutzen weiß, dem gehört die Gegenwart, wer es jedoch zu verändern weiß, dem gehört die Zukunft. for sale: madcity.de |
|
#4
|
|||
|
|||
|
well I retried, I copied your posted code... but then the calendar disappears!
|
|
#5
|
||||
|
||||
|
very nice, but there's still a minor bug.
for some photos it works, for others it doesn't work: the problem: marking of days does not work with multiple posts per day. only the first post of a day is marked, all following posts on that day are not marked. would be great, if you could fix this! thank you! |
|
#6
|
||||
|
||||
|
thanks to amalydia, the calendar addon is nearly perfect now,
but may i summarize, that there are two issues left, that should be fixed: when browsing months by clicking the forward/backward quotes, the addon should consequently show the first image of the chosen month (currently it always shows the last uploaded image). in case of multiple posts on a day, each post should have the day highlighted (currently only the first post of a day is highlighted). with these two issues fixed, the calendar addon would have full navigation capabilities! |
|
#7
|
|||
|
|||
|
i need some time, to get my page running as i want it to.. then i'll give it a try.
__________________
Wer das Internet zu nutzen weiß, dem gehört die Gegenwart, wer es jedoch zu verändern weiß, dem gehört die Zukunft. for sale: madcity.de |
| Post Reply |
| Thread Tools | |
|
|