状态 第一次草稿
Todo Expand on Start-of-week-day, add all methods
官方最后更新时间 2008/08/13 08:12

日历库(Calendar Library)

概述

为通用工作生成日历。这个类的输出格式为 HTML 格式,使用系统视图: system/views/kohana_calendar.php

加载日历类

在控制器中使用下面的方法加载:

$this->calendar = new Calendar();

通过 $this→calendar 激活日历类

参数的构造:

  • [integer] 月份
  • [integer] 年份
  • [boolean] 如果你认为一周开始的一天是星期一那么设置为 TRUE(取决于你的定位)

实例

$cal = new Calendar(1,2008); // 一月,2008. 默认当前的月份和年份
echo $cal->render(); // 从类中自动呈现日历

调整日历

通过创建文件:application/views/kohana_calendar.php 可以调整日历的布局。原始 Kohana 的日历文件存放在:system/views/kohana_calendar.php

添加事件到日历上

Kohana 日历运行添加事件。 实例

$calendar = new Calendar();
$calendar -> attach($calendar -> event() -> condition('year', '2008') -> condition('month', '5') -> condition('day', '23')  -> output(html::anchor('http://kohanaphp.com', 'Click here!')));
$calendar -> render();

条件语法

function condition($key, $value)
  • @chainable
  • @param string condition key
  • @param mixed condition value
  • @return object

条件列表

  • timestamp - UNIX 时间戳
  • day - 天数(1-31)
  • week - 周数(1-5)
  • month - 月份数(1-12)
  • year - 年份数(4 位)
  • day_of_week - 一周的天数(1-7)
  • current - 当前的月份(boolean) (only show data for the month being rendered)
  • weekend - 周末 (boolean)
  • first_day - 月份开始的一天 (boolean)
  • last_day - 月份的最后一天 (boolean)
  • occurrence - occurrence of the week day (1-5) (使用 “day_of_week”)
  • last_occurrence - last occurrence of week day (boolean) (use with “day_of_week”)
  • easter - 复活节 (boolean)
  • callback - 回调测试 (boolean)
libraries/calendar.txt · 最后更改: 2008/09/23 23:56 由 icyleaf