Commit 7ba73d16 authored by Tim Hunt's avatar Tim Hunt
Browse files

MDL-66553 tags: option to accesshide label when displaying a taglist

parent d30c6cdc
......@@ -4511,10 +4511,12 @@ EOD;
* @param int $limit limit the number of tags to display, if size of $tags is more than this limit the "more" link
* will be appended to the end, JS will toggle the rest of the tags
* @param context $pagecontext specify if needed to overwrite the current page context for the view tag link
* @param bool $accesshidelabel if true, the label should have class="accesshide" added.
* @return string
*/
public function tag_list($tags, $label = null, $classes = '', $limit = 10, $pagecontext = null) {
$list = new \core_tag\output\taglist($tags, $label, $classes, $limit, $pagecontext);
public function tag_list($tags, $label = null, $classes = '', $limit = 10,
$pagecontext = null, $accesshidelabel = false) {
$list = new \core_tag\output\taglist($tags, $label, $classes, $limit, $pagecontext, $accesshidelabel);
return $this->render_from_template('core_tag/taglist', $list->export_for_template($this));
}
......
......@@ -45,6 +45,9 @@ class taglist implements templatable {
/** @var string */
protected $label;
/** @var bool $accesshidelabel if true, the label should have class="accesshide" added. */
protected $accesshidelabel;
/** @var string */
protected $classes;
......@@ -59,14 +62,17 @@ class taglist implements templatable {
* to use default, set to '' (empty string) to omit the label completely
* @param string $classes additional classes for the enclosing div element
* @param int $limit limit the number of tags to display, if size of $tags is more than this limit the "more" link
* will be appended to the end, JS will toggle the rest of the tags
* will be appended to the end, JS will toggle the rest of the tags. 0 means no limit.
* @param context $pagecontext specify if needed to overwrite the current page context for the view tag link
* @param bool $accesshidelabel if true, the label should have class="accesshide" added.
*/
public function __construct($tags, $label = null, $classes = '', $limit = 10, $pagecontext = null) {
public function __construct($tags, $label = null, $classes = '',
$limit = 10, $pagecontext = null, $accesshidelabel = false) {
global $PAGE;
$canmanagetags = has_capability('moodle/tag:manage', \context_system::instance());
$this->label = ($label === null) ? get_string('tags') : $label;
$this->accesshidelabel = $accesshidelabel;
$this->classes = $classes;
$fromctx = $pagecontext ? $pagecontext->id :
(($PAGE->context->contextlevel == CONTEXT_SYSTEM) ? 0 : $PAGE->context->id);
......@@ -106,6 +112,7 @@ class taglist implements templatable {
return (object)array(
'tags' => array_values($this->tags),
'label' => $this->label,
'accesshidelabel' => $this->accesshidelabel,
'tagscount' => $cnt,
'overflow' => ($this->limit && $cnt > $this->limit) ? 1 : 0,
'classes' => $this->classes,
......
......@@ -648,7 +648,8 @@ class core_tag_tag {
* @param int[] $itemids
* @param int $standardonly wether to return only standard tags or any
* @param int $tiuserid tag instance user id, only needed for tag areas with user tagging
* @return core_tag_tag[] each object contains additional fields taginstanceid, taginstancecontextid and ordering
* @return core_tag_tag[][] first array key is itemid. For each itemid,
* an array tagid => tag object with additional fields taginstanceid, taginstancecontextid and ordering
*/
public static function get_items_tags($component, $itemtype, $itemids, $standardonly = self::BOTH_STANDARD_AND_NOT,
$tiuserid = 0) {
......
......@@ -38,6 +38,7 @@
{"id":1,"name":"Mice","viewurl":"http://moodle.org/tag/index.php?tag=Mice","isstandard":"0","flag":0}
],
"label": "Tags",
"accesshidelabel": false,
"tagscount": 3,
"overflow": 1,
"classes": "someadditionalclass"
......@@ -47,7 +48,7 @@
{{#tagscount}}
<div class="tag_list hideoverlimit {{classes}}">
{{#label}}
<b>{{label}}:</b>
<b{{#accesshidelabel}} class="accesshide"{{/accesshidelabel}}>{{label}}:</b>
{{/label}}
<ul class="inline-list">
{{#tags}}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment