Skip to content

Commit

Permalink
MDL-50851 blocks: convert to new tag API
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Jan 10, 2016
1 parent b0c62e0 commit ac840cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
7 changes: 5 additions & 2 deletions blocks/blog_tags/block_blog_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function get_content() {
}
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()) {
Expand Down Expand Up @@ -126,6 +126,7 @@ function get_content() {
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) {
Expand Down Expand Up @@ -195,7 +196,9 @@ function get_content() {
}

$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";
Expand Down
14 changes: 8 additions & 6 deletions blocks/tag_flickr/block_tag_flickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function get_content() {
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) {
Expand All @@ -56,11 +55,12 @@ function get_content() {

$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)) {
Expand All @@ -73,7 +73,9 @@ function get_content() {
//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);

Expand Down
2 changes: 1 addition & 1 deletion blocks/tag_flickr/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function specific_definition($mform) {
$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);
Expand Down
19 changes: 10 additions & 9 deletions blocks/tag_youtube/block_tag_youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function get_content() {
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) {
Expand Down Expand Up @@ -132,11 +131,12 @@ function get_videos_by_tag(){

$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)) {
Expand Down Expand Up @@ -172,11 +172,12 @@ function get_videos_by_tag_and_category(){

$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)) {
Expand Down

0 comments on commit ac840cf

Please sign in to comment.