Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 05-28-2005, 12:59 AM
amalydia Offline
pp regular
 
Join Date: May 2005
Location: Bernburg, Germany
Posts: 21
Send a message via ICQ to amalydia
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;
	}
next use this new calendar.php in your addon directory:

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&curr_year=$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_year=$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;
		}
	$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&curr_year=$curr_year&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&curr_year=$curr_year&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&curr_year=$curr_year&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&curr_year=$curr_year&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&curr_year=$curr_year&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&curr_year=$curr_year&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&curr_year=$prev_year&showimage=$showimage'>«</a>
	$asc_mon $curr_year
	<a href='$PHP_SELF?curr_month=$next_month&curr_year=$next_year&showimage=$showimage'>»</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
Reply With Quote
  #2  
Old 05-28-2005, 09:17 PM
steff Offline
pixelpost guru
 
Join Date: Feb 2005
Location: Milan, Italy
Posts: 151
Send a message via MSN to steff
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
Reply With Quote
  #3  
Old 05-30-2005, 02:53 PM
amalydia Offline
pp regular
 
Join Date: May 2005
Location: Bernburg, Germany
Posts: 21
Send a message via ICQ to amalydia
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
Reply With Quote
  #4  
Old 05-31-2005, 01:11 PM
steff Offline
pixelpost guru
 
Join Date: Feb 2005
Location: Milan, Italy
Posts: 151
Send a message via MSN to steff
well I retried, I copied your posted code... but then the calendar disappears!
Reply With Quote
  #5  
Old 06-01-2005, 08:24 AM
-okapi-'s Avatar
-okapi- Offline
pixelpost guru
 
Join Date: Feb 2005
Location: Vienna, Austria
Posts: 252
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!
__________________
a visual notebook
michael singer photography
http://www.a-visual-notebook.at
Reply With Quote
  #6  
Old 06-06-2005, 07:25 AM
-okapi-'s Avatar
-okapi- Offline
pixelpost guru
 
Join Date: Feb 2005
Location: Vienna, Austria
Posts: 252
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!
__________________
a visual notebook
michael singer photography
http://www.a-visual-notebook.at
Reply With Quote
  #7  
Old 06-06-2005, 07:42 AM
amalydia Offline
pp regular
 
Join Date: May 2005
Location: Bernburg, Germany
Posts: 21
Send a message via ICQ to amalydia
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
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 10:31 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs