Login   Register  
PHP Classes
elePHPant
Icontem

File: calendar.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of zandor  >  Simple Calendar  >  calendar.php  >  Download  
File: calendar.php
Role: Class source
Content type: text/plain
Description: class code for generating the calendar
Class: Simple Calendar
Displays month calendars
Author: By
Last change: none
Date: 7 years ago
Size: 6,400 bytes
 

Contents

Class file image Download
<?php

require_once( "dateclass.php" );

# calendar class
# coded by Alessandro Rosa
# e-mail : zandor_zz@yahoo.it
# site : http://malilla.supereva.it

# Copyright (C) 2006  Alessandro Rosa

# 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 3 of the License, or
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

# Compiled with PHP 4.4.0

$seasons_colors = array( => "#F0F8FF"
                         
=> "#ECF1EF",
                         
=> "#CD3278",
                         
=> "#B4EEB4",
                         
=> "#B22222",
                         
=> "#FF6347",
                         
=> "#00C5CD",
                         
=> "#7AC5CD",
                         
=> "#B3EE3A",
                         
10 => "#CD9B1D",
                         
11 => "#8B0000",
                         
12 => "#8B8B00" ) ;

# REMARK : refer to the global arrays in dateclass.php for months and days names

class calendar
{
      function 
calendar()
      {
      }
      
      function 
build_it()     
      {
             
$dclass = new date();

             echo 
"<table class=\"calendar\">";
             
             
$a getdate();
             
$this->today_d $day $a['mday'] ;
             
$week_day $a['wday'] ;
             
$this->today_m $month $a['mon'] ;
             
$this->today_y $year $a['year'] ;
             
$this->today_full_name $GLOBALS['name_days'][$week_day];
             
             
$season_clr $GLOBALS['seasons_colors'][$month] ;
             
             
$dclass->set_start_date1$month$year ) ;
             
             
$month_name $dclass->get_start_month_name();
             
$first_day_index $dclass->get_start_day_index() ;
             
             echo 
"<tr><td style=\"background-color:$season_clr;\" class=\"month\" colspan=\"7\">$month_name</td></tr>\r\n";
             echo 
"<tr class=\"weekdays\">\r\n";
             
             if ( 
$this->bSundayStart === true ) echo "\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['7']."</b>" $GLOBALS['short_name_days']['0'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['1']."</b>" $GLOBALS['short_name_days']['1'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['2']."</b>" $GLOBALS['short_name_days']['2'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['3']."</b>" $GLOBALS['short_name_days']['3'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['4']."</b>" $GLOBALS['short_name_days']['4'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['5']."</b>" $GLOBALS['short_name_days']['5'])."</td>";
             echo 
"\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['6']."</b>" $GLOBALS['short_name_days']['6'])."</td>";
             if ( 
$this->bSundayStart === false ) echo "\t\t\t\t<td class=\"weekdays\">".(( $week_day == ) ? "<b>".$GLOBALS['short_name_days']['7']."</b>" $GLOBALS['short_name_days']['0'])."</td>";

             echo 
"</tr>\r\n";
             echo 
"\t\t\t\t<tr><td style=\"height:5px;\"></td></tr>\r\n";

             
$cell_current_index = ( $this->bSundayStart ) ? $first_day_index $first_day_index ;
             
$cell_current_index = ( $cell_current_index == ) ? $cell_current_index ;
             
             echo 
"<tr>\r\n" ;
             
             for ( 
$i 0$i $cell_current_index$i++ )
             {
                 echo 
"\t<td class=\"calendar\"></td>\r\n" ;
             }
             
             
$cell_current_index $i ;
             
             
$month_days $dclass->get_month_days$month$year ) ;
             
             for( 
$i $i <= $month_days$i++ )
             {
                 if ( 
$i == $day ) echo "\t<td style=\"font-weight:bold;\" class=\"calendar\">$i</td>\r\n" ;
                 else echo 
"\t<td class=\"calendar\">$i</td>\r\n" ;
             
                 
$cell_current_index++ ;
             
                 
$cell_current_index %= ;
                 
                 if ( 
$cell_current_index == ) echo "</tr>\r\n\t<tr>\r\n" ;
             }
             
             echo 
"\t\t\t\t<tr><td style=\"height:5px;\"></td></tr>\r\n";
             
             if ( 
$this->get_display_today() ) echo "<tr><td colspan=\"7\" class=\"today\">Today is : ".$this->get_today_full_name()." ".$this->get_today_date()."</td></tr>" ;
             
             echo 
"</table>\r\n";
      }
      
      function 
display_english_date$bED )           { $this->bEngDate $bED ; }
      function 
get_display_english_date_opt$bED )   { return $this->bEngDate ; }

      function 
get_sunday_start()           { return $this->bSundayStart ; }
      function 
set_sunday_start$bS )      { $this->bSundayStart $bS ;  }

      function 
get_display_today()          { return $this->bDisplayToday ; }
      function 
set_display_today$bDt )    { $this->bDisplayToday $bDt ; }

      function 
get_today_date()             { return ( ( $this->bEngDate ) ? $this->today_m."-".$this->today_d $this->today_d."-".$this->today_m ) . "-".$this->today_y ; }
      function 
get_today_full_name()        { return $this->today_full_name ; }

      var 
$bSundayStart TRUE ;
      var 
$bDisplayToday TRUE ;
      var 
$bEngDate TRUE ;

      var 
$today_d ;
      var 
$today_m ;
      var 
$today_y ;
      var 
$today_full_name ;
}