====Calendar Code Formatter==== >>==See Also== ~- [[OnegWRNoDefaultCodeClass | NoDefaultCodeClass]] >> ==What== ~- Uses the CODE formatting feature to generate a calendar ~- The 'code' includes date / schedule information ~- Includes formatter and CSS code. ==Installation== ~- You MUST apply the [[OnegWRNoDefaultCodeClass | NoDefaultCodeClass]] workaround first. This will prevent the //code// class from being applied prior to your formatter being run. ~- install the following in ##formatters/cal.php## ~- splice in the CSS code ==Usage== ~- You only need to enter dates you wish to 'mark' with text (//Appointments, etc//) ~- All lines begin with the day number, a semicolon ';' then the text you want in that date ~- If directly following the ';' you include //%classname%//, that class will be applied to the **** date cell ~- Current 'classes' ~~- holiday - //Marks the day number in red// ~~- green - //Makes the day cell with green background// ~~- red - //Makes the day cell with red background// ~~- blue - //you guessed it..// ~~- high - //Highlight the cell (currently green)// ~- Can combine classes //(ex: 'blue holiday')// **Example** ""%%(cal)"" Jan 2008 1;%holiday% New Years 15;Joes Birthday ""%%"" //Note: The %holiday% will not display but will apply the 'holiday' class to the table cell for Jan 1// File: **formatters/cal.php** %%(php) $csv_line){ if(preg_match("/^#|^\s*$/",$csv_line)) continue; if($cal_firstline == 0) { preg_match("/^([^;]*);*(.*)/",$csv_line,$matches); // Make it the 1st of the month $cal_month = '1 ' . $matches[1]; // Get timestamp for 1st of month. Then extract values $cal_date = strtotime($cal_month); // Convert to 1st of month $cal_start = strftime("%w",$cal_date); // Calculate end of month (1st of month +1 month -1 day) = End of month = Number of days in month $cal_eom = $cal_month . ' +1 month -1 day'; $cal_date = strtotime($cal_eom); $cal_days = strftime("%d",$cal_date); $cal_firstline=1; // Fill up cal_day array with full month of data for($day=1;$day <= $cal_days;$day++) { $cal_data[$day] = ' '; } continue; } $wrk = $csv_line; while ($m = preg_match('/^([0-9]+);(.*)/',$wrk,$matches)) { $cal_day = $matches[1]; $wrk = $matches[2]; $cal_data[$cal_day] = $wrk; } } echo ""; echo ""; echo "\n"; // Create a COLSPAN until the 1st day of month if(!$cal_start) { echo ""; $dow = 0; } else { echo ""; $dow = $cal_start; } // Dump out the calendar foreach($cal_data as $c_day=>$c_data) { $c_class = ''; if(preg_match('/^%([^%]+)%(.*)/',$c_data,$matches)) { $c_class = $matches[1]; $c_data = $matches[2]; } if($dow == 7) { echo "\n"; $dow=0; echo "'; $dow++; } // Colspan for rest of week if($dow<7) { echo ""; } echo "
SunMonTueWedThuFriSat
 
" . $c_day . ' '; } else { echo "" . $c_day . ' '; } echo $this->format($c_data); echo ' 
\n"; ?> %% It also requires a small addition to your CSS file %%(css) /* Calendar Table */ table.cal { padding: 0 0 0 0; border: 1px solid #888; width: 99%; text-align: left; color: black; background-color: #FFF; border-collapse: collapse; } .cal tr.head { background-color: #FFFFCF; font: 10pt sans-serif; color: blue; border-bottom: 1px dotted #888; vertical-align: top; } .cal tr { background-color: #F9FFFF; border-bottom: 1px dotted #888; vertical-align: top; } .cal th { padding: 4px 0 8px 4px; border-bottom: 1px solid #000; text-align: center; } .cal td { font: 9pt sans-serif; vertical-align: top; border-bottom: 1px dotted #888; border-right: 1px dotted #888; padding: 4px 0 2px 8px; height: 90px; } .cal td.dim { background-color: #EEE; } .cal td.green,.high { background-color: #ccffcc; } .cal td.red { background-color: #FDE3E3; } .cal td.holiday { xbackground-color: #F8F8F8; } .cal td.blue { background-color: #DFDFFD; } .cal td a { color: blue; } .cal td span.day { font-weight: bold; } .cal td.holiday span.day { font-weight: bold; color: red; } .cal td span.sun { font-weight: bold; color: red; } %% ---- CategoryUserContributions