format('Y-m-01'); $last_day = $now->format('Y-m-t'); $req_select = "e.*"; $req_from = "spip_evenements AS e"; // Eviter un 'no such function: LAST_DAY' qd on utilise SQLite //$req_where = "e.date_debut >= CONCAT(DATE_FORMAT(NOW(),'%Y-%m'), '-01') AND e.date_debut <= LAST_DAY(NOW()) AND e.statut = 'publie'"; $req_where = "e.date_debut >= '$first_day' AND e.date_debut <= '$last_day' AND e.statut = 'publie'"; $req_orderby = "e.date_debut, e.date_fin"; // ---- Acces restreint --- $ar = simplecal_get_where_rubrique_exclure(); if ($ar){ $req_where .= " $ar"; } // ------------------------ /* SELECT e.* FROM `spip_evenements` as e WHERE e.date_debut >= CONCAT(DATE_FORMAT(NOW(),'%Y-%m'), '-01') AND e.date_debut <= LAST_DAY(NOW()) */ $dates = array(); $rows = sql_allfetsel($req_select, $req_from, $req_where, $req_orderby); foreach ($rows as $row){ $date_debut = $row['date_debut']; $dates[] = substr($date_debut, 0,10); } $imois = intval(date('m')); $iannee = intval(date('Y')); $calendrier = simplecal_generer_calendrier($imois, $iannee, $dates); $p->code = "'$calendrier'"; return $p; } function simplecal_generer_calendrier($mois, $annee, $tab_dates){ $sannee = "".$annee; $smois = "".$mois; if (strlen($smois)<2){ $smois = "0".$smois; } //$date_1er_du_mois = date('Y-m-d-N', mktime(0, 0, 0, $mois , 1, $annee)); // Ne gere pas les annees <= 1900... $date_1er_du_mois = date_format(date_create("".$sannee."-".$smois."-1"), 'Y-m-d-N'); if (preg_match("#([1-2][0-9]{3})\-([0-9]{2})\-([0-9]{2})\-([0-9]{1})#i", $date_1er_du_mois, $matches)){ $annee = intval($matches[1]); $mois = intval($matches[2]); $jour = intval($matches[3]); $num_jour = intval($matches[4]); } // **************** $nom_mois = array( 1 => ucfirst(_T('date_mois_1')), 2 => ucfirst(_T('date_mois_2')), 3 => ucfirst(_T('date_mois_3')), 4 => ucfirst(_T('date_mois_4')), 5 => ucfirst(_T('date_mois_5')), 6 => ucfirst(_T('date_mois_6')), 7 => ucfirst(_T('date_mois_7')), 8 => ucfirst(_T('date_mois_8')), 9 => ucfirst(_T('date_mois_9')), 10 => ucfirst(_T('date_mois_10')), 11 => ucfirst(_T('date_mois_11')), 12 => ucfirst(_T('date_mois_12')) ); $max_des_mois = array(1=>31, 2=>28, 3=>31, 4=>30, 5=>31, 6=>30, 7=>31, 8=>31, 9=>30, 10=>31, 11=>30, 12=>31); // Annee bissextile ? if (($annee%4 == 0 && $annee%100 != 0) || $annee%400 == 0){ $max_des_mois[2] = 29; } $jour_now = intval(date('d')); $mois_now = intval(date('m')); $annee_now = intval(date('Y')); $aujourdhui = $jour_now.' '.$nom_mois[$mois_now].' '.$annee_now; $rc = "\n"; $s = ''; $s .= $rc.'
'; $s .= $rc; return $s; }