本文整理汇总了PHP中tag_get_tags_csv函数的典型用法代码示例。如果您正苦于以下问题:PHP tag_get_tags_csv函数的具体用法?PHP tag_get_tags_csv怎么用?PHP tag_get_tags_csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tag_get_tags_csv函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: print_html
//.........这里部分代码省略.........
$leftsidecell = new html_table_cell();
$leftsidecell->attributes['class'] = 'left side';
$mainrow->cells[] = $leftsidecell;
$contentcell = new html_table_cell();
$contentcell->attributes['class'] = 'content';
$attachedimages = $OUTPUT->container($this->print_attachments(), 'attachments');
// retrieve associations in case they're needed early
$blogassociations = $DB->get_records('blog_association', array('blogid' => $this->id));
// determine text for publish state
switch ($template['publishstate']) {
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
case 'public':
$blogtype = get_string('publishtoworld', 'blog');
break;
default:
$blogtype = '';
break;
}
$contentcell->text .= $OUTPUT->container($blogtype, 'audience');
$contentcell->text .= $template['body'];
$contentcell->text .= $attachedimages;
// Uniquehash is used as a link to an external blog
if (!empty($this->uniquehash)) {
$contentcell->text .= $OUTPUT->container_start('externalblog');
$contentcell->text .= html_writer::link($this->uniquehash, get_string('linktooriginalentry', 'blog'));
$contentcell->text .= $OUTPUT->container_end();
}
// Links to tags
$officialtags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'official');
$defaulttags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'default');
if (!empty($CFG->usetags) && ($officialtags || $defaulttags)) {
$contentcell->text .= $OUTPUT->container_start('tags');
if ($officialtags) {
$contentcell->text .= get_string('tags', 'tag') . ': ' . $OUTPUT->container($officialtags, 'officialblogtags');
if ($defaulttags) {
$contentcell->text .= ', ';
}
}
$contentcell->text .= $defaulttags;
$contentcell->text .= $OUTPUT->container_end();
}
// Add associations
if (!empty($CFG->useblogassociations) && $blogassociations) {
$contentcell->text .= $OUTPUT->container_start('tags');
$assocstr = '';
$hascourseassocs = false;
$assoctype = '';
// First find and show the associated course
foreach ($blogassociations as $assocrec) {
$contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
if ($contextrec->contextlevel == CONTEXT_COURSE) {
$assocurl = new moodle_url('/course/view.php', array('id' => $contextrec->instanceid));
$text = $DB->get_field('course', 'shortname', array('id' => $contextrec->instanceid));
//TODO: performance!!!!
$assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('i/course', $text), null, array(), true);
$hascourseassocs = true;
$assoctype = get_string('course');
}
}
// Now show mod association
foreach ($blogassociations as $assocrec) {
开发者ID:nfreear,项目名称:moodle,代码行数:67,代码来源:locallib.php
示例2: get_string
} else {
$datestring = get_string("never");
}
print_row(get_string("firstaccess") . ":", $datestring);
}
if (!isset($hiddenfields['lastaccess'])) {
if ($user->lastaccess) {
$datestring = userdate($user->lastaccess) . " (" . format_time(time() - $user->lastaccess) . ")";
} else {
$datestring = get_string("never");
}
print_row(get_string("lastaccess") . ":", $datestring);
}
/// Printing tagged interests
if (!empty($CFG->usetags)) {
if ($interests = tag_get_tags_csv('user', $user->id)) {
print_row(get_string('interests') . ": ", $interests);
}
}
if (!isset($hiddenfields['suspended'])) {
if ($user->suspended) {
print_row('', get_string('suspended', 'auth'));
}
}
echo "</table></div></div>";
echo $OUTPUT->blocks_for_region('content');
// Print messaging link if allowed
if (isloggedin() && has_capability('moodle/site:sendmessage', $context) && !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && $USER->id != $user->id) {
echo '<div class="messagebox">';
echo '<a href="' . $CFG->wwwroot . '/message/index.php?id=' . $user->id . '">' . get_string('messageselectadd') . '</a>';
echo '</div>';
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:profile.php
示例3: print_edit
protected function print_edit($content = null) {
global $CFG, $OUTPUT, $USER, $PAGE;
if (!$this->check_locks()) {
return;
}
//delete old locks (> 1 hour)
wiki_delete_old_locks();
$version = wiki_get_current_version($this->page->id);
$format = $version->contentformat;
if ($content == null) {
if (empty($this->section)) {
$content = $version->content;
} else {
$content = $this->sectioncontent;
}
}
$versionnumber = $version->version;
if ($this->versionnumber >= 0) {
if ($version->version != $this->versionnumber) {
print $OUTPUT->box(get_string('wrongversionlock', 'wiki'), 'errorbox');
$versionnumber = $this->versionnumber;
}
}
$url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
if (!empty($this->section)) {
$url .= "§ion=" . urlencode($this->section);
}
$params = array(
'attachmentoptions' => page_wiki_edit::$attachmentoptions,
'format' => $version->contentformat,
'version' => $versionnumber,
'pagetitle' => $this->page->title,
'contextid' => $this->modcontext->id
);
$data = new StdClass();
$data->newcontent = $content;
$data->version = $versionnumber;
$data->format = $format;
switch ($format) {
case 'html':
$data->newcontentformat = FORMAT_HTML;
// Append editor context to editor options, giving preference to existing context.
page_wiki_edit::$attachmentoptions = array_merge(array('context' => $this->modcontext), page_wiki_edit::$attachmentoptions);
$data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
break;
default:
break;
}
if ($version->contentformat != 'html') {
$params['fileitemid'] = $this->subwiki->id;
$params['component'] = 'mod_wiki';
$params['filearea'] = 'attachments';
}
if (!empty($CFG->usetags)) {
$params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
}
$form = new mod_wiki_edit_form($url, $params);
if ($formdata = $form->get_data()) {
if (!empty($CFG->usetags)) {
$data->tags = $formdata->tags;
}
} else {
if (!empty($CFG->usetags)) {
$data->tags = tag_get_tags_array('wiki', $this->page->id);
}
}
$form->set_data($data);
$form->display();
}
开发者ID:Burick,项目名称:moodle,代码行数:83,代码来源:pagelib.php
示例4: blog_print_entry
/**
* This function is in lib and not in BlogInfo because entries being searched
* might be found in any number of blogs rather than just one.
*
* This function builds an array which can be used by the included
* template file, making predefined and nicely formatted variables available
* to the template. Template creators will not need to become intimate
* with the internal objects and vars of moodle blog nor will they need to worry
* about properly formatting their data
*
* @param BlogEntry blogEntry - a hopefully fully populated BlogEntry object
* @param string viewtype Default is 'full'. If 'full' then display this blog entry
* in its complete form (eg. archive page). If anything other than 'full'
* display the entry in its abbreviated format (eg. index page)
*/
function blog_print_entry($blogEntry, $viewtype = 'full', $filtertype = '', $filterselect = '', $mode = 'loud')
{
global $USER, $CFG, $COURSE, $ME;
$template['body'] = format_text($blogEntry->summary, $blogEntry->format);
$template['title'] = '<a id=b"' . s($blogEntry->id) . ' /">';
//enclose the title in nolink tags so that moodle formatting doesn't autolink the text
$template['title'] .= '<span class="nolink">' . format_string($blogEntry->subject) . '</span>';
$template['userid'] = $blogEntry->userid;
$template['author'] = fullname(get_record('user', 'id', $blogEntry->userid));
$template['created'] = userdate($blogEntry->created);
if ($blogEntry->created != $blogEntry->lastmodified) {
$template['lastmod'] = userdate($blogEntry->lastmodified);
}
$template['publishstate'] = $blogEntry->publishstate;
/// preventing user to browse blogs that they aren't supposed to see
/// This might not be too good since there are multiple calls per page
/*
if (!blog_user_can_view_user_post($template['userid'])) {
error ('you can not view this post');
}*/
$stredit = get_string('edit');
$strdelete = get_string('delete');
$user = get_record('user', 'id', $template['userid']);
/// Start printing of the blog
echo '<table cellspacing="0" class="forumpost blogpost blog' . $template['publishstate'] . '" width="100%">';
echo '<tr class="header"><td class="picture left">';
print_user_picture($user, SITEID, $user->picture);
echo '</td>';
echo '<td class="topic starter"><div class="subject">' . $template['title'] . '</div><div class="author">';
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $COURSE->id)));
$by = new object();
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $COURSE->id . '">' . $fullname . '</a>';
$by->date = $template['created'];
print_string('bynameondate', 'forum', $by);
echo '</div></td></tr>';
echo '<tr><td class="left side">';
/// Actual content
echo '</td><td class="content">' . "\n";
if ($blogEntry->attachment) {
echo '<div class="attachments">';
$attachedimages = blog_print_attachments($blogEntry);
echo '</div>';
} else {
$attachedimages = '';
}
switch ($template['publishstate']) {
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
case 'public':
$blogtype = get_string('publishtoworld', 'blog');
break;
default:
$blogtype = '';
break;
}
echo '<div class="audience">' . $blogtype . '</div>';
// Print whole message
echo $template['body'];
/// Print attachments
echo $attachedimages;
/// Links to tags
if (!empty($CFG->usetags) && ($blogtags = tag_get_tags_csv('post', $blogEntry->id))) {
echo '<div class="tags">';
if ($blogtags) {
print get_string('tags', 'tag') . ': ' . $blogtags;
}
echo '</div>';
}
/// Commands
echo '<div class="commands">';
if (blog_user_can_edit_post($blogEntry)) {
echo '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=edit&id=' . $blogEntry->id . '">' . $stredit . '</a>';
echo '| <a href="' . $CFG->wwwroot . '/blog/edit.php?action=delete&id=' . $blogEntry->id . '">' . $strdelete . '</a> | ';
}
echo '<a href="' . $CFG->wwwroot . '/blog/index.php?postid=' . $blogEntry->id . '">' . get_string('permalink', 'blog') . '</a>';
echo '</div>';
if (isset($template['lastmod'])) {
echo '<div style="font-size: 55%;">';
echo ' [ ' . get_string('modified') . ': ' . $template['lastmod'] . ' ]';
echo '</div>';
}
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:lib.php
示例5: user_get_user_details
//.........这里部分代码省略.........
if (in_array('icq', $userfields) && $user->icq && (!isset($hiddenfields['icqnumber']) or $isadmin)) {
$userdetails['icq'] = $user->icq;
}
if (in_array('skype', $userfields) && $user->skype && (!isset($hiddenfields['skypeid']) or $isadmin)) {
$userdetails['skype'] = $user->skype;
}
if (in_array('yahoo', $userfields) && $user->yahoo && (!isset($hiddenfields['yahooid']) or $isadmin)) {
$userdetails['yahoo'] = $user->yahoo;
}
if (in_array('aim', $userfields) && $user->aim && (!isset($hiddenfields['aimid']) or $isadmin)) {
$userdetails['aim'] = $user->aim;
}
if (in_array('msn', $userfields) && $user->msn && (!isset($hiddenfields['msnid']) or $isadmin)) {
$userdetails['msn'] = $user->msn;
}
if (in_array('firstaccess', $userfields) && (!isset($hiddenfields['firstaccess']) or $isadmin)) {
if ($user->firstaccess) {
$userdetails['firstaccess'] = $user->firstaccess;
} else {
$userdetails['firstaccess'] = 0;
}
}
if (in_array('lastaccess', $userfields) && (!isset($hiddenfields['lastaccess']) or $isadmin)) {
if ($user->lastaccess) {
$userdetails['lastaccess'] = $user->lastaccess;
} else {
$userdetails['lastaccess'] = 0;
}
}
if (in_array('email', $userfields) && ($isadmin or $currentuser or $canviewuseremail or in_array('email', $showuseridentityfields) or $user->maildisplay == 1 or $user->maildisplay == 2 and enrol_sharing_course($user, $USER))) {
$userdetails['email'] = $user->email;
}
if (in_array('interests', $userfields) && !empty($CFG->usetags)) {
require_once $CFG->dirroot . '/tag/lib.php';
if ($interests = tag_get_tags_csv('user', $user->id, TAG_RETURN_TEXT)) {
$userdetails['interests'] = $interests;
}
}
//Departement/Institution/Idnumber are not displayed on any profile, however you can get them from editing profile.
if ($isadmin or $currentuser or in_array('idnumber', $showuseridentityfields)) {
if (in_array('idnumber', $userfields) && $user->idnumber) {
$userdetails['idnumber'] = $user->idnumber;
}
}
if ($isadmin or $currentuser or in_array('institution', $showuseridentityfields)) {
if (in_array('institution', $userfields) && $user->institution) {
$userdetails['institution'] = $user->institution;
}
}
if ($isadmin or $currentuser or in_array('department', $showuseridentityfields)) {
if (in_array('department', $userfields) && isset($user->department)) {
//isset because it's ok to have department 0
$userdetails['department'] = $user->department;
}
}
if (in_array('roles', $userfields) && !empty($course)) {
// not a big secret
$roles = get_user_roles($context, $user->id, false);
$userdetails['roles'] = array();
foreach ($roles as $role) {
$userdetails['roles'][] = array('roleid' => $role->roleid, 'name' => $role->name, 'shortname' => $role->shortname, 'sortorder' => $role->sortorder);
}
}
// If groups are in use and enforced throughout the course, then make sure we can meet in at least one course level group
if (in_array('groups', $userfields) && !empty($course) && $canaccessallgroups) {
$usergroups = groups_get_all_groups($course->id, $user->id, $course->defaultgroupingid, 'g.id, g.name,g.description,g.descriptionformat');
$userdetails['groups'] = array();
foreach ($usergroups as $group) {
list($group->description, $group->descriptionformat) = external_format_text($group->description, $group->descriptionformat, $context->id, 'group', 'description', $group->id);
$userdetails['groups'][] = array('id' => $group->id, 'name' => $group->name, 'description' => $group->description, 'descriptionformat' => $group->descriptionformat);
}
}
//list of courses where the user is enrolled
if (in_array('enrolledcourses', $userfields) && !isset($hiddenfields['mycourses'])) {
$enrolledcourses = array();
if ($mycourses = enrol_get_users_courses($user->id, true)) {
foreach ($mycourses as $mycourse) {
if ($mycourse->category) {
$coursecontext = context_course::instance($mycourse->id);
$enrolledcourse = array();
$enrolledcourse['id'] = $mycourse->id;
$enrolledcourse['fullname'] = format_string($mycourse->fullname, true, array('context' => $coursecontext));
$enrolledcourse['shortname'] = format_string($mycourse->shortname, true, array('context' => $coursecontext));
$enrolledcourses[] = $enrolledcourse;
}
}
$userdetails['enrolledcourses'] = $enrolledcourses;
}
}
//user preferences
if (in_array('preferences', $userfields) && $currentuser) {
$preferences = array();
$userpreferences = get_user_preferences();
foreach ($userpreferences as $prefname => $prefvalue) {
$preferences[] = array('name' => $prefname, 'value' => $prefvalue);
}
$userdetails['preferences'] = $preferences;
}
return $userdetails;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:101,代码来源:lib.php
示例6: foreach
foreach ($values as $value) {
if (!preg_match('/value(\\d+)/', $value, $matches)) {
continue;
}
insert_record('course_classification', (object) array('course' => $course->id, 'value' => $matches[1]));
$cleanvalues[] = $matches[1];
}
// update the manual tags
tag_set('course', $course->id, explode(',', $formdata->tags));
// update the classification tags
$ctag_arr = array();
$sql = "SELECT value FROM {$CFG->prefix}classification_value WHERE id IN ( " . implode(',', $cleanvalues) . ")";
if (!empty($cleanvalues) && ($ctags = get_records_sql($sql))) {
foreach ($ctags as $ctag) {
$ctag_arr[] = strtolower($ctag->value);
}
}
tag_set('courseclassification', $course->id, $ctag_arr);
//set the tags (or clear them if none selected)
commit_sql();
events_trigger('lp_classification', $course->id);
notify(get_string('changessaved'), 'notifysuccess');
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
} else {
$post = new object();
if ($itemptags = tag_get_tags_csv('course', $course->id, TAG_RETURN_TEXT, 'default')) {
$post->tags = $itemptags;
}
$mform->set_data($post);
$mform->display();
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:classify.php
示例7: print_error
// Guest can not edit
if (isguestuser()) {
print_error('guestnoeditprofile');
}
// The user profile we are editing
if (!($user = get_record('user', 'id', $userid))) {
error('User ID was incorrect');
}
// Guest can not be edited
if (isguestuser($user)) {
print_error('guestnoeditprofile');
}
// User interests separated by commas
if (!empty($CFG->usetags)) {
require_once $CFG->dirroot . '/tag/lib.php';
$user->interests = tag_get_tags_csv('user', $user->id, TAG_RETURN_TEXT);
}
// remote users cannot be edited
if (is_mnet_remote_user($user)) {
redirect($CFG->wwwroot . "/user/view.php?course={$course->id}");
}
if ($course->id == SITEID) {
$coursecontext = get_context_instance(CONTEXT_SYSTEM);
// SYSTEM context
} else {
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Course context
}
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
// check access control
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:edit.php
示例8: get_string
$post->publishstate = 'site';
$strformheading = get_string('addnewentry', 'blog');
$post->action = $action;
break;
case 'edit':
if (!$existing) {
error('Incorrect blog post id');
}
$post->id = $existing->id;
$post->subject = $existing->subject;
$post->summary = $existing->summary;
$post->publishstate = $existing->publishstate;
$post->format = $existing->format;
$post->action = $action;
$strformheading = get_string('updateentrywithid', 'blog');
if ($itemptags = tag_get_tags_csv('post', $post->id, TAG_RETURN_TEXT, 'default')) {
$post->ptags = $itemptags;
}
if ($itemotags = tag_get_tags_array('post', $post->id, 'official')) {
$post->otags = array_keys($itemotags);
}
break;
default:
error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:edit.php
示例9: core_myprofile_navigation
//.........这里部分代码省略.........
$tree->add_node($node);
}
if (isset($identityfields['phone1']) && $user->phone1) {
$node = new core_user\output\myprofile\node('contact', 'phone1', get_string('phone'), null, null, $user->phone1);
$tree->add_node($node);
}
if (isset($identityfields['phone2']) && $user->phone2) {
$node = new core_user\output\myprofile\node('contact', 'phone2', get_string('phone2'), null, null, $user->phone2);
$tree->add_node($node);
}
if (isset($identityfields['institution']) && $user->institution) {
$node = new core_user\output\myprofile\node('contact', 'institution', get_string('institution'), null, null, $user->institution);
$tree->add_node($node);
}
if (isset($identityfields['department']) && $user->department) {
$node = new core_user\output\myprofile\node('contact', 'department', get_string('department'), null, null, $user->institution);
$tree->add_node($node);
}
if (isset($identityfields['idnumber']) && $user->idnumber) {
$node = new core_user\output\myprofile\node('contact', 'idnumber', get_string('idnumber'), null, null, $user->institution);
$tree->add_node($node);
}
if ($user->url && !isset($hiddenfields['webpage'])) {
$url = $user->url;
if (strpos($user->url, '://') === false) {
$url = 'http://' . $url;
}
$webpageurl = new moodle_url($url);
$node = new core_user\output\myprofile\node('contact', 'webpage', get_string('webpage'), null, null, html_writer::link($url, $webpageurl));
$tree->add_node($node);
}
// Printing tagged interests. We want this only for full profile.
if (!empty($CFG->usetags) && empty($course)) {
if ($interests = tag_get_tags_csv('user', $user->id)) {
$node = new core_user\output\myprofile\node('contact', 'interests', get_string('interests'), null, null, $interests);
$tree->add_node($node);
}
}
if (!isset($hiddenfields['mycourses'])) {
$showallcourses = optional_param('showallcourses', 0, PARAM_INT);
if ($mycourses = enrol_get_all_users_courses($user->id, true, null, 'visible DESC, sortorder ASC')) {
$shown = 0;
$courselisting = html_writer::start_tag('ul');
foreach ($mycourses as $mycourse) {
if ($mycourse->category) {
context_helper::preload_from_record($mycourse);
$ccontext = context_course::instance($mycourse->id);
if (!isset($course) || $mycourse->id != $course->id) {
$linkattributes = null;
if ($mycourse->visible == 0) {
if (!has_capability('moodle/course:viewhiddencourses', $ccontext)) {
continue;
}
$linkattributes['class'] = 'dimmed';
}
$params = array('id' => $user->id, 'course' => $mycourse->id);
if ($showallcourses) {
$params['showallcourses'] = 1;
}
$url = new moodle_url('/user/view.php', $params);
$courselisting .= html_writer::tag('li', html_writer::link($url, $ccontext->get_context_name(false), $linkattributes));
} else {
$courselisting .= html_writer::tag('li', $course->fullname);
}
}
$shown++;
开发者ID:mike-grant,项目名称:moodle,代码行数:67,代码来源:myprofilelib.php
示例10: test_create
public function test_create()
{
global $DB;
$this->resetAfterTest(true);
$generator = $this->getDataGenerator();
$count = $DB->count_records('course_categories');
$category = $generator->create_category();
$this->assertEquals($count + 1, $DB->count_records('course_categories'));
$this->assertRegExp('/^Course category \\d/', $category->name);
$this->assertSame('', $category->idnumber);
$this->assertRegExp('/^Test course category \\d/', $category->description);
$this->assertSame(FORMAT_MOODLE, $category->descriptionformat);
$count = $DB->count_records('cohort');
$cohort = $generator->create_cohort();
$this->assertEquals($count + 1, $DB->count_records('cohort'));
$this->assertEquals(context_system::instance()->id, $cohort->contextid);
$this->assertRegExp('/^Cohort \\d/', $cohort->name);
$this->assertSame('', $cohort->idnumber);
$this->assertRegExp('/^Test cohort \\d/', $cohort->description);
$this->assertSame(FORMAT_MOODLE, $cohort->descriptionformat);
$this->assertSame('', $cohort->component);
$this->assertLessThanOrEqual(time(), $cohort->timecreated);
$this->assertSame($cohort->timecreated, $cohort->timemodified);
$count = $DB->count_records('course');
$course = $generator->create_course();
$this->assertEquals($count + 1, $DB->count_records('course'));
$this->assertRegExp('/^Test course \\d/', $course->fullname);
$this->assertRegExp('/^tc_\\d/', $course->shortname);
$this->assertSame('', $course->idnumber);
$this->assertSame('topics', $course->format);
$this->assertEquals(0, $course->newsitems);
$this->assertEquals(5, $course->numsections);
$this->assertRegExp('/^Test course \\d/', $course->summary);
$this->assertSame(FORMAT_MOODLE, $course->summaryformat);
$section = $generator->create_course_section(array('course' => $course->id, 'section' => 3));
$this->assertEquals($course->id, $section->course);
$course = $generator->create_course(array('tags' => 'Cat, Dog'));
$this->assertEquals('Cat, Dog', tag_get_tags_csv('course', $course->id, TAG_RETURN_TEXT));
$scale = $generator->create_scale();
$this->assertNotEmpty($scale);
}
开发者ID:matiasma,项目名称:moodle,代码行数:41,代码来源:generator_test.php
示例11: get_tags
/**
* Retrieve the current set of tags for this object.
*
* @access public
* @return string CSV list of tags.
*/
public function get_tags()
{
return tag_get_tags_csv(static::$table, $this->id, TAG_RETURN_TEXT);
}
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:10,代码来源:base.php
示例12: render_blog_entry
/**
* Renders a blog entry
*
* @param blog_entry $entry
* @return string The table HTML
*/
public function render_blog_entry(blog_entry $entry)
{
global $CFG;
$syscontext = context_system::instance();
$stredit = get_string('edit');
$strdelete = get_string('delete');
// Header.
$mainclass = 'forumpost blog_entry blog clearfix ';
if ($entry->renderable->unassociatedentry) {
$mainclass .= 'draft';
} else {
$mainclass .= $entry->publishstate;
}
$o = $this->output->container_start($mainclass, 'b' . $entry->id);
$o .= $this->output->container_start('row header clearfix');
// User picture.
$o .= $this->output->container_start('left picture header');
$o .= $this->output->user_picture($entry->renderable->user);
$o .= $this->output->container_end();
$o .= $this->output->container_start('topic starter header clearfix');
// Title.
$titlelink = html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $entry->id)), format_string($entry->subject));
$o .= $this->output->container($titlelink, 'subject');
// Post by.
$by = new stdClass();
$fullname = fullname($entry->renderable->user, has_capability('moodle/site:viewfullnames', $syscontext));
$userurlparams = array('id' => $entry->renderable->user->id, 'course' => $this->page->course->id);
$by->name = html_writer::link(new moodle_url('/user/view.php', $userurlparams), $fullname);
$by->date = userdate($entry->created);
$o .= $this->output->container(get_string('bynameondate', 'forum', $by), 'author');
// Adding external blog link.
if (!empty($entry->renderable->externalblogtext)) {
$o .= $this->output->container($entry->renderable->externalblogtext, 'externalblog');
}
// Closing subject tag and header tag.
$o .= $this->output->container_end();
$o .= $this->output->container_end();
// Post content.
$o .= $this->output->container_start('row maincontent clearfix');
// Entry.
$o .= $this->output->container_start('no-overflow content ');
// Determine text for publish state.
switch ($entry->publishstate) {
case 'draft':
$blogtype = get_string('publishtonoone', 'blog');
break;
case 'site':
$blogtype = get_string('publishtosite', 'blog');
break;
case 'public':
$blogtype = get_string('publishtoworld', 'blog');
break;
default:
$blogtype = '';
break;
}
$o .= $this->output->container($blogtype, 'audience');
// Attachments.
$attachmentsoutputs = array();
if ($entry->renderable->attachments) {
foreach ($entry->renderable->attachments as $attachment) {
$o .= $this->render($attachment, false);
}
}
// Body.
$o .= format_text($entry->summary, $entry->summaryformat, array('overflowdiv' => true));
if (!empty($entry->uniquehash)) {
// Uniquehash is used as a link to an external blog.
$url = clean_param($entry->uniquehash, PARAM_URL);
if (!empty($url)) {
$o .= $this->output->container_start('externalblog');
$o .= html_writer::link($url, get_string('linktooriginalentry', 'blog'));
$o .= $this->output->container_end();
}
}
// Links to tags.
$officialtags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'official');
$defaulttags = tag_get_tags_csv('post', $entry->id, TAG_RETURN_HTML, 'default');
if (!empty($CFG->usetags) && ($officialtags || $defaulttags)) {
$o .= $this->output->container_start('tags');
if ($officialtags) {
$o .= get_string('tags', 'tag') . ': ' . $this->output->container($officialtags, 'officialblogtags');
if ($defaulttags) {
$o .= ', ';
}
}
$o .= $defaulttags;
$o .= $this->output->container_end();
}
// Add associations.
if (!empty($CFG->useblogassociations) && !empty($entry->renderable->blogassociations)) {
// First find and show the associated course.
$assocstr = '';
$coursesarray = array();
//.........这里部分代码省略.........
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:101,代码来源:renderer.php
示例13: print_edit
protected function print_edit($content = null) {
global $CFG, $OUTPUT, $USER, $PAGE;
if (!$this->check_locks()) {
return;
}
//delete old locks (> 1 hour)
wiki_delete_old_locks();
$version = wiki_get_current_version($this->page->id);
$format = $version->contentformat;
if ($content == null) {
if (empty($this->section)) {
$content = $version->content;
} else {
$content = $this->sectioncontent;
}
}
$versionnumber = $version->version;
if ($this->versionnumber >= 0) {
if ($version->version != $this->versionnumber) {
print $OUTPUT->box(get_string('wrongversionlock', 'wiki'), 'errorbox');
$versionnumber = $this->versionnumber;
}
}
$url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
if (!empty($this->section)) {
$url .= "§ion=" . $this->section;
}
$params = array('attachmentoptions' => page_wiki_edit::$attachmentoptions, 'format' => $version->contentformat, 'version' => $versionnumber, 'pagetitle'=>$this->page->title);
$data = new StdClass();
$data->newcontent = $content;
$data->version = $versionnumber;
$data->format = $format;
switch ($format) {
case 'html':
$data->newcontentformat = FORMAT_HTML;
$data = file_prepare_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id);
break;
default:
//$draftitemid = file_get_submitted_draft_itemid('attachments');
//file_prepare_draft_area($draftitemid, $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
//$data->attachments = $draftitemid;
}
if ($version->contentformat != 'html') {
$params['contextid'] = $this->modcontext->id;
$params['component'] = 'mod_wiki';
$params['filearea'] = 'attachments';
$params['fileitemid'] = $this->subwiki->id;
}
if (!empty($CFG->usetags)) {
$params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
}
$form = new mod_wiki_edit_form($url, $params);
if ($formdata = $form->get_data()) {
if ($format != 'html') {
$errors = $this->process_uploads($this->modcontext);
if (!empty($errors)) {
$contenterror = "";
foreach ($errors as $e) {
$contenterror .= "<p>" . get_string('filenotuploadederror', 'wiki', $e->get_filename()) . "</p>";
}
print $OUTPUT->box($contenterror, 'errorbox');
}
}
if (!empty($CFG->usetags)) {
$data->tags = $formdata->tags;
}
} else {
if (!empty($CFG->usetags)) {
$data->tags = tag_get_tags_array('wiki', $this->page->id);
}
}
$form->set_data($data);
$form->display();
}
开发者ID:nfreear,项目名称:moodle,代码行数:88,代码来源:pagelib.php
示例14: get_course_participants_by_id
//.........这里部分代码省略.........
if ($user->phone1) {
$userarray['phone1'] = $user->phone1;
}
if ($user->phone2) {
$userarray['phone2'] = $user->phone2;
}
}
if ($currentuser
or $user->maildisplay == 1
or has_capability('moodle/course:useremail', $context)
or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER))) {
$userarray['email'] = $user->email;;
}
if ($user->url && (!isset($hiddenfields['webpage']) or $isadmin)) {
$url = $user->url;
if (strpos($user->url, '://') === false) {
$url = 'http://'. $url;
}
$user->url = clean_param($user->url, PARAM_URL);
$userarray['url'] = $user->url;
}
if ($user->icq && (!isset($hiddenfields['icqnumber']) or $isadmin)) {
$userarray['icq'] = $user->icq;
}
if ($user->skype && (!isset($hiddenfields['skypeid']) or $isadmin)) {
$userarray['skype'] = $user->skype;
}
if ($user->yahoo && (!isset($hiddenfields['yahooid']) or $isadmin)) {
$userarray['yahoo'] = $user->yahoo;
}
if ($user->aim && (!isset($hiddenfields['aimid']) or $isadmin)) {
$userarray['aim'] = $user->aim;
}
if ($user->msn && (!isset($hiddenfields['msnid']) or $isadmin)) {
$userarray['msn'] = $user->msn;
}
if ((!isset($hiddenfields['firstaccess'])) or $isadmin) {
if ($user->firstaccess) {
$userarray['firstaccess'] = $user->firstaccess;
} else {
$userarray['firstaccess'] = 0;
}
}
if ((!isset($hiddenfields['lastaccess'])) or $isadmin) {
if ($user->lastaccess) {
$userarray['lastaccess'] = $user->lastaccess;
} else {
$userarray['lastaccess'] = 0;
}
}
/// Printing tagged interests
if (!empty($CFG->usetags)) {
require_once($CFG->dirroot . '/tag/lib.php');
if ($interests = tag_get_tags_csv('user', $user->id, TAG_RETURN_TEXT) ) {
$userarray['interests'] = $interests;
}
}
//Departement/Institution are not displayed on any profile, however you can get them from editing profile.
if ($isadmin or $currentuser) {
if ($user->institution) {
$userarray['institution'] = $user->institution;
}
if (isset($user->department)) { //isset because it's ok to have department 0
$userarray['department'] = $user->department;
}
}
// not a big secret
$userarray['roles'] = array();
$roles = get_user_roles($context, $user->id, false);
foreach ($roles as $role) {
$userarray['roles'][] = array(
'roleid' => $role->roleid,
'name' => $role->name,
'shortname' => $role->shortname,
'sortorder' => $role->sortorder
);
}
// If groups are in use and enforced throughout the course, then make sure we can meet in at least one course level group
if (has_capability('moodle/site:accessallgroups', $context)) {
$usergroups = groups_get_all_groups($course->id, $user->id, $course->defaultgroupingid, 'g.id, g.name,g.description');
foreach ($usergroups as $group) {
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
$userarray['groups'][] = array('id'=>$group->id, 'name'=>$group->name, 'description'=>$group->description);
}
}
$result[] = $userarray;
}
$users->close();
return $result;
}
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:externallib.php
注:本文中的tag_get_tags_csv函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论