本文整理汇总了PHP中forum_print_attachments函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_print_attachments函数的具体用法?PHP forum_print_attachments怎么用?PHP forum_print_attachments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_print_attachments函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_print_post
//.........这里部分代码省略.........
$str->prune = get_string('prune', 'forum');
$str->displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
$str->markread = get_string('markread', 'forum');
$str->markunread = get_string('markunread', 'forum');
}
$discussionlink = new moodle_url('/mod/forum/discuss.php', array('d'=>$post->discussion));
// Build an object that represents the posting user
$postuser = new stdClass;
$postuser->id = $post->userid;
$postuser->firstname = $post->firstname;
$postuser->lastname = $post->lastname;
$postuser->imagealt = $post->imagealt;
$postuser->picture = $post->picture;
$postuser->email = $post->email;
// Some handy things for later on
$postuser->fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']);
$postuser->profilelink = new moodle_url('/user/view.php', array('id'=>$post->userid, 'course'=>$course->id));
// Prepare the groups the posting user belongs to
if (isset($cm->cache->usersgroups)) {
$groups = array();
if (isset($cm->cache->usersgroups[$post->userid])) {
foreach ($cm->cache->usersgroups[$post->userid] as $gid) {
$groups[$gid] = $cm->cache->groups[$gid];
}
}
} else {
$groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid);
}
// Prepare the attachements for the post, files then images
list($attachments, $attachedimages) = forum_print_attachments($post, $cm, 'separateimages');
// Determine if we need to shorten this post
$shortenpost = ($link && (strlen(strip_tags($post->message)) > $CFG->forum_longpost));
// Prepare an array of commands
$commands = array();
// SPECIAL CASE: The front page can display a news item post to non-logged in users.
// Don't display the mark read / unread controls in this case.
if ($istracked && $CFG->forum_usermarksread && isloggedin()) {
$url = new moodle_url($discussionlink, array('postid'=>$post->id, 'mark'=>'unread'));
$text = $str->markunread;
if (!$postisread) {
$url->param('mark', 'read');
$text = $str->markread;
}
if ($str->displaymode == FORUM_MODE_THREADED) {
$url->param('parent', $post->parent);
} else {
$url->set_anchor('p'.$post->id);
}
$commands[] = array('url'=>$url, 'text'=>$text);
}
// Zoom in to the parent specifically
if ($post->parent) {
$url = new moodle_url($discussionlink);
if ($str->displaymode == FORUM_MODE_THREADED) {
$url->param('parent', $post->parent);
} else {
$url->set_anchor('p'.$post->parent);
示例2: forum_print_post
//.........这里部分代码省略.........
}
if (empty($str)) {
$str = new stdClass();
$str->edit = get_string('edit', 'forum');
$str->delete = get_string('delete', 'forum');
$str->reply = get_string('reply', 'forum');
$str->parent = get_string('parent', 'forum');
$str->pruneheading = get_string('pruneheading', 'forum');
$str->prune = get_string('prune', 'forum');
$str->displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
$str->markread = get_string('markread', 'forum');
$str->markunread = get_string('markunread', 'forum');
}
$discussionlink = new moodle_url('/mod/forum/discuss.php', array('d' => $post->discussion));
// Build an object that represents the posting user
$postuser = new stdClass();
$postuserfields = explode(',', user_picture::fields());
$postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields);
$postuser->id = $post->userid;
$postuser->fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']);
$postuser->profilelink = new moodle_url('/user/view.php', array('id' => $post->userid, 'course' => $course->id));
// Prepare the groups the posting user belongs to
if (isset($cm->cache->usersgroups)) {
$groups = array();
if (isset($cm->cache->usersgroups[$post->userid])) {
foreach ($cm->cache->usersgroups[$post->userid] as $gid) {
$groups[$gid] = $cm->cache->groups[$gid];
}
}
} else {
$groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid);
}
// Prepare the attachements for the post, files then images
list($attachments, $attachedimages) = forum_print_attachments($post, $cm, 'separateimages');
// Determine if we need to shorten this post
$shortenpost = $link && strlen(strip_tags($post->message)) > $CFG->forum_longpost;
// Prepare an array of commands
$commands = array();
// Add a permalink.
$permalink = new moodle_url($discussionlink);
$permalink->set_anchor('p' . $post->id);
$commands[] = array('url' => $permalink, 'text' => get_string('permalink', 'forum'));
// SPECIAL CASE: The front page can display a news item post to non-logged in users.
// Don't display the mark read / unread controls in this case.
if ($istracked && $CFG->forum_usermarksread && isloggedin()) {
$url = new moodle_url($discussionlink, array('postid' => $post->id, 'mark' => 'unread'));
$text = $str->markunread;
if (!$postisread) {
$url->param('mark', 'read');
$text = $str->markread;
}
if ($str->displaymode == FORUM_MODE_THREADED) {
$url->param('parent', $post->parent);
} else {
$url->set_anchor('p' . $post->id);
}
$commands[] = array('url' => $url, 'text' => $text);
}
// Zoom in to the parent specifically
if ($post->parent) {
$url = new moodle_url($discussionlink);
if ($str->displaymode == FORUM_MODE_THREADED) {
$url->param('parent', $post->parent);
} else {
$url->set_anchor('p' . $post->parent);
}
示例3: forum_print_post
//.........这里部分代码省略.........
}
if (!empty($post->subjectnoformat)) {
echo '<div class="subject">' . $post->subject . '</div>';
} else {
echo '<div class="subject">' . format_string($post->subject) . '</div>';
}
echo '<div class="author">';
$fullname = fullname($postuser, $cm->cache->caps['moodle/site:viewfullnames']);
$by = new object();
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $course->id . '">' . $fullname . '</a>';
$by->date = userdate($post->modified);
print_string('bynameondate', 'forum', $by);
echo '</div></td></tr>';
echo '<tr><td class="left side">';
if (isset($cm->cache->usersgroups)) {
$groups = array();
if (isset($cm->cache->usersgroups[$post->userid])) {
foreach ($cm->cache->usersgroups[$post->userid] as $gid) {
$groups[$gid] = $cm->cache->groups[$gid];
}
}
} else {
$groups = groups_get_all_groups($course->id, $post->userid, $cm->groupingid);
}
if ($groups) {
print_group_picture($groups, $course->id, false, false, true);
} else {
echo ' ';
}
// Actual content
echo '</td><td class="content">' . "\n";
if ($post->attachment) {
echo '<div class="attachments">';
$attachedimages = forum_print_attachments($post);
echo '</div>';
} else {
$attachedimages = '';
}
$options = new object();
$options->para = false;
$options->trusttext = true;
if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) {
// Print shortened version
echo format_text(forum_shorten_post($post->message), $post->format, $options, $course->id);
$numwords = count_words(strip_tags($post->message));
echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
echo get_string('readtherest', 'forum');
echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>';
} else {
// Print whole message
if ($highlight) {
echo highlight($highlight, format_text($post->message, $post->format, $options, $course->id));
} else {
echo format_text($post->message, $post->format, $options, $course->id);
}
echo $attachedimages;
}
// Commands
$commands = array();
if ($istracked) {
// SPECIAL CASE: The front page can display a news item post to non-logged in users.
// Don't display the mark read / unread controls in this case.
if ($CFG->forum_usermarksread and isloggedin()) {
if ($post_read) {
$mcmd = '&mark=unread&postid=' . $post->id;
$mtxt = $strmarkunread;
示例4: format_message_attachments
/**
* The plaintext version of the attachments list.
*
* @param \stdClass $cm
* @param \stdClass $post
* @return string
*/
public function format_message_attachments($cm, $post)
{
return forum_print_attachments($post, $cm, "text");
}
示例5: forum_print_post
//.........这里部分代码省略.........
$rootpath = $CFG->wwwroot;
//parse_url( $CFG->wwwroot );
//$rootpath = $rootpath[ 'path' ];
$refurl = "{$rootpath}/mod/forum/permalink.php?p={$post->id}";
$discussurl = "{$rootpath}/mod/forum/discuss.php?d={$post->discussion}";
// used for summary link
// This class author, used by Marginalia, must preceed the one below, used by Moodle. (Well, not in Moodle 1.8)
// Unfortunately I can't use that one - it's marked author but it is not, in fact, the author
// - it also includes "by", the date, etc. (grrr) #geof#
echo "<span style='display:none' class='" . PM_AUTHOR_CLASS . "' title='" . htmlspecialchars($post->username) . "'>" . htmlspecialchars($post->firstname . ' ' . $post->lastname) . "</span>\n";
echo "<abbr style='display:none' class='" . PM_DATE_CLASS . "' title='" . date('Ymd', $post->modified) . 'T' . date('HiO', $post->modified) . "'></abbr>\n";
echo "<a style='display:none' rel='" . PM_URL_REL . "' href='{$refurl}'></a>\n";
echo '<div class="author">';
$fullname = fullname($post, has_capability('moodle/site:viewfullnames', $post->modcontext));
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $courseid . '">' . $fullname . '</a>';
$by->date = userdate($post->modified);
// This, I presume, is to localize string display. Unfortunately it's
// unstructured text, so I can't insert the necessary <abbr> element with the date.
// Instead that's done in a hidden tag above.
print_string('bynameondate', 'forum', $by);
echo '</div></td></tr>';
echo '<tr><td class="left side">';
if ($group = user_group($courseid, $post->userid)) {
print_group_picture($group, $courseid, false, false, true);
} else {
echo ' ';
}
// Actual content
echo '</td><td class="content ' . PM_CONTENT_CLASS . '" valign="top">' . "\n";
if ($post->attachment) {
$post->course = $courseid;
$post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion);
echo '<div class="attachments">';
$attachedimages = forum_print_attachments($post);
echo '</div>';
} else {
$attachedimages = '';
}
$options = new Object();
$options->para = false;
$options->trusttext = true;
if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) {
// Print shortened version
echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid);
$numwords = count_words(strip_tags($post->message));
echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
echo get_string('readtherest', 'forum');
echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>';
} else {
// Print whole message
if ($highlight) {
echo highlight($highlight, format_text($post->message, $post->format, $options, $courseid));
} else {
echo format_text($post->message, $post->format, $options, $courseid);
}
echo $attachedimages;
}
// Commands
$commands = array();
if ($istracked) {
// SPECIAL CASE: The front page can display a news item post to non-logged in users.
// Don't display the mark read / unread controls in this case.
if ($CFG->forum_usermarksread && !empty($USER)) {
if ($post_read) {
$mcmd = '&mark=unread&postid=' . $post->id;
$mtxt = $strmarkunread;