Skip to content

Commit

Permalink
Code formatting, and different HTML for the calendar view.
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed May 5, 2010
1 parent 389442d commit b5e9584
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 41 deletions.
19 changes: 10 additions & 9 deletions usage-example.php
@@ -1,20 +1,21 @@
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Calendar extends Controller {

class Controller_Calendar extends Controller
{

public function action_index()
{
$calendar = new Calendar(Arr::get($_GET, 'month', date('m')), Arr::get($_GET, 'year', date('Y')));
$calendar->attach(
$calendar ->event()
->condition('timestamp', time())
->output(html::anchor('http://google.de', 'google'))
);
$calendar->event()
->condition('timestamp', time())
->output(html::anchor('http://google.de', 'google'))
);

$data = array(
'content' => $calendar->render(),
'content' => $calendar->render()
);

$this->request->response = new View('index', $data);
}
}
78 changes: 46 additions & 32 deletions views/calendar.php
Expand Up @@ -15,39 +15,53 @@
$path_info = Arr::get($_SERVER, 'PATH_INFO');
$prev = $path_info.URL::query(array_merge($qs, array('month' => date('n', $prev), 'year' => date('Y', $prev))));
$next = $path_info.URL::query(array_merge($qs, array('month' => date('n', $next), 'year' => date('Y', $next))));

?>
<div class="controls">
<span class="prev"><?php echo html::anchor($prev, '&laquo;') ?></span>
<span class="title"><?php echo strftime('%B %Y', mktime(0, 0, 0, $month, 1, $year)) ?></span>
<span class="next"><?php echo html::anchor($next, '&raquo;') ?></span>
</div>

<table class="calendar">
<tr>
<?php foreach ($days as $weekday_name): ?>
<th><?php echo $weekday_name ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($weeks as $week): ?>
<tr>
<?php foreach ($week as $day):

list ($number, $current, $data) = $day;

if (is_array($data))
{
$classes = $data['classes'];
$output = empty($data['output']) ? '' : '<ul class="output"><li>'.implode('</li><li>', $data['output']).'</li></ul>';
}
else
{
$classes = array();
$output = '';
}
<caption>
<span class="prev"><?php echo html::anchor($prev, '&larr;') ?></span>
<span class="title"><?php echo strftime('%B %Y', mktime(0, 0, 0, $month, 1, $year)) ?></span>
<span class="next"><?php echo html::anchor($next, '&rarr;') ?></span>
</caption>
<thead>
<tr>
<?php foreach ($days as $weekday_name): ?>
<th><?php echo $weekday_name ?></th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php foreach ($weeks as $week): ?>
<tr>
<?php foreach ($week as $day):

?>
<td class="<?php echo implode(' ', $classes) ?>"><span class="day"><?php echo $day[0] ?></span><?php echo $output ?></td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
list($number, $current, $data) = $day;

if (is_array($data))
{
$classes = $data['classes'];
$output = '';
if (!empty($data['output']))
{
$output = '<ul class="output"><li>'
.implode('</li><li>', $data['output'])
.'</li></ul>';
}
}
else
{
$classes = array();
$output = '';
}

?>
<td class="<?php echo implode(' ', $classes) ?>">
<span class="day"><?php echo $day[0] ?></span>
<?php echo $output ?>
</td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</tbody>
</table>

0 comments on commit b5e9584

Please sign in to comment.