Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 399 → Rev 446

/trunk/bibliotheque/bazar.fonct.cal.php
25,7 → 25,7
* Fonctions calendrier du module bazar
*
* TODO : ajouter la gestion du multilinguisme
*
*
*@package bazar
//Auteur original :
*@author David Delon <david.delon@clapas.net>
41,7 → 41,7
 
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
57,13 → 57,13
function setEntry($entry)
{
$this->entry[] = $entry;
 
}
function getEntry()
{
return $this->entry;
}
}
}
 
 
// $type : calendrier
76,7 → 76,7
if (is_string ($tab_arguments)) {
$tab_arguments = substr($tab_arguments, 1);
} else {
unset($tab_arguments[0]);
unset($tab_arguments[0]);
}
if (is_array($tab_arguments)) {
foreach($tab_arguments as $argument) {
83,13 → 83,13
if ($argument != '') {
$tab_parametres = explode('=', $argument, 2);
if (is_array($tab_parametres)) {
$options[$tab_parametres[0]] =
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
$options[$tab_parametres[0]] =
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
}
}
}
}
 
if (!isset($options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
} else {
97,13 → 97,13
$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
}
}
 
$retour = '';
 
$url = $GLOBALS['_GEN_commun']['url'] ;
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
 
// Nettoyage de l'url de la query string
$chaine_url = $url->getQueryString();
$tab_params = explode('&amp;', $chaine_url);
114,16 → 114,16
$tab_parametre = explode('=', $param);
$url->removeQueryString($tab_parametre[0]);
}
if (!isset($_GET['y'])) {
 
if (!isset($_GET['y'])) {
$_GET['y'] = date('Y');
}
if (!isset($_GET['m'])) {
 
if (!isset($_GET['m'])) {
$_GET['m'] = date('m');
}
// Construction Mois en Cours
 
// Construction Mois en Cours
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
 
$curStamp = $month->getTimeStamp();
167,24 → 167,24
// Gestion des champs cachés pour le formulaire de filtre
// Attention à la position dans le fichier...
$ficnat_chps_cache = $url->querystring;
unset($ficnat_chps_cache['ficnat']);
// Navigation
unset($ficnat_chps_cache['ficnat']);
 
// 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();
 
// Suppression du paramêtre 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);
 
194,13 → 194,13
'WHERE bn_id_nature IN ('.BAZ_NUM_ANNONCE_CALENDRIER.') ';
$resultat_nature_fiche = $db->query($requete_nature_fiche);
(DB::isError($resultat_nature_fiche)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_nature_fiche->getMessage(), $requete_nature_fiche), E_USER_WARNING) : '';
 
// Ajout du javascript et des styles du bazar
if (defined('PAP_VERSION')) { //si on est dans Papyrus
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
 
// DomToolTip
$script = 'var domTT_styleClass = "niceTitle";'."\n";
$script .= 'function nicetitleDecorator(el) {'."\n";
214,15 → 214,15
$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
}
 
// Titre
if ($type == 'calendrier') {
$retour .= '<div id="cal_entete">'."\n";
$retour .= '<span class="cal_navigation">'."\n";
$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
$retour .= '<span class="cal_navigation">'."\n";
$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
$retour .= $fr_month[(date('n',$curStamp))];
$retour .= $fr_month[(date('n',$curStamp))];
$retour .= '&nbsp;';
$retour .= (date('Y',$curStamp));
$retour .= '</a></span>'."\n";
231,19 → 231,19
$retour .= '</span>'."\n";
$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>'."\n";
$retour .= '</div>'."\n";
 
$retour .= '<form action="'.$tc_lien.'" method="get">'."\n";
$retour .= '<a href="'.$tc_lien.'">'.$tc_txt.'</a>'."\n";
$retour .= '<fieldset>'."\n";
$retour .= '<legend>'.'Filtrer : '.'</legend>'."\n";
$retour .= '<select id="ficnat" name="ficnat" class="filtre_'.((!is_null($ficnat_id)) ? $ficnat_id: 'tous').'" onchange="javascript:this.form.submit();">'."\n";
 
$retour .= '<option id="filtre_tous" value="*" ';
if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
$retour .= 'selected="selected" ';
}
$retour .= '>'.'Tout afficher'.'</option>';
 
while ($ligne_nature_fiche = $resultat_nature_fiche->fetchRow(DB_FETCHMODE_OBJECT)) {
$opt = '<option class="filtre_'.$ligne_nature_fiche->bn_id_nature.'" value="'.$ligne_nature_fiche->bn_id_nature.'" ';
if (isset($_GET['ficnat']) && $ligne_nature_fiche->bn_id_nature == $_GET['ficnat']) {
250,10 → 250,10
$opt .= 'selected="selected" ';
}
$opt .= '>';
 
$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
}
 
$retour .= '</select>'."\n";
$retour .= '<input id="ficnat_ok" type="submit" value="'.'OK'.'" onload="javascript:this.setAttribute(\'style\', \'display:none;\')"/>'."\n";
$script_ok = 'if (document.getElementById(\'ficnat_ok\')) {'.
265,7 → 265,7
}
$retour .= '</fieldset>'."\n";
$retour .= '</form>'."\n";
 
} else {
// Appel du template
ob_start();
274,12 → 274,12
ob_end_clean();
}
// Vue Mois calendrier ou vue applette
 
