protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
 {
     global $CFG;
     if (!isset($this->strings->summary)) {
         $this->strings->summary = get_string('summary');
     }
     if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $classes = trim('panel panel-default coursebox clearfix ' . $additionalclasses);
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $classes .= ' collapsed';
     }
     // Start .coursebox div.
     $content .= html_writer::start_tag('div', array('class' => $classes, 'data-courseid' => $course->id, 'data-type' => self::COURSECAT_TYPE_COURSE));
     $content .= html_writer::start_tag('div', array('class' => 'panel-heading info'));
     // Course name.
     $coursename = $chelper->get_course_formatted_name($course);
     $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
     $content .= html_writer::tag('span', $coursenamelink, array('class' => 'coursename'));
     // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
     $content .= html_writer::start_tag('span', array('class' => 'moreinfo'));
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) {
             $url = new moodle_url('/course/info.php', array('id' => $course->id));
             $image = html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/info'), 'alt' => $this->strings->summary));
             $content .= html_writer::link($url, $image, array('title' => $this->strings->summary));
             // Make sure JS file to expand course content is included.
             $this->coursecat_include_js();
         }
     }
     $content .= html_writer::end_tag('span');
     // End .moreinfo span.
     // Print enrolmenticons.
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pixicon) {
             $content .= $this->render($pixicon);
         }
         $content .= html_writer::end_tag('div');
         // End .enrolmenticons div.
     }
     $content .= html_writer::end_tag('div');
     // End .info div.
     $content .= html_writer::start_tag('div', array('class' => 'content panel-body'));
     $content .= $this->coursecat_coursebox_content($chelper, $course);
     $content .= html_writer::end_tag('div');
     // End .content div.
     $content .= html_writer::end_tag('div');
     // End .coursebox div.
     return $content;
 }
