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


PHP moodle_page::add_body_class方法代碼示例

本文整理匯總了PHP中moodle_page::add_body_class方法的典型用法代碼示例。如果您正苦於以下問題:PHP moodle_page::add_body_class方法的具體用法?PHP moodle_page::add_body_class怎麽用?PHP moodle_page::add_body_class使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moodle_page的用法示例。


在下文中一共展示了moodle_page::add_body_class方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: page_set_course

 /**
  * Allows course format to execute code on moodle_page::set_course()
  *
  * This function is executed before the output starts.
  *
  * If everything is configured correctly, user is redirected from the
  * default course view page to the activity view page.
  *
  * "Section 1" is the administrative page to manage orphaned activities
  *
  * If user is on course view page and there is no module added to the course
  * and the user has 'moodle/course:manageactivities' capability, redirect to create module
  * form.
  *
  * @param moodle_page $page instance of page calling set_course
  */
 public function page_set_course(moodle_page $page)
 {
     global $PAGE;
     $page->add_body_class('format-' . $this->get_format());
     if ($PAGE == $page && $page->has_set_url() && $page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         $edit = optional_param('edit', -1, PARAM_BOOL);
         if (($edit == 0 || $edit == 1) && confirm_sesskey()) {
             // This is a request to turn editing mode on or off, do not redirect here, /course/view.php will do redirection.
             return;
         }
         $cm = $this->get_activity();
         $cursection = optional_param('section', null, PARAM_INT);
         if (!empty($cursection) && has_capability('moodle/course:viewhiddensections', context_course::instance($this->courseid))) {
             // Display orphaned activities (course view page, section 1).
             return;
         }
         if (!$this->get_activitytype()) {
             if (has_capability('moodle/course:update', context_course::instance($this->courseid))) {
                 // Teacher is redirected to edit course page.
                 $url = new moodle_url('/course/edit.php', array('id' => $this->courseid));
                 redirect($url, get_string('erroractivitytype', 'format_singleactivity'));
             } else {
                 // Student sees an empty course page.
                 return;
             }
         }
         if ($cm === null) {
             if ($this->can_add_activity()) {
                 // This is a user who has capability to create an activity.
                 if ($this->activity_has_subtypes()) {
                     // Activity that requires subtype can not be added automatically.
                     if (optional_param('addactivity', 0, PARAM_INT)) {
                         return;
                     } else {
                         $url = new moodle_url('/course/view.php', array('id' => $this->courseid, 'addactivity' => 1));
                         redirect($url);
                     }
                 }
                 // Redirect to the add activity form.
                 $url = new moodle_url('/course/mod.php', array('id' => $this->courseid, 'section' => 0, 'sesskey' => sesskey(), 'add' => $this->get_activitytype()));
                 redirect($url);
             } else {
                 // Student views an empty course page.
                 return;
             }
         } else {
             if (!$cm->uservisible || !$cm->get_url()) {
                 // Activity is set but not visible to current user or does not have url.
                 // Display course page (either empty or with availability restriction info).
                 return;
             } else {
                 // Everything is set up and accessible, redirect to the activity page!
                 redirect($cm->get_url());
             }
         }
     }
 }
開發者ID:tyleung,項目名稱:CMPUT401MoodleExams,代碼行數:73,代碼來源:lib.php


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