Gå til innhold

Kalender i julegave?


Anbefalte innlegg

Noen som sliter med å finne på julegaver?

Hva med å gi en kalender for 2007? ;)

Har tatt utgangspunkt i et script jeg fant og endret det slik at det genererer en kalender med helligdager og flaggdager markert.

 

Kjempe ide til f.eks en svaksynt bestemor? ;)

Har lett mye, men finner svært lite kalendere som har store tall, dessuten er det jo ingenting som er bedre enn en kalender med bilder av familien? ;)

 

Legger ut scriptet her, bare å endre CSS og sånt og legge bilder i ./bilder/ med navn 1.jpg, 2.jpg, osv for hver mnd. ;)

 

flagg.gif bør du også legge dit, bruk f.eks det norske flagget fra ezUserManager/ezOnlineGallery. ;)

 

Edit:

For å få hver mnd på en side kan man i FireFox velge forhåndsvisning og justere skaleringen der... ;)

 

Edit 2:

Lastet opp flagg.gif også. ;)

 

<?php
////////////////////////////////////////////////////////////////
// Another Calendar ///////////////////////////////////////////
//
// Please visit http://www.blog.snag.se/forum/ 
// and post your thoughts about the script. 
//
// Creative Commons License (creativecommons.org)
// http://creativecommons.org/licenses/by-nc-sa/2.0/
//
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

// If you're happy with the style of the calendar.
// You don't need to change anything.
// Else you can change the colours below.

// Name of the month, in the language you want.
$january = 'JANUAR';
$february = 'FEBRUAR';
$march = 'MARS';
$april = 'APRIL';
$may = 'MAI';
$june = 'JUNI';
$july = 'JULI';
$august = 'AUGUST';
$september = 'SEPTEMBER';
$october = 'OKTOBER';
$november = 'NOVEMBER';
$december = 'DESEMBER';

// Name of the days, in the language you want.
$monday = "MA";
$tuesday = "TI"; 
$wednesday = "ON";
$thursday = "TO";
$friday = "FR";
$saturday = "LØ";
$sunday = "SØ";

// If you wish the calendar to start the week with Monday, leave this true.
// Else edit it to "false", to make the week start with Sunday.
$startwithmonday = true;

// Bevegelige helligdager
               // Y-m-d => beskrivelse av flaggdag/false?
$bevHelligDag = array("2007-4-1" => false,
                   "2007-4-5" => false,
                   "2007-4-6" => false,
                   "2007-4-8" => "1. påskedag",
                   "2007-4-9" => false,
                   "2007-5-17" => false,
                   "2007-5-25" => "1. pinsedag",
                   "2007-5-26" => false);

// Faste helligdager                    
                   // m-d => beskrivelse av flaggdag/false?
$fastHelligDag = array("1-1" => "Nyttårsdag", 
                   "5-1" => "Offentlig høytidsdag",
                   "5-17" => "Grunnlovsdag",
                   "12-25" => "1. juledag",
                   "12-26" => false);
       
// Flaggdager           
                   // m-d => beskrivelse
$flaggDag = array("1-21" => "HKH Prinsesse Ingrid Alexandras fødselsdag",
                   "2-6" => "Samefolkets dag",
                   "2-21" => "HM Kong Haralds fødselsdag",
                   "5-8" => "Frigjøringsdag 1945",
                   "6-7" => "Unionsoppløsningen 1905",
                   "7-4" => "HM Dronning Sonjas fødselsdag",
                   "7-20" => "HKH Kronprins Haakons fødselsdag",
                   "7-29" => "Olsok",
                   "8-19" => "HKH Kronprinsesse Mette-Marits fødselsdag");

// If you want to se weeknumber, else false.
$weeknumber = true;

// Width of the calander. 
$width = "1000px";

// Color of the days in current month.
$numberBGColor = "#EEE";
$numberTextColor ="#000";

// Color of the days before and after current month.
$emptyBGColor = "#FFF";
$emptyTextColor ="#FFF";

// The color the "hover" day should change to.
$selBGColor = "#999";
$selTextColor = "#000";

// The colour for today.
$todayBGColor = "#FF9999";
$todayTextColor = "#FFFFFF";

// Colours for the month and day names.
$monthBGColor = "#FFFFFF";
$monthTextColor = "#A7D18D";
$daysBGColor = "#CCCCCC";
$weekBGColor = "#EEEEEE";


$background = "#FFFFFF";

// Colours to toggle between if more then one event.
$event1 = "#EEEEEE";
$event2 = "#CCCCCC";

