public function tag_index_page($tag, $entities, $tagareaid, $exclusivemode, $fromctx, $ctx, $rec, $page) {
        global $CFG, $OUTPUT;
        $this->page->requires->js_call_amd('core/tag', 'initTagindexPage');

        $tagname = $tag->get_display_name();
        $systemcontext = context_system::instance();

        if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
            $tagname = '<span class="flagged-tag">' . $tagname . '</span>';
        }

        $rv = '';
        $rv .= $this->output->heading($tagname, 2);

        $rv .= $this->tag_links($tag);

        if ($desciption = $tag->get_formatted_description()) {
            $rv .= $this->output->box($desciption, 'generalbox tag-description');
        }

        $relatedtagslimit = 10;
        $relatedtags = $tag->get_related_tags();
        $taglist = new \core_tag\output\taglist($relatedtags, get_string('relatedtags', 'tag'),
                'tag-relatedtags', $relatedtagslimit);
        $rv .= $OUTPUT->render_from_template('core_tag/taglist', $taglist->export_for_template($OUTPUT));

        // Display quick menu of the item types (if more than one item type found).
        $entitylinks = array();
        foreach ($entities as $entity) {
            if (!empty($entity->hascontent)) {
                $entitylinks[] = '<li><a href="#'.$entity->anchor.'">' .
                        core_tag_area::display_name($entity->component, $entity->itemtype) . '</a></li>';
            }
        }

        if (count($entitylinks) > 1) {
            $rv .= '<div class="tag-index-toc"><ul class="inline-list">' . join('', $entitylinks) . '</ul></div>';
        } else if (!$entitylinks) {
            $rv .= '<div class="tag-noresults">' . get_string('noresultsfor', 'tag', $tagname) . '</div>';
        }

        // Display entities tagged with the tag.
        $content = '';
        foreach ($entities as $entity) {
            if (!empty($entity->hascontent)) {
                $content .= $this->output->render_from_template('core_tag/index', $entity->export_for_template($this->output));
            }
        }

        if ($exclusivemode) {
            $rv .= $content;
        } else if ($content) {
            $rv .= html_writer::div($content, 'tag-index-items');
        }

        // Display back link if we are browsing one tag area.
        if ($tagareaid) {
            $url = $tag->get_view_url(0, $fromctx, $ctx, $rec);
            $rv .= '<div class="tag-backtoallitems">' .
                    html_writer::link($url, get_string('backtoallitems', 'tag', $tag->get_display_name())) .
                    '</div>';
        }

        return $rv;
    }
public function tag_index_page($tag, $entities, $tagareaid, $exclusivemode, $fromctx, $ctx, $rec, $page) {
        global $CFG, $OUTPUT;
        $this->page->requires->js_call_amd('core/tag', 'initTagindexPage');

        $tagname = $tag->get_display_name();
        $systemcontext = context_system::instance();

        if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
            $tagname = '<span class="flagged-tag">' . $tagname . '</span>';
        }

        $rv = '';
        $rv .= $this->output->heading($tagname, 2);

        $rv .= $this->tag_links($tag);

        if ($desciption = $tag->get_formatted_description()) {
            $rv .= $this->output->box($desciption, 'generalbox tag-description');
        }

        $relatedtagslimit = 10;
        $relatedtags = $tag->get_related_tags();
        $taglist = new \core_tag\output\taglist($relatedtags, get_string('relatedtags', 'tag'),
                'tag-relatedtags', $relatedtagslimit);
        $rv .= $OUTPUT->render_from_template('core_tag/taglist', $taglist->export_for_template($OUTPUT));

        // Display quick menu of the item types (if more than one item type found).
        $entitylinks = array();
        foreach ($entities as $entity) {
            if (!empty($entity->hascontent)) {
                $entitylinks[] = '<li><a href="#'.$entity->anchor.'">' .
                        core_tag_area::display_name($entity->component, $entity->itemtype) . '</a></li>';
            }
        }

        if (count($entitylinks) > 1) {
            $rv .= '<div class="tag-index-toc"><ul class="inline-list">' . join('', $entitylinks) . '</ul></div>';
        } else if (!$entitylinks) {
            $rv .= '<div class="tag-noresults">' . get_string('noresultsfor', 'tag', $tagname) . '</div>';
        }

        // Display entities tagged with the tag.
        $content = '';
        foreach ($entities as $entity) {
            if (!empty($entity->hascontent)) {
                $content .= $this->output->render_from_template('core_tag/index', $entity->export_for_template($this->output));
            }
        }

        if ($exclusivemode) {
            $rv .= $content;
        } else if ($content) {
            $rv .= html_writer::div($content, 'tag-index-items');
        }

        // Display back link if we are browsing one tag area.
        if ($tagareaid) {
            $url = $tag->get_view_url(0, $fromctx, $ctx, $rec);
            $rv .= '<div class="tag-backtoallitems">' .
                    html_writer::link($url, get_string('backtoallitems', 'tag', $tag->get_display_name())) .
                    '</div>';
        }

        return $rv;
    }
