public static function get_tag_cloud($tagcollid = 0, $isstandard = false, $limit = 150, $sort = 'name',
            $search = '', $fromctx = 0, $ctx = 0, $rec = 1) {
        global $CFG, $PAGE;

        $params = self::validate_parameters(self::get_tag_cloud_parameters(),
            array(
                'tagcollid' => $tagcollid,
                'isstandard' => $isstandard,
                'limit' => $limit,
                'sort' => $sort,
                'search' => $search,
                'fromctx' => $fromctx,
                'ctx' => $ctx,
                'rec' => $rec,
            )
        );

        if (empty($CFG->usetags)) {
            throw new moodle_exception('tagsaredisabled', 'tag');
        }

        $context = context_system::instance();
        self::validate_context($context);
        $PAGE->set_context($context); // Needed by internal APIs.
        $output = $PAGE->get_renderer('core');

        $tagcloud = core_tag_collection::get_tag_cloud($params['tagcollid'], $params['isstandard'], $params['limit'],
            $params['sort'], $params['search'], $params['fromctx'], $params['ctx'], $params['rec']);

        $result = $tagcloud->export_for_template($output);
        $result->warnings = array();

        return (array) $result;
    }