Ejemplo n.º 1
0
<?php

// Get the day names
$days = Calendar::days(TRUE);
// Previous and next month timestamps
$next = mktime(0, 0, 0, $month + 1, 1, $year);
$prev = mktime(0, 0, 0, $month - 1, 1, $year);
// Import the GET query array locally and remove the day
$qs = $_GET;
unset($qs['day']);
// Previous and next month query URIs
$prev = Router::$current_uri . '?' . http_build_query(array_merge($qs, array('month' => date('n', $prev), 'year' => date('Y', $prev))));
$next = Router::$current_uri . '?' . http_build_query(array_merge($qs, array('month' => date('n', $next), 'year' => date('Y', $next))));
?>
<table class="calendar">
<tr class="controls">
<td class="prev"><?php 
echo html::anchor($prev, '&laquo;');
?>
</td>
<td class="title" colspan="5"><?php 
echo strftime('%B %Y', mktime(0, 0, 0, $month, 1, $year));
?>
</td>
<td class="next"><?php 
echo html::anchor($next, '&raquo;');
?>
</td>
</tr>
<tr>
<?php 
Ejemplo n.º 2
0
<?php

defined('SYSPATH') or die('No direct access allowed.');
// Get the day names
$days = Calendar::days(2);
// Previous and next month timestamps
$next = mktime(0, 0, 0, $month + 1, 1, $year);
$prev = mktime(0, 0, 0, $month - 1, 1, $year);
// Import the GET query array locally and remove the day
$qs = $_GET;
unset($qs['day']);
// Previous and next month query URIs
$prev = Router::$current_uri . '?' . http_build_query(array_merge($qs, array('month' => date('n', $prev), 'year' => date('Y', $prev))));
$next = Router::$current_uri . '?' . http_build_query(array_merge($qs, array('month' => date('n', $next), 'year' => date('Y', $next))));
?>
<table class="calendar">
<tr class="controls">
<td class="title" colspan="7" align="center">
<a href="<? print url::site("calendarview/month/" . $year . "/" . $calendar_user . "/" . $month ) ?>"><?php 
print t(strftime('%B', mktime(0, 0, 0, $month, 1, $year))) . " " . t(strftime('%Y', mktime(0, 0, 0, $month, 1, $year)));
?>
</a>
</td>
</tr>
<tr>
<?php 
foreach ($days as $day) {
    ?>
<th><?php 
    echo t($day);
    ?>
Ejemplo n.º 3
0
 public function month($date, $event_assocs = NULL, $may_edit = false)
 {
     $calendar_url = $this->calendar_url;
     $self_url = $this->self_url;
     $range = Calendar::range($date, 'month');
     $days = Calendar::days($range, $event_assocs);
     $today_ts = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
     $thism_ts = $days[0]['date_ts'];
     // find on which day this month starts
     $first_week_day = date('w', $thism_ts);
     // header with Month and Year
     $html = "<ul class=\"calendar\">\n";
     // calendar|list
     $html .= "<li class=\"calendarcell header\">\n";
     $prevm_ts = mktime(0, 0, 0, date("m", $thism_ts) - 1, 1, date("Y", $thism_ts));
     $nextm_ts = mktime(0, 0, 0, date("m", $thism_ts) + 1, 1, date("Y", $thism_ts));
     $html .= "<a class=\"month-prev\" href=\"{$self_url}&date=" . date("Y-m-d", $prevm_ts) . "\" title=\"" . date("F Y", $prevm_ts) . "\">&lt;</a>";
     $html .= "<a class=\"month-next\" href=\"{$self_url}&date=" . date("Y-m-d", $nextm_ts) . "\" title=\"" . date("F Y", $nextm_ts) . "\">&gt;</a>";
     $html .= date("F Y", $thism_ts);
     $html .= "</li>\n";
     // render dayheaders
     $fd = $this->first_day_of_week;
     $ld = $fd + 7;
     for ($i = $fd; $i < $ld; $i++) {
         if ($i > 6) {
             $d = $i - 7;
         } else {
             $d = $i;
         }
         $html .= "<li class=\"calendarcell dayheader\">\n";
         $html .= $this->week_days[$d];
         $html .= "</li>\n";
     }
     $grid_count = 0;
     // render empty days at start of month if required
     if ($first_week_day < $fd) {
         $ed = 7 - $first_week_day;
     } else {
         $ed = $first_week_day;
     }
     for ($i = $fd; $i < $ed; $i++) {
         $html .= "<li class=\"calendarcell\">&nbsp;</li>\n";
         $grid_count++;
     }
     // render actual days
     $cnt = count($days);
     $last_week_day = 0;
     for ($i = 0; $i < $cnt; $i++) {
         $events = $days[$i]['events'];
         $event_cnt = count($events);
         $html .= "<li class=\"calendarcell";
         // mark today as special
         if ($days[$i]['date_ts'] == $today_ts) {
             $html .= " today";
         }
         if ($event_cnt) {
             $html .= " hasevents";
         } else {
             $html .= " noevents";
         }
         $html .= "\">\n";
         $html .= "<span class=\"daynumber\">";
         $html .= date("d", $days[$i]['date_ts']);
         $html .= "</span>";
         $html .= "<div class=\"hovertip\">";
         // . "$event_cnt Events for "
         // . date("D jS", $days[$i]['date_ts'])
         if ($event_cnt) {
             $html .= "<ul class=\"eventlist\">\n";
             foreach ($events as $n => $assoc) {
                 $html .= "<li>";
                 if ($may_edit) {
                     $html .= "<a href=\"{$calendar_url}&display_event=" . $assoc->event_id . "\">";
                 }
                 $html .= "<b>" . _out($assoc->event_title);
                 $html .= "</b> on ";
                 $html .= $assoc->start_time;
                 if ($may_edit) {
                     $html .= "</a>";
                 }
                 $html .= "</li>\n";
             }
             $html .= "</ul>\n";
         }
         if ($may_edit) {
             // create link
             $html .= "<a class=\"create-event\" href=\"{$calendar_url}&date=" . date("Y-m-d", $days[$i]['date_ts']) . "\">New</a>";
         }
         $html .= "</div>";
         $html .= "</li>\n";
         $grid_count++;
     }
     // render empty days at end of month if required
     for ($i = $grid_count; $i < 42; $i++) {
         $html .= "<li class=\"calendarcell\">&nbsp;</li>\n";
     }
     $html .= "<li class=\"calendarcell header\">";
     if ($may_edit) {
         // edit link
         $html .= "<b><a class=\"goto-edit\" href=\"{$calendar_url}\">Edit</a></b>&nbsp;&nbsp;&nbsp;";
     }
     $html .= "Display as:\n";
     $html .= "<a href=# class=\"list-style\">List</a>";
     $html .= "<a href=# class=\"calendar-style\">Calendar</a>";
     $html .= "</li>\n";
     $html .= "</ul>\n";
     return $html;
 }