// If you want space between the days comment out this.
//$spacing = "collapse";


////////////////////////////////////////////////////////////////
// Start of actual code, no need to change ////////////////////
//
if($startwithmonday) {
$dayName = array($monday, $tuesday, $wednesday, $thursday, $friday, $saturday,$sunday);
} else {
$dayName = array($sunday, $monday, $tuesday, $wednesday, $thursday, $friday, $saturday);
}

$monthName = array($january, $february, $march, $april, $may, $june, $july, $august, $september, $october,
$november, $december);

if(isset($_GET['date'])){
$date = $_GET['date'];
} else {
$date = date("Y-m-d");
}

////////////////////////////////////////////////////////////////
// CSS for the calender ///////////////////////////////////////
//
echo "<STYLE type=\"text/css\">
<!--
.A {	
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    1px;
font-style:    normal;
line-height:    normal;
font-weight:    bold;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
vertical-align:  	middle;
text-align:    center;
color:    $numberTextColor;

}

.sel {	
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    65px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
text-align:    center;
vertical-align:  	middle; 
cursor:    default;
color:    $selTextColor;
background-color:  $selBGColor;
}
.event {
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    65px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
cursor:    default;
vertical-align:  	middle;
text-align:    center;
color:    $numberTextColor;
background-color:  $numberBGColor;
border:                1px solid black;
padding:  	5px;
margin:  	5px;
}

.hellig {
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    65px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
cursor:    default;
vertical-align:  	middle;
text-align:    center;
color:    red;
background-color:  $numberBGColor;
border:                1px solid black;
padding:  	5px;
margin:  	5px;
}

.weekNr {
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    65px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
cursor:    default;
vertical-align:  	middle;
text-align:    center;
color:    $numberTextColor;
background-color:     lightgreen;
border:                1px solid black;
}

.empty {
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    65px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
cursor:    default;
vertical-align:  	middle;
text-align:    center;
color:    $emptyTextColor;
background-color:  $emptyBGColor;
visibility: hidden;
}

.monthName {	
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:          60px;
font-weight:        bold;
font-style:        	normal;
text-align:    center;
vertical-align:  	middle;
padding:  	2 2 2 2;
text-align:  	center;
vertical-align:  	top;
vertical-align:  	middle;
}

.flaggDagerListe {
   font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    25px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
cursor:    default;
vertical-align:  	middle;
text-align:    left;
color:    $numberTextColor;
background-color:  $numberBGColor;
border:                1.5px solid black;
padding:  	8px;
margin:  	8px;
border-collapse:  	collapse;
}

.table {
border-style:    none;
 border-collapse:  	$spacing;
empty-cells:    hide;
}

.td {	
font-family:    Verdana, Arial, Helvetica, sans-serif;
font-size:    55px;
font-style:    normal;
line-height:    normal;
font-weight:    normal;
font-variant:    normal;
text-transform:  	none;
text-decoration:  	none;
text-align:    center;
vertical-align:  	middle; 
}-->\n</STYLE>\n\n";
// End of CSS
////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
// Function for creating the current month ////////////////////
//
function createMonth($date) {

global $startwithmonday;

$date = split("\-", $date);
$year = $date[0];
$month = $date[1];

// Dates

$this_month_date = makeDate($year, $month, 1);
$last_month_date = makeDate($year, $month - 1, 1);
$next_month_date = makeDate($year, $month + 1, 1);
// Numbers
$this_month_first_day = trim(date("w", $this_month_date));

$this_month_days = trim(date("t", $this_month_date));
$last_month_days = trim(date("t", $last_month_date));

$this_month_number = trim(date("n", $this_month_date));
$last_month_number = trim(date("n", $last_month_date));
$next_month_number = trim(date("n", $next_month_date));

$this_month_year = trim(date("Y", $this_month_date));
$last_month_year = trim(date("Y", $last_month_date));
$next_month_year = trim(date("Y", $next_month_date));

if($startwithmonday) {
 if($this_month_first_day == 0) {
 	$this_month_first_day = 7;
 }
} else {
 $this_month_first_day++;
}

 
// Förra
for($I = 1; $I < $this_month_first_day; $I++) {
 $temp = $last_month_days - $this_month_first_day + $I + 1;
 $monthArray["$last_month_year-$last_month_number-$temp"] = array(0, "$last_month_year-$last_month_number-$temp");
}
// Månad.
for($I = 1; $I <= $this_month_days; $I++) {
 $monthArray["$this_month_year-$this_month_number-$I"] = array(1, "$this_month_year-$this_month_number-$I");
}
// Nästa
for($I = 1; $I <= 43 - $this_month_days - $this_month_first_day; $I++) {
 $monthArray["$next_month_year-$next_month_number-$I"] = array(0, "$next_month_year-$next_month_number-$I");
}
return $monthArray;	
};

