示例#1
0
         foreach ($this->calendar->children as $i => $child) {
             $stamp1 = $this->calendar->cE->dateToStamp($child->thisYear(), $child->thisMonth(), $child->thisDay());
             $stamp2 = $this->calendar->cE->dateToStamp($child->thisYear(), $child->thisMonth(), $child->nextDay());
             foreach ($events as $event) {
                 if ($stamp1 >= $event['start'] && $stamp1 <= $event['end']) {
                     $this->calendar->children[$i]->addEntry($event);
                     $this->calendar->children[$i]->setSelected();
                 }
             }
         }
     }
 }
 //utolso parameter megmondja, hogy a hetnek melyik az elso napja, 0 = vasarnap, 1 = hetfo
 $month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m'], 1);
 //Add the workshop events to the decorator
 $monthDecorator = new MonthPayload_Decorator($month);
 $monthDecorator->build($events);
 // Set the current day as a Selected Day and put it in the array
 $selectedDays = array(new Calendar_Day(date('Y'), date('m'), date('d')));
 //$this->yearOfMonth[] = $month->thisYear();
 // build the month
 //$month->build($selectedDays);
 // Fetch all days in the month object
 $daysInMonth = $monthDecorator->fetchAll();
 // Split the month into weeks
 $weeksInMonth = array_chunk($daysInMonth, 7);
 // Create links
 $prevStamp = $month->prevMonth(true);
 $prev = 'index.php?p=calendar&amp;y=' . date('Y', $prevStamp) . '&amp;m=' . date('n', $prevStamp) . '&amp;d=' . date('j', $prevStamp);
 $nextStamp = $month->nextMonth(true);
 $next = 'index.php?p=calendar&amp;y=' . date('Y', $nextStamp) . '&amp;m=' . date('n', $nextStamp) . '&amp;d=' . date('j', $nextStamp);
示例#2
0
文件: 20.php 项目: godboko/modules
        } else {
            reset($this->children);
            return false;
        }
    }
}
// Calendar instance used to get the dates in the preferred format:
// you can switch Calendar Engine and the example still works
$cal = new Calendar();
$events = array();
//add some events
$events[] = array('start' => $cal->cE->dateToStamp(2004, 6, 1, 10), 'end' => $cal->cE->dateToStamp(2004, 6, 1, 12), 'desc' => 'Important meeting');
$events[] = array('start' => $cal->cE->dateToStamp(2004, 6, 1, 21), 'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59), 'desc' => 'Dinner with the boss');
$events[] = array('start' => $cal->cE->dateToStamp(2004, 6, 5), 'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59), 'desc' => 'Holidays!');
$Month =& new Calendar_Month_Weekdays(2004, 6);
$MonthDecorator = new MonthPayload_Decorator($Month);
$MonthDecorator->build($events);
?>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Calendar </title>
<style text="text/css">
table {
    border-collapse: collapse;
}
caption {
    font-family: verdana;
    font-size: 14pt;
    padding-bottom: 4pt;
}
function smarty_function_calendar($params, &$smarty){

        require_once $smarty->_get_plugin_filepath('function','html_select_date');
  $days = array('Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado');
  $months = array(1=>'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
  $start = 'start';
  $end = 'end';
  $desc = 'desc';
  $year = '';
  $month = '';
  $id = null;
  
  //  Month is required
  if (!isset($params['month']))
    $month = date("m");  
  else
    $month = $params['month'];
  
  //  Year is required
  if (!isset($params['year']))
    $year = date("Y");
  else  $year = $params['year'];
  
  //  Name of day of the week
  if(isset($params['days'])){
    unset($days);
    $days = $params['days'];
  }
  
  
  if(isset($params['months'])){
    unset($months);
    $months = $params['months'];
  }
  
  if(isset($params['events'])){
    //  This param describe who is the field that
    //  contain the info of  star date, if there's not
    //  is the same name
    if(isset($params['start'])){
      $start = $params['start'];
    }
    //  Describe name field of the end date
    if(isset($params['end'])){
      $end = $params['end'];
    }
    //  Field describe the description of event
    if(isset($params['desc'])){
      $desc = $params['desc'];
    }
    //  Field id is number unique of the event
    if(isset($params['id'])){
      $id = $params['id'];
    }
    
    $events = array();
    //  add the events
    for($i=0;$i<count($params['events']);$i++){
      $events[] = array(
        'id' => $params['events'][$i][$id],
        'start' => $params['events'][$i][$start],
        'end' => $params['events'][$i][$end],
        'desc' => $params['events'][$i][$desc]
      );
    }
  }
  
  $Month = & new Calendar_Month_Weekdays($year, $month);
  $MonthDecorator = new MonthPayload_Decorator($Month);
  $MonthDecorator->build($events);
  
  echo '<table class="calendar" cellspacing="0" cellpadding="0" border="0">';
  echo '<caption class="caption">';
   echo $months[$MonthDecorator->thisMonth()].' / '.$MonthDecorator->thisYear();
  echo '</caption>';
  echo '<tr>';
  //  Days of weeks
  for($i=0;$i<count($days);$i++)
    echo '<th class="day_week">'.$days[$i].'</th>';
  echo '</tr>';
  
  while ($Day = $MonthDecorator->fetch()) {

    if ($Day->isFirst()) {
        echo "<tr>\n";
    }

    echo '<td class="general calCell';
    if ($Day->isSelected()) {
        echo ' calCellBusy';
    } elseif ($Day->isEmpty()) {
        echo ' calCellEmpty';
    }
    echo '">';
    
    if($Day->isEmpty())
      echo '<div class="dayNumber2">'.$Day->thisDay().'</div>';
    else
      echo '<div class="dayNumber">'.$Day->thisDay().'</div>';

    if ($Day->isEmpty()) {
        echo '&nbsp;';
    } else {
        echo '<div class="dayContents"><ul>';
        while ($entry = $Day->getEntry()) {
            echo  '<li>';
            if(isset($entry['id']))
              echo '<a href="?'.$id.'='.$entry['id'].'" class="event">'.$entry['desc'].'</a>';
             else echo $entry['desc'];
            echo '</li>';
            //you can print the time range as well
        }
        echo '</ul></div>';
    }
    echo '</td>';

    if ($Day->isLast()) {
        echo "</tr>\n";
    }
    
  }
  echo '</table>';
  $PMonth = $Month->prevMonth('object');
  $prev = $_SERVER['PHP_SELF'].'?year='.$PMonth->thisYear().'&month='.$PMonth->thisMonth();
  $NMonth = $Month->nextMonth('object');
  $next = $_SERVER['PHP_SELF'].'?year='.$NMonth->thisYear().'&month='.$NMonth->thisMonth();
  echo '<table class="calendar_option"><tr><td class="prev"><a href="'.$prev.'" class="option">&lt;&lt; '.$months[$PMonth->thisMonth()].' '.$PMonth->thisYear().'</a></td><td class="next"><a href="'.$next.'" class="option">'.$months[$NMonth->thisMonth()].' '.$NMonth->thisYear().' &gt;&gt;</a></td></tr></table>';
        echo '<form method="GET"><table><tr><td>'.smarty_function_html_select_date(array('prefix'=>'','start_year'=>'-5','end_year'=>'+5','display_days'=>false),$smarty).'</td><td></td>'.'<td><input type="submit" value="Mostrar"/></td></table></form>';
}