* 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 echo $_SERVER['PHP_SELF'] . '?' . $Uri->next('month');
$_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> <head> <title> Calendar using PEAR::Date Engine </title> <style text="text/css"> table { background-color: silver; } caption { font-family: verdana; font-size: 12px; background-color: while; } .prevMonth {
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 { $navPrevYear = $Month->thisYear(); } if (!$to_pass["branch"]) { $to_pass["branch"] = $_SESSION["auth"]["use_branch"]; } foreach ($to_pass as $key => $val) { $query_string .= $key . '=' . $val . '&'; $hidden_fields .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />' . "\n";
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';
/** * メッセージページのカレンダー生成 */ 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; }
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"; }