// End of createMonth function
////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
// Function for adding the current day ////////////////////////
//
function addToday($date, $monthArray) {
$date = split("\-", $date);
$year = $date[0];
$month = $date[1];
$this_year = date("Y");
$this_month = date("n");

if($year == $this_year && $month == $this_month) {
 $monthArray[date("Y-n-j")][0] +=2;
}
return $monthArray;
};
// End of addToday function
////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
// Function for displaying the current month //////////////////
//
function displayMonth($date, $monthArray) {
global $path, $weekBGColor, $weeknumber, $width, $monthName, $dayName, $monthBGColor, 
           $monthTextColor, $daysBGColor, $bevHelligDag, $fastHelligDag, $flaggDag;

$date = split("\-", $date);
$year = $date[0];
$month = $date[1];

$this_month = mktime(0, 0, 0, $month, 1,  $year);
$last_month = mktime(0, 0, 0, $month - 1, 1,  $year);
$next_month = mktime(0, 0, 0, $month + 1, 1,  $year);


echo "<center><img style=\"border: 2px solid black\" width=\"850px\" src=\"./bilder/" . date("n", $this_month) . ".jpg\"><br><br><br><br>";

echo "<TABLE CELLSPACING=\"15\" class=\"table\" style=\"border: 1.5px solid black;\" width=\"$width\">\n<TR>\n";
echo "<TD class=\"td\" color=\"$monthTextColor\" bgcolor=\"$monthBGColor\" onMouseOver=\"this.className='sel'\" onMouseOut=\"this.className='td'\" >\n<A class=\"A\" HREF=\"?date=";
echo date("Y-m-j", $last_month);
echo "\">«</A>\n</TD>\n<TD class=\"monthName\" color=\"$monthTextColor\"  bgcolor=\"$monthBGColor\">\n";
echo $monthName[$month-1];
echo date(" Y", $this_month);
echo "\n</TD>\n<TD class=\"td\" color=\"$monthTextColor\"  bgcolor=\"$monthBGColor\" onMouseOver=\"this.className='sel'\" onMouseOut=\"this.className='td'\" >\n<A class=\"A\" HREF=\"?date=";
echo date("Y-m-j", $next_month);
echo "\">»</A>\n</TD>\n</TR>\n<TR>\n";

echo "<TD class=\"td\" colspan=\"3\">\n	<TABLE class=\"table\" width=\"100%\">\n<TR>\n";

foreach ($dayName as $key) {
echo "<TD class=\"td\" style=\"border: 3px solid black;\" width=\"100px\" bgcolor=\"$daysBGColor\">$key</TD>\n";
}

if($weeknumber) {
   echo "<TD class=\"td\" width=\"15px\" style=\"border: 3px solid black;\" bgcolor=\"white\"></TD>\n";
echo "<TD class=\"td\" width=\"100px\" style=\"border: 3px solid black;\" bgcolor=\"$daysBGColor\">UKE</TD>\n";
}

echo "</TR>\n\n<TR>\n";


////////////////////////////////////////////////////////
// Prints the days. ///////////////////////////////////
//
$day = 0;

if($weeknumber) {
 $week = date("W", $this_month);
}

   $selectedMonth = date("n", $this_month);

foreach ($monthArray as $key) {
 $date = split("\-", $key[1]);

    if($key[0] == 0) {
       echo "<TD class=\"empty\">$date[2]</TD>\n";
 } 
       else if($key[0] == 1) {
           echo "<TD class=\"";
           // Hvis helligdag eller søndag
 	if (array_key_exists($date[0]."-".$date[1]."-".$date[2], $bevHelligDag) 
                   || $day == 6
                   || array_key_exists($date[1]."-".$date[2], $fastHelligDag)) {
       echo "hellig";
           }
           else {
               echo "event";
           }
           echo "\">$date[2]";
           // Hvis flaggdag
           if (!empty($bevHelligDag[$date[0]."-".$date[1]."-".$date[2]]) 
                   || !empty($fastHelligDag[$date[1]."-".$date[2]])
                   || !empty($flaggDag[$date[1]."-".$date[2]])) {
               echo "<br><div align=\"right\"><img src=\"./bilder/flagg.gif\" border=0>";
               
               $timestampFlaggDag = makeDate($date[0], $date[1], $date[2]);
               
               // Lag beskrivelse av flaggdagen
               if (!empty($flaggDag[$date[1]."-".$date[2]])) {
                   $flaggDager[$timestampFlaggDag] = $flaggDag[$date[1]."-".$date[2]];
               }
               else if (!empty($fastHelligDag[$date[1]."-".$date[2]])) {
                   $flaggDager[$timestampFlaggDag] = $fastHelligDag[$date[1]."-".$date[2]];
               }
               else if (!empty($bevHelligDag[$date[0]."-".$date[1]."-".$date[2]])) {
                   $flaggDager[$timestampFlaggDag] = $bevHelligDag[$date[0]."-".$date[1]."-".$date[2]];
               }
           }
           echo "</TD>\n";
 } 
       else if($key[0] == 2) {
 	echo "<TD onMouseOver=\"this.className='sel'\" onMouseOut=\"this.className='event'\" class=\"event\"><A class=\"A\" HREF=\"javascript:event('$path?act=event&date=" . $key[1] . "')\">$date[2]</A></TD>\n";
 } 
       else if ($key[0] == 3) {
 	echo "<TD onMouseOver=\"this.className='sel'\" onMouseOut=\"this.className='today'\" class=\"today\">$date[2]</TD>\n";
 }
       else if ($key[0] == 4) {
 	echo "<TD onMouseOver=\"this.className='sel'\" onMouseOut=\"this.className='today'\" class=\"today\"><A class=\"A\" HREF=\"javascript:event('$path?act=event&date=" . $key[1] . "')\"><B>$date[2]</B></A></TD>\n";
 }
    $day++;
       if($day >= 7) {
           if($weeknumber && ($selectedMonth == date("n", mktime(0, 0, 1, $date[1], $date[2], $date[0])) || $date[2] < 7)) {
               $week += 0;
               echo "<TD class=\"td\" style=\"border: 3px solid black;\" bgcolor=\"white\"></TD>\n";
               echo "<TD bgcolor=\"$weekBGColor\" class=\"weekNr\">$week</TD>\n";
               if($week >= 53) {
       $week = 0;
               }
               $week++;
           }
           echo "</TR>\n<TR>\n";
           $day = 0;
       }
//
////////////////////////////////////////////////////////
}
echo "</TR>\n</TABLE>\n</TD></TR></TABLE>\n";

// Vis flaggdag-beskrivelse
if (isset($flaggDager)) {
   ksort($flaggDager);
   echo "<br><table width=\"$width\" class=\"flaggDagerListe\">";
   echo "<tr><td class=\"flaggDagerListe\" colspan=2><center><b>Flaggdager:</b></center></td></tr>";

   foreach ($flaggDager as $key => $value) {
       $dato = date("j.", $key);
       echo "<tr class=\"flaggDagerListe\"><td class=\"flaggDagerListe\"><center>$dato</center></td>
               <td width=\"100%\" class=\"flaggDagerListe\">$value</td></tr>";
   }
   echo "</table>";
}
};