Ejemplo n.º 2
0
             if ($up) {
                 echo $OUTPUT->action_icon(new moodle_url('/course/category.php', array('id' => $category->id, 'page' => $page, 'perpage' => $perpage, 'moveup' => $acourse->id, 'sesskey' => sesskey())), new pix_icon('t/up', $strmoveup));
             }
             if ($down) {
                 echo $OUTPUT->action_icon(new moodle_url('/course/category.php', array('id' => $category->id, 'page' => $page, 'perpage' => $perpage, 'movedown' => $acourse->id, 'sesskey' => sesskey())), new pix_icon('t/down', $strmovedown));
             }
             $abletomovecourses = true;
         }
         echo '</td>';
         echo '<td align="center">';
         echo '<input type="checkbox" name="c' . $acourse->id . '" />';
         echo '</td>';
     } else {
         echo '<td align="right">';
         // print enrol info
         if ($icons = enrol_get_course_info_icons($acourse)) {
             foreach ($icons as $pix_icon) {
                 echo $OUTPUT->render($pix_icon);
             }
         }
         if (!empty($acourse->summary)) {
             $link = new moodle_url("/course/info.php?id={$acourse->id}");
             echo $OUTPUT->action_link($link, '<img alt="' . get_string('info') . '" class="icon" src="' . $OUTPUT->pix_url('i/info') . '" />', new popup_action('click', $link, 'courseinfo'), array('title' => $strsummary));
         }
         echo "</td>";
     }
     echo "</tr>";
 }
 if ($abletomovecourses) {
     $movetocategories = array();
     $notused = array();
Ejemplo n.º 3
0
/**
 * Print a description of a course, suitable for browsing in a list.
 *
 * @param object $course the course object.
 * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
 */
function print_course($course, $highlightterms = '')
{
    global $CFG, $USER, $DB, $OUTPUT;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    // Rewrite file URLs so that they are correct
    $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
    echo html_writer::start_tag('div', array('class' => 'coursebox clearfix'));
    echo html_writer::start_tag('div', array('class' => 'info'));
    echo html_writer::start_tag('h3', array('class' => 'name'));
    $linkhref = new moodle_url('/course/view.php', array('id' => $course->id));
    $coursename = get_course_display_name_for_list($course);
    $linktext = highlight($highlightterms, format_string($coursename));
    $linkparams = array('title' => get_string('entercourse'));
    if (empty($course->visible)) {
        $linkparams['class'] = 'dimmed';
    }
    echo html_writer::link($linkhref, $linktext, $linkparams);
    echo html_writer::end_tag('h3');
    /// first find all roles that are supposed to be displayed
    if (!empty($CFG->coursecontact)) {
        $managerroles = explode(',', $CFG->coursecontact);
        $namesarray = array();
        $rusers = array();
        if (!isset($course->managers)) {
            $rusers = get_role_users($managerroles, $context, true, 'ra.id AS raid, u.id, u.username, u.firstname, u.lastname,
                 r.name AS rolename, r.sortorder, r.id AS roleid', 'r.sortorder ASC, u.lastname ASC');
        } else {
            //  use the managers array if we have it for perf reasosn
            //  populate the datastructure like output of get_role_users();
            foreach ($course->managers as $manager) {
                $u = new stdClass();
                $u = $manager->user;
                $u->roleid = $manager->roleid;
                $u->rolename = $manager->rolename;
                $rusers[] = $u;
            }
        }
        /// Rename some of the role names if needed
        if (isset($context)) {
            $aliasnames = $DB->get_records('role_names', array('contextid' => $context->id), '', 'roleid,contextid,name');
        }
        $namesarray = array();
        $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
        foreach ($rusers as $ra) {
            if (isset($namesarray[$ra->id])) {
                //  only display a user once with the higest sortorder role
                continue;
            }
            if (isset($aliasnames[$ra->roleid])) {
                $ra->rolename = $aliasnames[$ra->roleid]->name;
            }
            $fullname = fullname($ra, $canviewfullnames);
            $namesarray[$ra->id] = format_string($ra->rolename) . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $ra->id, 'course' => SITEID)), $fullname);
        }
        if (!empty($namesarray)) {
            echo html_writer::start_tag('ul', array('class' => 'teachers'));
            foreach ($namesarray as $name) {
                echo html_writer::tag('li', $name);
            }
            echo html_writer::end_tag('ul');
        }
    }
    echo html_writer::end_tag('div');
    // End of info div
    echo html_writer::start_tag('div', array('class' => 'summary'));
    $options = new stdClass();
    $options->noclean = true;
    $options->para = false;
    $options->overflowdiv = true;
    if (!isset($course->summaryformat)) {
        $course->summaryformat = FORMAT_MOODLE;
    }
    echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
    if ($icons = enrol_get_course_info_icons($course)) {
        echo html_writer::start_tag('div', array('class' => 'enrolmenticons'));
        foreach ($icons as $icon) {
            echo $OUTPUT->render($icon);
        }
        echo html_writer::end_tag('div');
        // End of enrolmenticons div
    }
    echo html_writer::end_tag('div');
    // End of summary div
    echo html_writer::end_tag('div');
    // End of coursebox div
}
Ejemplo n.º 4
0
 protected function coursecat_coursebox_enrolmenticons($course)
 {
     $content = '';
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pixicon) {
             $content .= $this->render($pixicon);
         }
         $content .= html_writer::end_tag('div');
         // Enrolmenticons.
     }
     return $content;
 }
Ejemplo n.º 5
0
 /**
  * Displays one course in the list of courses.
  *
  * This is an internal function, to display an information about just one course
  * please use {@link core_course_renderer::course_info_box()}
  *
  * @param coursecat_helper $chelper various display options
  * @param course_in_list|stdClass $course
  * @param string $additionalclasses additional classes to add to the main <div> tag (usually
  *    depend on the course position in list - first/last/even/odd)
  * @return string
  */
 protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
 {
     global $CFG;
     if (!isset($this->strings->summary)) {
         $this->strings->summary = get_string('summary');
     }
     if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $classes = trim('coursebox clearfix ' . $additionalclasses);
     if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $nametag = 'h3';
     } else {
         $classes .= ' collapsed';
         $nametag = 'div';
     }
     $content .= html_writer::start_tag('div', array('class' => $classes));
     // .coursebox
     $content .= html_writer::start_tag('div', array('class' => 'info'));
     // course name
     $coursename = $chelper->get_course_formatted_name($course);
     $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
     $content .= html_writer::tag($nametag, $coursenamelink, array('class' => 'name'));
     // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
     $content .= html_writer::start_tag('div', array('class' => 'moreinfo'));
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) {
             $url = new moodle_url('/course/info.php', array('id' => $course->id));
             $image = html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/info'), 'alt' => $this->strings->summary));
             $content .= html_writer::link($url, $image, array('title' => $this->strings->summary));
         }
     }
     $content .= html_writer::end_tag('div');
     // .moreinfo
     // print enrolmenticons
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pix_icon) {
             $content .= $this->render($pix_icon);
         }
         $content .= html_writer::end_tag('div');
         // .enrolmenticons
     }
     $content .= html_writer::end_tag('div');
     // .info
     $content .= html_writer::start_tag('div', array('class' => 'content'));
     $content .= $this->coursecat_coursebox_content($chelper, $course);
     $content .= html_writer::end_tag('div');
     // .content
     $content .= html_writer::end_tag('div');
     // .coursebox
     return $content;
 }
