本文整理汇总了PHP中format_base::is_section_current方法的典型用法代码示例。如果您正苦于以下问题:PHP format_base::is_section_current方法的具体用法?PHP format_base::is_section_current怎么用?PHP format_base::is_section_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format_base
的用法示例。
在下文中一共展示了format_base::is_section_current方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_section_current
/**
* Is the section passed in the current section?
*
* @param stdClass $section The course_section entry from the DB
* @return bool true if the section is current
*/
public function is_section_current($section)
{
$tcsettings = $this->get_settings();
if ($tcsettings['layoutstructure'] == 2 || $tcsettings['layoutstructure'] == 3) {
if ($section->section < 1) {
return false;
}
$timenow = time();
$dates = $this->format_collblct_get_section_dates($section, $this->get_course());
return $timenow >= $dates->start && $timenow < $dates->end;
} else {
if ($tcsettings['layoutstructure'] == 5) {
if ($section->section < 1) {
return false;
}
$timenow = time();
$day = $this->format_collblct_get_section_day($section, $this->get_course());
$onedayseconds = 86400;
return $timenow >= $day && $timenow < $day + $onedayseconds;
} else {
return parent::is_section_current($section);
}
}
}
示例2: is_section_current
/**
* Is the section passed in the current section?
*
* @param stdClass $section The course_section entry from the DB
* @return bool true if the section is current
*/
public function is_section_current($section) {
$tcsettings = $this->get_settings();
if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3)) {
if ($section->section < 1) {
return false;
}
$timenow = time();
$dates = $this->format_topcoll_get_section_dates($section, $this->get_course());
return (($timenow >= $dates->start) && ($timenow < $dates->end));
} else if ($tcsettings['layoutstructure'] == 5) {
if ($section->section < 1) {
return false;
}
$timenow = time();
$day = $this->format_topcoll_get_section_day($section, $this->get_course());
$onedayseconds = 86400;
return (($timenow >= $day) && ($timenow < ($day + $onedayseconds)));
} else {
return parent::is_section_current($section);
}
}
示例3: set_chapters
protected function set_chapters()
{
$this->chapters = (object) [];
$this->chapters->listlarge = $this->course->numsections > 9 ? 'list-large' : '';
$this->chapters->chapters = [];
$canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($this->course->id));
$modinfo = get_fast_modinfo($this->course);
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
if ($section > $this->course->numsections) {
continue;
}
// Students - If course hidden sections completely invisible & section is hidden, and you cannot
// see hidden things, bale out.
if ($this->course->hiddensections && !$thissection->visible && !$canviewhidden) {
continue;
}
$conditional = $this->is_section_conditional($thissection);
$chapter = new course_toc_chapter();
$chapter->outputlink = true;
if ($canviewhidden) {
// Teachers.
if ($conditional) {
$chapter->availabilityclass = 'text-danger';
$chapter->availabilitystatus = get_string('conditional', 'theme_snap');
}
if (!$thissection->visible) {
$chapter->availabilityclass = 'text-warning';
$chapter->availabilitystatus = get_string('notpublished', 'theme_snap');
}
} else {
// Students.
if ($conditional && !$thissection->uservisible && !$thissection->availableinfo) {
// Conditional section, totally hidden from user so skip.
continue;
}
if ($conditional && $thissection->availableinfo) {
$chapter->availabilityclass = 'text-danger';
$chapter->availabilitystatus = get_string('conditional', 'theme_snap');
}
if (!$conditional && !$thissection->visible) {
// Hidden section collapsed, so show as text in TOC.
$chapter->outputlink = false;
$chapter->availabilityclass = 'text-warning';
$chapter->availabilitystatus = get_string('notavailable');
}
}
$chapter->title = get_section_name($this->course, $section);
if ($chapter->title == get_string('general')) {
$chapter->title = get_string('introduction', 'theme_snap');
}
if ($this->format->is_section_current($section)) {
$chapter->iscurrent = true;
}
if ($chapter->outputlink) {
$singlepage = $this->course->format !== 'folderview';
if ($singlepage) {
$chapter->url = '#section-' . $section;
} else {
if ($section > 0) {
$chapter->url = course_get_url($this->course, $section, ['navigation' => true, 'sr' => $section]);
} else {
// We need to create the url for section 0, or a hash will get returned.
$chapter->url = new moodle_url('/course/view.php', ['id' => $this->course->id, 'section' => $section]);
}
}
}
$chapter->progress = new course_toc_progress($this->course, $thissection);
$this->chapters->chapters[] = $chapter;
}
}