sugarengine Posted July 13, 2008 Share Posted July 13, 2008 Hi, congrats on the site redesign, it is first class. Is there any chance of the Calendar tutorial being resurrected? Or perhaps if I could get the code/text of the tutorial? It would be greatly appreciated. Thanks Jamie Quote Link to comment https://forums.phpfreaks.com/topic/114550-any-chance-or-resurrecting-the-calendar-tutorial/ Share on other sites More sharing options...
.josh Posted July 14, 2008 Share Posted July 14, 2008 I just looked through the list of tutorials that was salvaged from the previous site and I'm sorry to say that unless Dan or Ober happens to have some previous ancient sql dump, that one was not salvaged. Only 62 tutorials were salvaged :*( Quote Link to comment https://forums.phpfreaks.com/topic/114550-any-chance-or-resurrecting-the-calendar-tutorial/#findComment-589243 Share on other sites More sharing options...
sugarengine Posted July 14, 2008 Author Share Posted July 14, 2008 That is too bad. I may actually have the code for the tutorial on a CD-ROM back up in Vancouver. I will be back there in a few days, there is a slim chance but it could be there. If it is I will send it to you. Thanks, Jamie Quote Link to comment https://forums.phpfreaks.com/topic/114550-any-chance-or-resurrecting-the-calendar-tutorial/#findComment-589315 Share on other sites More sharing options...
Daniel0 Posted July 14, 2008 Share Posted July 14, 2008 Chances are a guru, recommended member, mod or admin could write a new calender tutorial... It's likely that the calendar tutorial you are referring to is outdated anyways. Quote Link to comment https://forums.phpfreaks.com/topic/114550-any-chance-or-resurrecting-the-calendar-tutorial/#findComment-589983 Share on other sites More sharing options...
dave_sticky Posted September 16, 2008 Share Posted September 16, 2008 Hi, I was looking for the tutorial earlier, and couldn't find it either. I found some code that was originally based on the tutorial though. This has been heavily modified over a long period of time, but this one *should* be XHTML, CSS and WCAG 1.0 compliant. I don't remember if the original had more functionality than this, or less, or whatever, but I hope people find it useful anyway. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Calendar</title> <style type="text/css"> body { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 0.7em; } .day { display: block; float: left; margin: 0 2px 2px 0; border: 1px solid #666666; width: 25px; padding: 2px; height: 20px; text-align: center; line-height: 20px; } .day_out { display: block; float: left; margin: 0 2px 2px 0; border: 1px solid #EEEEEE; color: #999999; width: 25px; padding: 2px; height: 20px; text-align: center; line-height: 20px; } .day_letter { display: block; float: left; margin: 0 2px 2px 0; border: 1px solid #666666; width: 25px; padding: 2px; height: 20px; text-align: center; line-height: 20px; font-weight: bold; background: #efefef; } .month { display: block; float: left; margin: 0 2px 2px 0; border: 1px solid #666666; width: 223px; padding: 2px; height: 20px; text-align: center; line-height: 20px; background: #efefef; font-weight:bold; } .left { float: left; } .right { float: right; } .prev { float:left; text-align:left; width: 74px; padding: 0; margin: 0; } .next { float:right; text-align:right; width: 74px; padding: 0; margin: 0; } .month_name { float:left; width: 75px; padding: 0; margin: 0; } .links { display: block; float: left; margin: 0 2px 2px 0; width: 223px; padding: 2px; height: 20px; text-align: center; line-height: 20px; } </style> </head> <body> <?php // Error Reporting. On. //ini_set("display_errors","2"); //error_reporting("E_ALL"); error_reporting('0'); ini_set('display_errors', '0'); if(!isset($_GET['date'])){ $date = mktime(0,0,0,date('m'), date('d'), date('Y')); } else { $date = $_GET['date']; } $day = date('d', $date); $month = date('n', $date); $year = date('Y', $date); $month_start = mktime(0,0,0,$month, 1, $year); $month_name = date('F', $month_start); $month_start_day = date('D', $month_start); switch($month_start_day){ case "Sun": $offset = 0; break; case "Mon": $offset = 1; break; case "Tue": $offset = 2; break; case "Wed": $offset = 3; break; case "Thu": $offset = 4; break; case "Fri": $offset = 5; break; case "Sat": $offset = 6; break; } // Works for PHP 4 >= 4.0.7, PHP5 // determine how many days are in the last month. if($month == 1){ $num_days_last = cal_days_in_month(0, 12, ($year -1)); } else { $num_days_last = cal_days_in_month(0, ($month -1), $year); } // determine how many days are in the current month. $num_days_current = cal_days_in_month(0, $month, $year); // Build an array for the current days // in the month for($i = 1; $i <= $num_days_current; $i++){ $num_days_array[] = $i; } // Build an array for the number of days // in last month for($i = 1; $i <= $num_days_last; $i++){ $num_days_last_array[] = $i; } // If the $offset from the starting day of the // week happens to be Sunday, $offset would be 0, // so don't need an offset correction. if($offset > 0){ $offset_correction = array_slice($num_days_last_array, -$offset, $offset); $new_count = array_merge($offset_correction, $num_days_array); $offset_count = count($offset_correction); } // The else statement is to prevent building the $offset array. else { $offset_count = 0; $new_count = $num_days_array; } // count how many days we have with the two // previous arrays merged together $current_num = count($new_count); // Since we will have 5 HTML table rows (TR) // with 7 table data entries (TD) // we need to fill in 35 TDs // so, we will have to figure out // how many days to appened to the end // of the final array to make it 35 days. if($current_num > 35){ $num_weeks = 6; $outset = (42 - $current_num); } elseif($current_num < 35){ $num_weeks = 5; $outset = (35 - $current_num); } if($current_num == 35){ $num_weeks = 5; $outset = 0; } // Outset Correction for($i = 1; $i <= $outset; $i++){ $new_count[] = $i; } // Now let's "chunk" the $all_days array // into weeks. Each week has 7 days // so we will array_chunk it into 7 days. $weeks = array_chunk($new_count, 7); // Build Previous and Next Links $previous_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; if($month == 1){ $previous_link .= mktime(0,0,0,0,$day,($year)); } else { $previous_link .= mktime(0,0,0,($month - 1),$day,$year); } $previous_link .= "\">« Prev</a>\n"; $next_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; if($month == 12){ $next_link .= mktime(0,0,0,1,$day,($year + 1)); } else { $next_link .= mktime(0,0,0,($month + 1),$day,$year); } $next_link .= "\">Next »</a>\n"; ?> <span class="month"> <strong><?PHP echo $month_name." ".$year; ?></strong> </span> <br clear="all" /> <span class="day_letter">S</span> <span class="day_letter">M</span> <span class="day_letter">T</span> <span class="day_letter">W</span> <span class="day_letter">T</span> <span class="day_letter">F</span> <span class="day_letter">S</span> <br clear="all" /> <?PHP // Now we break each key of the array // into a week and create a new table row for each // week with the days of that week in the table data $i = 0; foreach($weeks AS $week) { foreach($week as $d) { if($i < $offset_count) { // Days BEFORE Current Month echo "<span class='day_out'>$d</span>\n"; } if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { if($date != mktime(0,0,0,$month,$d,$year)) { // Other Days in Current Month echo "<span class='day'>$d</span>\n"; } else { // Day Selected in Current Month echo "\n<span class='day'><strong>$d</strong></span>\n\n"; } } elseif ($outset > 0) { if (($i >= ($num_weeks * 7) - $outset)) { // Days AFTER Current Conth. echo "<span class='day_out'>$d</span>\n"; } } $i++; } echo "<br clear='all' />\n\n"; } ?> <span class="links"> <span class="prev"> <?PHP echo $previous_link; ?> </span> <?PHP if ($month_name != date('F') || $year != date('Y')) { echo "<span class='month_name'>\n\t<a href='index.php'>To ".date('M')." ".date('Y')."</a>\n </span>\n"; } ?> <span class="next"> <?PHP echo $next_link; ?> </span> </span> </body> </html> Ps. I know the tutorial was really good, and really detailed, but I'm at work at the moment, and don't really have time to explain all the code. Sorry! Quote Link to comment https://forums.phpfreaks.com/topic/114550-any-chance-or-resurrecting-the-calendar-tutorial/#findComment-642772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.