Ejemplo n.º 6
0
/**
 * Print a description of a course, suitable for browsing in a list.
 *
 * @param object $course the course object.
 * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
 */
function print_course($course, $highlightterms = '')
{
    global $CFG, $USER, $DB, $OUTPUT;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    // Rewrite file URLs so that they are correct
    $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
    echo html_writer::start_tag('div', array('class' => 'coursebox clearfix'));
    echo html_writer::start_tag('div', array('class' => 'info'));
    echo html_writer::start_tag('h3', array('class' => 'name'));
    $linkhref = new moodle_url('/course/view.php', array('id' => $course->id));
    $linktext = highlight($highlightterms, format_string($course->fullname));
    $linkparams = array('title' => get_string('entercourse'));
    if (empty($course->visible)) {
        $linkparams['class'] = 'dimmed';
    }
    echo html_writer::link($linkhref, $linktext, $linkparams);
    echo html_writer::end_tag('h3');
    /// first find all roles that are supposed to be displayed
    if (!empty($CFG->coursecontact)) {
        $managerroles = explode(',', $CFG->coursecontact);
        $namesarray = array();
        if (isset($course->managers)) {
            if (count($course->managers)) {
                $rusers = $course->managers;
                $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
                /// Rename some of the role names if needed
                if (isset($context)) {
                    $aliasnames = $DB->get_records('role_names', array('contextid' => $context->id), '', 'roleid,contextid,name');
                }
                // keep a note of users displayed to eliminate duplicates
                $usersshown = array();
                foreach ($rusers as $ra) {
                    // if we've already displayed user don't again
                    if (in_array($ra->user->id, $usersshown)) {
                        continue;
                    }
                    $usersshown[] = $ra->user->id;
                    $fullname = fullname($ra->user, $canviewfullnames);
                    if (isset($aliasnames[$ra->roleid])) {
                        $ra->rolename = $aliasnames[$ra->roleid]->name;
                    }
                    $namesarray[] = format_string($ra->rolename) . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $ra->user->id, 'course' => SITEID)), $fullname);
                }
            }
        } else {
            $rusers = get_role_users($managerroles, $context, true, '', 'r.sortorder ASC, u.lastname ASC');
            if (is_array($rusers) && count($rusers)) {
                $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
                /// Rename some of the role names if needed
                if (isset($context)) {
                    $aliasnames = $DB->get_records('role_names', array('contextid' => $context->id), '', 'roleid,contextid,name');
                }
                foreach ($rusers as $teacher) {
                    $fullname = fullname($teacher, $canviewfullnames);
                    /// Apply role names
                    if (isset($aliasnames[$teacher->roleid])) {
                        $teacher->rolename = $aliasnames[$teacher->roleid]->name;
                    }
                    $namesarray[] = format_string($teacher->rolename) . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $teacher->id, 'course' => SITEID)), $fullname);
                }
            }
        }
        if (!empty($namesarray)) {
            echo html_writer::start_tag('ul', array('class' => 'teachers'));
            foreach ($namesarray as $name) {
                echo html_writer::tag('li', $name);
            }
            echo html_writer::end_tag('ul');
        }
    }
    echo html_writer::end_tag('div');
    // End of info div
    echo html_writer::start_tag('div', array('class' => 'summary'));
    $options = NULL;
    $options->noclean = true;
    $options->para = false;
    $options->overflowdiv = true;
    if (!isset($course->summaryformat)) {
        $course->summaryformat = FORMAT_MOODLE;
    }
    echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
    if ((!isloggedin() || is_siteadmin()) && ($icons = enrol_get_course_info_icons($course))) {
        echo html_writer::start_tag('div', array('class' => 'enrolmenticons'));
        foreach ($icons as $icon) {
            echo $OUTPUT->render($icon);
        }
        echo html_writer::end_tag('div');
        // End of enrolmenticons div
    }
    echo html_writer::end_tag('div');
    // End of summary div
    echo html_writer::end_tag('div');
    // End of coursebox div
}
Ejemplo n.º 7
0
    /**
     * Renderers a category for use with course_category_tree
     *
     * @param array $category
     * @param int $depth
     * @return string
     */
    protected function course_category_tree_category(stdClass $category, $depth=1) {
        $content = '';
        $hassubcategories = (isset($category->categories) && count($category->categories)>0);
        $hascourses = (isset($category->courses) && count($category->courses)>0);
        $classes = array('category');
        if ($category->parent != 0) {
            $classes[] = 'subcategory';
        }
        if (empty($category->visible)) {
            $classes[] = 'dimmed_category';
        }
        if ($hassubcategories || $hascourses) {
            $classes[] = 'with_children';
            if ($depth > 1) {
                $classes[] = 'collapsed';
            }
        }
        $categoryname = format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id)));

        $content .= html_writer::start_tag('div', array('class'=>join(' ', $classes)));
        $content .= html_writer::start_tag('div', array('class'=>'category_label'));
        $content .= html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $categoryname, array('class'=>'category_link'));
        $content .= html_writer::end_tag('div');
        if ($hassubcategories) {
            $content .= html_writer::start_tag('div', array('class'=>'subcategories'));
            foreach ($category->categories as $subcategory) {
                $content .= $this->course_category_tree_category($subcategory, $depth+1);
            }
            $content .= html_writer::end_tag('div');
        }
        if ($hascourses) {
            $content .= html_writer::start_tag('div', array('class'=>'courses'));
            $coursecount = 0;
            $strinfo = new lang_string('info');
            foreach ($category->courses as $course) {
                $classes = array('course');
                $linkclass = 'course_link';
                if (!$course->visible) {
                    $linkclass .= ' dimmed';
                }
                $coursecount ++;
                $classes[] = ($coursecount%2)?'odd':'even';
                $content .= html_writer::start_tag('div', array('class'=>join(' ', $classes)));
                $content .= html_writer::link(new moodle_url('/course/view.php', array('id'=>$course->id)), format_string($course->fullname), array('class'=>$linkclass));
                $content .= html_writer::start_tag('div', array('class'=>'course_info clearfix'));

                // print enrol info
                if ($icons = enrol_get_course_info_icons($course)) {
                    foreach ($icons as $pix_icon) {
                        $content .= $this->render($pix_icon);
                    }
                }

                if ($course->summary) {
                    $url = new moodle_url('/course/info.php', array('id' => $course->id));
                    $image = html_writer::empty_tag('img', array('src'=>$this->output->pix_url('i/info'), 'alt'=>$this->strings->summary));
                    $content .= $this->action_link($url, $image, new popup_action('click', $url, 'courseinfo'), array('title' => $this->strings->summary));
                }
                $content .= html_writer::end_tag('div');
                $content .= html_writer::end_tag('div');
            }
            $content .= html_writer::end_tag('div');
        }
        $content .= html_writer::end_tag('div');
        return $content;
    }