// End of displayMonth function
////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////
// Function for creating a date. //////////////////////////////
//  

function makeDate($year, $month, $day) {
return mktime(0, 0, 0, $month, $day,  $year);
};

// End of makeDate function
////////////////////////////////////////////////////////////////




$monthArray = createMonth($date);
$monthArray = addToday($date, $monthArray);
displayMonth($date, $monthArray);
?>

post-4579-1164740056_thumb.gif

Endret av ZoRaC
Lenke til kommentar
Videoannonse
Annonse
Ja, men problemet er at julaften er siste dagen på julekalenderen da... :p

Kjipt med gave som man bare har glede av der og da, bedre med en kalender for hele året. ;)

7379454[/snapback]

 

Kan kjøpe julekalender for 2007?? :whistle:

 

Men uansett så hat eg hørt at man kan kjøpe vanlige kaldendere som du henger på veggen :p

Lenke til kommentar

Da må man ha bedre orden enn meg, hadde rotet bort julekalenderen lenge før advent 2007 jeg :p:lol:

 

Ja, man får kjøpt det, men:

1. Mye mer personlig med egne bilder

2. Det er dyrt i forhold til å lage selv, men man bør ha tilgang på en bra printer

3. De har få kalendere med store tall/bokstaver, noe som var poenget for min del, da svaksynte gjerne vil ha litt store tall ;)

Endret av ZoRaC
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...