function get_content() {
        global $CFG, $DB, $PAGE;

        require_once($CFG->libdir . '/filelib.php');
        require_once($CFG->dirroot . '/blocks/cobalt_reports/report.class.php');
        require_once($CFG->dirroot . '/blocks/cobalt_reports/locallib.php');
        if ($this->content !== NULL) {
            return $this->content;
        }

        $filteropt = new stdClass;
        $filteropt->overflowdiv = true;
        if ($this->content_is_trusted()) {
            // fancy reportdashboard allowed only on course, category and system blocks.
            $filteropt->noclean = true;
        }
        $this->content = new stdClass;
        $this->content->footer = '';
        $this->content->text = "";

        if (isset($this->config->reportlist)) {
            $reportid = $this->config->reportlist;
            $reportclass = create_reportclass($reportid);
            $components = cr_unserialize($reportclass->config->components);
            $reportcontenttypes = cr_listof_reporttypes($this->config->reportlist);
            $blockinstanceid = $this->instance->id;
            $this->content->text .= html_writer::select($reportcontenttypes, 'report', $this->config->reportcontenttype, false, array('id' => 'reporttype_' . $this->instance->id . '', 'onchange' => "generate_report(\"reporttype_\",$reportid,\"reportcontainer\",$blockinstanceid,\"$CFG->wwwroot\")"));
            $this->content->text .= html_writer::start_tag('div', array('id' => 'reportcontainer' . $this->instance->id . ''));
            $report = cr_get_reportinstance($this->config->reportlist);
            if (isset($report) && !$report->global) {
                $this->content->text .= '';
            } elseif (isset($this->config->reportlist)) {
                $renderer = $this->page->get_renderer('block_reportdashboard');
                $this->content->text .= $renderer->generate_dashboardreport($reportclass, $this->config->reportcontenttype, $blockinstanceid);
            }
            $this->content->text .=html_writer::end_tag('div');
            $link_url = new moodle_url('/blocks/cobalt_reports/viewreport.php', array('id'=>$reportid, 'courseid' => 1));
            $link = html_writer::link($link_url, html_writer::span(get_string('viewmore'), '', array('id'=>'reportdashboard_right')));
            $this->content->text .=$link;
        } else {
            $this->content->text .= '';
        }

        unset($filteropt); // memory footprint

        return $this->content;
    }
예제 #2
0
function create_reportclass($reportid) {
    global $CFG, $DB;
    $report = cr_get_reportinstance($reportid);
    require_once($CFG->dirroot . '/blocks/cobalt_reports/reports/' . $report->type . '/report.class.php');
    $reportclassname = 'report_' . $report->type;
    $reportclass = new $reportclassname($report);
    return $reportclass;
}