Ejemplo n.º 8
0
 protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
 {
     /**
      * This is used to output any course block - including inside AJAX or SEARCH 
      * We had to override this renderer to enable the section=1 to be added to any link
      **/
     global $CFG;
     if (!isset($this->strings->summary)) {
         $this->strings->summary = get_string('summary');
     }
     if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $classes = trim('panel panel-default coursebox clearfix ' . $additionalclasses);
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $classes .= ' collapsed';
     }
     // .coursebox
     $content .= html_writer::start_tag('div', array('class' => $classes, 'data-courseid' => $course->id, 'data-type' => self::COURSECAT_TYPE_COURSE));
     $content .= html_writer::start_tag('div', array('class' => 'panel-heading info'));
     // course name
     $coursename = $chelper->get_course_formatted_name($course);
     $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id, 'section' => 1)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
     $content .= html_writer::tag('span', $coursenamelink, array('class' => 'coursename'));
     // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
     $content .= html_writer::start_tag('span', array('class' => 'moreinfo'));
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) {
             $url = new moodle_url('/course/info.php', array('id' => $course->id, 'section' => 1));
             $image = html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/info'), 'alt' => $this->strings->summary));
             $content .= html_writer::link($url, $image, array('title' => $this->strings->summary));
             // Make sure JS file to expand course content is included.
             $this->coursecat_include_js();
         }
     }
     $content .= html_writer::end_tag('span');
     // .moreinfo
     // print enrolmenticons
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pix_icon) {
             $content .= $this->render($pix_icon);
         }
         $content .= html_writer::end_tag('div');
         // .enrolmenticons
     }
     $content .= html_writer::end_tag('div');
     // .info
     $content .= html_writer::start_tag('div', array('class' => 'content panel-body'));
     // this bit gets the details for the contents of the panel -
     // for a search this might be the CATEGORY: LINK
     //$content .= "<pre>" . print_r($chelper, true) . "</pre>";
     $content .= $this->coursecat_coursebox_content($chelper, $course);
     if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $icondirection = 'left';
         if ('ltr' === get_string('thisdirection', 'langconfig')) {
             $icondirection = 'right';
         }
         /** HIDE THE course -> if the user is enrolled **/
         /** this annoyed Mark on the front page :-) **/
         // if (is_enrolled(context_course::instance($course->id))) {
         //     $arrow = html_writer::tag('span', '', array('class' => ' glyphicon glyphicon-arrow-'.$icondirection));
         //     $visit = html_writer::tag('span', get_string('course') . ' ' . $arrow);
         //     $visitlink = html_writer::link(new moodle_url('/course/view.php',
         //         array('id' => $course->id, 'section'=>1)), $visit);
         //     $content .= html_writer::tag('div', $visitlink, array('class' => 'visitlink'));
         // }
     }
     $content .= html_writer::end_tag('div');
     // .content
     $content .= html_writer::end_tag('div');
     // .coursebox
     return $content;
 }
