- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在许多项目中都使用了CodeIgniter,因此我决定在Jquery Calendar上使用Calendaring类来显示每月的预订。我已经设置好并显示数据FINE。
这是事实,我不需要周末,那里占用了我的网页上宝贵的空间。我在网上进行了研究,有人解释说您可以在$ prefs数组中使用该模板。
我认为这与模板解析器类有关,但是我无法理解。
如果可以给我链接,帮助或示例,将不胜感激。
最佳答案
希望这就是您想要的。
请将MY_Calendar.php复制到您的库目录,然后在您的 Controller 中粘贴以下代码:
//controller
$prefs['start_day'] = 'monday';
$this->load->library('calendar',$prefs);
echo $this->calendar->generate_weekdays();
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Calendar extends CI_Calendar
{
public function __construct($config = array())
{
parent::__construct($config);
}
public function generate_weekdays($year = '', $month = '', $data = array())
{
// Set and validate the supplied month/year
if ($year == '')
$year = date("Y", $this->local_time);
if ($month == '')
$month = date("m", $this->local_time);
if (strlen($year) == 1)
$year = '200'.$year;
if (strlen($year) == 2)
$year = '20'.$year;
if (strlen($month) == 1)
$month = '0'.$month;
$adjusted_date = $this->adjust_date($month, $year);
$month = $adjusted_date['month'];
$year = $adjusted_date['year'];
// Determine the total days in the month
$total_days = $this->get_total_days($month, $year);
// Set the starting day of the week
$start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
$start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
// Set the starting day number
$local_date = mktime(12, 0, 0, $month, 1, $year);
$date = getdate($local_date);
$day = $start_day + 1 - $date["wday"];
while ($day > 1)
{
$day -= 7;
}
// Set the current month/year/day
// We use this to determine the "today" date
$cur_year = date("Y", $this->local_time);
$cur_month = date("m", $this->local_time);
$cur_day = date("j", $this->local_time);
$is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
// Generate the template data array
$this->parse_template();
// Begin building the calendar output
$out = $this->temp['table_open'];
$out .= "\n";
$out .= "\n";
$out .= $this->temp['heading_row_start'];
$out .= "\n";
// "previous" month link
if ($this->show_next_prev == TRUE)
{
// Add a trailing slash to the URL if needed
$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
$adjusted_date = $this->adjust_date($month - 1, $year);
$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
$out .= "\n";
}
// Heading containing the month/year
$colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
$this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
$this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)." ".$year, $this->temp['heading_title_cell']);
$out .= $this->temp['heading_title_cell'];
$out .= "\n";
// "next" month link
if ($this->show_next_prev == TRUE)
{
$adjusted_date = $this->adjust_date($month + 1, $year);
$out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
}
$out .= "\n";
$out .= $this->temp['heading_row_end'];
$out .= "\n";
// Write the cells containing the days of the week
$out .= "\n";
$out .= $this->temp['week_row_start'];
$out .= "\n";
$day_names = $this->get_day_names();
for ($i = 0; $i < 5; $i ++)
{
$out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
}
$out .= "\n";
$out .= $this->temp['week_row_end'];
$out .= "\n";
// Build the main body of the calendar
while ($day <= $total_days)
{
$out .= "\n";
$out .= $this->temp['cal_row_start'];
$out .= "\n";
for ($i = 0; $i < 7; $i++)
{
if($i!=5 && $i!=6)
{
$out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
if ($day > 0 AND $day <= $total_days)
{
if (isset($data[$day]))
{
// Cells with content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
}
else
{
// Cells with no content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
}
else
{
// Blank cells
$out .= $this->temp['cal_cell_blank'];
}
$out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
}
$day++;
}
$out .= "\n";
$out .= $this->temp['cal_row_end'];
$out .= "\n";
}
$out .= "\n";
$out .= $this->temp['table_close'];
return $out;
}
}
/* End of file MY_Calendar.php */
关于codeigniter - CodeIgniter日历类删除周末,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10282173/
有人可以帮我解决这个问题吗?当填写周五、周六或周日时,需要返回"is",而在所有其他情况下,则需要返回“否”。每次它都以“JA”结尾...... 代码: // Nieuwe Array aan
我知道,标题并不具体,但我对 DatePicker 有疑问。我尝试禁用国庆节、周末和今天之后的 48 小时。目前我这样做了: 隐藏今天 + 48 小时,我使用 minDate: 3 隐藏周末 隐藏国庆
我必须计算以下两个日期之间的周末计数和假期计数。 var startDate = new Date("01/02/2014"); var endDate = new Date("02/
我正在尝试编写一个脚本来实现以下目的: 我需要根据一天中的时间和星期几将我页面上某个元素的颜色从绿色更改为红色。因此,例如,在星期六我需要一个不同于星期一的时间窗口。 我正在努力寻找有用的东西。我找到
给定 postgres 中的 2 个时间戳,你如何在不计算整个星期六和星期日的情况下计算时差? 或 如何计算给定时间间隔内的周六和周日的数量? 最佳答案 以下函数返回两个日期之间的完整周末天数。由于您
我无法在没有周末的情况下呈现日期时间图表。怎么做到的? 这是示例代码 ( http://jsfiddle.net/LLExL/1720/ ): $('#container').highcharts({
ax.plot_date((dates, dates), (highs, lows), '-') 我目前正在使用此命令通过 Matplotlib 绘制财务高点和低点.效果很好,但如何删除 x 轴上因没
从今天早上开始,我无法使用原始 HTTP 协议(protocol)在用户对象上设置 orgUnitPath。 PATCH /admin/directory/v1/users/testuser_1440
我有这些 Dag DAG_A(每天运行)、DAG_B(周一至周五运行)和 DAG_C(周六和周日运行),其中 DAG_A 依赖于 DAG_B 和 DAG_C。我尝试使用 External Task S
我正在使用 JQuery UI Datepicker Disbale Next Day After 12pm 中的代码禁用周末、公共(public)假期和第二天(如果在上午 10 点之后选择),但我不
我是一名优秀的程序员,十分优秀!