Login   Register  
PHP Classes
elePHPant
Icontem

File: class.calendar.phtml

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ricardo Costa  >  DCalendar  >  class.calendar.phtml  >  Download  
File: class.calendar.phtml
Role: Class source
Content type: text/plain
Description: Show a calendar with events options, year ...
Class: DCalendar
Show a calendar with options of events color
Author: By
Last change: - New feature. Show hint of events days
Date: 11 years ago
Size: 7,604 bytes
 

Contents

Class file image Download
<?php
//
// By Ricardo Costa - ricardo@icorp.com.br - 2002
// Classe para exibiçao de calendário
//
//  calendar
//    +---- calendar()
//    +---- show()
//
//

class calendar {

   var 
$content;   // Conteudo HTML formatado
   
var $page;   // Página para link
   
var $month_name;   // Nome do mes
   
var $year_bgcolor "CCCCCC"// Cor de fundo do ano
   
var $month_bgcolor "CCCCCC"// Cor de fundo do mes
   
var $days_bgcolor "8D9ABA"// Cor de fundo dos dias da semana
   
var $day_color "E9EBF1"// Cor de fundo dos dias
   
var $day_today_color "FF9999"// Cor de fundo de hoje
   
var $font_color "4C5B7D"// Cor da fonte
   
var $bg_color "E9EBF1"// Cor de fundo
   
var $event_bgcolor "FFCC99"// Cor de fundo dos compromissos
   
var $events = array(); // Array de eventos
   
var $events_hint = array(); // Array com a descrição dos eventos


   
   # Inicializar variáveis ################################################################### Revisao 09/09/2002 #
   
function calendar() {

      
$this->page $GLOBALS["PHP_SELF"];
           
/*        BUG fixed by TeeCee              */
      /* Here wasn't isset, so if I gave         */
     /* no parameters, error notice was given.. */
    /*           teecee@freemail.hu            */
      
if (isset($GLOBALS["nyear"])) $GLOBALS["year"] = $GLOBALS["nyear"]; else $GLOBALS["nyear"] = $GLOBALS["year"];
      if (isset(
$GLOBALS["nmonth"])) $GLOBALS["month"] = $GLOBALS["nmonth"]; else $GLOBALS["nmonth"] = $GLOBALS["month"];
      if (isset(
$GLOBALS["nday"])) $GLOBALS["day"] = $GLOBALS["nday"]; else $GLOBALS["nday"] = $GLOBALS["day"];

      if (
$GLOBALS["nmonth"] == 0) {
         
$GLOBALS["nyear"] --;
         
$GLOBALS["nmonth"] = 12;
      }
      elseif (
$GLOBALS["nmonth"] == 13) {
         
$GLOBALS["nyear"] ++;
         
$GLOBALS["nmonth"] = 1;
      }

      
$this->month_name $GLOBALS["month_year"];
      
$this->month_name $this->month_name[$GLOBALS["nmonth"]];
   }
   
# Inicializar variáveis ################################################################### Revisao 09/09/2002 #



