本文整理汇总了PHP中tag_display_name函数的典型用法代码示例。如果您正苦于以下问题:PHP tag_display_name函数的具体用法?PHP tag_display_name怎么用?PHP tag_display_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tag_display_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_header
function print_header()
{
global $USER, $CFG;
$tagname = tag_display_name($this->tag_object);
$navlinks = array();
$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
$navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
$navigation = build_navigation($navlinks);
$title = get_string('tag', 'tag') . ' - ' . $tagname;
$button = '';
if ($this->user_allowed_editing()) {
$button = update_tag_button($this->id);
}
print_header_simple($title, '', $navigation, '', '', '', $button);
}
示例2: get_videos_by_tag_and_category
function get_videos_by_tag_and_category()
{
$tagid = optional_param('id', 0, PARAM_INT);
// tag id
$query_tag = tag_display_name(tag_by_id($tagid));
$query_tag = urlencode($query_tag);
$numberofvideos = DEFAULT_NUMBER_OF_VIDEOS;
if (!empty($this->config->numberofvideos)) {
$numberofvideos = $this->config->numberofvideos;
}
$request = 'http://www.youtube.com/api2_rest?method=youtube.videos.list_by_category_and_tag';
$request .= '&category_id=' . $this->config->category;
$request .= '&dev_id=' . YOUTUBE_DEV_KEY;
$request .= "&tag={$query_tag}";
$request .= "&page=1";
$request .= "&per_page={$numberofvideos}";
return $this->fetch_request($request);
}
示例3: tag_get_related_tags_csv
/**
* Get a comma-separated list of tags related to another tag.
*
* @param array $related_tags the array returned by tag_get_related_tags
* @param int $html either TAG_RETURN_HTML (default) or TAG_RETURN_TEXT : return html links, or just text.
* @return string comma-separated list
*/
function tag_get_related_tags_csv($related_tags, $html = TAG_RETURN_HTML)
{
global $CFG;
$tags_names = array();
foreach ($related_tags as $tag) {
if ($html == TAG_RETURN_TEXT) {
$tags_names[] = tag_display_name($tag, TAG_RETURN_TEXT);
} else {
// TAG_RETURN_HTML
$tags_names[] = '<a href="' . $CFG->wwwroot . '/tag/index.php?tag=' . rawurlencode($tag->name) . '">' . tag_display_name($tag) . '</a>';
}
}
return implode(', ', $tags_names);
}
示例4: tag_get
if ($tag_name) {
$tag = tag_get('name', $tag_name, '*');
} else {
if ($tag_id) {
$tag = tag_get('id', $tag_id, '*');
}
}
if (empty($tag)) {
redirect($CFG->wwwroot . '/tag/search.php');
}
$PAGE->set_url('/tag/index.php', array('id' => $tag->id));
$PAGE->set_subpage($tag->id);
$PAGE->set_context($systemcontext);
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
$PAGE->set_pagelayout('base');
$tagname = tag_display_name($tag);
// set the relatedtags field of the $tag object that will be passed to the form
$tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
$options = new stdClass();
$options->smiley = false;
$options->filter = false;
// convert and remove any XSS
$tag->description = format_text($tag->description, $tag->descriptionformat, $options);
$tag->descriptionformat = FORMAT_HTML;
$errorstring = '';
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id));
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
$tagform = new tag_edit_form(null, compact('editoroptions'));
if ($tag->tagtype == 'official') {
$tag->tagtype = '1';
} else {
示例5: get_content
function get_content()
{
global $CFG, $SITE, $USER, $DB, $OUTPUT;
if (empty($CFG->usetags) || empty($CFG->bloglevel)) {
$this->content->text = '';
if ($this->page->user_is_editing()) {
$this->content->text = get_string('tagsaredisabled', 'tag');
}
return $this->content;
}
if (empty($this->config->timewithin)) {
$this->config->timewithin = BLOGDEFAULTTIMEWITHIN;
}
if (empty($this->config->numberoftags)) {
$this->config->numberoftags = BLOGDEFAULTNUMBEROFTAGS;
}
if (empty($this->config->sort)) {
$this->config->sort = BLOGDEFAULTSORT;
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
/// Get a list of tags
$timewithin = time() - $this->config->timewithin * 24 * 60 * 60;
/// convert to seconds
$context = $this->page->context;
// admins should be able to read all tags
$type = '';
if (!has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
$type = " AND (p.publishstate = 'site' or p.publishstate='public')";
}
$sql = "SELECT t.id, t.tagtype, t.rawname, t.name, COUNT(DISTINCT ti.id) AS ct\n FROM {tag} t, {tag_instance} ti, {post} p, {blog_association} ba\n WHERE t.id = ti.tagid AND p.id = ti.itemid\n {$type}\n AND ti.itemtype = 'post'\n AND ti.timemodified > {$timewithin}";
if ($context->contextlevel == CONTEXT_MODULE) {
$sql .= " AND ba.contextid = {$context->id} AND p.id = ba.blogid ";
} else {
if ($context->contextlevel == CONTEXT_COURSE) {
$sql .= " AND ba.contextid = {$context->id} AND p.id = ba.blogid ";
}
}
$sql .= "\n GROUP BY t.id, t.tagtype, t.name, t.rawname\n ORDER BY ct DESC, t.name ASC";
if ($tags = $DB->get_records_sql($sql, null, 0, $this->config->numberoftags)) {
/// There are 2 things to do:
/// 1. tags with the same count should have the same size class
/// 2. however many tags we have should be spread evenly over the
/// 20 size classes
$totaltags = count($tags);
$currenttag = 0;
$size = 20;
$lasttagct = -1;
$etags = array();
foreach ($tags as $tag) {
$currenttag++;
if ($currenttag == 1) {
$lasttagct = $tag->ct;
$size = 20;
} else {
if ($tag->ct != $lasttagct) {
$lasttagct = $tag->ct;
$size = 20 - (int) (($currenttag - 1) / $totaltags * 20);
}
}
$tag->class = "{$tag->tagtype} s{$size}";
$etags[] = $tag;
}
/// Now we sort the tag display order
$CFG->tagsort = $this->config->sort;
usort($etags, "blog_tags_sort");
/// Finally we create the output
/// Accessibility: markup as a list.
$this->content->text .= "\n<ul class='inline-list'>\n";
foreach ($etags as $tag) {
$blogurl = new moodle_url('/blog/index.php');
switch ($CFG->bloglevel) {
case BLOG_USER_LEVEL:
$blogurl->param('userid', $USER->id);
break;
default:
if ($context->contextlevel == CONTEXT_MODULE) {
$blogurl->param('modid', $context->instanceid);
} else {
if ($context->contextlevel == CONTEXT_COURSE) {
$blogurl->param('courseid', $context->instanceid);
}
}
break;
}
$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)));
$this->content->text .= '<li>' . $link . '</li> ';
}
$this->content->text .= "\n</ul>\n";
}
return $this->content;
}
示例6: list
list($where, $params) = $table->get_sql_where();
if ($where) {
$where = 'WHERE ' . $where;
}
$query = "\n SELECT tg.id, tg.name, tg.rawname, tg.tagtype, tg.flag, tg.timemodified,\n u.id AS owner, u.firstname, u.lastname,\n COUNT(ti.id) AS count\n FROM {tag} tg\n LEFT JOIN {tag_instance} ti ON ti.tagid = tg.id\n LEFT JOIN {user} u ON u.id = tg.userid\n {$where}\n GROUP BY tg.id, tg.name, tg.rawname, tg.tagtype, tg.flag, tg.timemodified,\n u.id, u.firstname, u.lastname\n {$sort}";
$totalcount = $DB->count_records_sql("\n SELECT COUNT(DISTINCT(tg.id))\n FROM {tag} tg\n LEFT JOIN {user} u ON u.id = tg.userid\n {$where}", $params);
$table->initialbars(true);
// always initial bars
$table->pagesize($perpage, $totalcount);
echo '<form class="tag-management-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php"><div>';
//retrieve tags from DB
if ($tagrecords = $DB->get_records_sql($query, $params, $table->get_page_start(), $table->get_page_size())) {
//populate table with data
foreach ($tagrecords as $tag) {
$id = $tag->id;
$name = '<a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $tag->id . '">' . tag_display_name($tag) . '</a>';
$owner = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $tag->owner . '">' . fullname($tag) . '</a>';
$count = $tag->count;
$flag = $tag->flag;
$timemodified = format_time(time() - $tag->timemodified);
$checkbox = '<input type="checkbox" name="tagschecked[]" value="' . $tag->id . '" />';
$text = html_writer::label(get_string('newname', 'tag'), 'newname_' . $tag->id, false, array('class' => 'accesshide'));
$text .= '<input type="text" id="newname_' . $tag->id . '" name="newname[' . $tag->id . ']" />';
$tagtype = html_writer::label(get_string('tagtype', 'tag'), 'menutagtypes' . $tag->id, false, array('class' => 'accesshide'));
$tagtype .= html_writer::select($existing_tagtypes, 'tagtypes[' . $tag->id . ']', $tag->tagtype, false, array('id' => 'menutagtypes' . $tag->id));
//if the tag if flagged, highlight it
if ($tag->flag > 0) {
$id = '<span class="flagged-tag">' . $id . '</span>';
$name = '<span class="flagged-tag">' . $name . '</span>';
$owner = '<span class="flagged-tag">' . $owner . '</span>';
$count = '<span class="flagged-tag">' . $count . '</span>';
示例7: define
/**
* @package core
* @subpackage tag
* @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('AJAX_SCRIPT', true);
require_once '../config.php';
require_once 'lib.php';
if (empty($CFG->usetags)) {
// Tags are disabled.
die;
}
require_login(0, false);
if (isguestuser()) {
// Guests should not be using this.
die;
}
// If a user cannot edit tags, they cannot add related tags which is what this auto complete is for.
require_capability('moodle/tag:edit', context_system::instance());
$query = optional_param('query', '', PARAM_TAG);
echo $OUTPUT->header();
// Limit the query to a minimum of 3 characters.
$similartags = array();
if (core_text::strlen($query) >= 3) {
$similartags = tag_autocomplete($query);
}
foreach ($similartags as $tag) {
echo clean_param($tag->name, PARAM_TAG) . "\t" . tag_display_name($tag) . "\n";
}
echo $OUTPUT->footer();
示例8: get_all_user_name_fields
$allusernames = get_all_user_name_fields(true, 'u');
$query = "\n SELECT tg.id, tg.name, tg.rawname, tg.tagtype, tg.flag, tg.timemodified,\n u.id AS owner, {$allusernames},\n COUNT(ti.id) AS count\n FROM {tag} tg\n LEFT JOIN {tag_instance} ti ON ti.tagid = tg.id\n LEFT JOIN {user} u ON u.id = tg.userid\n {$where}\n GROUP BY tg.id, tg.name, tg.rawname, tg.tagtype, tg.flag, tg.timemodified,\n u.id, u.firstname, u.lastname\n {$sort}";
$totalcount = $DB->count_records_sql("\n SELECT COUNT(DISTINCT(tg.id))\n FROM {tag} tg\n LEFT JOIN {user} u ON u.id = tg.userid\n {$where}", $params);
$table->initialbars(true);
// always initial bars
$table->pagesize($perpage, $totalcount);
//@todo MDL-35474 convert to mform
echo '<form class="tag-management-form" method="post" action="' . $CFG->wwwroot . '/tag/manage.php"><div>';
//retrieve tags from DB
if ($tagrecords = $DB->get_records_sql($query, $params, $table->get_page_start(), $table->get_page_size())) {
//populate table with data
foreach ($tagrecords as $tag) {
$id = $tag->id;
$params = array('id' => $tag->id);
$taglink = new moodle_url($CFG->wwwroot . '/tag/index.php', $params);
$name = html_writer::link($taglink, tag_display_name($tag));
$params = array('id' => $tag->owner);
$ownerlink = new moodle_url($CFG->wwwroot . '/user/view.php', $params);
$owner = html_writer::link($ownerlink, fullname($tag));
$count = $tag->count;
$flag = $tag->flag;
$timemodified = format_time(time() - $tag->timemodified);
$checkbox = html_writer::tag('input', '', array('type' => 'checkbox', 'name' => 'tagschecked[]', 'value' => $tag->id));
$attrs = array('type' => 'text', 'id' => 'newname_' . $tag->id, 'name' => 'newname[' . $tag->id . ']');
$text = html_writer::label(get_string('newname', 'tag'), 'newname_' . $tag->id, false, array('class' => 'accesshide'));
$text .= html_writer::empty_tag('input', $attrs);
$tagtype = html_writer::label(get_string('tagtype', 'tag'), 'menutagtypes' . $tag->id, false, array('class' => 'accesshide'));
$tagtype .= html_writer::select($existing_tagtypes, 'tagtypes[' . $tag->id . ']', $tag->tagtype, false, array('id' => 'menutagtypes' . $tag->id));
//if the tag if flagged, highlight it
if ($tag->flag > 0) {
$id = html_writer::tag('span', $id, array('class' => 'flagged-tag'));
示例9: require_login
<?php
// $Id: tag_autocomplete.php,v 1.3 2007/09/16 21:24:13 skodak Exp $
require_once '../config.php';
require_once 'lib.php';
require_login();
if (empty($CFG->usetags)) {
error(get_string('tagsaredisabled', 'tag'));
}
$query = optional_param('query', '', PARAM_TAG);
if ($similar_tags = similar_tags($query)) {
foreach ($similar_tags as $tag) {
echo tag_display_name($tag) . "\t" . $tag->id . "\n";
}
}
示例10: require_login
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package core
* @subpackage tag
* @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../config.php';
require_once 'lib.php';
require_login();
if (empty($CFG->usetags)) {
print_error('tagsaredisabled', 'tag');
}
$query = optional_param('query', '', PARAM_RAW);
if ($similar_tags = tag_autocomplete($query)) {
foreach ($similar_tags as $tag) {
echo $tag->name . "\t" . tag_display_name($tag) . "\n";
}
}
示例11: get_content
function get_content()
{
global $CFG, $USER, $PAGE;
if ($this->content !== NULL) {
return $this->content;
}
$tagid = optional_param('id', 0, PARAM_INT);
// tag id
//include related tags in the photo query ?
$tags_csv = tag_display_name(tag_by_id($tagid));
if (!empty($this->config->includerelatedtags)) {
$tags_csv .= ',' . tag_names_csv(get_item_tags('tag', $tagid));
}
$tags_csv = urlencode($tags_csv);
//number of photos to display
$numberofphotos = DEFAULT_NUMBER_OF_PHOTOS;
if (!empty($this->config->numberofphotos)) {
$numberofphotos = $this->config->numberofphotos;
}
//sort search results by
$sortby = 'relevance';
if (!empty($this->config->sortby)) {
$sortby = $this->config->sortby;
}
//pull photos from a specific photoset
if (!empty($this->config->photoset)) {
$request = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos';
$request .= '&api_key=' . FLICKR_DEV_KEY;
$request .= '&photoset_id=' . $this->config->photoset;
$request .= '&per_page=' . $numberofphotos;
$request .= '&format=php_serial';
$response = $this->fetch_request($request);
$search = unserialize($response);
foreach ($search['photoset']['photo'] as $p) {
$p['owner'] = $search['photoset']['owner'];
}
$photos = array_values($search['photoset']['photo']);
} else {
$request = 'http://api.flickr.com/services/rest/?method=flickr.photos.search';
$request .= '&api_key=' . FLICKR_DEV_KEY;
$request .= '&tags=' . $tags_csv;
$request .= '&per_page=' . $numberofphotos;
$request .= '&sort=' . $sortby;
$request .= '&format=php_serial';
$response = $this->fetch_request($request);
$search = unserialize($response);
$photos = array_values($search['photos']['photo']);
}
if (strcmp($search['stat'], 'ok') != 0) {
return;
}
//if no results were returned, exit...
//render the list of photos
$text = '';
foreach ($photos as $photo) {
$text .= '<a href="http://www.flickr.com/photos/' . $photo['owner'] . '/' . $photo['id'] . '/">';
$text .= '<img title="' . s($photo['title']) . '" alt="' . s($photo['title']) . '" class="flickr-photos" src="' . $this->build_photo_url($photo, 'square') . '" /></a>';
}
$this->content = new stdClass();
$this->content->text = $text;
$this->content->footer = '';
return $this->content;
}
示例12: tag_get
// tag id
if ($tagid) {
$tag = tag_get('id', $tagid, '*');
} else {
redirect($CFG->wwwroot . '/tag/search.php');
}
/// Print the page header
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
} else {
$navigation = '';
}
$navlinks = array();
$navlinks[] = array('name' => get_string('tags'), 'link' => $CFG->wwwroot . '/tag/search.php', 'type' => 'misc');
$navlinks[] = array('name' => format_string(tag_display_name($tag)), 'link' => $CFG->wwwroot . '/mod/wiki/tags/view.php?;amp;cid=' . $cid . '&tagid=' . $tagid, 'type' => 'misc');
$navigation = build_navigation($navlinks);
$title = get_string('tag', 'tag') . ' - ' . tag_display_name($tag);
print_header($title, $course->fullname, $navigation);
$modcontext = get_context_instance(CONTEXT_MODULE, $cmid);
if (has_capability('moodle/tag:manage', $modcontext)) {
//echo '<div class="managelink"><a href="'.$CFG->wwwroot.
echo '<div style="text-align:right; padding:10px;"><a href="' . $CFG->wwwroot . '/tag/manage.php">' . get_string('managetags', 'tag') . '</a></div>';
}
/// Print the page content
echo '<br/>';
print_heading(tag_display_name($tag), '', 2, 'headingblock header tag-heading');
tag_print_management_box($tag);
tag_print_description_box($tag);
wiki_tags_print_wikipages($tag);
//// Print the page footer
print_footer($course);
示例13: get_content
function get_content()
{
global $CFG, $SITE, $USER, $DB;
if (empty($CFG->usetags) || empty($CFG->bloglevel)) {
$this->content->text = '';
return $this->content;
}
if (empty($this->config->timewithin)) {
$this->config->timewithin = BLOGDEFAULTTIMEWITHIN;
}
if (empty($this->config->numberoftags)) {
$this->config->numberoftags = BLOGDEFAULTNUMBEROFTAGS;
}
if (empty($this->config->sort)) {
$this->config->sort = BLOGDEFAULTSORT;
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
/// Get a list of tags
$timewithin = time() - $this->config->timewithin * 24 * 60 * 60;
/// convert to seconds
// admins should be able to read all tags
$type = '';
if (!has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
$type = " AND (p.publishstate = 'site' or p.publishstate='public')";
}
$sql = "SELECT t.id, t.tagtype, t.rawname, t.name, COUNT(DISTINCT ti.id) AS ct\n FROM {tag} t, {tag_instance} ti, {post} p\n WHERE t.id = ti.tagid AND p.id = ti.itemid\n {$type}\n AND ti.itemtype = 'post'\n AND ti.timemodified > {$timewithin}\n GROUP BY t.id, t.tagtype, t.name, t.rawname\n ORDER BY ct DESC, t.name ASC";
if ($tags = $DB->get_records_sql($sql, null, 0, $this->config->numberoftags)) {
/// There are 2 things to do:
/// 1. tags with the same count should have the same size class
/// 2. however many tags we have should be spread evenly over the
/// 20 size classes
$totaltags = count($tags);
$currenttag = 0;
$size = 20;
$lasttagct = -1;
$etags = array();
foreach ($tags as $tag) {
$currenttag++;
if ($currenttag == 1) {
$lasttagct = $tag->ct;
$size = 20;
} else {
if ($tag->ct != $lasttagct) {
$lasttagct = $tag->ct;
$size = 20 - (int) (($currenttag - 1) / $totaltags * 20);
}
}
$tag->class = "{$tag->tagtype} s{$size}";
$etags[] = $tag;
}
/// Now we sort the tag display order
$CFG->tagsort = $this->config->sort;
usort($etags, "blog_tags_sort");
/// Finally we create the output
/// Accessibility: markup as a list.
$this->content->text .= "\n<ul class='inline-list'>\n";
foreach ($etags as $tag) {
switch ($CFG->bloglevel) {
case BLOG_USER_LEVEL:
$filtertype = 'user';
$filterselect = $USER->id;
break;
default:
if ($this->page->course->id != SITEID) {
$filtertype = 'course';
$filterselect = $this->page->course->id;
} else {
$filtertype = 'site';
$filterselect = SITEID;
}
break;
}
$link = blog_get_blogs_url(array($filtertype => $filterselect, 'tag' => $tag->id));
$this->content->text .= '<li><a href="' . $link . '" ' . 'class="' . $tag->class . '" ' . 'title="' . get_string('numberofentries', 'blog', $tag->ct) . '">' . tag_display_name($tag) . '</a></li> ';
}
$this->content->text .= "\n</ul>\n";
}
return $this->content;
}
示例14: get_set_tags
/**
* Call to get forum wide 'set' tags.
*
* @param int $forumid used to get context id
* @param int $groupid used to specify group that we require set tags for
* @param boolean $grouponly used to specify whether we are returning set tags for a single specified group
* @return array set tags for that forum
*/
public static function get_set_tags($forumid, $groupid = self::ALL_GROUPS, $grouponly = false)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/tag/lib.php';
$forum = self::get_from_id($forumid, self::CLONE_DIRECT);
$forumid = $forum->get_id();
$context = $forum->get_context(true);
if ($groupid == self::ALL_GROUPS || $groupid == self::NO_GROUPS) {
$groupid = 0;
}
$conditionparams = array();
$conditions = '';
if ($grouponly && $groupid) {
$conditions .= " (ti.component = ? AND ti.itemtype = ? AND ti.contextid = ? AND ti.itemid = ?)";
$conditionparams[] = 'mod_forumng';
$conditionparams[] = 'groups';
$conditionparams[] = $context->id;
$conditionparams[] = $groupid;
} else {
// Check to see whether tags have been set at forumng level.
$conditions = "(ti.component = ? AND ti.itemtype = ? AND ti.contextid = ? AND ti.itemid = ?)";
$conditionparams[] = 'mod_forumng';
$conditionparams[] = 'forumng';
$conditionparams[] = $context->id;
$conditionparams[] = $forumid;
if ($groupid) {
$conditions .= " OR (ti.component = ? AND ti.itemtype = ? AND ti.contextid = ? AND ti.itemid = ?)";
$conditionparams[] = 'mod_forumng';
$conditionparams[] = 'groups';
$conditionparams[] = $context->id;
$conditionparams[] = $groupid;
}
}
$rs = $DB->get_records_sql("\n SELECT DISTINCT t.*\n FROM {tag} t\n INNER JOIN {tag_instance} ti\n ON t.id = ti.tagid\n WHERE {$conditions}\n ORDER BY t.name", $conditionparams);
// Create tags associative array with tagid as key and tag name as value.
$tags = array();
foreach ($rs as $tag) {
$tags[$tag->id] = strtolower(tag_display_name($tag, TAG_RETURN_TEXT));
}
return $tags;
}
示例15: tag_print_search_results
/**
* Prints the tag search results
*
* @param string $query text that tag names will be matched against
* @param int $page current page
* @param int $perpage nr of users displayed per page
* @param $return if true return html string
*/
function tag_print_search_results($query, $page, $perpage, $return = false)
{
global $CFG, $USER;
$query = array_shift(tag_normalize($query, TAG_CASE_ORIGINAL));
$count = sizeof(tag_find_tags($query, false));
$tags = array();
if ($found_tags = tag_find_tags($query, true, $page * $perpage, $perpage)) {
$tags = array_values($found_tags);
}
$baseurl = $CFG->wwwroot . '/tag/search.php?query=' . rawurlencode($query);
$output = '';
// link "Add $query to my interests"
$addtaglink = '';
if (!tag_record_tagged_with('user', $USER->id, $query)) {
$addtaglink = '<a href="' . $CFG->wwwroot . '/tag/user.php?action=addinterest&sesskey=' . sesskey() . '&tag=' . rawurlencode($query) . '">';
$addtaglink .= get_string('addtagtomyinterests', 'tag', htmlspecialchars($query)) . '</a>';
}
if (!empty($tags)) {
// there are results to display!!
$output .= print_heading(get_string('searchresultsfor', 'tag', htmlspecialchars($query)) . " : {$count}", '', 3, 'main', true);
//print a link "Add $query to my interests"
if (!empty($addtaglink)) {
$output .= print_box($addtaglink, 'box', 'tag-management-box', true);
}
$nr_of_lis_per_ul = 6;
$nr_of_uls = ceil(sizeof($tags) / $nr_of_lis_per_ul);
$output .= '<ul id="tag-search-results">';
for ($i = 0; $i < $nr_of_uls; $i++) {
$output .= '<li>';
foreach (array_slice($tags, $i * $nr_of_lis_per_ul, $nr_of_lis_per_ul) as $tag) {
$tag_link = ' <a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $tag->id . '">' . tag_display_name($tag) . '</a>';
$output .= '•' . $tag_link . '<br/>';
}
$output .= '</li>';
}
$output .= '</ul>';
$output .= '<div> </div>';
// <-- small layout hack in order to look good in Firefox
$output .= print_paging_bar($count, $page, $perpage, $baseurl . '&', 'page', false, true);
} else {
//no results were found!!
$output .= print_heading(get_string('noresultsfor', 'tag', htmlspecialchars($query)), '', 3, 'main', true);
//print a link "Add $query to my interests"
if (!empty($addtaglink)) {
$output .= print_box($addtaglink, 'box', 'tag-management-box', true);
}
}
if ($return) {
return $output;
} else {
echo $output;
}
}