MDL-50851 blocks: convert to new tag API

This commit is contained in:
Marina Glancy
2016-01-10 15:25:48 +08:00
parent b0c62e00bc
commit ac840cf487
4 changed files with 24 additions and 18 deletions
+5 -2
View File
@@ -75,7 +75,7 @@ class block_blog_tags extends block_base {
}
return $this->content;
} else if (empty($CFG->usetags)) {
} else if (!core_tag_tag::is_enabled('core', 'post')) {
$this->content = new stdClass();
$this->content->text = '';
if ($this->page->user_is_editing()) {
@@ -126,6 +126,7 @@ class block_blog_tags extends block_base {
WHERE t.id = ti.tagid AND p.id = ti.itemid
$type
AND ti.itemtype = 'post'
AND ti.component = 'core'
AND ti.timemodified > $timewithin";
if ($context->contextlevel == CONTEXT_MODULE) {
@@ -195,7 +196,9 @@ class block_blog_tags extends block_base {
}
$blogurl->param('tagid', $tag->id);
$link = html_writer::link($blogurl, tag_display_name($tag), array('class'=>$tag->class, 'title'=>get_string('numberofentries','blog',$tag->ct)));
$link = html_writer::link($blogurl, core_tag_tag::make_display_name($tag),
array('class' => $tag->class,
'title' => get_string('numberofentries', 'blog', $tag->ct)));
$this->content->text .= '<li>' . $link . '</li> ';
}
$this->content->text .= "\n</ul>\n";
+8 -6
View File
@@ -47,7 +47,6 @@ class block_tag_flickr extends block_base {
global $CFG, $USER;
//note: do NOT include files at the top of this file
require_once($CFG->dirroot.'/tag/lib.php');
require_once($CFG->libdir . '/filelib.php');
if ($this->content !== NULL) {
@@ -56,11 +55,12 @@ class block_tag_flickr extends block_base {
$tagid = optional_param('id', 0, PARAM_INT); // tag id - for backware compatibility
$tag = optional_param('tag', '', PARAM_TAG); // tag
$tc = optional_param('tc', 0, PARAM_INT); // Tag collection id.
if ($tag) {
$tagobject = tag_get('name', $tag);
} else if ($tagid) {
$tagobject = tag_get('id', $tagid);
if ($tagid) {
$tagobject = core_tag_tag::get($tagid);
} else if ($tag) {
$tagobject = core_tag_tag::get_by_name($tc, $tag);
}
if (empty($tagobject)) {
@@ -73,7 +73,9 @@ class block_tag_flickr extends block_base {
//include related tags in the photo query ?
$tagscsv = $tagobject->name;
if (!empty($this->config->includerelatedtags)) {
$tagscsv .= ',' . tag_get_related_tags_csv(tag_get_related_tags($tagobject->id), TAG_RETURN_TEXT);
foreach ($tagobject->get_related_tags() as $t) {
$tagscsv .= ',' . $t->get_display_name(false);
}
}
$tagscsv = urlencode($tagscsv);
+1 -1
View File
@@ -36,7 +36,7 @@ class block_tag_flickr_edit_form extends block_edit_form {
$mform->setType('config_title', PARAM_TEXT);
$mform->addElement('text', 'config_numberofphotos', get_string('numberofphotos', 'block_tag_flickr'), array('size' => 5));
$mform->setType('config_numberofvideos', PARAM_INT);
$mform->setType('config_numberofphotos', PARAM_INT);
$mform->addElement('selectyesno', 'config_includerelatedtags', get_string('includerelatedtags', 'block_tag_flickr'));
$mform->setDefault('config_includerelatedtags', 0);
+10 -9
View File
@@ -64,7 +64,6 @@ class block_tag_youtube extends block_base {
global $CFG;
//note: do NOT include files at the top of this file
require_once($CFG->dirroot.'/tag/lib.php');
require_once($CFG->libdir . '/filelib.php');
if ($this->content !== NULL) {
@@ -132,11 +131,12 @@ class block_tag_youtube extends block_base {
$tagid = optional_param('id', 0, PARAM_INT); // tag id - for backware compatibility
$tag = optional_param('tag', '', PARAM_TAG); // tag
$tc = optional_param('tc', 0, PARAM_INT); // Tag collection id.
if ($tag) {
$tagobject = tag_get('name', $tag);
} else if ($tagid) {
$tagobject = tag_get('id', $tagid);
if ($tagid) {
$tagobject = core_tag_tag::get($tagid);
} else if ($tag) {
$tagobject = core_tag_tag::get_by_name($tc, $tag);
}
if (empty($tagobject)) {
@@ -172,11 +172,12 @@ class block_tag_youtube extends block_base {
$tagid = optional_param('id', 0, PARAM_INT); // tag id - for backware compatibility
$tag = optional_param('tag', '', PARAM_TAG); // tag
$tc = optional_param('tc', 0, PARAM_INT); // Tag collection id.
if ($tag) {
$tagobject = tag_get('name', $tag);
} else if ($tagid) {
$tagobject = tag_get('id', $tagid);
if ($tagid) {
$tagobject = core_tag_tag::get($tagid);
} else if ($tag) {
$tagobject = core_tag_tag::get_by_name($tc, $tag);
}
if (empty($tagobject)) {