示例#1
0
文件: year.php 项目: godboko/modules
function calendar_user_year()
{
    $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
    $Year = new Calendar_Year($data['cal_year']);
    $Year->build();
    // TODO: find a better way to handle this
    $data['Year'] =& $Year;
    $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK;
    return $data;
}
示例#2
0
<h1>Select and Update</h1>
<?php 
if (isset($_POST['update'])) {
    $Second =& new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']);
    if (!$Second->isValid()) {
        $V =& $Second->getValidator();
        echo '<p>Validation failed:</p>';
        while ($error = $V->fetch()) {
            echo $error->toString() . '<br>';
        }
    } else {
        echo '<p>Validation success.</p>';
        echo '<p>New timestamp is: ' . $Second->getTimeStamp() . ' which could be used to update a database, for example';
    }
} else {
    $Year = new Calendar_Year($_POST['y']);
    $Month = new Calendar_Month($_POST['y'], $_POST['m']);
    $Day = new Calendar_Day($_POST['y'], $_POST['m'], $_POST['d']);
    $Hour = new Calendar_Hour($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h']);
    $Minute = new Calendar_Minute($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i']);
    $Second = new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']);
    ?>
<p><b>Set the alarm clock</p></p>
<form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method="post">
Year: <input type="text" name="y" value="<?php 
    echo $_POST['y'];
    ?>
" size="4">&nbsp;
示例#3
0
文件: 21.php 项目: khrisna/eccubedrm
}
$start = getmicrotime();
if (!@(include 'Calendar/Calendar.php')) {
    define('CALENDAR_ROOT', '../../');
}
require_once CALENDAR_ROOT . 'Year.php';
require_once CALENDAR_ROOT . 'Month/Weeks.php';
define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH_WEEKS);
if (!isset($_GET['year'])) {
    $_GET['year'] = date('Y');
}
$week_types = array('n_in_year', 'n_in_month');
if (!isset($_GET['week_type']) || !in_array($_GET['week_type'], $week_types)) {
    $_GET['week_type'] = 'n_in_year';
}
$Year = new Calendar_Year($_GET['year']);
$Year->build();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> <?php 
echo $Year->thisYear();
?>
 </title>
<style type="text/css">
body {
    font-family: Georgia, serif;
}
caption.year {
    font-weight: bold;
 function testYear()
 {
     $Unit = new Calendar_Year(2038);
     $Validator =& $Unit->getValidator();
     $this->assertFalse($Validator->isValidYear());
 }
示例#5
0
 /**
  * Computes the data nececssary for the welcome screen. Automatically put into the request
  * data array.
  *
  * @access private
  */
 function _compute_welcome_data()
 {
     setlocale(LC_ALL, 'fi_FI@UTF-8');
     // First step of request data: Overall info
     $year_data = array();
     $first_month = $this->_compute_first_month();
     $last_month = $this->_compute_last_month();
     $this->_request_data['first_month'] =& $first_month;
     $this->_request_data['last_month'] =& $last_month;
     $this->_request_data['total_count'] = $this->_compute_events_count_total();
     $this->_request_data['year_data'] =& $year_data;
     if (!$first_month) {
         return;
     }
     // Second step of request data: Years and months.
     $first_year = $first_month->thisYear();
     $last_year = $last_month->thisYear();
     for ($year_nr = $first_year; $year_nr <= $last_year; $year_nr++) {
         $year = new Calendar_Year($year_nr);
         $year->build();
         $year_url = $this->_get_calendar_yearlink($year);
         $year_count = $this->_compute_events_count_between($year->thisYear('timestamp'), $year->nextYear('timestamp'));
         $month_data = array();
         // Loop over the months, start month is either first posting month
         // or January in all other cases.
         $month = null;
         if ($year_nr == $first_year) {
             for ($i = 1; $i < $first_month->thisMonth(); $i++) {
                 $month = $year->fetch();
             }
         }
         while ($month = $year->fetch()) {
             $month_textual = new Calendar_Decorator_Textual($month);
             $month_url = $this->_get_calendar_monthlink($month);
             $month_count = $this->_compute_events_count_between($month->thisMonth('timestamp'), $month->nextMonth('timestamp'));
             $month_data[$month->thisMonth()] = array('month' => $month_textual, 'name' => $month_textual->thisMonthName(), 'url' => $month_url, 'count' => $month_count);
             // Check for end month in end year
             if ($year_nr == $last_year && $month->thisMonth() >= $last_month->thisMonth()) {
                 break;
             }
         }
         $year_data[$year_nr] = array('year' => $year_nr, 'url' => $year_url, 'count' => $year_count, 'month_data' => $month_data);
     }
 }
示例#6
0
 public function setup($timeframe, $role_id)
 {
     $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
     switch ($timeframe) {
         case 'week':
             $WeekEvents = new Calendar_Week($data['cal_year'], $data['cal_month'], $data['cal_day'], CALENDAR_FIRST_DAY_OF_WEEK);
             $start_time = $WeekEvents->thisWeek;
             $end_time = $WeekEvents->nextWeek;
             $events = $this->getEvents($start_time, $end_time, $role_id);
             $WeekDecorator = new WeekEvent_Decorator($WeekEvents);
             $WeekDecorator->build($events);
             $data['Week'] =& $WeekDecorator;
             $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK;
             break;
         case 'month':
             $MonthEvents = new Calendar_Month_Weekdays($data['cal_year'], $data['cal_month'] + 1, xarModVars::get('calendar', 'cal_sdow'));
             $end_time = $MonthEvents->getTimestamp();
             $MonthEvents = new Calendar_Month_Weekdays($data['cal_year'], $data['cal_month'], xarModVars::get('calendar', 'cal_sdow'));
             $start_time = $MonthEvents->getTimestamp();
             $events = $this->getEvents($start_time, $end_time, $role_id);
             $MonthDecorator = new MonthEvent_Decorator($MonthEvents);
             $MonthDecorator->build($events);
             $data['Month'] =& $MonthDecorator;
             break;
         case 'year':
             $Year = new Calendar_Year($data['cal_year'] + 1);
             $end_time = $Year->getTimestamp();
             $Year = new Calendar_Year($data['cal_year']);
             $start_time = $Year->getTimestamp();
             $events = $this->getEvents($start_time, $end_time, $role_id);
             $YearDecorator = new YearEvent_Decorator($Year);
             $YearDecorator->build($events);
             $data['Year'] =& $YearDecorator->calendar;
             $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK;
             break;
     }
     return $data;
 }