/** * カレンダー情報取得. * * @param integer $disp_month 表示する月数 * @return array カレンダー情報の配列を返す */ public function lfGetCalendar($disp_month = 1) { $objDate = new SC_Date_Ex(); $arrCalendar = array(); $today = date('Y/m/d'); for ($j = 0; $j <= $disp_month - 1; $j++) { $time = mktime(0, 0, 0, date('n') + $j, 1); $year = date('Y', $time); $month = date('n', $time); $objMonth = new Calendar_Month_Weekdays($year, $month, 0); $objMonth->build(); $i = 0; while ($objDay = $objMonth->fetch()) { $arrCalendar[$j][$i]['in_month'] = $month == $objDay->month; $arrCalendar[$j][$i]['first'] = $objDay->first; $arrCalendar[$j][$i]['last'] = $objDay->last; $arrCalendar[$j][$i]['empty'] = $objDay->empty; $arrCalendar[$j][$i]['year'] = $year; $arrCalendar[$j][$i]['month'] = $month; $arrCalendar[$j][$i]['day'] = $objDay->day; $arrCalendar[$j][$i]['holiday'] = $objDate->isHoliday($year, $month, $objDay->day); $arrCalendar[$j][$i]['today'] = $today === sprintf('%04d/%02d/%02d', $year, $month, $objDay->day); $i++; } } return $arrCalendar; }
protected function generateCalendar(sfWebRequest $request) { $this->setTemplate('index'); $old_error_level = error_reporting(); error_reporting($old_error_level & ~(E_STRICT | E_DEPRECATED)); include_once 'Calendar/Month/Weekdays.php'; $this->year = (int) $request->getParameter('year', date('Y')); $this->month = (int) $request->getParameter('month', date('n')); $this->add_schedule = $this->year < date('Y') || $this->year > date('Y') + 1 ? false : true; $first_day = sprintf('%04d-%02d-01', $this->year, $this->month); $end_day = sprintf('%04d-%02d-%02d', $this->year, $this->month, date('t', strtotime($first_day))); if ($this->is_community) { if ('all' === $this->calendar_show_flag || 'only_community_event' === $this->calendar_show_flag) { $event_list = opCalendarPluginExtension::getMyCommunityEventByStartDayToEndDayInCommunity($this->community, $first_day, $end_day); } } else { $birth_list = $this->isSelf ? opCalendarPluginExtension::getScheduleBirthMemberByMonths(array($this->month)) : array(); $event_list = $this->isSelf ? opCalendarPluginExtension::getMyCommunityEventByStartDayToEndDay($first_day, $end_day) : array(); } $Month = new Calendar_Month_Weekdays($this->year, $this->month, 1); $Month->build(); $this->calendar = array(); $row = 0; $col = 0; $this->dayofweek = array('class' => array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'), 'item' => array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')); while ($Day = $Month->fetch()) { if ($Day->isFirst()) { $row++; $col = 0; } $item = array('dayofweek_class_name' => $this->dayofweek['class'][$col], 'dayofweek_item_name' => $this->dayofweek['item'][$col]); $scheduleTable = Doctrine::getTable('Schedule'); if ($Day->isEmpty()) { $this->calendar[$row][$col++] = $item; } else { $day = $Day->thisDay(); $month_day = sprintf('%02d-%02d', $this->month, $day); $year_month_day = sprintf('%04d-%s', $this->year, $month_day); $is_today = (int) date('Y') === $this->year && (int) date('n') === $this->month && (int) date('d') === $day; $schedules = array(); if ($this->is_community) { if ('all' === $this->calendar_show_flag || 'only_member_schedule' === $this->calendar_show_flag) { $schedules = $scheduleTable->getScheduleByThisDayAndMemberInCommunity($this->community, $this->year, $this->month, $day); } } else { $schedules = $scheduleTable->getScheduleByThisDayAndMember($this->year, $this->month, $day, $this->member); } $item += array('day' => $day, 'today' => $is_today, 'births' => isset($birth_list[$month_day]) ? $birth_list[$month_day] : array(), 'events' => isset($event_list[$year_month_day]) ? $event_list[$year_month_day] : array(), 'schedules' => $schedules, 'holidays' => Doctrine::getTable('Holiday')->getByYearAndMonthAndDay($this->year, $this->month, $day)); $this->calendar[$row][$col++] = $item; } } $this->ym = array('year_disp' => $this->year, 'month_disp' => $this->month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true))); error_reporting($old_error_level); }
function execute($requests) { $u = $GLOBALS['AUTH']->uid(); // --- リクエスト変数 $year = intval($requests['year']); $month = intval($requests['month']); // ---------- if (!$year) { $year = date('Y'); } if (!$month) { $month = date('n'); } if ($year == date('Y') && $month == date('n')) { $is_curr = true; $curr_day = date('d'); } if ($year < date('Y') || $year > intval(date('Y')) + 1) { $this->set('add_schedule', false); } else { $this->set('add_schedule', true); } $this->set('inc_navi', fetch_inc_navi('h')); // イベント $event_list = db_schedule_event4c_member_id($year, $month, $u); // 誕生日 $birth_list = db_schedule_birth4c_member_id($month, $u); include_once 'Calendar/Month/Weekdays.php'; $Month = new Calendar_Month_Weekdays($year, $month, 0); $Month->build(); $calendar = array(); $i = 0; while ($Day = $Month->fetch()) { if ($Day->isFirst()) { $i++; } if ($Day->isEmpty()) { $calendar[$i][] = array(); } else { $day = $Day->thisDay(); $item = array('day' => $day, 'now' => false, 'birth' => $birth_list[$day], 'event' => $event_list[$day], 'schedule' => db_schedule_c_schedule_list4date($year, $month, $day, $u), 'holiday' => db_c_holiday_list4date($month, $day)); $item['day'] = $day; if ($is_curr && $item['day'] == $curr_day) { $item['now'] = true; } $calendar[$i][] = $item; } } $ym = array('year_disp' => $year, 'month_disp' => $month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true))); $this->set("ym", $ym); $this->set("year", $year); $this->set("month", $month); $this->set("calendar", $calendar); $c_member = db_member_c_member4c_member_id($u); $this->set("pref_list", p_regist_prof_c_profile_pref_list4null()); $this->set("c_member", $c_member); return 'success'; }
function calendar_user_month() { $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo'); $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(); $q = new Query('SELECT'); $a[] = $q->plt('start_time', $start_time); $a[] = $q->pge('start_time + duration', $start_time); $b[] = $q->plt('start_time', $end_time); $b[] = $q->pge('start_time + duration', $end_time); $c[] = $q->pgt('start_time', $start_time); $c[] = $q->ple('start_time + duration', $end_time); $d[] = $q->pqand($a); $d[] = $q->pqand($b); $d[] = $q->pqand($c); $q->qor($d); $q->eq('role_id', xarSession::getVar('role_id')); $data['conditions'] = $q; return $data; }
/** * Builds monhtly calendar * * @param array $options */ public static function buildMonthly(array $options = array()) { if (!isset($options['year'])) { $options['year'] = date('Y'); } else { $options['year'] = $options['year']; } if (!isset($options['month'])) { $options['month'] = date('m'); } else { $options['month'] = $options['month']; } if (!isset($options['day'])) { $options['day'] = date('d'); } else { $options['day'] = $options['day']; } $monthWeekdays = new Calendar_Month_Weekdays($options['year'], $options['month']); $selectedDays = array(new Calendar_Day($options['year'], $options['month'], $options['day'])); $monthWeekdays->build($selectedDays); return $monthWeekdays; }
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; }
function build($events = array()) { require_once CALENDAR_ROOT . 'Day.php'; require_once CALENDAR_ROOT . 'Table/Helper.php'; $this->tableHelper =& new Calendar_Table_Helper($this, $this->firstDay); $this->cE =& $this->getEngine(); $this->year = $this->thisYear(); $this->month = $this->thisMonth(); $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i = 1; $i <= $daysInMonth; $i++) { $Day = new Calendar_Day(2000, 1, 1); // Create Day with dummy values $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new DiaryEvent($Day); } if (count($events) > 0) { $this->setSelection($events); } Calendar_Month_Weekdays::buildEmptyDaysBefore(); Calendar_Month_Weekdays::shiftDays(); Calendar_Month_Weekdays::buildEmptyDaysAfter(); Calendar_Month_Weekdays::setWeekMarkers(); return true; }
$template = new HTML_Template_IT("./templates"); $template->loadTemplatefile("dashboard.tpl", true, true); session_start(); // Get a connection to the database. if (!($connection = @mysql_connect($hostName, $username, $password))) { die("Could not connect to database"); } // Now that we are connected, select the correct database. if (!mysql_select_db($databaseName, $connection)) { showerror(); } $userID = getUserID($connection); //See if we have an authenticated user, if so, setup the appropriate message. if (isset($_SESSION["loggedinUserName"])) { $date = new Date(); $Month = new Calendar_Month_Weekdays($date->getYear(), $date->getMonth(), 1); $Month->build(); //Popluate the user's dashboard page $template->setCurrentBlock("NAVIGATION"); $template->setVariable("DATE", $date->format("%A %b %e, %Y")); $template->setVariable("GREETING", setupGreeting()); $displayName = getUserFirstName($connection, $userID); if (!$displayName) { $displayName = $_SESSION["loggedinUserName"]; } $template->setVariable("USER", $displayName . "!"); $template->parseCurrentBlock(); // Setup and load the quickentry calendar for actual workout data entry. $template->setCurrentBlock("WEEKLY"); loadQuickEntry($template, $Month, $connection); // Setup the weekly graphs for actual and planned workout volumes.
function setSelection($events) { 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&y=' . date('Y', $prevStamp) . '&m=' . date('n', $prevStamp) . '&d=' . date('j', $prevStamp);
} } if ($_GET["do"] == "zoom") { $_SESSION["zoom"] = $_GET["zoom"]; } if (!isset($to_pass['y'])) { $to_pass['y'] = date('Y'); } if (!isset($to_pass['m'])) { $to_pass['m'] = date('n'); } if (!isset($to_pass['d'])) { $to_pass['d'] = date('j'); } $today = $to_pass['y'] . '/' . $to_pass['m'] . '/' . $to_pass['d']; $Month = new Calendar_Month_Weekdays($to_pass['y'], $to_pass['m']); $Day = new Calendar_Day($to_pass['y'], $to_pass['m'], $to_pass['d']); $currentDateShown = strtotime($to_pass['y'] . '-' . $to_pass['m'] . '-' . $to_pass['d']); $Yesterday = array('d' => date('d', $Day->prevDay($currentDateShown)), 'm' => date('m', $Day->prevDay($currentDateShown)), 'y' => date('Y', $Day->prevDay($currentDateShown))); $Tomorrow = array('d' => date('d', $Day->nextDay($currentDateShown)), 'm' => date('m', $Day->nextDay($currentDateShown)), 'y' => date('Y', $Day->nextDay($currentDateShown))); $selection = array($Day); $ThisMonth = date("F"); // go to next year if current month is dec if ($Month->thisMonth() == 12) { $navNextYear = $Month->nextYear(); } else { $navNextYear = $Month->thisYear(); } if ($Month->thisMonth() == 1) { $navPrevYear = $Month->prevYear(); } else {
function execute($requests) { $u = $GLOBALS['AUTH']->uid(); // --- リクエスト変数 $year = $requests['year']; $month = $requests['month']; $pref_id = $requests['pref_id']; // ---------- if (empty($requests['target_id']) || $requests['target_id'] == $u) { //自分自身 $target_id = $u; $this->set('is_h', true); //判別フラグ $this->set('inc_navi', fetch_inc_navi('h')); } else { //他人 $target_id = $requests['target_id']; $this->set('is_f', true); //判別フラグ $this->set('inc_navi', fetch_inc_navi('f', $target_id)); } if (!$year) { $year = date('Y'); } if (!$month) { $month = date('n'); } if ($year == date('Y') && $month == date('n')) { $is_curr = true; $curr_day = date('d'); } // イベント $event_list = db_schedule_event4c_member_id($year, $month, $target_id); // 誕生日 $birth_list = db_schedule_birth4c_member_id($month, $target_id); // Todo $todo_list = biz_schedule_todo4c_member_id($u, $target_id, $year, $month); require_once 'Calendar/Month/Weekdays.php'; $Month = new Calendar_Month_Weekdays($year, $month, 0); $Month->build(); $calendar = array(); $schedule = array(); $i = 0; while ($Day = $Month->fetch()) { if ($Day->isFirst()) { $i++; } if ($Day->isEmpty()) { $calendar[$i][] = array(); } else { $day = $Day->thisDay(); $schedule = biz_getDateMemberSchedule($year, sprintf("%02d", $month), sprintf("%02d", $day), $target_id, $u); $banner = biz_isBannerSchedule($year, sprintf("%02d", $month), sprintf("%02d", $day), $target_id); if (!empty($banner)) { foreach ($banner as $value) { array_push($schedule, $value); } } $item = array('day' => $day, 'now' => false, 'birth' => $birth_list[$day], 'event' => $event_list[$day], 'schedule' => $schedule, 'todo' => $todo_list[$day], 'holiday' => db_c_holiday_list4date($month, $day)); $item['day'] = $day; if ($is_curr && $item['day'] == $curr_day) { $item['now'] = true; } $calendar[$i][] = $item; } } $ym = array('year_disp' => $year, 'month_disp' => $month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true))); $this->set("ym", $ym); $this->set("year", $year); $this->set("month", $month); $this->set("calendar", $calendar); $c_member = db_member_c_member4c_member_id($target_id); $this->set("pref_list", p_regist_prof_c_profile_pref_list4null()); $this->set("c_member", $c_member); return 'success'; }
/** * Description: demonstrates using the Uri decorator */ if (!@(include 'Calendar/Calendar.php')) { define('CALENDAR_ROOT', '../../'); } require_once CALENDAR_ROOT . 'Month/Weekdays.php'; require_once CALENDAR_ROOT . 'Decorator/Uri.php'; if (!isset($_GET['jahr'])) { $_GET['jahr'] = date('Y'); } if (!isset($_GET['monat'])) { $_GET['monat'] = date('m'); } // Build the month $Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']); echo '<p>The current month is ' . $Calendar->thisMonth() . ' of year ' . $Calendar->thisYear() . '</p>'; $Uri =& new Calendar_Decorator_Uri($Calendar); $Uri->setFragments('jahr', 'monat'); // $Uri->setSeperator('/'); // Default is & // $Uri->setScalar(); // Omit variable names echo "<pre>Previous Uri:\t" . $Uri->prev('month') . "\n"; echo "This Uri:\t" . $Uri->this('month') . "\n"; echo "Next Uri:\t" . $Uri->next('month') . "\n</pre>"; ?> <p> <a href="<?php echo $_SERVER['PHP_SELF'] . '?' . $Uri->prev('month'); ?> ">Prev</a> : <a href="<?php
//Set the date to the first day of the month. $display_mo->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear()); // Get the previous day from the displayed month. $prevDay = $display_mo->getPrevDay(); $prevDay->setDayMonthYear(1, $prevDay->getMonth(), $prevDay->getYear()); // Get the next day in from the diplayed month. $display_mo->setDayMonthYear($display_mo->getDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear()); $nextDay = $display_mo->getNextDay(); $template->setCurrentBlock("NAVIGATION"); $template->setVariable("MONTH", "{$display_mo->getMonthName()} {$display_mo->getYear()}"); $template->setVariable("PREVIOUS", $prevDay->format("%Y-%m-%d")); $template->setVariable("NEXT", $nextDay->format("%Y-%m-%d")); $template->setVariable("TYPE", $display); setSelectOption($display, $template); $template->parseCurrentBlock(); $Month = new Calendar_Month_Weekdays($display_mo->getYear(), $display_mo->getMonth(), 1); $Month->build(); $template->setCurrentBlock("WEEK"); while ($Day = $Month->fetch()) { // Set the delete all button to off by default. $delAll = FALSE; if ($Day->isFirst()) { // Set the begining block area to {ONE} // and set the current block $currentDay = 1; } $curyear = strval($Day->thisYear()); $curmonth = strval($Day->thisMonth()); $curday = strval($Day->thisDay()); $txtDay = new Date(); $txtDay->setDayMonthYear($curday, $curmonth, $curyear);
foreach ($events as $event) { if (!$event['event_isrecur']) { $eventsArray[] = $event; } else { $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth); foreach ($recurEvents as $recurEvent) { $eventsArray[] = $recurEvent; } } } // Formating date $eventHandler->formatEventsDate($eventsArray, $xoopsModuleConfig['event_date_month']); // Assigning events to the template $xoopsTpl->assign('events', $eventsArray); // Retriving categories $cats = $catHandler->objectToArray($catHandler->getAllCat($xoopsUser)); // Assigning categories to the template $xoopsTpl->assign('cats', $cats); // Making navig data $monthCalObj = new Calendar_Month_Weekdays($year, $month); $pMonthCalObj = $monthCalObj->prevMonth('object'); $nMonthCalObj = $monthCalObj->nextMonth('object'); $navig = array('prev' => array('uri' => 'year=' . $pMonthCalObj->thisYear() . '&month=' . $pMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $pMonthCalObj->getTimestamp())), 'this' => array('uri' => 'year=' . $monthCalObj->thisYear() . '&month=' . $monthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $monthCalObj->getTimestamp())), 'next' => array('uri' => 'year=' . $nMonthCalObj->thisYear() . '&month=' . $nMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $nMonthCalObj->getTimestamp()))); // Assigning navig data to the template $xoopsTpl->assign('navig', $navig); // Assigning current form navig data to the template $xoopsTpl->assign('selectedCat', $cat); $xoopsTpl->assign('year', $year); $xoopsTpl->assign('month', $month); $xoopsTpl->assign('view', "month"); include XOOPS_ROOT_PATH . '/footer.php';
/** * Description: demonstrates using the Uri util */ if (!@(include 'Calendar/Calendar.php')) { define('CALENDAR_ROOT', '../../'); } require_once CALENDAR_ROOT . 'Month/Weekdays.php'; require_once CALENDAR_ROOT . 'Util/Uri.php'; if (!isset($_GET['jahr'])) { $_GET['jahr'] = date('Y'); } if (!isset($_GET['monat'])) { $_GET['monat'] = date('m'); } // Build the month $Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']); echo '<p>The current month is ' . $Calendar->thisMonth() . ' of year ' . $Calendar->thisYear() . '</p>'; $Uri =& new Calendar_Util_Uri('jahr', 'monat'); $Uri->setFragments('jahr', 'monat'); echo "\"Vector\" URIs<pre>"; echo "Previous Uri:\t" . htmlentities($Uri->prev($Calendar, 'month')) . "\n"; echo "This Uri:\t" . htmlentities($Uri->this($Calendar, 'month')) . "\n"; echo "Next Uri:\t" . htmlentities($Uri->next($Calendar, 'month')) . "\n"; echo "</pre>"; // Switch to scalar URIs $Uri->separator = '/'; // Default is & $Uri->scalar = true; // Omit variable names echo "\"Scalar\" URIs<pre>"; echo "Previous Uri:\t" . $Uri->prev($Calendar, 'month') . "\n";
/** * メッセージページのカレンダー生成 */ function db_common_message_monthly_calendar($u, $year, $month, $c_member_id, $box) { include_once 'Calendar/Month/Weekdays.php'; $Month = new Calendar_Month_Weekdays($year, $month, 0); $Month->build(); $is_message_list = db_message_is_message_list4date($u, $year, $month, $box); $calendar = array(); $week = 0; while ($Day = $Month->fetch()) { if ($Day->isFirst()) { $week++; } if ($Day->isEmpty()) { $calendar['days'][$week][] = array(); } else { $day = $Day->thisDay(); $item = array('day' => $day, 'is_message' => @in_array($day, $is_message_list)); $calendar['days'][$week][] = $item; } } if ($box == 'inbox' || !$box) { $where = "c_member_id_to = ?" . " AND is_deleted_to = 0" . " AND is_send = 1"; } elseif ($box == 'outbox') { $where = "c_member_id_from = ?" . " AND is_deleted_from = 0" . " AND is_send = 1"; } else { return null; } // 最初にメッセージを書いた日 $sql = "SELECT r_datetime FROM c_message WHERE {$where} ORDER BY r_datetime"; $first_datetime = db_get_one($sql, array(intval($u))); // 前の月、次の月 $prev_month = $Month->prevMonth('timestamp'); $this_month = $Month->thisMonth('timestamp'); $next_month = $Month->nextMonth('timestamp'); $ym = array('disp_year' => $year, 'disp_month' => $month, 'prev_year' => null, 'prev_month' => null, 'next_year' => null, 'next_month' => null); if ($first_datetime && strtotime($first_datetime) < $this_month) { $ym['prev_year'] = date('Y', $prev_month); $ym['prev_month'] = date('n', $prev_month); } if ($next_month < time()) { $ym['next_year'] = date('Y', $next_month); $ym['next_month'] = date('n', $next_month); } $calendar['ym'] = $ym; return $calendar; }
/** * カレンダー情報取得. * * @param integer $disp_month 表示する月数 * @return array $arrCalendar カレンダー情報の配列を返す */ function lfGetCalendar($disp_month = 1) { for ($j = 0; $j <= $disp_month - 1; ++$j) { $year = date('Y'); $month = date('n') + $j; if ($month > 12) { $month = $month % 12; $year = $year + $month % 12; } $objMonth = new Calendar_Month_Weekdays($year, $month, 0); $objMonth->build(); $i = 0; while ($objDay = $objMonth->fetch()) { if ($month == $objDay->month) { $arrCalendar[$j][$i]['in_month'] = true; } else { $arrCalendar[$j][$i]['in_month'] = false; } $arrCalendar[$j][$i]['first'] = $objDay->first; $arrCalendar[$j][$i]['last'] = $objDay->last; $arrCalendar[$j][$i]['empty'] = $objDay->empty; $arrCalendar[$j][$i]['year'] = $year; $arrCalendar[$j][$i]['month'] = $month; $arrCalendar[$j][$i]['day'] = $objDay->day; if ($this->lfCheckHoliday($year, $month, $objDay->day)) { $arrCalendar[$j][$i]['holiday'] = true; } else { $arrCalendar[$j][$i]['holiday'] = false; } ++$i; } } return $arrCalendar; }
define('CALENDAR_ROOT', '../../'); } require_once CALENDAR_ROOT . 'Month/Weekdays.php'; require_once CALENDAR_ROOT . 'Day.php'; // Initialize GET variables if not set if (!isset($_GET['y'])) { $_GET['y'] = date('Y'); } if (!isset($_GET['m'])) { $_GET['m'] = date('m'); } if (!isset($_GET['d'])) { $_GET['d'] = date('d'); } // Build the month $month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']); // Create an array of days which are "selected" // Used for Week::build() below $selectedDays = array(new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']), new Calendar_Day($_GET['y'], 12, 25)); // Build the days in the month $month->build($selectedDays); // Construct strings for next/previous links $PMonth = $month->prevMonth('object'); // Get previous month as object $prev = $_SERVER['PHP_SELF'] . '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay(); $NMonth = $month->nextMonth('object'); $next = $_SERVER['PHP_SELF'] . '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay(); $thisDate = new Date($month->thisMonth('timestamp')); ?> <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>
function setSelection($events) { 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 = 'admin.php?p=' . $module_name . '&act=' . $page . '&y=' . date('Y', $prevStamp) . '&m=' . date('n', $prevStamp) . '&d=' . date('j', $prevStamp);
if (!@(include 'Calendar/Calendar.php')) { define('CALENDAR_ROOT', '../../'); } require_once CALENDAR_ROOT . 'Month/Weekdays.php'; require_once CALENDAR_ROOT . 'Day.php'; if (!isset($_GET['y'])) { $_GET['y'] = date('Y'); } if (!isset($_GET['m'])) { $_GET['m'] = date('m'); } if (!isset($_GET['d'])) { $_GET['d'] = date('d'); } // Build the month $Month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']); // Construct strings for next/previous links $PMonth = $Month->prevMonth('object'); // Get previous month as object $prev = $_SERVER['PHP_SELF'] . '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay(); $NMonth = $Month->nextMonth('object'); $next = $_SERVER['PHP_SELF'] . '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay(); ?> <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> Calendar </title> <style text="text/css"> table { background-color: silver; }
function smarty_function_mini_calendar($params, &$smarty){ $start = getmicrotime(); # includes require_once 'Calendar/Calendar.php'; require_once 'Calendar/Month/Weekdays.php'; require_once 'Calendar/Day.php'; require_once $smarty->_get_plugin_filepath('modifier','date_format'); require_once $smarty->_get_plugin_filepath('function','html_select_date'); require_once $smarty->_get_plugin_filepath('modifier','strip'); # Cuando se hacia un redirect usando el ErrorDocument del 403 al archivo, no se pasaban los # parametros if((!isset($_REQUEST['Year'])&&!isset($_REQUEST['Month']))||!isset($_REQUEST['Day'])) { $query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY); parse_str($query,$_REQUEST); } if (!isset($_REQUEST['Year'])) $_REQUEST['Year'] = date('Y'); if (!isset($_REQUEST['Month'])) $_REQUEST['Month'] = date('m'); if (!isset($_REQUEST['Day'])) $_REQUEST['Day'] = date('d'); // Build the month $Month = new Calendar_Month_Weekdays($_REQUEST['Year'],$_REQUEST['Month']); // Construct strings for next/previous links $PMonth = $Month->prevMonth('object'); // Get previous month as object $prev = '?Year='.$PMonth->thisYear().'&Month='.$PMonth->thisMonth().'&Day='.$PMonth->thisDay(); $NMonth = $Month->nextMonth('object'); $next = '?Year='.$NMonth->thisYear().'&Month='.$NMonth->thisMonth().'&Day='.$NMonth->thisDay(); // Build the days in the month if($params['selectedDays']) foreach($params['selectedDays'] as $selectedDay) { $selectedDays[] = new Calendar_Day(smarty_modifier_date_format($selectedDay,"%Y"),smarty_modifier_date_format($selectedDay,"%m"), smarty_modifier_date_format($selectedDay,"%d")); } $class = ($params['custom_class']?$params['custom_class']:''); $Month->build($selectedDays); $out = "<table class=\"calendar\">"; $out .= "<caption>".smarty_modifier_date_format($Month->getTimeStamp(),"%B %Y")."</caption>"; $out .= "<tr>"; $out .= "<th>Lun</th>"; $out .= "<th>Mar</th>"; $out .= "<th>Mie</th>"; $out .= "<th>Jue</th>"; $out .= "<th>Vie</th>"; $out .= "<th".($params['dif_weekend']?" class=\"weekend sat\"":"").">Sáb</th>"; $out .= "<th".($params['dif_weekend']?" class=\"weekend sun\"":"").">Dom</th>"; $out .= "</tr>"; while ( $Day = $Month->fetch() ) { // Build a link string for each day //$link = $_SERVER['PHP_SELF']. $link = ($params['action']?$params['action']:"").'?Year='.$Day->thisYear(). '&Month='.$Day->thisMonth(). '&Day='.$Day->thisDay(); // Contain the week's day's number, 0 = sunday, ..., 6 = saturday $num_day = date("w",strtotime($Day->thisYear()."-".$Day->thisMonth()."-".$Day->thisDay())); // isFirst() to find start of week if ( $Day->isFirst() ) $out .= "<tr>\n"; if ( $Day->isSelected() ) { $out .= "<td class=\"selected\">"; if($params['dif_weekend']) if($num_day == 6) $out .= "<div class=\"weekend sat\">"; elseif($num_day == 0) $out .= "<div class=\"weekend sun\">"; elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y")) $out .= "<div class=\"now\">"; $out .= "<a href=\"".$link."\"".(($class)?" class=\"$class\"":"").">".$Day->thisDay()."</a>"; if(($params['dif_weekend'] && ($num_day == 6 || $num_day == 0)) || ($Day->thisDay()==date("d") && $Day->thisMonth()==date("m") && $Day->thisYear()==date("Y"))) $out .= "</div>"; $out .= "</td>\n"; } else if ( $Day->isEmpty() ) { $out .= "<td> </td>\n"; } elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y")) { $out .= "<td><div class=\"now\">".$Day->thisDay()."</div></td>\n"; } else { $out .= "<td>"; if($num_day == 6 && $params['dif_weekend']) $out .= "<div class=\"weekend sat\">".$Day->thisDay()."</div>"; elseif($num_day == 0 && $params['dif_weekend']) $out .= "<div class=\"weekend sun\">".$Day->thisDay()."</div>"; else $out .= $Day->thisDay(); $out .= "</td>\n"; } // isLast() to find end of week if ( $Day->isLast() ) $out .= "</tr>\n"; } $start_year = ($params['start_year'])?$params['start_year']:"-5"; $end_year = ($params['end_year'])?$params['end_year']:"+5"; if (!isset($params['display_date'])) $params['display_date'] = true; $display_date = $params['display_date']; $day = $_REQUEST['Year']."-".$_REQUEST['Month']."-01"; if($display_date) { $out .= "<tr>"; $out .= "<td colspan=\"7\" class=\"control\"><form method=\"get\" action=\"".$params['action']."\""; $out .= ($params['frm_extra']?" ".$params['frm_extra']:"").">".smarty_function_html_select_date(array('time'=>$day,'prefix'=>'','start_year'=>$start_year,'end_year'=>$end_year,'display_days'=>false, 'display_months'=>true, 'display_years'=>true, 'month_extra'=>'id="Month"', 'year_extra'=>'id="Year"'),$smarty)." ".($params['btn_img']?"<input name=\"btnsubmit\" type=\"image\" src=\"".$params['btn_img']."\"/>":"<input name=\"btnsubmit\" type=\"submit\" value=\"Ir\" />").($params['today_btn']===true?" <input name=\"today\" type=\"button\" value=\"Hoy\" title=\"Presione para ir al mes en curso\" onclick=\"location.href = './'\" />":"")."</form></td>"; $out .= "</tr>"; } $out .= "</table>"; $out = smarty_modifier_strip($out); return $out; }
/** * setSelection * * @access public * @return void */ public function setSelection() { $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i = 1; $i <= $daysInMonth; $i++) { $day = new Calendar_Day(2000, 1, 1); // Create Day with dummy values $day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new TimetableEvent($day); $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i); $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i + 1); foreach ($this->timetable->events as $event) { if ($stamp1 >= $event['start'] && $stamp1 < $event['end'] || $stamp2 > $event['start'] && $stamp2 <= $event['end'] || $stamp1 <= $event['start'] && $stamp2 >= $event['end']) { $this->children[$i]->addEntry($event); $this->children[$i]->setSelected(); } } } Calendar_Month_Weekdays::buildEmptyDaysBefore(); Calendar_Month_Weekdays::shiftDays(); Calendar_Month_Weekdays::buildEmptyDaysAfter(); Calendar_Month_Weekdays::setWeekMarkers(); }
/** * Print a tabular calendar for selecting dates for appointments * Based on code from the PEAR package * * @link http://pear.php.net/package/Calendar PEAR Calendar * @link http://pearcalendar.sourceforge.net/examples/3.php Example this code based on * * @see make_appointment() * @see display_time() * * @param int $respondent_id The respondent id * @param int $questionnaire_id The questionnaire id * @param bool|int $day the day of the month if selected else false * @param bool|int $month the month of the year if selected else false * @param bool|int $year the year (4 digit) if selected else false * */ function display_calendar($respondent_id, $questionnaire_id, $year = false, $month = false, $day = false) { global $db; /** * PEAR Caldendar Weekday functions */ include_once 'Calendar/Month/Weekdays.php'; /** * PEAR Caldendar Day functions */ include_once 'Calendar/Day.php'; /** * See if questionnaire has shift restrictions */ $restricted = is_shift_restricted($questionnaire_id); $rtime = strtotime(get_respondent_time($respondent_id)); $y = date('Y', $rtime); $m = date('m', $rtime); $d = date('d', $rtime); if (!$year) { $year = $y; } if (!$month) { $month = $m; } if (!$day) { $day = $d; } $ttoday = new Calendar_Day($y, $m, $d); $Month = new Calendar_Month_Weekdays($year, $month); // Construct strings for next/previous links $PMonth = $Month->prevMonth('object'); // Get previous month as object $prev = '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay() . '&respondent_id=' . $respondent_id; $NMonth = $Month->nextMonth('object'); $next = '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay() . '&respondent_id=' . $respondent_id; // Build the days in the month $Month->build(); print "<table class=\"calendar table-hover table-condensed text-center\">"; print "<caption class=\"text-center text-primary\"><b>" . T_(date('F Y', $Month->getTimeStamp())) . "</b></caption>\r\n\t\t\t\t<thead style=\"font-weight: bolder;\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Mon") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Tue") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Wed") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Thu") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Fri") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sat") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sun") . "</td>\r\n\t\t\t\t</tr></thead>"; while ($Day = $Month->fetch()) { // Build a link string for each day $link = '?y=' . $Day->thisYear() . '&m=' . $Day->thisMonth() . '&d=' . $Day->thisDay() . '&respondent_id=' . $respondent_id; $today = ""; if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) { $today = "today"; } // isFirst() to find start of week if ($Day->isFirst()) { echo "<tr>\n"; } if ($Day->isSelected()) { echo "<td class=\"selected {$today}\">" . $Day->thisDay() . "</td>\n"; } else { if ($Day->isEmpty()) { echo "<td> </td>\n"; } else { //if it is in the past -> unavailable if ($Day->getTimeStamp() < $ttoday->getTimeStamp()) { echo "<td style=\"color:grey;\" class=\"notavailable\">" . $Day->thisDay() . "</td>\n"; } else { if ($restricted) { $rs = $db->Execute(" SELECT s.shift_id\r\n\t\t\t\t\t\tFROM shift as s\r\n\t\t\t\t\t\tLEFT JOIN respondent as r on (r.respondent_id = '{$respondent_id}')\r\n\t\t\t\t\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\t\t\t\tAND DAY(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisDay()}'\r\n\t\t\t\t\t\tAND MONTH(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisMonth()}'\r\n\t\t\t\t\t\tAND YEAR(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisYear()}'"); if (!empty($rs) && $rs->RecordCount() == 0) { echo "<td style=\"color:grey;\" class=\"notavailable {$today}\">" . $Day->thisDay() . "</td>\n"; } else { echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n"; } } else { echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n"; } } } } // isLast() to find end of week if ($Day->isLast()) { echo "</tr>\n"; } } ?> <tr> <td> <a href="<?php echo $prev; ?> " class="prevMonth btn btn-default"><< </a> </td> <td colspan="5"><?php print "<b class=\"text-primary\">" . date('l j F Y', mktime(0, 0, 0, $month, $day, $year)) . "</b>"; ?> </td> <td> <a href="<?php echo $next; ?> " class="nextMonth btn btn-default"> >></a> </td> </tr> </table> <?php }
echo '</pre>'; echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>"; print_r(Calendar_Decorator_Textual::weekdayNames('two')); echo '</pre>'; echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />"; $Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); // Decorate $Textual =& new Calendar_Decorator_Textual($Calendar); echo '<hr>Previous month is: ' . $Textual->prevMonthName('two') . '<br />'; echo 'This month is: ' . $Textual->thisMonthName('short') . '<br />'; echo 'Next month is: ' . $Textual->nextMonthName() . '<br /><hr />'; echo 'Previous day is: ' . $Textual->prevDayName() . '<br />'; echo 'This day is: ' . $Textual->thisDayName('short') . '<br />'; echo 'Next day is: ' . $Textual->nextDayName('one') . '<br /><hr />'; echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />"; $Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); // Decorate $Textual =& new Calendar_Decorator_Textual($Calendar); ?> <p>Rendering calendar....</p> <table> <caption><?php echo $Textual->thisMonthName() . ' ' . $Textual->thisYear(); ?> </caption> <tr> <?php $dayheaders = $Textual->orderedWeekdays('short'); foreach ($dayheaders as $dayheader) { echo '<th>' . $dayheader . '</th>'; }
function GestionAffichageCalendrier($type = 'calendrier') { $retour = '<div class="' . $type . '">'; $url = $GLOBALS['_BAZAR_']['url']; $db =& $GLOBALS['_BAZAR_']['db']; // Nettoyage de l'url de la query string $chaine_url = $url->getQueryString(); $tab_params = explode('&', $chaine_url); if (count($tab_params) == 0) { $tab_params = explode('&', $chaine_url); } foreach ($tab_params as $param) { $tab_parametre = explode('=', $param); if ($tab_parametre[0] != 'wiki') { $url->removeQueryString($tab_parametre[0]); } } if (!isset($_GET['y'])) { $_GET['y'] = date('Y'); } if (!isset($_GET['m'])) { $_GET['m'] = date('m'); } // Construction Mois en Cours $month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']); $curStamp = $month->getTimeStamp(); $url->addQueryString('y', date('Y', $curStamp)); $url->addQueryString('m', date('n', $curStamp)); $url->addQueryString('d', date('j', $curStamp)); $cur = str_replace('&', '&', $url->getUrl()); // Gestion de l'affichage des titres des evenements if (isset($_GET['ctt']) && $_GET['ctt'] == '1') { $url->addQueryString('tt', '0'); if (isset($_GET['tt']) && $_GET['tt'] == '0') { $url->addQueryString('tt', '1'); } $tc_lien = str_replace('&', '&', $url->getUrl()); } else { $url->addQueryString('tt', '0'); if (isset($_GET['tt']) && $_GET['tt'] == '0') { $url->addQueryString('tt', '1'); } $url->addQueryString('ctt', '1'); $tc_lien = str_replace('&', '&', $url->getUrl()); } $url->removeQueryString('ctt'); $url->removeQueryString('tt'); $tc_txt = BAZ_AFFICHE_TITRES_COMPLETS; if (isset($_GET['tt']) && $_GET['tt'] == '0') { $tc_txt = BAZ_TRONQUER_TITRES; $url->addQueryString('tt', $_GET['tt']); } // Navigation $prevStamp = $month->prevMonth(true); $url->addQueryString('y', date('Y', $prevStamp)); $url->addQueryString('m', date('n', $prevStamp)); $url->addQueryString('d', date('j', $prevStamp)); $prev = str_replace('&', '&', $url->getUrl()); $nextStamp = $month->nextMonth(true); $url->addQueryString('y', date('Y', $nextStamp)); $url->addQueryString('m', date('n', $nextStamp)); $url->addQueryString('d', date('j', $nextStamp)); $next = str_replace('&', '&', $url->getUrl()); // Suppression du parametre de troncage des titres $url->removeQueryString('tt'); $fr_month = array("1" => BAZ_JANVIER, "2" => BAZ_FEVRIER, "3" => BAZ_MARS, "4" => BAZ_AVRIL, "5" => BAZ_MAI, "6" => BAZ_JUIN, "7" => BAZ_JUILLET, "8" => BAZ_AOUT, "9" => BAZ_SEPTEMBRE, "10" => BAZ_OCTOBRE, "11" => BAZ_NOVEMBRE, "12" => BAZ_DECEMBRE); if ($type == 'calendrier' || $type == 'calendrierjquery' || $type == 'calendrierjquerymini') { $retour .= '<div class="cal_entete">' . "\n"; $retour .= '<span class="cal_navigation">' . "\n"; $retour .= '<a class="cal_precedent_lien" href="' . $prev . '" title="Allez au mois precedent"><img class="cal_precedent_img" src="' . BAZ_CHEMIN . 'presentation/images/cal_precedent.png" alt="<<"/></a>' . "\n"; $retour .= '<a class="cal_mois_courrant" href="' . $cur . '">'; $retour .= $fr_month[date('n', $curStamp)]; $retour .= ' '; $retour .= date('Y', $curStamp); $retour .= '</a>' . "\n"; $retour .= '<a class="cal_suivant_lien" href="' . $next . '" title="Allez au mois suivant"><img class="cal_suivant_img" src="' . BAZ_CHEMIN . 'presentation/images/cal_suivant.png" alt=">>"/></a>' . "\n"; $retour .= '</span>' . "\n"; if ($type == 'calendrier') { $retour .= '<span class="tc_lien">' . '<a href="' . $tc_lien . '">' . $tc_txt . '</a>' . '</span>' . "\n"; } $retour .= '</div>' . "\n"; } // Vue Mois calendrier ou vue applette if (!isset($_GET['id_fiche']) && ($type == 'calendrier' || $type == 'calendrierjquery' || $type == 'calendrierjquerymini')) { // Recherche evenement de la periode selectionnée $ts_jour_fin_mois = $month->nextMonth('timestamp'); $ts_jour_debut_mois = $month->thisMonth('timestamp'); //on recherche toutes les fiches puis on trie sur ceux qui possede une date $tableau_resultat = baz_requete_recherche_fiches('', 'chronologique', $GLOBALS['_BAZAR_']['id_typeannonce'], $GLOBALS['_BAZAR_']['categorie_nature']); $tab_fiches = array(); foreach ($tableau_resultat as $fiche) { $valeurs_fiche = json_decode($fiche[0], true); $valeurs_fiche = array_map('utf8_decode', $valeurs_fiche); //echo $valeurs_fiche['bf_titre'].' du '.$valeurs_fiche['bf_date_debut_evenement'].' au '.$valeurs_fiche['bf_date_fin_evenement'].'<br />'; //echo 'date fin mois : '.date('Y-n-j', $ts_jour_fin_mois).'<br />'; //echo 'date debut mois : '.date('Y-n-j', $ts_jour_debut_mois).'<br />'; if (isset($valeurs_fiche['bf_date_debut_evenement'])) { $dateArr = explode("-", $valeurs_fiche['bf_date_debut_evenement']); $date1Int = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]); } else { $date1Int = NULL; } if (isset($valeurs_fiche['bf_date_fin_evenement'])) { $dateArr = explode("-", $valeurs_fiche['bf_date_fin_evenement']); $date2Int = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]); } else { $date2Int = NULL; } //echo ($date1Int < $ts_jour_fin_mois).' = ($date1Int < $ts_jour_fin_mois)'; //echo ($date2Int >= $ts_jour_debut_mois).' = ($date2Int >= $ts_jour_debut_mois)'; if ($date1Int && $date2Int) { $tab_fiches[] = $valeurs_fiche; } } $selection = array(); $evenements = array(); $annee = date('Y', $curStamp); $mois = date('m', $curStamp); $tablo_jours = array(); foreach ($tab_fiches as $val_fiche) { list($annee_debut, $mois_debut, $jour_debut) = explode('-', $val_fiche['bf_date_debut_evenement']); list($annee_fin, $mois_fin, $jour_fin) = explode('-', $val_fiche['bf_date_fin_evenement']); $Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut); $ts_jour_suivant = $Calendrier->thisDay('timestamp'); $ts_jour_fin = mktime(0, 0, 0, $mois_fin, $jour_fin, $annee_fin); $naviguer = true; while ($naviguer && $ts_jour_suivant <= $ts_jour_fin) { // Si le jours suivant est inferieur a la date de fin du mois courrant, on continue... if ($ts_jour_suivant < $ts_jour_fin_mois) { $cle_j = date('Y-m-d', $ts_jour_suivant); if (!isset($tablo_jours[$cle_j])) { $tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant), date('m', $ts_jour_suivant), date('d', $ts_jour_suivant)); $tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']); } $tablo_jours[$cle_j]['Diary_Event']->setEntry($val_fiche['bf_titre']); $ts_jour_suivant = $Calendrier->nextDay('timestamp'); //echo "ici$ts_jour_suivant-"; $Calendrier->setTimestamp($ts_jour_suivant); //echo "la".$Calendrier->thisDay('timestamp')."-"; } else { $naviguer = false; } } } // Add the decorator to the selection foreach ($tablo_jours as $jour) { $selection[] = $jour['Diary_Event']; } // Affichage Calendrier $month->build($selection); $retour .= '<table>' . "\n" . '<colgroup>' . "\n" . '<col class="cal_lundi"/>' . "\n" . '<col class="cal_mardi"/>' . "\n" . '<col class="cal_mercredi"/>' . "\n" . '<col class="cal_jeudi"/>' . "\n" . '<col class="cal_vendredi"/>' . "\n" . '<col class="cal_samedi"/>' . "\n" . '<col class="cal_dimanche"/>' . "\n" . '</colgroup>' . "\n" . '<thead>' . "\n" . "<tr>" . "\n"; if ($type == 'calendrier' || $type == 'calendrierjquery') { $retour .= "<th> " . BAZ_LUNDI . "</th>\n\t\t\t <th> " . BAZ_MARDI . "</th>\n\t\t\t <th> " . BAZ_MERCREDI . "</th>\n\t\t\t <th> " . BAZ_JEUDI . "</th>\n\t\t\t <th> " . BAZ_VENDREDI . "</th>\n\t\t\t <th> " . BAZ_SAMEDI . "</th>\n\t\t\t <th> " . BAZ_DIMANCHE . "</th>\n\t\t\t </tr>\n\t\t\t " . '</thead>' . "\n" . '<tbody>' . "\n"; } elseif ($type == 'calendrierjquerymini') { $retour .= "<th> " . BAZ_LUNDI_COURT . "</th>\n\t\t\t <th> " . BAZ_MARDI_COURT . "</th>\n\t\t\t <th> " . BAZ_MERCREDI_COURT . "</th>\n\t\t\t <th> " . BAZ_JEUDI_COURT . "</th>\n\t\t\t <th> " . BAZ_VENDREDI_COURT . "</th>\n\t\t\t <th> " . BAZ_SAMEDI_COURT . "</th>\n\t\t\t <th> " . BAZ_DIMANCHE_COURT . "</th>\n\t\t\t </tr>\n\t\t\t " . '</thead>' . "\n" . '<tbody>' . "\n"; } $todayStamp = time(); $today_ymd = date('Ymd', $todayStamp); // Other month : mois while ($day = $month->fetch()) { $dayStamp = $day->thisDay(true); $day_ymd = date('Ymd', $dayStamp); if ($day->isEmpty()) { $class = "cal_autre_mois"; } else { if ($day_ymd < $today_ymd) { $class = "cal_mois_precedent"; } else { if ($day_ymd == $today_ymd) { $class = "cal_jour_courant"; } else { $class = "cal_mois_courant"; } } } $url->addQueryString('y', date('Y', $dayStamp)); $url->addQueryString('m', date('n', $dayStamp)); $url->addQueryString('d', date('j', $dayStamp)); $link = $url->getUrl(); // isFirst() to find start of week if ($day->isFirst()) { $retour .= "<tr>\n"; } if ($type == 'calendrier') { $retour .= "<td class=\"" . $class . "\">" . '<span class="cal_j">' . $day->thisDay() . '</span>' . "\n"; if ($day->isSelected()) { $evenements = $day->getEntry(); $evenements_nbre = count($evenements); $evenemt_xhtml = ''; while ($ligne_evenement = array_pop($evenements)) { $id_fiches = $ligne_evenement->bf_id_fiche; $url->addQueryString('id_fiche', $id_fiches); $link = str_replace('&', '&', $url->getUrl()); if (!isset($_GET['tt']) || isset($_GET['tt']) && $_GET['tt'] == '1') { $titre_taille = strlen($ligne_evenement->bf_titre); $titre = htmlentities($titre_taille > 40 ? substr($ligne_evenement->bf_titre, 0, 40) . '...' : $ligne_evenement->bf_titre, ENT_QUOTES); } else { $titre = htmlentities($ligne_evenement->bf_titre, ENT_QUOTES); } $evenemt_xhtml .= '<li class="tooltip" title="' . htmlentities($ligne_evenement->bf_titre, ENT_QUOTES) . '"><a class="cal_evenemt" href="' . $link . '">' . $titre . '</a></li>' . "\n"; $url->removeQueryString('id_fiches'); } if ($evenements_nbre > 0) { $retour .= '<ul class="cal_evenemt_liste">'; $retour .= $evenemt_xhtml; $retour .= '</ul>'; } } } elseif ($type == 'calendrierjquery' || $type == 'calendrierjquerymini') { if ($day->isSelected()) { $evenements = $day->getEntry(); $evenements_nbre = count($evenements); $evenemt_xhtml = ''; while ($ligne_evenement = array_pop($evenements)) { $id_fiches = $ligne_evenement->bf_id_fiche; $url->addQueryString('id_fiche', $id_fiches); $link = str_replace('&', '&', $url->getUrl()); $titre = htmlentities($ligne_evenement->bf_titre, ENT_QUOTES); $evenemt_xhtml .= '<li> <span class="titre_evenement"><a class="cal_evenemt" href="' . $link . '">' . $titre . '</a></span> </li>'; $url->removeQueryString('id_fiches'); } if ($evenements_nbre > 0) { $retour .= '<td class="' . $class . ' date_avec_evenements">' . $day->thisDay() . ' <div class="evenements"> <ul>'; $retour .= $evenemt_xhtml; $retour .= '</ul> </div>'; } else { $retour .= '<td class="' . $class . '">' . $day->thisDay() . "\n"; } } else { $retour .= '<td class="' . $class . '">' . $day->thisDay() . "\n"; } } elseif ($type == 'calendriermini') { $lien_date = "<td class=\"" . $class . "\">" . $day->thisDay(); if ($day->isSelected()) { $evenements = $day->getEntry(); $id_fiches = array(); while ($ligne_evenement = array_pop($evenements)) { $id_fiches[] = $ligne_evenement->bf_id_fiche; } $url->addQueryString('id_fiches', $id_fiches); $link = str_replace('&', '&', $url->getUrl()); $lien_date = "<td class=\"" . $class . "\"><a href=\"" . $link . "\">" . $day->thisDay() . "</a>\n"; $url->removeQueryString('id_fiches'); } $retour .= $lien_date; } $retour .= "</td>\n"; // isLast() to find end of week if ($day->isLast()) { $retour .= "</tr>\n"; } } $retour .= "</tbody></table>"; } // Vue detail if (isset($_GET['id_fiche'])) { // Ajout d'un titre pour la page avec la date $jours = array('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'); $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'); $timestamp = strtotime($_GET['y'] . '/' . $_GET['m'] . '/' . $_GET['d']); $retour .= '<h1>' . $jours[date('w', $timestamp) - 1] . ' ' . $_GET['d'] . ' ' . $mois[$_GET['m'] - 1] . ' ' . $_GET['y'] . '</h1>'; $retour .= baz_voir_fiche(0, $_GET['id_fiche']); // Un lien pour retourner au calendrier $url->removeQueryString('id_fiche'); $url->removeQueryString('y'); $url->removeQueryString('m'); $url->removeQueryString('d'); $url->addQueryString('y', $_GET['y']); $url->addQueryString('m', $_GET['m']); $url->addQueryString('d', $_GET['d']); $retour .= '<div class="retour"><a href="' . str_replace('&', '&', $url->getUrl()) . '">Retour au calendrier</a></div>'; } // Nettoyage de l'url $url->removeQueryString('id_fiche'); $url->removeQueryString('y'); $url->removeQueryString('m'); $url->removeQueryString('d'); return $retour . "\n" . '</div>' . "\n"; }