当前位置: 首页>>代码示例>>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;未经允许,请勿转载。