Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-areas-table';
     $this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag'), get_string('showstandard', 'tag') . $OUTPUT->help_icon('showstandard', 'tag'));
     $this->data = array();
     $this->rowclasses = array();
     $tagareas = core_tag_area::get_areas();
     $tagcollections = core_tag_collection::get_collections_menu(true);
     $tagcollectionsall = core_tag_collection::get_collections_menu();
     $standardchoices = array(core_tag_tag::BOTH_STANDARD_AND_NOT => get_string('standardsuggest', 'tag'), core_tag_tag::STANDARD_ONLY => get_string('standardforce', 'tag'), core_tag_tag::HIDE_STANDARD => get_string('standardhide', 'tag'));
     foreach ($tagareas as $itemtype => $it) {
         foreach ($it as $component => $record) {
             $areaname = core_tag_area::display_name($record->component, $record->itemtype);
             $tmpl = new \core_tag\output\tagareaenabled($record);
             $enabled = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $tmpl = new \core_tag\output\tagareacollection($record);
             $collectionselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $tmpl = new \core_tag\output\tagareashowstandard($record);
             $showstandardselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
             $this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect, $showstandardselect);
             $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-areas-table';
     $this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag'));
     $this->data = array();
     $this->rowclasses = array();
     $tagareas = core_tag_area::get_areas();
     $tagcollections = core_tag_collection::get_collections_menu(true);
     $tagcollectionsall = core_tag_collection::get_collections_menu();
     foreach ($tagareas as $itemtype => $it) {
         foreach ($it as $component => $record) {
             $areaname = core_tag_area::display_name($record->component, $record->itemtype);
             $baseurl = new moodle_url($pageurl, array('ta' => $record->id, 'sesskey' => sesskey()));
             if ($record->enabled) {
                 $enableurl = new moodle_url($baseurl, array('action' => 'areadisable'));
                 $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/hide', get_string('disable')));
             } else {
                 $enableurl = new moodle_url($baseurl, array('action' => 'areaenable'));
                 $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/show', get_string('enable')));
             }
             if ($record->enabled && empty($record->locked) && count($tagcollections) > 1) {
                 $changecollurl = new moodle_url($baseurl, array('action' => 'areasetcoll'));
                 $select = new single_select($changecollurl, 'areacollid', $tagcollections, $record->tagcollid, null);
                 $select->set_label(get_string('changetagcoll', 'core_tag', $areaname), array('class' => 'accesshide'));
                 $collectionselect = $OUTPUT->render($select);
             } else {
                 $collectionselect = $tagcollectionsall[$record->tagcollid];
             }
             $this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect);
             $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param core_tag_tag|stdClass $tag
  * @param string $component
  * @param string $itemtype
  * @param string $content
  * @param bool $exclusivemode
  * @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 we need to search for items
  * @param int $rec search items in sub contexts as well
  * @param int $page
  * @param bool $totalpages
  */
 public function __construct($tag, $component, $itemtype, $content, $exclusivemode = false, $fromctx = 0, $ctx = 0, $rec = 1, $page = 0, $totalpages = 1)
 {
     $this->record = new stdClass();
     $this->tag = $tag;
     $tagareas = \core_tag_area::get_areas();
     if (!isset($tagareas[$itemtype][$component])) {
         throw new \coding_exception('Tag area for component ' . $component . ' and itemtype ' . $itemtype . ' is not defined');
     }
     $this->tagarea = $tagareas[$itemtype][$component];
     $this->record->tagid = $tag->id;
     $this->record->ta = $this->tagarea->id;
     $this->record->itemtype = $itemtype;
     $this->record->component = $component;
     $a = (object) array('tagarea' => \core_tag_area::display_name($component, $itemtype), 'tag' => \core_tag_tag::make_display_name($tag));
     if ($exclusivemode) {
         $this->record->title = get_string('itemstaggedwith', 'tag', $a);
     } else {
         $this->record->title = (string) $a->tagarea;
     }
     $this->record->content = $content;
     $this->record->nextpageurl = null;
     $this->record->prevpageurl = null;
     $this->record->exclusiveurl = null;
     $url = core_tag_tag::make_url($tag->tagcollid, $tag->rawname, $exclusivemode, $fromctx, $ctx, $rec);
     $urlparams = array('ta' => $this->tagarea->id);
     if ($totalpages > $page + 1) {
         $this->record->nextpageurl = new moodle_url($url, $urlparams + array('page' => $page + 1));
     }
     if ($page > 0) {
         $this->record->prevpageurl = new moodle_url($url, $urlparams + array('page' => $page - 1));
     }
     if (!$exclusivemode && ($totalpages > 1 || $page)) {
         $this->record->exclusiveurl = new moodle_url($url, $urlparams + array('excl' => 1));
     }
     $this->record->exclusivetext = get_string('exclusivemode', 'tag', $a);
     $this->record->hascontent = $totalpages > 1 || $page || $content;
     $this->record->anchor = $component . '_' . $itemtype;
 }
Exemplo n.º 4
0
 /**
  * Returns the list of names of areas (enabled only) that are in this collection.
  *
  * @param int $tagcollid
  * @return array
  */
 public static function get_areas_names($tagcollid, $enabledonly = true)
 {
     $allitemtypes = core_tag_area::get_areas($tagcollid, $enabledonly);
     $itemtypes = array();
     foreach ($allitemtypes as $itemtype => $it) {
         foreach ($it as $component => $v) {
             $itemtypes[$v->id] = core_tag_area::display_name($component, $itemtype);
         }
     }
     return $itemtypes;
 }
Exemplo n.º 5
0
 /**
  * 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
  */
 public function tag_index_page($tag, $entities, $tagareaid, $exclusivemode, $fromctx, $ctx, $rec, $page)
 {
     global $CFG, $OUTPUT;
     $this->page->requires->js_call_amd('core/tag', 'init_tagindex_page');
     $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;
 }