Esempio n. 1
0
 /**
  * Generate the edit control items of a section
  *
  * @param stdClass $course The course entry from DB
  * @param stdClass $section The course_section entry from DB
  * @param bool $onsectionpage true if being printed on a section page
  * @return array of edit control items
  */
 protected function section_edit_control_items($course, $section, $onsectionpage = false)
 {
     global $PAGE;
     if (!$PAGE->user_is_editing()) {
         return array();
     }
     $coursecontext = context_course::instance($course->id);
     if ($onsectionpage) {
         $url = course_get_url($course, $section->section);
     } else {
         $url = course_get_url($course);
     }
     $url->param('sesskey', sesskey());
     $isstealth = $section->section > $course->numsections;
     $controls = array();
     if (!$isstealth && $section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
         if ($course->marker == $section->section) {
             // Show the "light globe" on/off.
             $url->param('marker', 0);
             $markedthistopic = get_string('markedthistopic');
             $highlightoff = get_string('highlightoff');
             $controls['highlight'] = array('url' => $url, "icon" => 'i/marked', 'name' => $highlightoff, 'pixattr' => array('class' => '', 'alt' => $markedthistopic), 'attr' => array('class' => 'editing_highlight', 'title' => $markedthistopic));
         } else {
             $url->param('marker', $section->section);
             $markthistopic = get_string('markthistopic');
             $highlight = get_string('highlight');
             $controls['highlight'] = array('url' => $url, "icon" => 'i/marker', 'name' => $highlight, 'pixattr' => array('class' => '', 'alt' => $markthistopic), 'attr' => array('class' => 'editing_highlight', 'title' => $markthistopic));
         }
     }
     $parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage);
     // If the edit key exists, we are going to insert our controls after it.
     if (array_key_exists("edit", $parentcontrols)) {
         $merged = array();
         // We can't use splice because we are using associative arrays.
         // Step through the array and merge the arrays.
         foreach ($parentcontrols as $key => $action) {
             $merged[$key] = $action;
             if ($key == "edit") {
                 // If we have come to the edit key, merge these controls here.
                 $merged = array_merge($merged, $controls);
             }
         }
         return $merged;
     } else {
         return array_merge($controls, $parentcontrols);
     }
 }
Esempio n. 2
0
 /**
  * Generate the edit control items of a section
  *
  * @param stdClass $course The course entry from DB
  * @param stdClass $section The course_section entry from DB
  * @param bool $onsectionpage true if being printed on a section page
  * @return array of edit control items
  */
 protected function section_edit_control_items($course, $section, $onsectionpage = false)
 {
     global $PAGE;
     if (!$PAGE->user_is_editing()) {
         return array();
     }
     $coursecontext = context_course::instance($course->id);
     if ($onsectionpage) {
         $url = course_get_url($course, $section->section);
     } else {
         $url = course_get_url($course);
     }
     $url->param('sesskey', sesskey());
     $isstealth = $section->section > $course->numsections;
     $controls = array();
     if (!$isstealth && $section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
         if ($course->marker == $section->section) {
             // Show the "light globe" on/off.
             $url->param('marker', 0);
             $markedthistopic = get_string('markedthistopic');
             $highlightoff = get_string('highlightoff');
             $controls[] = array("url" => $url, "icon" => 'i/marked', "name" => $highlightoff, 'pixattr' => array('class' => '', 'alt' => $markedthistopic), "attr" => array('class' => 'editing_highlight', 'title' => $markedthistopic));
         } else {
             $url->param('marker', $section->section);
             $markthistopic = get_string('markthistopic');
             $highlight = get_string('highlight');
             $controls[] = array("url" => $url, "icon" => 'i/marker', "name" => $highlight, 'pixattr' => array('class' => '', 'alt' => $markthistopic), "attr" => array('class' => 'editing_highlight', 'title' => $markthistopic));
         }
     }
     return array_merge($controls, parent::section_edit_control_items($course, $section, $onsectionpage));
 }
 /**
  * Generate the edit controls of a section
  *
  * @param stdClass $course The course entry from DB
  * @param stdClass $section The course_section entry from DB
  * @param bool $onsectionpage true if being printed on a section page
  * @return array of links with edit controls
  */
 protected function section_edit_controls($course, $section, $onsectionpage = false)
 {
     global $PAGE;
     if (!$PAGE->user_is_editing()) {
         return array();
     }
     $coursecontext = context_course::instance($course->id);
     if ($onsectionpage) {
         $url = course_get_url($course, $section->section);
     } else {
         $url = course_get_url($course);
     }
     $url->param('sesskey', sesskey());
     $isstealth = $section->section > $course->numsections;
     $controls = array();
     if (!$isstealth && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
         if ($course->marker == $section->section) {
             // Show the "light globe" on/off.
             $url->param('marker', 0);
             $controls['setactive']['url'] = $url;
             $controls['setactive']['icon'] = 'i/marked';
             $controls['setactive']['name'] = get_string('markedthistopic');
             $controls['setactive']['attr']['class'] = 'icon';
         } else {
             $url->param('marker', $section->section);
             $controls['setactive']['url'] = $url;
             $controls['setactive']['icon'] = 'i/marker';
             $controls['setactive']['name'] = get_string('markthistopic');
             $controls['setactive']['attr']['class'] = 'icon';
         }
     }
     return array_merge($controls, parent::section_edit_control_items($course, $section, $onsectionpage));
 }