Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagarea
  */
 public function __construct($tagarea)
 {
     if (!empty($tagarea->locked)) {
         // If the tag collection for the current tag area is locked, display the
         // name of the collection without possibility to edit it.
         $tagcoll = \core_tag_collection::get_by_id($tagarea->tagcollid);
         parent::__construct('core_tag', 'tagareacollection', $tagarea->id, false, \core_tag_collection::display_name($tagcoll), $tagarea->tagcollid);
         return;
     }
     $tagcollections = \core_tag_collection::get_collections_menu(true);
     $editable = count($tagcollections) > 1 && has_capability('moodle/tag:manage', context_system::instance());
     $areaname = core_tag_area::display_name($tagarea->component, $tagarea->itemtype);
     $edithint = new lang_string('edittagcollection', 'core_tag');
     $editlabel = new lang_string('changetagcoll', 'core_tag', $areaname);
     $value = $tagarea->tagcollid;
     parent::__construct('core_tag', 'tagareacollection', $tagarea->id, $editable, null, $value, $edithint, $editlabel);
     $this->set_type_select($tagcollections);
 }
Ejemplo n.º 2
0
if ($perpage != DEFAULT_PAGE_SIZE) {
    $params['perpage'] = $perpage;
}
if ($page > 0) {
    $params['page'] = $page;
}
admin_externalpage_setup('managetags', '', $params, '', array('pagelayout' => 'report'));
if (empty($CFG->usetags)) {
    print_error('tagsaredisabled', 'tag');
}
$tagobject = null;
if ($tagid) {
    $tagobject = core_tag_tag::get($tagid, '*', MUST_EXIST);
    $tagcollid = $tagobject->tagcollid;
}
$tagcoll = core_tag_collection::get_by_id($tagcollid);
$tagarea = core_tag_area::get_by_id($tagareaid);
$manageurl = new moodle_url('/tag/manage.php');
if ($tagcoll) {
    // We are inside a tag collection - add it to the page url and the breadcrumb.
    $PAGE->set_url(new moodle_url($PAGE->url, array('tc' => $tagcoll->id)));
    $PAGE->navbar->add(core_tag_collection::display_name($tagcoll), new moodle_url($manageurl, array('tc' => $tagcoll->id)));
}
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
switch ($action) {
    case 'colladd':
    case 'colledit':
        if ($action === 'colladd' || $action === 'colledit' && $tagcoll && empty($tagcoll->component)) {
            $form = new core_tag_collection_form($manageurl, $tagcoll);
            if ($form->is_cancelled()) {
                redirect($manageurl);
Ejemplo n.º 3
0
 /**
  * Creates a URL to view a tag
  *
  * @param int $tagcollid
  * @param string $name
  * @param int $exclusivemode
  * @param int $fromctx context id where this tag cloud is displayed
  * @param int $ctx context id for tag view link
  * @param int $rec recursive argument for tag view link
  * @return \moodle_url
  */
 public static function make_url($tagcollid, $name, $exclusivemode = 0, $fromctx = 0, $ctx = 0, $rec = 1)
 {
     $coll = core_tag_collection::get_by_id($tagcollid);
     if (!empty($coll->customurl)) {
         $url = '/' . ltrim(trim($coll->customurl), '/');
     } else {
         $url = '/tag/index.php';
     }
     $params = array('tc' => $tagcollid, 'tag' => $name);
     if ($exclusivemode) {
         $params['excl'] = 1;
     }
     if ($fromctx) {
         $params['from'] = $fromctx;
     }
     if ($ctx) {
         $params['ctx'] = $ctx;
     }
     if (!$rec) {
         $params['rec'] = 0;
     }
     return new moodle_url($url, $params);
 }