if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
// trigger_error('ICI', E_USER_NOTICE);
// Recherche evenement de la periode selectionnée
// Recherche evenement de la periode selectionnée
$ts_jour_fin_mois = $month->nextMonth('timestamp');
$ts_jour_debut_mois = $month->thisMonth('timestamp');;
$ts_jour_debut_mois = $month->thisMonth('timestamp');;
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
" DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement, bf_date_debut_evenement, ".
" bf_date_fin_evenement, bf_description, bn_id_nature ".
290,9 → 290,9
"AND bn_id_nature IN (".$cal_num_annonce.") ".
"AND bf_statut_fiche = 1 ".
"ORDER BY bf_jour_debut_evenement";
 
$resultat_evenement = $db->query($requete_evenements);
 
(DB::isError($resultat_evenement)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements), E_USER_WARNING) : '';
 
$selection = array();
303,52 → 303,38
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
list($annee_debut, $mois_debut, $jour_debut) = explode('-', $ligne_evenements->bf_date_debut_evenement);
list($annee_fin, $mois_fin, $jour_fin) = explode('-', $ligne_evenements->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);
if ($ts_jour_suivant < $ts_jour_fin) {
//echo "$ts_jour_suivant-";
$naviguer = true;
while ($naviguer) {
// Si le jours suivant est inférieur à la date de fin, on continue...
if ($ts_jour_suivant <= $ts_jour_fin) {
// Si le jours suivant est inférieur à 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($ligne_evenements);
$ts_jour_suivant = $Calendrier->nextDay('timestamp');
//echo "ici$ts_jour_suivant-";
$Calendrier->setTimestamp($ts_jour_suivant);
//echo "la".$Calendrier->thisDay('timestamp')."-";
} else {
$naviguer = false;
}
} else {
$naviguer = false;
 
$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($ligne_evenements);
 
$ts_jour_suivant = $Calendrier->nextDay('timestamp');
//echo "ici$ts_jour_suivant-";
$Calendrier->setTimestamp($ts_jour_suivant);
//echo "la".$Calendrier->thisDay('timestamp')."-";
} else {
$naviguer = false;
}
} else {
$curday_ymd = $annee.$mois.$ligne_evenements->bf_jour_debut_evenement;
$cle_j = $annee.'-'.$mois.'-'.sprintf('%02s', $ligne_evenements->bf_jour_debut_evenement);
if (!isset($tablo_jours[$cle_j])) {
$tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day($annee, $mois, $ligne_evenements->bf_jour_debut_evenement);
$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
}
$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
}
}
 
 
// Add the decorator to the selection
foreach ($tablo_jours as $jour) {
$selection[] = $jour['Diary_Event'];
$selection[] = $jour['Diary_Event'];
}
 
// Affichage Calendrier
$month->build($selection);
if ($type == 'calendrier') {
364,7 → 350,7
'</colgroup>'.
'<thead>'.
"<tr>
 
<th> ". BAZ_LUNDI ."</th>
<th> ". BAZ_MARDI ."</th>
<th> ". BAZ_MERCREDI ."</th>
387,7 → 373,7
'</colgroup>'.
'<thead>'.
"<tr>
 
<th> ". BAZ_LUNDI_COURT ."</th>
<th> ". BAZ_MARDI_COURT ."</th>
<th> ". BAZ_MERCREDI_COURT ."</th>
398,11 → 384,11
</tr>
".'</thead>'.'<tbody>';
}
 
$todayStamp=time();
$today_ymd=date('Ymd',$todayStamp);
 
// Other month : mois
// Other month : mois
while ($day = $month->fetch() ) {
$dayStamp = $day->thisDay(true);
$day_ymd = date('Ymd',$dayStamp);
419,12 → 405,12
}
}
}
 
$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" );
440,7 → 426,7
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$url->addQueryString ('id_fiches',$id_fiches);
$link = $url->getUrl();
 
if (!isset($_GET['tt']) || (isset($_GET['tt']) && $_GET['tt'] == '1')) {
$titre_taille = strlen($ligne_evenement->bf_titre);
$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
474,7 → 460,7
$retour .= $lien_date;
}
$retour.= ( "</td>\n" );
 
// isLast() to find end of week
if ( $day->isLast() ) {
$retour.= ( "</tr>\n" );
484,7 → 470,7
}
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script.'//]]></script>'."\n";
// Vue detail
 
if ((isset($_GET['id_fiches']))) {
// Ajout d'un titre pour la page avec la date
$jours = array ('dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
491,7 → 477,7
$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']) ;
 
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
499,7 → 485,7
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
 
$GLOBALS['_GEN_commun']['info_menu'] = '';
 
// Un lien pour retourner au calendrier
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
513,8 → 499,8
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
 
 
return $retour;
}
?>