function print_category_info2($category, $depth = 0, $showcourses = false)
{
    global $CFG, $DB, $OUTPUT;
    $strsummary = get_string('summary');
    $catlinkcss = null;
    if (!$category->visible) {
        $catlinkcss = array('class' => 'dimmed');
    }
    static $coursecount = null;
    if (null === $coursecount) {
        // only need to check this once
        $coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;
    }
    if ($showcourses and $coursecount) {
        $catimage = '<img src="' . $OUTPUT->pix_url('i/course') . '" alt="" />';
    } else {
        $catimage = "&nbsp;";
    }
    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
    if ($showcourses and $coursecount) {
        echo '<div class="categorylist clearfix ' . $depth . '">';
        $cat = '';
        $cat .= html_writer::tag('div', $catimage, array('class' => 'image'));
        $catlink = html_writer::link(new moodle_url('', array('id' => $category->id)), format_string($category->name), $catlinkcss);
        $cat .= html_writer::tag('div', $catlink, array('class' => 'name'));
        $html = '';
        if ($depth > 0) {
            for ($i = 0; $i < $depth; $i++) {
                $html = html_writer::tag('div', $html . $cat, array('class' => 'indentation'));
                $cat = '';
            }
        } else {
            $html = $cat;
        }
        echo html_writer::tag('div', $html, array('class' => 'category'));
        echo html_writer::tag('div', '', array('class' => 'clearfloat'));
        // does the depth exceed maxcategorydepth
        // maxcategorydepth == 0 or unset meant no limit
        $limit = !(isset($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth - 1);
        if ($courses && ($limit || $CFG->maxcategorydepth == 0)) {
            foreach ($courses as $course) {
                $linkcss = null;
                if (!$course->visible) {
                    $linkcss = array('class' => 'dimmed');
                }
                $courselink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->fullname), $linkcss);
                // print enrol info
                $courseicon = '';
                if ($icons = enrol_get_course_info_icons($course)) {
                    foreach ($icons as $pix_icon) {
                        $courseicon = $OUTPUT->render($pix_icon) . ' ';
                    }
                }
                $coursecontent = html_writer::tag('div', $courseicon . $courselink, array('class' => 'name'));
                if ($course->summary) {
                    $link = new moodle_url('/course/info.php?id=' . $course->id);
                    $actionlink = $OUTPUT->action_link($link, '<img alt="' . $strsummary . '" src="' . $OUTPUT->pix_url('i/info') . '" />', new popup_action('click', $link, 'courseinfo', array('height' => 400, 'width' => 500)), array('title' => $strsummary));
                    $coursecontent .= html_writer::tag('div', $actionlink, array('class' => 'info'));
                }
                $html = '';
                for ($i = 0; $i <= $depth; $i++) {
                    $html = html_writer::tag('div', $html . $coursecontent, array('class' => 'indentation'));
                    $coursecontent = '';
                }
                echo html_writer::tag('div', $html, array('class' => 'course clearfloat'));
            }
        }
        echo '</div>';
    } else {
        echo '<div class="categorylist level' . $depth . '">';
        $html = '';
        $cat = html_writer::link(new moodle_url('', array('id' => $category->id)), format_string($category->name), $catlinkcss);
        $cat .= html_writer::tag('span', ' (' . count($courses) . ')', array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
        if ($depth > 0) {
            for ($i = 0; $i < $depth; $i++) {
                //$html = html_writer::tag('div', $html .$cat, array('class'=>'indentation'));
                $html = html_writer::tag('div', $html . $cat, array('class' => 'indentation level' . $i));
                $cat = '';
            }
        } else {
            $html = $cat;
        }
        //Added By Hina Yousuf to show only those categories in which the user has access
        $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
        if (has_capability('block/custom_reports:getresults', $context)) {
            echo html_writer::tag('div', $html, array('class' => 'category'));
        }
        //end
        echo html_writer::tag('div', '', array('class' => 'clearfloat', 'style' => 'clear: both;'));
        echo '</div>';
    }
}
Ejemplo n.º 10
0
 /**
  * Displays one course in the list of courses.
  *
  * This is an internal function, to display an information about just one course
  * please use {@link core_course_renderer::course_info_box()}
  *
  * @param coursecat_helper $chelper various display options
  * @param course_in_list|stdClass $course
  * @param string $additionalclasses additional classes to add to the main <div> tag (usually
  *    depend on the course position in list - first/last/even/odd)
  * @return string
  */
 protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
 {
     global $CFG;
     if (!isset($this->strings->summary)) {
         $this->strings->summary = get_string('summary');
     }
     if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $classes = trim('coursebox clearfix ' . $additionalclasses);
     if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $nametag = 'h3';
         $nametag1 = 'div';
         /* GWL*/
     } else {
         $classes .= ' collapsed';
         $nametag = 'div';
     }
     // .coursebox
     $content .= html_writer::start_tag('div', array('class' => $classes, 'data-courseid' => $course->id, 'data-type' => self::COURSECAT_TYPE_COURSE));
     $content .= html_writer::start_tag('div', array('class' => 'info'));
     // display course overview files
     $contentimages = $contentfiles = '';
     foreach ($course->get_course_overviewfiles() as $file) {
         $isimage = $file->is_valid_image();
         $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
         if ($isimage) {
             $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage')) . html_writer::link(new moodle_url('#', array('' => '')), 'Plus', array('class' => 'icon-plus')) . html_writer::link(new moodle_url('#', array('' => '')), 'Minus', array('class' => 'icon-minus'));
         } else {
             $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
             $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
             $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
         }
     }
     $content .= $contentimages . $contentfiles;
     // course name
     $coursename = $chelper->get_course_formatted_name($course);
     $coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
     $coursenamelink1 = html_writer::tag('span', '', array('class' => 'duration-time')) . html_writer::tag('span', '', array('class' => 'time-text')) . html_writer::link(new moodle_url('#page-footer'), 'CONTACT US', array('class' => 'anchor-1 join-now'));
     /* GWL : Add extra, Remove Duration, Remove Time & Change Contact Us url to Footer */
     /*GWL - Remove Contact Us Link */
     /*
             $coursenamelink1 = html_writer::tag('span','', array('class'=>'duration-time')).html_writer::tag('span','', array('class'=>'time-text')).html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
                               'CONTACT US', array('class' => 'anchor-1 join-now')); */
     /* GWL : Add extra, Remove Duration & Remove Time */
     /* GWL - Duration & Time */
     /*
             $coursenamelink1 = html_writer::tag('span','Duration', array('class'=>'duration-time')).html_writer::tag('span','10hrs', array('class'=>'time-text')).html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
                               'Join Now', array('class' => 'anchor-1 join-now')); */
     /* gwl */
     $content .= html_writer::tag($nametag, $coursenamelink, array('class' => 'coursename'));
     $content .= html_writer::tag($nametag1, $coursenamelink1, array('class' => 'course-bottom'));
     /* GWL*/
     // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
     $content .= html_writer::start_tag('div', array('class' => 'moreinfo'));
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) {
             $url = new moodle_url('/course/info.php', array('id' => $course->id));
             $image = html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/info'), 'alt' => $this->strings->summary));
             $content .= html_writer::link($url, $image, array('title' => $this->strings->summary));
             // Make sure JS file to expand course content is included.
             $this->coursecat_include_js();
         }
     }
     $content .= html_writer::end_tag('div');
     // .moreinfo
     // print enrolmenticons
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pix_icon) {
             $content .= $this->render($pix_icon);
         }
         $content .= html_writer::end_tag('div');
         // .enrolmenticons
     }
     $content .= html_writer::end_tag('div');
     // .info
     $content .= html_writer::start_tag('div', array('class' => 'content'));
     $content .= $this->coursecat_coursebox_content($chelper, $course);
     $content .= html_writer::end_tag('div');
     // .content
     $content .= html_writer::end_tag('div');
     // .coursebox
     return $content;
 }
