Difference between revisions of "Calendar.php"

From Organic Design wiki
m
m
Line 2: Line 2:
  
 
function month( $m, $y ) {
 
function month( $m, $y ) {
$c = ' align=center';
+
$c = '';
 
if ( !$d = date( 'w', $ts = mktime( 0, 0, 0, $m, 1, $y) ) ) $d = 7;
 
if ( !$d = date( 'w', $ts = mktime( 0, 0, 0, $m, 1, $y) ) ) $d = 7;
 
$month = date( 'F', $ts );
 
$month = date( 'F', $ts );
 
$article = "<table border=0><tr><th colspan=7$c><h2>$month</h2>\n<tr>";
 
$article = "<table border=0><tr><th colspan=7$c><h2>$month</h2>\n<tr>";
$article .= "<th$c>Mon<th$c>Tue<th$c>Wed<th$c>Thu<th$c>Fri<th$c>Sat<th$c>Sun\n";
+
$article .= "<th$c>M<th$c>T<th$c>W<th$c>T<th$c>F<th$c>S<th$c>S\n";
 
if ( $d > 1 ) $article .= '<tr>'.str_repeat( '<td>', $d-1 );
 
if ( $d > 1 ) $article .= '<tr>'.str_repeat( '<td>', $d-1 );
 
for ( $i = $d; $i < 39; $i++ ) {
 
for ( $i = $d; $i < 39; $i++ ) {
Line 26: Line 26:
 
$article .= "\n<tr>";
 
$article .= "\n<tr>";
 
for ( $cols = 0; $cols < 4; $cols++ )
 
for ( $cols = 0; $cols < 4; $cols++ )
$article .= "\n<td align=top style='border:groove 2px #eeeeee'>".month( $m++, $y );
+
$article .= "\n<td valign=top style='border:groove 2px #eeeeee'>".month( $m++, $y );
  
 
       }
 
       }
 
$article .= '</table>';
 
$article .= '</table>';
 
?>
 
?>

Revision as of 02:58, 7 March 2006

<?

function month( $m, $y ) { $c = ; if ( !$d = date( 'w', $ts = mktime( 0, 0, 0, $m, 1, $y) ) ) $d = 7; $month = date( 'F', $ts );

$article = "

";

$article .= "<th$c>M<th$c>T<th$c>W<th$c>T<th$c>F<th$c>S<th$c>S\n";

if ( $d > 1 ) $article .= ''.str_repeat( '"; $article .= "<td$c>$day"; } } $article .= "\n

$month

\n
', $d-1 );

for ( $i = $d; $i < 39; $i++ ) { $day = $i - $d + 1; $day = $day < 10 ? "0$day" : $day; if ( checkdate( $m, $day, $y ) ) {

if ( $i%7 == 1 ) $article .= "\n

";

return $article; }

$article = "

"; for ( $cols = 0; $cols < 4; $cols++ ) $article .= "\n
\n";

$m = 1; $y = date( 'Y' ); for ( $rows = 0; $rows < 3; $rows++ ) {

$article .= "\n
".month( $m++, $y );
      }
$article .= '

';

?>