Modelo (mycal_model.php)
Código PHP:
<?php
class Mycal_model extends CI_Model
{
var $conf;
function Mycal_model()
{
parent::__construct();
$conf = array(
'start_day' => 'monday',
'show_next_prev' => true,
'next_prev_url' => base_url() . 'mycal/display'
);
$this->conf['template'] = '
{table_open}<table border="0" cellpadding="0" cellspacing="0" class="calendar">{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><<</a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">>></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr>{/cal_row_start}
{cal_cell_start}<td>{/cal_cell_start}
{cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content}
{cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today}
{cal_cell_no_content}{day}{/cal_cell_no_content}
{cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}
{cal_cell_blank} {/cal_cell_blank}
{cal_cell_end}</td>{/cal_cell_end}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}
';
}
function generate ($year, $month)
{
$this->load->library('calendar', $this->conf);
$cal_data = array(
15 => 'foo',
17 => 'bar'
);
return $this->calendar->generate($year, $month, $cal_data);
}
}
?>
Código PHP:
<?php
class Mycal extends CI_Controller
{
function display($year = null, $month = null)
{
$this->load->model('Mycal_model');
$data['calendar'] = $this->Mycal_model->generate($year, $month);
$this->load->view('mycal', $data);
}
}
?>
Código PHP:
<!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=utf-8" />
<title>My Calendar</title>
<style type="text/css">
.calendar
{
font-family: Arial;
font-size: 12px;
}
table.calendar
{
margin: auto;
border-collapse: collapse;
}
</style>
</head>
<body>
<?php echo $calendar; ?>
</body>
</html>