Ejemplo n.º 11
0
/**
 *  Prints the category info in indented fashion
 *  There are two display possibilities.
 *    1. Display categories without courses ($showcourses = false)
 *    2. Display categories with courses ($showcategories = true)
 *
 *  This function is only used by print_whole_manager_category_list() above
 */
function print_category_manager_info($category, $depth = 0, $showcourses = false, $visible)
{
    global $CFG, $DB, $OUTPUT;
    $output = '';
    $strsummary = get_string('summary');
    $catlinkcss = null;
    if (!$category->visible) {
        $catlinkcss = array('class' => 'dimmed');
    }
    static $coursecount = null;
    if (null === $coursecount) {
        // Only need to check this once.
        $coursecount = $DB->count_records('course') <= $CFG->frontpagecourselimit;
    }
    if ($visible) {
        $catimage = '<img src="' . $OUTPUT->pix_url('i/course') . '" alt="" />&nbsp;';
    } else {
        $catimage = '<img src="' . $OUTPUT->pix_url('courseclosed', 'local_contextadmin') . '" alt="" />&nbsp;';
    }
    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
    $context = context_coursecat::instance($category->id);
    $fullname = format_string($category->name, true, array('context' => $context));
    $output .= '<div class="categorylist clearfix">';
    $cat = '';
    $cat .= html_writer::tag('div', $catimage, array('class' => 'image'));
    if ($visible) {
        $catlink = html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $category->id, 'categoryedit' => true)), $fullname, $catlinkcss);
        $cat .= html_writer::tag('div', $catlink, array('class' => 'name'));
    } else {
        $cat .= html_writer::tag('div', $fullname, array('class' => 'name'));
    }
    $html = '';
    if ($depth > 0) {
        for ($i = 0; $i < $depth; $i++) {
            $html = html_writer::tag('div', $html . $cat, array('class' => 'indentation'));
            $cat = '';
        }
    } else {
        $html = $cat;
    }
    $output .= html_writer::tag('div', $html, array('class' => 'category'));
    $output .= html_writer::tag('div', '', array('class' => 'clearfloat'));
    // Does the depth exceed maxcategorydepth.
    // Note: maxcategorydepth == 0 or unset meant no limit.
    $limit = !(isset($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth - 1);
    if ($courses && ($limit || $CFG->maxcategorydepth == 0) && $showcourses) {
        $output .= '<br>';
        foreach ($courses as $course) {
            $linkcss = null;
            if (!$course->visible) {
                $linkcss = array('class' => 'dimmed');
            }
            $courselink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->fullname), $linkcss);
            // Print enrol info.
            $courseicon = '';
            if ($icons = enrol_get_course_info_icons($course)) {
                foreach ($icons as $pixicon) {
                    $courseicon = $OUTPUT->render($pixicon) . ' ';
                }
            }
            $coursecontent = html_writer::tag('div', $courseicon . $courselink, array('class' => 'name'));
            if ($course->summary) {
                $link = new moodle_url('/course/info.php?id=' . $course->id);
                $actionlink = $OUTPUT->action_link($link, '<img alt="' . $strsummary . '" src="' . $OUTPUT->pix_url('i/info') . '" />', new popup_action('click', $link, 'courseinfo', array('height' => 400, 'width' => 500)), array('title' => $strsummary));
                $coursecontent .= html_writer::tag('div', $actionlink, array('class' => 'info'));
            }
            $html = '';
            for ($i = 0; $i <= $depth; $i++) {
                $html = html_writer::tag('div', $html . $coursecontent, array('class' => 'indentation'));
                $coursecontent = '';
            }
            $output .= html_writer::tag('div', $html, array('class' => 'course clearfloat'));
        }
    }
    $output .= '</div>';
    return $output;
}
Ejemplo n.º 12
0
 protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
 {
     global $CFG, $OUTPUT;
     if (!isset($this->strings->summary)) {
         $this->strings->summary = get_string('summary');
     }
     if ($chelper->get_show_courses() <= self::COURSECAT_SHOW_COURSES_COUNT) {
         return '';
     }
     if ($course instanceof stdClass) {
         require_once $CFG->libdir . '/coursecatlib.php';
         $course = new course_in_list($course);
     }
     $content = '';
     $classes = trim($additionalclasses);
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $classes .= ' collapsed';
     }
     $content .= html_writer::start_tag('div', array('class' => 'panel panel-default coursebox'));
     $content .= html_writer::start_tag('div', array('class' => 'panel-heading'));
     // Course name.
     $coursename = $chelper->get_course_formatted_name($course);
     $content .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
     // If we display course in collapsed form but the course has summary or course contacts, display the link to the info page.
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         if ($course->has_summary() || $course->has_course_contacts() || $course->has_course_overviewfiles()) {
             $url = new moodle_url('/course/info.php', array('id' => $course->id));
             $arrow = html_writer::tag('span', '', array('class' => 'glyphicon glyphicon-info-sign'));
             $content .= html_writer::link('#coursecollapse' . $course->id, '&nbsp;' . $arrow, array('data-toggle' => 'collapse', 'data-parent' => '#frontpage-category-combo'));
         }
     }
     // print enrolmenticons
     if ($icons = enrol_get_course_info_icons($course)) {
         $content .= html_writer::start_tag('div', array('class' => 'enrolmenticons'));
         foreach ($icons as $pix_icon) {
             $content .= $this->render($pix_icon);
         }
         $content .= html_writer::end_tag('div');
         // .enrolmenticons
     }
     $content .= html_writer::end_tag('div');
     // End .panel-heading.
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $content .= html_writer::start_tag('div', array('id' => 'coursecollapse' . $course->id, 'class' => 'panel-collapse collapse'));
     }
     $content .= html_writer::start_tag('div', array('class' => 'panel-body'));
     // This gets the course image or files
     $content .= $this->coursecat_coursebox_content($chelper, $course);
     if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $icondirection = 'left';
         if ('ltr' === get_string('thisdirection', 'langconfig')) {
             $icondirection = 'right';
         }
         $arrow = html_writer::tag('span', '', array('class' => ' glyphicon glyphicon-arrow-' . $icondirection));
         $btn = html_writer::tag('span', get_string('course') . ' ' . $arrow, array('class' => 'coursequicklink'));
         $content .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $btn, array('class' => 'coursebtn btn btn-info btn-sm pull-right'));
     }
     $content .= html_writer::end_tag('div');
     // End .panel-body.
     if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
         $content .= html_writer::end_tag('div');
         // End .collapse.
     }
     $content .= html_writer::end_tag('div');
     // End .panel.
     return $content;
 }