Changeset 2331 for trunk/system/views

Show
Ignore:
Timestamp:
03/24/2008 09:54:18 AM (8 months ago)
Author:
Shadowhand
Message:

Updated Calendar with observer pattern, using Event_Subject/Event_Observer

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/views/kohana_calendar.php

    r1616 r2331  
    22 
    33$first_day = mktime(1, 0, 0, $month, 1, $year); 
    4 $today = (date('Y/m') === date('Y/m', $first_day)) ? date('j') : FALSE; 
     4$today = (date('Y/m') === date('Y/m', $first_day)) ? (int) date('j') : FALSE; 
    55 
    66/** 
     
    99$headings = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); 
    1010 
    11 /** 
    12  * @todo This needs to be removed and placed in documentation. Inline styles are not allowed. 
    13  */ 
    14 ?><style type="text/css"> 
    15 table.calendar { text-align: right; } 
    16 table.calendar caption { font-size: 1.5em; padding: 0.2em; } 
    17 table.calendar th, table.calendar td { padding: 0.2em; background: #fff; border: 0; } 
    18 table.calendar td:hover { background: #ddf; } 
    19 table.calendar td.prev-next { background: #ccc; color: #999; } 
    20 table.calendar td.today { color: #800; } 
    21 </style> 
    22  
     11?> 
    2312<table class="calendar"> 
    2413<caption><?php echo strftime('%B %Y', $first_day) ?></caption> 
    2514<tr> 
    26 <?php foreach ($headings as $day): ?> 
    27 <th><?php echo $day ?></th> 
    28 <?php endforeach ?> 
    29 </tr> 
    30 <?php foreach ($weeks as $week): ?> 
    31 <tr> 
    32 <?php foreach ($week as $day): ?> 
    33 <?php if ($day[1] === FALSE): ?> 
    34 <td class="prev-next"><?php echo $day[0] ?></td> 
    35 <?php else: ?> 
    3615<?php 
    3716 
    38 if ($today > 0 AND $day[0] == $today) 
     17foreach ($headings as $day): 
     18 
     19?> 
     20<th><?php echo $day ?></th> 
     21<?php 
     22 
     23endforeach 
     24 
     25?> 
     26</tr> 
     27<?php 
     28 
     29foreach ($weeks as $week): 
     30 
     31?> 
     32<tr> 
     33<?php 
     34 
     35foreach ($week as $day): 
     36 
     37list ($number, $current, $data) = $day; 
     38 
     39if (is_array($data)) 
    3940{ 
    40         $class = ' class="today"'; 
     41        $classes = $data['classes']; 
     42        $output = empty($data['output']) ? '' : '<ul class="output"><li>'.implode('</li><li>', $data['output']).'</li></ul>'; 
    4143} 
    4244else 
    4345{ 
    44         $class = ''; 
     46        $classes = array(); 
     47        $output = ''; 
    4548} 
    46 /** 
    47  * @todo Need to add assignable stuff to this. For example, making certain dates into links. 
    48  */ 
     49 
     50if ($current === FALSE) 
     51{ 
     52        $classes[] = 'prev-next'; 
     53} 
     54elseif ($today > 0 AND $day[0] === $today) 
     55{ 
     56        $classes[] = 'today';; 
     57} 
     58 
    4959?> 
    50 <td<?php echo $class ?>><?php echo $day[0] ?></td> 
    51 <?php endif; ?> 
    52 <?php endforeach ?> 
     60<td class="<?php echo implode(' ', $classes) ?>"><span class="day"><?php echo $day[0] ?></span><?php echo $output ?></td> 
     61<?php 
     62 
     63endforeach 
     64 
     65?> 
    5366</tr> 
    54 <?php endforeach ?> 
     67<?php 
     68 
     69endforeach 
     70 
     71?> 
    5572</table>