   # Exibir Calendário ####################################################################### Revisao 16/09/2002 #
   
function show($year 1$month 1$today 1) {
    global 
$today_str$days_week;

      
$this->content "<style type='text/css'>
                        <!--
                        .calendar_font {  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #"
.$this->font_color."; text-decoration: none}
                        .calendar_font:hover {  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #"
.$this->font_color."; text-decoration: underline}
                         -->
                        </style>
                        <table width='140' border='0' cellspacing='0' cellpadding='0' class='calendar_font'>"
;

      if (
$year == 1) {
        
$this->content .= "<tr align='center'>
                           <td width='20' bgcolor='#"
.$this->year_bgcolor."' height='14'><b><a href='".$this->page."?nmonth=".$GLOBALS["nmonth"]."&nyear=".($GLOBALS["nyear"] - 1)."&nday=".$GLOBALS["nday"]."' class='calendar_font'>&#139;&#139;</a></b></td>
                           <td colspan='5' bgcolor='#"
.$this->year_bgcolor."' height='14'><b>".$GLOBALS["nyear"]."</b></td>
                           <td width='20' bgcolor='#"
.$this->year_bgcolor."' height='14'><b><a href='".$this->page."?nmonth=".$GLOBALS["nmonth"]."&nyear=".($GLOBALS["nyear"] + 1)."&nday=".$GLOBALS["nday"]."' class='calendar_font'>&#155;&#155;</a></b></td>
                           </tr>"
;
      } 
    
      if (
$month == 1) {
        
$this->content .= "<tr align='center'>
                           <td width='20' bgcolor='#"
.$this->month_bgcolor."' height='18'><b><a href='".$this->page."?nmonth=".($GLOBALS["nmonth"] - 1)."&nyear=".$GLOBALS["nyear"]."&nday=".$GLOBALS["nday"]."' class='calendar_font'>&#139;</a></b></td>
                           <td colspan='5' bgcolor='#"
.$this->month_bgcolor."' height='18'><b>".$this->month_name."</b></td>
                           <td width='20' bgcolor='#"
.$this->month_bgcolor."' height='18'><b><a href='".$this->page."?nmonth=".($GLOBALS["nmonth"] + 1)."&nyear=".$GLOBALS["nyear"]."&nday=".$GLOBALS["nday"]."' class='calendar_font'>&#155;</a></b></td>
                           </tr>
                           <tr align='center'>
                           <td width='20' bgcolor='#000000' height='1'></td>
                           <td colspan='5' bgcolor='#000000' height='1'></td>
                           <td width='20' bgcolor='#000000' height='1'></td>
                           </tr>"
;
      }

 
      
$this->content .= "<tr align='center' bgcolor='#".$this->days_bgcolor."'>";
         
/* Improvement by TeeCee ,)                 */
       /* Theheader generated by the first char of */
      /* the names of the days                    */
    /*            teecee@freemail.hu            */
      
for ($l 0$l <=6$l++)
    { 
$this->content .= "<td width='20' height='14'><b>".$days_week[$l][0]."</b></td>"; }
      
$this->content .= "</tr>";

      
$cont_day 1;
      
$event_number 0;
      for( 
$l 1$l <= 6$l++) {

         
$this->content .= "<tr>";

         for(
$c 0$c <= $c++) {
            
$xday date("w",mktime (0,0,0$GLOBALS["nmonth"],$cont_day$GLOBALS["nyear"]));
 
           if (
in_array($GLOBALS["nyear"]."-".$GLOBALS["nmonth"]."-".mformat(,$cont_day), $this->events) && $cont_day != $GLOBALS["nday"])
              
$bg $this->event_bgcolor;
           else { 
              if (
$cont_day != $GLOBALS["nday"])
                 
$bg $this->day_color;
                 else 
                  
$bg $this->day_today_color;
           }
            
            if (
checkdate($GLOBALS["nmonth"], $cont_day$GLOBALS["nyear"]) & $xday == $c) {
                  if (
in_array($GLOBALS["nyear"]."-".$GLOBALS["nmonth"]."-".mformat(,$cont_day), $this->events))
                     
$this->content .= "<td align='center' width='20' bgcolor='#".$bg."'><a href='".$this->page."?nmonth=".$GLOBALS["nmonth"]."&nyear=".$GLOBALS["nyear"]."&nday=".$cont_day."' class='calendar_font' title='".$this->events_hint[$event_number++]."'>".$cont_day."</a></td>";
                     else 
                     
$this->content .= "<td align='center' width='20' bgcolor='#".$bg."'><a href='".$this->page."?nmonth=".$GLOBALS["nmonth"]."&nyear=".$GLOBALS["nyear"]."&nday=".$cont_day."' class='calendar_font'>".$cont_day."</a></td>";
               
$cont_day++;
            }
            else {
               
$this->content .= "<td align='center' width='20' bgcolor='#".$this->bg_color."'>&nbsp;</td>";
            }
         }
    
         
$this->content .= "</tr>";
         if (!
checkdate($GLOBALS["nmonth"], $cont_day$GLOBALS["nyear"])) break;
      }
   
      if (
$today == 1) {
        
$this->content .= "</table>
                           <table width='140' border='0' cellspacing='0' cellpadding='0' class='calendar_font'>
                           <tr><td align='center' bgcolor=#"
.$this->year_bgcolor."><b><a href='".$this->page."?nmonth=".date("n")."&nyear=".date("Y")."&nday=".date("d")."' class='calendar_font'>$today_str</a></b></td></tr>
                           <tr height='10'><td></td></tr></table>"
;
      }
      
      
$this->content .= "</table>";
     
      print(
$this->content);
   }
   
# Exibir Calendário ####################################################################### Revisao 16/09/2002 #



# Final da Classe
?>