Ejemplo n.º 1
0
 /**
  * Get tags by their ids
  *
  * @param array $params
  */
 public static function get_tagindex($params)
 {
     global $PAGE;
     // Validate and normalize parameters.
     $tagindex = self::validate_parameters(self::get_tagindex_parameters(), array('tagindex' => $params));
     $params = $tagindex['tagindex'] + array('excl' => 0, 'from' => 0, 'ctx' => 0, 'rec' => 1, 'page' => 0);
     // Login to the course / module if applicable.
     $context = $params['ctx'] ? context::instance_by_id($params['ctx']) : context_system::instance();
     require_login(null, false, null, false, true);
     self::validate_context($context);
     $tag = core_tag_tag::get_by_name($params['tc'], $params['tag'], '*', MUST_EXIST);
     $tagareas = core_tag_collection::get_areas($params['tc']);
     $tagindex = $tag->get_tag_index($tagareas[$params['ta']], $params['excl'], $params['from'], $params['ctx'], $params['rec'], $params['page']);
     $renderer = $PAGE->get_renderer('core');
     return $tagindex->export_for_template($renderer);
 }
Ejemplo n.º 2
0
$buttons = '';
if (has_capability('moodle/tag:manage', context_system::instance())) {
    $buttons .= $OUTPUT->single_button(new moodle_url('/tag/manage.php'), get_string('managetags', 'tag'), 'GET');
}
if ($PAGE->user_allowed_editing()) {
    if ($edit != -1) {
        $USER->editing = $edit;
    }
    $buttons .= $OUTPUT->edit_button(clone $PAGE->url);
}
$PAGE->navbar->add($tagname);
$PAGE->set_title(get_string('tag', 'tag') . ' - ' . $tag->get_display_name());
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_button($buttons);
// Find all areas in this collection and their items tagged with this tag.
$tagareas = core_tag_collection::get_areas($tagcollid);
if ($tagareaid) {
    $tagareas = array_intersect_key($tagareas, array($tagareaid => 1));
}
if (!$tagareaid && count($tagareas) == 1) {
    // Automatically set "exclusive" mode for tag collection with one tag area only.
    $exclusivemode = 1;
}
$entities = array();
foreach ($tagareas as $ta) {
    $entities[] = $tag->get_tag_index($ta, $exclusivemode, $fromctx, $ctx, $rec, $page);
}
$entities = array_filter($entities);
$tagrenderer = $PAGE->get_renderer('core', 'tag');
$pagecontents = $tagrenderer->tag_index_page($tag, array_filter($entities), $tagareaid, $exclusivemode, $fromctx, $ctx, $rec, $page);
echo $OUTPUT->header();