32,7 → 32,7 |
// pris connaissance de la licence CeCILL, et que vous en avez accepté les |
// termes. |
// ---- |
// CVS : $Id: bazar.calendrier.php,v 1.4 2005-10-01 11:21:39 ddelon Exp $ |
// CVS : $Id: bazar.calendrier.php,v 1.5 2005-10-12 17:20:33 ddelon Exp $ |
/** |
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier |
* |
40,229 → 40,23 |
*@package Bazar |
//Auteur original : |
*@author David DELON <david.delon@clapas.net> |
*@version $Revision: 1.4 $ $Date: 2005-10-01 11:21:39 $ |
*@version $Revision: 1.5 $ $Date: 2005-10-12 17:20:33 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// TODO : afficher evenement sur plusieur jours |
// TODO : traduction entete mois calendrier |
// Parametrage EVENEMENT : template |
|
// Fonction Calendrier de Pear |
|
require_once 'Calendar/Month/Weekdays.php'; |
require_once 'Calendar/Day.php'; |
require_once 'Calendar/Decorator.php'; |
|
define ('BAZ_VOIR_FICHE', 8) ; |
if (!defined('BAZ_VOIR_FICHE')) { |
define ('BAZ_VOIR_FICHE', 8); |
} |
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar |
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar |
|
|
include_once 'bibliotheque/bazar.fonct.cal.php'; //fichier des fonctions de Bazar |
|
// Classe Utilitaire pour Calendrier |
|
class DiaryEvent extends Calendar_Decorator { |
var $entry=array(); |
function DiaryEvent($calendar) { |
Calendar_Decorator::Calendar_Decorator($calendar); |
} |
function setEntry($entry) { |
$this->entry[]=$entry; |
|
} |
function getEntry() { |
return $this->entry; |
} |
} |
|
|
function afficherContenuCorps() { |
|
// Ajout d'une feuille de style externe |
GEN_stockerStyleExterne ('wikini', 'client/bazar/presentations/styles/calendrier.css') ; |
return GestionAffichageCalendrier(''); |
|
$retour=''; |
|
$url = $GLOBALS['_GEN_commun']['url'] ; |
$db = &$GLOBALS['_GEN_commun']['pear_db'] ; |
$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ; |
} |
|
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 = $url->getUrl(); |
|
// Navigation |
$prevStamp = $month->prevMonth(true); |
$url->addQueryString ('y', date('Y',$prevStamp)); |
$url->addQueryString ('m', date('n',$prevStamp)); |
$url->addQueryString ('d', date('j',$prevStamp)); |
$prev = $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 = $url->getUrl(); |
|
$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); |
|
$retour.= "<div class=\"navi\">"; |
$retour.= "<a href=\"".$prev."\"> << </a>"; |
|
$retour.= " "; |
$retour.= "<a href=\"".$cur; |
$retour.= "\"> "; |
$retour.= $fr_month[(date('n',$curStamp))]; |
$retour.= " "; |
$retour.= (date('Y',$curStamp)); |
$retour.= "</a>"; |
$retour.= " "; |
$retour.= "<a href=\"".$next."\"> >> </a>"; |
|
$retour.= "</div>"; |
|
$retour.="<br></br>"; |
|
// Vue Mois |
if (!isset($_GET['id_fiche'])) { |
|
// Recherche evenement de la periode selectionnée |
|
// TODO : Selectionner element du mois en cours |
|
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, day(bf_date_debut_evenement) as bf_jour_debut_evenement , bf_date_fin_evenement, bf_description FROM bazar_fiche, bazar_nature where year(bf_date_debut_evenement) =".date('Y',$curStamp)." and month(bf_date_debut_evenement)=".date('m',$curStamp)." and bf_ce_nature=bn_id_nature and bn_label_nature='Évènements'"; |
|
|
$resultat_evenement = $db->query($requete_evenements); |
|
(DB::isError($resultat_evenement)) |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements)) |
: ''; |
|
$calcom=""; |
|
$selection=array(); |
$evenements=array(); |
|
$prev_curday_ymd=0; |
|
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) { |
|
$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement; |
if ($curday_ymd!=$prev_curday_ymd) { |
$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement); |
$DiaryEvent = new DiaryEvent($Day); |
$prev_curday_ymd=$curday_ymd; |
} |
|
$DiaryEvent->setEntry($ligne_evenements); |
|
// Add the decorator to the selection |
$selection[] = $DiaryEvent; |
|
} |
|
// Affichage Calendrier |
|
|
$month->build($selection); |
|
$retour.= "<table class=\"calendar\"> |
<tr> |
|
<th> ". BAZ_LUNDI ."</th> |
<th> ". BAZ_MARDI ."</th> |
<th> ". BAZ_MERCREDI ."</th> |
<th> ". BAZ_JEUDI ."</th> |
<th> ". BAZ_VENDREDI ."</th> |
<th> ". BAZ_SAMEDI ."</th> |
<th> ". BAZ_DIMANCHE ."</th> |
</tr> |
"; |
|
$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 = "other_month"; |
} |
else { |
if (($day_ymd < $today_ymd)) { |
$class="previous_month"; |
} |
else { |
if ($day_ymd == $today_ymd) { |
$class="current_day"; |
} |
else { |
$class="current_month"; |
} |
} |
} |
|
$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" ); |
|
$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" ); |
|
if ($day->isSelected() ) { |
$evenements=$day->getEntry(); |
while ($ligne_evenement=array_pop($evenements)) { |
$url->addQueryString ('id_fiche',$ligne_evenement->bf_id_fiche); |
$link = $url->getUrl(); |
$retour.= ( "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n" ); |
} |
|
} |
|
$retour.= ( "</td>\n" ); |
|
// isLast() to find end of week |
if ( $day->isLast() ) |
$retour.= ( "</tr>\n" ); |
} |
|
$retour.= "</table>"; |
|
return $retour; |
|
} |
else { |
// Vue jour |
if (isset($_GET['id_fiche'])) { |
return $retour.baz_voir_fiche(0, $_GET['id_fiche']); |
} |
} |
} |
|
?> |