public function parse_template()
{
$this->replacements = $this->default_template();
if (empty($this->template)) {
return $this;
}
if (is_string($this->template)) {
$today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val) {
if (preg_match('/\\{' . $val . '\\}(.*?)\\{\\/' . $val . '\\}/si', $this->template, $match)) {
$this->replacements[$val] = $match[1];
} elseif (in_array($val, $today, TRUE)) {
$this->replacements[$val] = $this->replacements[substr($val, 0, -6)];
}
}
} elseif (is_array($this->template)) {
$this->replacements = array_merge($this->replacements, $this->template);
}
return $this;
}