Abbi pazienza....
questa è la function che genera il calendario nel mio blog..... verifica che ci siano dei post inseriti... nel caso positivo, il giorno in cui è presente il post lo rende linkabile
Codice PHP:
function build_calendar($year="",$month="") {
global $theme;
// validate data
if ($month==""){
// if we have no month, make it THIS month
$month = date("n");
}
if ($year==""){
// if we have no year, make it THIS year
$year = date("Y");
}
global $monthnames_long;
global $monthnames_short;
global $daynames_long;
global $daynames_short;
// fill an array with number of entries per day for hilighting purposes
$con = db_connect();
$sql = db_sql_calendar_counts($year,$month);
$result = mysql_query($sql,$con);
if ($result!=false){
while($row =@ mysql_fetch_array($result)){
$calendar_counts[$row["nDay"]] = $row["nCount"];
}
} else {
report_problem(1,"<b>build_calendar</b>\n\n".mysql_error()."\n\n".$sql);
}
define ('ADAY', (60*60*24));
// make arrays of values representing the first of the month
$datearray = getdate(mktime(0,0,0,$month,1,$year));
$start = mktime(0,0,0,$month,1,$year);
$firstdayarray = getdate($start);
// work out the URLs for previous and next buttons
// default
$prev_month = $month - 1;
$prev_year = $year;
$next_month = $month + 1;
$next_year = $year;
// handle exceptions
// end of year
if ($month==12) {
$prev_month = $month - 1;
$prev_year = $year;
$next_month = 1;
$next_year = $year + 1;
}
// start of year
if ($month==1) {
$prev_month = 12;
$prev_year = $year - 1;
$next_month = $month + 1;
$next_year = $year;
}
$url_next = $_SERVER["PHP_SELF"]."?month=".$next_month."&year=".$next_year;
$url_prev = $_SERVER["PHP_SELF"]."?month=".$prev_month."&year=".$prev_year;
// get template for entire calendar area
$html = theme_calendar_section();
// do the replacements
$html = str_replace("<!--month_previous_url-->",$url_prev,$html);
$html = str_replace("<!--month_current_url-->","index.php?year=".$year."&month=".$month,$html);
$html = str_replace("<!--month_next_url-->",$url_next,$html);
$html = str_replace("<!--monthname_long-->",$monthnames_long[$datearray["mon"]-1],$html);
$html = str_replace("<!--year-->",$year,$html);
// get templates for various squares
$t_day_heading = theme_calendar_day_heading();
$t_day_empty = theme_calendar_day_empty();
$t_day_on = theme_calendar_day_on();
$t_day_off = theme_calendar_day_off();
$t_day_today = theme_calendar_day_today();
$t_calendar_sep = theme_calendar_row_seperator();
foreach($daynames_short as $day)
{
$day_heading = $t_day_heading;
$day_heading = str_replace("<!--day_heading-->",$day,$day_heading);
$day_headings .= $day_heading;
}
$html = str_replace("<!--day_headings-->",$day_headings,$html);
// Create the rows of days
for ($count=1;$count<(6*7+1);$count++){
$dayarray = getdate($start);
// new rows on mondays
if((($count) % 7) == 1) {
if($dayarray["mon"] != $datearray["mon"]) break;
$html_days .= $t_calendar_sep;
}
if ($firstdayarray["wday"]==0) {
$firstday = 7;
} else {
$firstday = $firstdayarray["wday"];
}
if($count < $firstday || $dayarray['mon'] != $month) {
$html_days .= $t_day_empty;
} else {
// build the html for a day within the calendar
$date_url = "index.php?year=".$dayarray["year"]."&month=".$dayarray["mon"]."&day=".$dayarray["mday"];
$today = getdate();
// work out if the current day is today
if ( ($today["year"] == $dayarray["year"]) && ($today["mon"] == $dayarray["mon"]) && ($today["mday"] == $dayarray["mday"]) ){
$html_day = $t_day_today;
$html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray["mday"]."</a>",$html_day);
} else {
if ($calendar_counts[$dayarray["mday"]]>0){
$html_day = $t_day_on;
$html_day = str_replace("<!--day-->","<a class='calendar_link' href='".$date_url."'>".$dayarray["mday"]."</a>",$html_day);
} else {
$html_day = $t_day_off;
$html_day = str_replace("<!--day-->",$dayarray["mday"],$html_day);
}
}
$html_days .= $html_day;
$start += ADAY;
// check that day has moved on (to solve the daylight savings problem)
$testday = getdate($start);
if ($testday["yday"]==$dayarray["yday"]){
$start += (ADAY/2);
}
}
}
// put the days into the calendar
$html = str_replace("<!--calendar_days-->",$html_days,$html);
db_disconnect($con);
return $html;
}
la riga incriminata inizia dopo l'etichetta // work out if the current day is today
studio da autodidatta php da un paio di anni e le lacune sono tante...... tanto che a me sembra tutto in ordine...... intanto mi dice sempre
Notice: Undefined offset: 1 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 2 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 3 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 4 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 5 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 6 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 7 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 8 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 9 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 10 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 11 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 12 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 14 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 16 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 18 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 19 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 20 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 21 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 22 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 23 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 24 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 25 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 26 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 27 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 28 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 29 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 30 in C:\www\blog\lib\html.php on line 171
Notice: Undefined offset: 31 in C:\www\blog\lib\html.php on line 171