public function tag_index_page ( $ tag , $ entities , $ tagareaid , $ exclusivemode , $ fromctx , $ ctx , $ rec , $ page ) { global $ CFG , $ OUTPUT ; $ this -> page -> requires -> js_call_amd ( 'core/tag' , 'initTagindexPage' ) ; $ tagname = $ tag -> get_display_name ( ) ; $ systemcontext = context_system :: instance ( ) ; if ( $ tag -> flag > 0 && has_capability ( 'moodle/tag:manage' , $ systemcontext ) ) { $ tagname = '<span class="flagged-tag">' . $ tagname . '</span>' ; } $ rv = '' ; $ rv .= $ this -> output -> heading ( $ tagname , 2 ) ; $ rv .= $ this -> tag_links ( $ tag ) ; if ( $ desciption = $ tag -> get_formatted_description ( ) ) { $ rv .= $ this -> output -> box ( $ desciption , 'generalbox tag-description' ) ; } $ relatedtagslimit = 10 ; $ relatedtags = $ tag -> get_related_tags ( ) ; $ taglist = new \ core_tag \ output \ taglist ( $ relatedtags , get_string ( 'relatedtags' , 'tag' ) , 'tag-relatedtags' , $ relatedtagslimit ) ; $ rv .= $ OUTPUT -> render_from_template ( 'core_tag/taglist' , $ taglist -> export_for_template ( $ OUTPUT ) ) ; // Display quick menu of the item types (if more than one item type found). $ entitylinks = array ( ) ; foreach ( $ entities as $ entity ) { if ( ! empty ( $ entity -> hascontent ) ) { $ entitylinks [ ] = '<li><a href="#' . $ entity -> anchor . '">' . core_tag_area :: display_name ( $ entity -> component , $ entity -> itemtype ) . '</a></li>' ; } } if ( count ( $ entitylinks ) > 1 ) { $ rv .= '<div class="tag-index-toc"><ul class="inline-list">' . join ( '' , $ entitylinks ) . '</ul></div>' ; } else if ( ! $ entitylinks ) { $ rv .= '<div class="tag-noresults">' . get_string ( 'noresultsfor' , 'tag' , $ tagname ) . '</div>' ; } // Display entities tagged with the tag. $ content = '' ; foreach ( $ entities as $ entity ) { if ( ! empty ( $ entity -> hascontent ) ) { $ content .= $ this -> output -> render_from_template ( 'core_tag/index' , $ entity -> export_for_template ( $ this -> output ) ) ; } } if ( $ exclusivemode ) { $ rv .= $ content ; } else if ( $ content ) { $ rv .= html_writer :: div ( $ content , 'tag-index-items' ) ; } // Display back link if we are browsing one tag area. if ( $ tagareaid ) { $ url = $ tag -> get_view_url ( 0 , $ fromctx , $ ctx , $ rec ) ; $ rv .= '<div class="tag-backtoallitems">' . html_writer :: link ( $ url , get_string ( 'backtoallitems' , 'tag' , $ tag -> get_display_name ( ) ) ) . '</div>' ; } return $ rv ; }
Renders the tag index page

@param core_tag_tag $tag
@param \core_tag\output\tagindex[] $entities
@param int $tagareaid
@param bool $exclusivemode if set to true it means that no other entities tagged with this tag
are displayed on the page and the per-page limit may be bigger
@param int $fromctx context id where the link was displayed, may be used by callbacks
to display items in the same context first
@param int $ctx context id where to search for records
@param bool $rec search in subcontexts as well
@param int $page 0-based number of page being displayed
@return string
Renders the tag index page