Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagcoll
  */
 public function __construct($tagcoll)
 {
     $editable = has_capability('moodle/tag:manage', context_system::instance());
     $edithint = new lang_string('editcollname', 'core_tag');
     $value = $tagcoll->name;
     $name = \core_tag_collection::display_name($tagcoll);
     $editlabel = new lang_string('newcollnamefor', 'core_tag', $name);
     $manageurl = new moodle_url('/tag/manage.php', array('tc' => $tagcoll->id));
     $displayvalue = html_writer::link($manageurl, $name);
     parent::__construct('core_tag', 'tagcollname', $tagcoll->id, $editable, $displayvalue, $value, $edithint, $editlabel);
 }
Ejemplo n.º 2
0
 /**
  * Constructor
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-collections-table';
     $this->head = array(get_string('name'), get_string('component', 'tag'), get_string('tagareas', 'tag'), get_string('searchable', 'tag') . $OUTPUT->help_icon('searchable', 'tag'), '');
     $this->data = array();
     $tagcolls = core_tag_collection::get_collections();
     $idx = 0;
     foreach ($tagcolls as $tagcoll) {
         $actions = '';
         $name = core_tag_collection::display_name($tagcoll);
         $url = new moodle_url($pageurl, array('sesskey' => sesskey(), 'tc' => $tagcoll->id));
         if (!$tagcoll->isdefault) {
             // Move up.
             if ($idx > 1) {
                 $url->param('action', 'collmoveup');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')), null, array('class' => 'action-icon action_moveup'));
             }
             // Move down.
             if ($idx < count($tagcolls) - 1) {
                 $url->param('action', 'collmovedown');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')), null, array('class' => 'action-icon action_movedown'));
             }
         }
         if (!$tagcoll->isdefault && empty($tagcoll->component)) {
             // Delete.
             $url->param('action', 'colldelete');
             $actions .= $OUTPUT->action_icon('#', new pix_icon('t/delete', get_string('delete')), null, array('data-url' => $url->out(false), 'data-collname' => $name, 'class' => 'action-icon action_delete'));
         }
         $component = '';
         if ($tagcoll->component) {
             $component = $tagcoll->component === 'core' || preg_match('/^core_/', $tagcoll->component) ? get_string('coresystem') : get_string('pluginname', $tagcoll->component);
         }
         $allareas = core_tag_collection::get_areas_names(null, false);
         $validareas = core_tag_collection::get_areas_names($tagcoll->id);
         $areaslist = array_map(function ($key) use($allareas, $validareas) {
             return "<li data-areaid=\"{$key}\" " . (array_key_exists($key, $validareas) ? "" : "style=\"display:none;\"") . ">{$allareas[$key]}</li>";
         }, array_keys($allareas));
         $displayname = new \core_tag\output\tagcollname($tagcoll);
         $searchable = new \core_tag\output\tagcollsearchable($tagcoll);
         $this->data[] = array($displayname->render($OUTPUT), $component, "<ul data-collectionid=\"{$tagcoll->id}\">" . join('', $areaslist) . '</ul>', $searchable->render($OUTPUT), $actions);
         $idx++;
     }
 }
Ejemplo n.º 3
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.º 4
0
 /**
  * Constructor
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-collections-table';
     $this->head = array(get_string('name'), get_string('component', 'tag'), get_string('tagareas', 'tag'), get_string('searchable', 'tag') . $OUTPUT->help_icon('searchable', 'tag'), '');
     $this->data = array();
     $tagcolls = core_tag_collection::get_collections();
     $idx = 0;
     foreach ($tagcolls as $tagcoll) {
         $actions = '';
         $name = core_tag_collection::display_name($tagcoll);
         $url = new moodle_url($pageurl, array('sesskey' => sesskey(), 'tc' => $tagcoll->id));
         if (!$tagcoll->isdefault) {
             // Move up.
             if ($idx > 1) {
                 $url->param('action', 'collmoveup');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')));
             }
             // Move down.
             if ($idx < count($tagcolls) - 1) {
                 $url->param('action', 'collmovedown');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')));
             }
         }
         if (empty($tagcoll->component)) {
             // Edit.
             $url->param('action', 'colledit');
             $actions .= $OUTPUT->action_icon($url, new pix_icon('t/edit', get_string('edittagcoll', 'tag', $name)));
         }
         if (!$tagcoll->isdefault && empty($tagcoll->component)) {
             // Delete.
             $url->param('action', 'colldelete');
             $actions .= $OUTPUT->action_icon($url, new pix_icon('t/delete', get_string('delete')));
         }
         $manageurl = new moodle_url('/tag/manage.php', array('tc' => $tagcoll->id));
         $component = '';
         if ($tagcoll->component) {
             $component = $tagcoll->component === 'core' || preg_match('/^core_/', $tagcoll->component) ? get_string('coresystem') : get_string('pluginname', $tagcoll->component);
         }
         $this->data[] = array(html_writer::link($manageurl, $name), $component, join(', ', core_tag_collection::get_areas_names($tagcoll->id)), $tagcoll->searchable ? get_string('yes') : '-', $actions);
         $idx++;
     }
 }
Ejemplo n.º 5
0
}
if (!$tagcoll) {
    // Tag collection is not specified. Display the overview of tag collections and tag areas.
    $tagareastable = new core_tag_areas_table($manageurl);
    $colltable = new core_tag_collections_table($manageurl);
    echo $OUTPUT->heading(get_string('tagcollections', 'core_tag') . $OUTPUT->help_icon('tagcollection', 'tag'), 3);
    echo html_writer::table($colltable);
    $url = new moodle_url($manageurl, array('action' => 'colladd'));
    echo html_writer::div(html_writer::link($url, get_string('addtagcoll', 'tag')), 'mdl-right addtagcoll');
    echo $OUTPUT->heading(get_string('tagareas', 'core_tag'), 3);
    echo html_writer::table($tagareastable);
    echo $OUTPUT->footer();
    exit;
}
// Tag collection is specified. Manage tags in this collection.
echo $OUTPUT->heading(core_tag_collection::display_name($tagcoll));
// Small form to add an standard tag.
print '<form class="tag-addtags-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php">';
print '<input type="hidden" name="tc" value="' . $tagcollid . '" />';
print '<input type="hidden" name="action" value="addstandardtag" />';
print '<input type="hidden" name="perpage" value="' . $perpage . '" />';
print '<input type="hidden" name="page" value="' . $page . '" />';
print '<div class="tag-management-form generalbox"><label class="accesshide" for="id_otagsadd">' . get_string('addotags', 'tag') . '</label>' . '<input name="otagsadd" id="id_otagsadd" type="text" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '">' . '<input name="addotags" value="' . get_string('addotags', 'tag') . '" onclick="skipClientValidation = true;" id="id_addotags" type="submit" />' . '</div>';
print '</form>';
$table = new core_tag_manage_table($tagcollid);
echo '<form class="tag-management-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php">';
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'tc', 'value' => $tagcollid));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'perpage', 'value' => $perpage));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'page', 'value' => $page));
Ejemplo n.º 6
0
                 $title = $action === 'colladd' ? get_string('addtagcoll', 'tag') : get_string('edittagcoll', 'tag', core_tag_collection::display_name($tagcoll));
                 $PAGE->navbar->add($title);
                 echo $OUTPUT->header();
                 echo $OUTPUT->heading($title, 2);
                 $form->display();
                 echo $OUTPUT->footer();
                 exit;
             }
         }
     }
     break;
 case 'colldelete':
     $confirm = optional_param('confirm', false, PARAM_BOOL);
     if (!$confirm) {
         echo $OUTPUT->header();
         $strconfirm = get_string('suredeletecoll', 'tag', core_tag_collection::display_name($tagcoll));
         $params = array('tc' => $tagcoll->id, 'confirm' => 1, 'sesskey' => sesskey(), 'action' => 'colldelete');
         $formcontinue = new single_button(new moodle_url($manageurl, $params), get_string('yes'));
         $formcancel = new single_button($manageurl, get_string('no'), 'get');
         echo $OUTPUT->confirm($strconfirm, $formcontinue, $formcancel);
         echo $OUTPUT->footer();
         die;
     }
     if ($tagcoll && !$tagcoll->component) {
         require_sesskey();
         core_tag_collection::delete($tagcoll);
         redirect(new moodle_url($manageurl, array('notice' => 'changessaved')));
     }
     redirect($manageurl);
     break;
 case 'collmoveup':