當前位置: 首頁>>代碼示例>>PHP>>正文


PHP format_base::get_view_url方法代碼示例

本文整理匯總了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;
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:67,代碼來源:formatlegacy.php


注:本文中的format_base::get_view_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。