diff --git a/lang/en/tag.php b/lang/en/tag.php
index a575ce6dc2b58..15fc377b505ba 100644
--- a/lang/en/tag.php
+++ b/lang/en/tag.php
@@ -74,6 +74,7 @@
$string['combineselected'] = 'Combine selected';
$string['id'] = 'id';
$string['inalltagcoll'] = 'Everywhere';
+$string['inputstandardtags'] = 'Enter comma-separated list of new tags';
$string['itemstaggedwith'] = '{$a->tagarea} tagged with "{$a->tag}"';
$string['lesstags'] = 'less...';
$string['managestandardtags'] = 'Manage standard tags';
@@ -96,6 +97,7 @@
$string['relatedtags'] = 'Related tags';
$string['removetagfrommyinterests'] = 'Remove "{$a}" from my interests';
$string['reset'] = 'Tag flag reset';
+$string['resetfilter'] = 'Reset filter';
$string['resetflag'] = 'Reset flag';
$string['responsiblewillbenotified'] = 'The person responsible will be notified';
$string['rssdesc'] = 'This RSS feed was automatically generated by Moodle and contains user generated tags for courses.';
diff --git a/lib/amd/build/tag.min.js b/lib/amd/build/tag.min.js
index fa12f307e67d5..fdb2a95bf9dfb 100644
--- a/lib/amd/build/tag.min.js
+++ b/lib/amd/build/tag.min.js
@@ -1 +1 @@
-define(["jquery","core/ajax","core/templates","core/notification","core/str"],function(a,b,c,d,e){return{initTagindexPage:function(){a("body").delegate(".tagarea[data-ta] a[data-quickload=1]","click",function(d){d.preventDefault();var e=a(this),f=e.context.search.replace(/^\?/,""),g=e.closest(".tagarea[data-ta]"),h=f.split("&").reduce(function(a,b){var c=b.split("=");return a[c[0]]=decodeURIComponent(c[1]),a},{}),i=b.call([{methodname:"core_tag_get_tagindex",args:{tagindex:h}}],!0);a.when.apply(a,i).done(function(a){c.render("core_tag/index",a).done(function(a){g.replaceWith(a)})})})},initManagePage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){if(e.get_string("now").done(function(c){a(b.target).closest("tr").find("td.col-timemodified").html(c)}),"tagflag"===b.ajaxreturn.itemtype){var c=a(b.target).closest("tr");"0"===b.ajaxreturn.value?c.removeClass("flagged-tag"):c.addClass("flagged-tag")}}),a(".tag-management-table").delegate("a.tagdelete","click",function(b){b.preventDefault();var c=a(this).attr("href");e.get_strings([{key:"delete"},{key:"confirmdeletetag",component:"tag"},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=c})})}),a("#tag-management-delete").click(function(b){var c=a(this).closest("form").get(0),f=a(c).find("input[type=checkbox]:checked").length;if(!f)return!1;var g=a("").attr("name",this.name);b.preventDefault(),e.get_strings([{key:"delete"},{key:"confirmdeletetags",component:"tag"},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){g.appendTo(c),c.submit()})})}),a("#tag-management-combine").click(function(b){b.preventDefault();var c=a(this).closest("form").get(0),f=a(c).find("input[type=checkbox]:checked");if(f.length<=1)return e.get_strings([{key:"combineselected",component:"tag"},{key:"selectmultipletags",component:"tag"},{key:"ok"}]).done(function(a){d.alert(a[0],a[1],a[2])}),!1;var g=a("").attr("name",this.name);e.get_strings([{key:"combineselected",component:"tag"},{key:"selectmaintag",component:"tag"},{key:"continue"},{key:"cancel"}]).done(function(b){var d=a('
');d.find(".description").html(b[1]),d.find("#combinetags_submit").attr("value",b[2]),d.find("#combinetags_cancel").attr("value",b[3]);var e=d.find(".options");f.each(function(){var b=a(this).val(),c=a(".inplaceeditable[data-itemtype=tagname][data-itemid="+b+"]").attr("data-value");e.append(a('
"))});var h=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,headerContent:b[0],bodyContent:d.html()});h.show(),a("#combinetags_form input[type=radio]").first().focus().prop("checked",!0),a("#combinetags_form #combinetags_cancel").on("click",function(){h.destroy()}),a("#combinetags_form").on("submit",function(){g.appendTo(c);var b=a("input[name=maintag]:checked","#combinetags_form").val();return a("").attr("name","maintag").attr("value",b).appendTo(c),c.submit(),!1})})}),a("body").on("updatefailed","[data-inplaceeditable][data-itemtype=tagname]",function(b){var c=b.exception,f=b.newvalue,g=a(b.target).attr("data-itemid");"namesalreadybeeingused"===c.errorcode&&(b.preventDefault(),e.get_strings([{key:"nameuseddocombine",component:"tag"},{key:"yes"},{key:"cancel"}]).done(function(a){d.confirm(b.message,a[0],a[1],a[2],function(){window.location.href=window.location.href+"&newname="+encodeURIComponent(f)+"&tagid="+encodeURIComponent(g)+"&action=renamecombine&sesskey="+M.cfg.sesskey})}))})},initManageCollectionsPage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){var c,d,e,f=b.ajaxreturn;"core_tag"===f.component&&"tagareaenable"===f.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").addClass("hidden"),e=f.value,"1"===e?(a(this).closest("tr").removeClass("dimmed_text"),d=a(this).closest("tr").find('[data-itemtype="tagareacollection"]').attr("data-value"),a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").removeClass("hidden")):a(this).closest("tr").addClass("dimmed_text")),"core_tag"===f.component&&"tagareacollection"===f.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").addClass("hidden"),d=a(this).attr("data-value"),e=a(this).closest("tr").find('[data-itemtype="tagareaenable"]').attr("data-value"),"1"===e&&a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").removeClass("hidden"))}),a("body").on("click",".addtagcoll > a",function(b){b.preventDefault();var c=a(this).attr("data-url")+"&sesskey="+M.cfg.sesskey;e.get_strings([{key:"addtagcoll",component:"tag"},{key:"name"},{key:"searchable",component:"tag"},{key:"create"},{key:"cancel"}]).done(function(b){var d=a('');d.find('label[for="addtagcoll_name"]').html(b[1]),d.find('label[for="addtagcoll_searchable"]').html(b[2]),d.find("#addtagcoll_submit").attr("value",b[3]),d.find("#addtagcoll_cancel").attr("value",b[4]);var e=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,headerContent:b[0],bodyContent:d.html()});e.show(),a("#addtagcoll_form #addtagcoll_name").focus(),a("#addtagcoll_form #addtagcoll_cancel").on("click",function(){e.destroy()}),a("#addtagcoll_form").on("submit",function(){var b=a("#addtagcoll_form #addtagcoll_name").val(),d=a("#addtagcoll_form #addtagcoll_searchable").prop("checked")?1:0;return String(b).length>0&&(window.location.href=c+"&name="+encodeURIComponent(b)+"&searchable="+d),!1})})}),a("body").on("click",".tag-collections-table .action_delete",function(b){b.preventDefault();var c=a(this).attr("data-url")+"&sesskey="+M.cfg.sesskey;e.get_strings([{key:"delete"},{key:"suredeletecoll",component:"tag",param:a(this).attr("data-collname")},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=c})})})}}});
\ No newline at end of file
+define(["jquery","core/ajax","core/templates","core/notification","core/str"],function(a,b,c,d,e){return{initTagindexPage:function(){a("body").delegate(".tagarea[data-ta] a[data-quickload=1]","click",function(d){d.preventDefault();var e=a(this),f=e.context.search.replace(/^\?/,""),g=e.closest(".tagarea[data-ta]"),h=f.split("&").reduce(function(a,b){var c=b.split("=");return a[c[0]]=decodeURIComponent(c[1]),a},{}),i=b.call([{methodname:"core_tag_get_tagindex",args:{tagindex:h}}],!0);a.when.apply(a,i).done(function(a){c.render("core_tag/index",a).done(function(a){g.replaceWith(a)})})})},initManagePage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){if(e.get_string("now").done(function(c){a(b.target).closest("tr").find("td.col-timemodified").html(c)}),"tagflag"===b.ajaxreturn.itemtype){var c=a(b.target).closest("tr");"0"===b.ajaxreturn.value?c.removeClass("flagged-tag"):c.addClass("flagged-tag")}}),a(".tag-management-table").delegate("a.tagdelete","click",function(b){b.preventDefault();var c=a(this).attr("href");e.get_strings([{key:"delete"},{key:"confirmdeletetag",component:"tag"},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=c})})}),a("#tag-management-delete").click(function(b){var c=a(this).closest("form").get(0),f=a(c).find("input[type=checkbox]:checked").length;if(!f)return!1;var g=a("").attr("name",this.name);b.preventDefault(),e.get_strings([{key:"delete"},{key:"confirmdeletetags",component:"tag"},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){g.appendTo(c),c.submit()})})}),a("#tag-management-combine").click(function(b){b.preventDefault();var c=a(this).closest("form").get(0),f=a(c).find("input[type=checkbox]:checked");if(f.length<=1)return e.get_strings([{key:"combineselected",component:"tag"},{key:"selectmultipletags",component:"tag"},{key:"ok"}]).done(function(a){d.alert(a[0],a[1],a[2])}),!1;var g=a("").attr("name",this.name);e.get_strings([{key:"combineselected",component:"tag"},{key:"selectmaintag",component:"tag"},{key:"continue"},{key:"cancel"}]).done(function(b){var d=a('');d.find(".description").html(b[1]),d.find("#combinetags_submit").attr("value",b[2]),d.find("#combinetags_cancel").attr("value",b[3]);var e=d.find(".options");f.each(function(){var b=a(this).val(),c=a(".inplaceeditable[data-itemtype=tagname][data-itemid="+b+"]").attr("data-value");e.append(a('
"))});var h=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,headerContent:b[0],bodyContent:d.html()});h.show(),a("#combinetags_form input[type=radio]").first().focus().prop("checked",!0),a("#combinetags_form #combinetags_cancel").on("click",function(){h.destroy()}),a("#combinetags_form").on("submit",function(){g.appendTo(c);var b=a("input[name=maintag]:checked","#combinetags_form").val();return a("").attr("name","maintag").attr("value",b).appendTo(c),c.submit(),!1})})}),a("body").on("updatefailed","[data-inplaceeditable][data-itemtype=tagname]",function(b){var c=b.exception,f=b.newvalue,g=a(b.target).attr("data-itemid");"namesalreadybeeingused"===c.errorcode&&(b.preventDefault(),e.get_strings([{key:"nameuseddocombine",component:"tag"},{key:"yes"},{key:"cancel"}]).done(function(a){d.confirm(b.message,a[0],a[1],a[2],function(){window.location.href=window.location.href+"&newname="+encodeURIComponent(f)+"&tagid="+encodeURIComponent(g)+"&action=renamecombine&sesskey="+M.cfg.sesskey})}))}),a("body").on("click","a[data-action=addstandardtag]",function(b){b.preventDefault(),e.get_strings([{key:"addotags",component:"tag"},{key:"inputstandardtags",component:"tag"},{key:"continue"},{key:"cancel"}]).done(function(b){var c=a('');c.find("#addtags_form").attr("action",window.location.href),c.find("#addtags_submit").attr("value",b[2]),c.find("#addtags_cancel").attr("value",b[3]);var d=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,headerContent:b[0],bodyContent:c.html()});d.show(),a("#addtags_form input[type=text]").focus(),a("#addtags_form #addtags_cancel").on("click",function(){d.destroy()})})})},initManageCollectionsPage:function(){a("body").on("updated","[data-inplaceeditable]",function(b){var c,d,e,f=b.ajaxreturn;"core_tag"===f.component&&"tagareaenable"===f.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").addClass("hidden"),e=f.value,"1"===e?(a(this).closest("tr").removeClass("dimmed_text"),d=a(this).closest("tr").find('[data-itemtype="tagareacollection"]').attr("data-value"),a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").removeClass("hidden")):a(this).closest("tr").addClass("dimmed_text")),"core_tag"===f.component&&"tagareacollection"===f.itemtype&&(c=a(this).attr("data-itemid"),a(".tag-collections-table ul[data-collectionid] li[data-areaid="+c+"]").addClass("hidden"),d=a(this).attr("data-value"),e=a(this).closest("tr").find('[data-itemtype="tagareaenable"]').attr("data-value"),"1"===e&&a(".tag-collections-table ul[data-collectionid="+d+"] li[data-areaid="+c+"]").removeClass("hidden"))}),a("body").on("click",".addtagcoll > a",function(b){b.preventDefault();var c=a(this).attr("data-url")+"&sesskey="+M.cfg.sesskey;e.get_strings([{key:"addtagcoll",component:"tag"},{key:"name"},{key:"searchable",component:"tag"},{key:"create"},{key:"cancel"}]).done(function(b){var d=a('');d.find('label[for="addtagcoll_name"]').html(b[1]),d.find('label[for="addtagcoll_searchable"]').html(b[2]),d.find("#addtagcoll_submit").attr("value",b[3]),d.find("#addtagcoll_cancel").attr("value",b[4]);var e=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,headerContent:b[0],bodyContent:d.html()});e.show(),a("#addtagcoll_form #addtagcoll_name").focus(),a("#addtagcoll_form #addtagcoll_cancel").on("click",function(){e.destroy()}),a("#addtagcoll_form").on("submit",function(){var b=a("#addtagcoll_form #addtagcoll_name").val(),d=a("#addtagcoll_form #addtagcoll_searchable").prop("checked")?1:0;return String(b).length>0&&(window.location.href=c+"&name="+encodeURIComponent(b)+"&searchable="+d),!1})})}),a("body").on("click",".tag-collections-table .action_delete",function(b){b.preventDefault();var c=a(this).attr("data-url")+"&sesskey="+M.cfg.sesskey;e.get_strings([{key:"delete"},{key:"suredeletecoll",component:"tag",param:a(this).attr("data-collname")},{key:"yes"},{key:"no"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){window.location.href=c})})})}}});
\ No newline at end of file
diff --git a/lib/amd/src/tag.js b/lib/amd/src/tag.js
index 01cad6888f080..bb8196245e40b 100644
--- a/lib/amd/src/tag.js
+++ b/lib/amd/src/tag.js
@@ -196,6 +196,41 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
});
}
});
+
+ // Form for adding standard tags.
+ $('body').on('click', 'a[data-action=addstandardtag]', function(e) {
+ e.preventDefault();
+ str.get_strings([
+ {key : 'addotags', component : 'tag'},
+ {key : 'inputstandardtags', component : 'tag'},
+ {key : 'continue'},
+ {key : 'cancel'},
+ ]).done(function(s) {
+ var el = $('');
+ el.find('#addtags_form').attr('action', window.location.href);
+ el.find('#addtags_submit').attr('value', s[2]);
+ el.find('#addtags_cancel').attr('value', s[3]);
+ var panel = new M.core.dialogue ({
+ draggable: true,
+ modal: true,
+ closeButton: true,
+ headerContent: s[0],
+ bodyContent: el.html()
+ });
+ panel.show();
+ $('#addtags_form input[type=text]').focus();
+ $('#addtags_form #addtags_cancel').on('click', function() {
+ panel.destroy();
+ });
+ });
+ });
},
/**
diff --git a/mod/wiki/tests/behat/edit_tags.feature b/mod/wiki/tests/behat/edit_tags.feature
index 87931c42a880d..c36897866abfa 100644
--- a/mod/wiki/tests/behat/edit_tags.feature
+++ b/mod/wiki/tests/behat/edit_tags.feature
@@ -44,14 +44,16 @@ Feature: Edited wiki pages handle tags correctly
Then I should see "Cool" in the ".form-autocomplete-selection" "css_element"
And I press "Cancel"
+ @javascript
Scenario: Wiki page edition of standard tags works as expected
Given I log in as "admin"
And I expand "Site administration" node
And I expand "Appearance" node
And I follow "Manage tags"
And I follow "Default collection"
- And I set the field "otagsadd" to "OT1, OT2, OT3"
- And I press "Add standard tags"
+ And I follow "Add standard tags"
+ And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3"
+ And I press "Continue"
And I log out
And I log in as "student1"
And I follow "Course 1"
diff --git a/tag/classes/manage_table.php b/tag/classes/manage_table.php
index b01e2c6dcba9d..ed2e88abd8505 100644
--- a/tag/classes/manage_table.php
+++ b/tag/classes/manage_table.php
@@ -54,8 +54,9 @@ public function __construct($tagcollid) {
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
+ $filter = optional_param('filter', '', PARAM_NOTAGS);
$baseurl = new moodle_url('/tag/manage.php', array('tc' => $tagcollid,
- 'perpage' => $perpage, 'page' => $page));
+ 'perpage' => $perpage, 'page' => $page, 'filter' => $filter));
$tablecolumns = array('select', 'name', 'fullname', 'count', 'flag', 'timemodified', 'isstandard', 'controls');
$tableheaders = array(get_string('select', 'tag'),
@@ -88,9 +89,9 @@ public function __construct($tagcollid) {
$this->set_attribute('id', 'tag-management-list');
$this->set_attribute('class', 'admintable generaltable tag-management-table');
- $totalcount = "SELECT COUNT(id)
- FROM {tag}
- WHERE tagcollid = :tagcollid";
+ $totalcount = "SELECT COUNT(tg.id)
+ FROM {tag} tg
+ WHERE tg.tagcollid = :tagcollid";
$params = array('tagcollid' => $this->tagcollid);
$this->set_count_sql($totalcount, $params);
@@ -103,6 +104,19 @@ public function __construct($tagcollid) {
}
+ /**
+ * @return string sql to add to where statement.
+ */
+ function get_sql_where() {
+ $filter = optional_param('filter', '', PARAM_NOTAGS);
+ list($wsql, $wparams) = parent::get_sql_where();
+ if ($filter !== '') {
+ $wsql .= ($wsql ? ' AND ' : '') . 'tg.name LIKE :tagfilter';
+ $wparams['tagfilter'] = '%' . $filter . '%';
+ }
+ return array($wsql, $wparams);
+ }
+
/**
* Query the db. Store results in the table object for use by build_table.
*
diff --git a/tag/manage.php b/tag/manage.php
index c08a456abd9ee..968c12fd37889 100644
--- a/tag/manage.php
+++ b/tag/manage.php
@@ -38,6 +38,7 @@
$page = optional_param('page', 0, PARAM_INT);
$tagcollid = optional_param('tc', 0, PARAM_INT);
$tagareaid = optional_param('ta', null, PARAM_INT);
+$filter = optional_param('filter', '', PARAM_NOTAGS);
$params = array();
if ($perpage != DEFAULT_PAGE_SIZE) {
@@ -49,6 +50,9 @@
if ($tagcollid) {
$params['tc'] = $tagcollid;
}
+if ($filter !== '') {
+ $params['filter'] = $filter;
+}
admin_externalpage_setup('managetags', '', $params, '', array('pagelayout' => 'report'));
@@ -163,8 +167,8 @@
require_sesskey();
$tagobjects = array();
if ($tagcoll) {
- $otagsadd = optional_param('otagsadd', '', PARAM_RAW);
- $newtags = preg_split('/\s*,\s*/', trim($otagsadd), -1, PREG_SPLIT_NO_EMPTY);
+ $tagslist = optional_param('tagslist', '', PARAM_RAW);
+ $newtags = preg_split('/\s*,\s*/', trim($tagslist), -1, PREG_SPLIT_NO_EMPTY);
$tagobjects = core_tag_tag::create_if_missing($tagcoll->id, $newtags, true);
}
foreach ($tagobjects as $tagobject) {
@@ -202,21 +206,24 @@
// 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('