本文整理汇总了PHP中format_base::get_view_url方法的典型用法代码示例。如果您正苦于以下问题:PHP format_base::get_view_url方法的具体用法?PHP format_base::get_view_url怎么用?PHP format_base::get_view_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format_base
的用法示例。
在下文中一共展示了format_base::get_view_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_view_url
/**
* The URL to use for the specified course (with section)
*
* This function calls function callback_FORMATNAME_get_section_url() if it exists
*
* @param int|stdClass $section Section object from database or just field course_sections.section
* if omitted the course view page is returned
* @param array $options options for view URL. At the moment core uses:
* 'navigation' (bool) if true and section has no separate page, the function returns null
* 'sr' (int) used by multipage formats to specify to which section to return
* @return null|moodle_url
*/
public function get_view_url($section, $options = array())
{
// Use course formatter callback if it exists
$featurefunction = 'callback_' . $this->format . '_get_section_url';
if (function_exists($featurefunction) && ($course = $this->get_course())) {
if (is_object($section)) {
$sectionnum = $section->section;
} else {
$sectionnum = $section;
}
if ($sectionnum) {
$url = $featurefunction($course, $sectionnum);
if ($url || !empty($options['navigation'])) {
return $url;
}
}
}
// if function is not defined
if (!$this->uses_sections() || !array_key_exists('coursedisplay', $this->course_format_options())) {
// default behaviour
return parent::get_view_url($section, $options);
}
$course = $this->get_course();
$url = new moodle_url('/course/view.php', array('id' => $course->id));
$sr = null;
if (array_key_exists('sr', $options)) {
$sr = $options['sr'];
}
if (is_object($section)) {
$sectionno = $section->section;
} else {
$sectionno = $section;
}
if ($sectionno !== null) {
if ($sr !== null) {
if ($sr) {
$usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
$sectionno = $sr;
} else {
$usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
}
} else {
$usercoursedisplay = $course->coursedisplay;
}
if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$url->param('section', $sectionno);
} else {
if (!empty($options['navigation'])) {
return null;
}
$url->set_anchor('section-' . $sectionno);
}
}
return $url;
}