本文整理汇总了PHP中forum_shorten_post函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_shorten_post函数的具体用法?PHP forum_shorten_post怎么用?PHP forum_shorten_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_shorten_post函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_print_post
//.........这里部分代码省略.........
$by->name = html_writer::link($postuser->profilelink, $postuser->fullname);
$by->date = userdate($post->modified);
$output .= html_writer::tag('div', get_string('bynameondate', 'forum', $by), array('class'=>'author'));
$output .= html_writer::end_tag('div'); //topic
$output .= html_writer::end_tag('div'); //row
$output .= html_writer::start_tag('div', array('class'=>'row maincontent clearfix'));
$output .= html_writer::start_tag('div', array('class'=>'left'));
$groupoutput = '';
if ($groups) {
$groupoutput = print_group_picture($groups, $course->id, false, true, true);
}
if (empty($groupoutput)) {
$groupoutput = ' ';
}
$output .= html_writer::tag('div', $groupoutput, array('class'=>'grouppictures'));
$output .= html_writer::end_tag('div'); //left side
$output .= html_writer::start_tag('div', array('class'=>'no-overflow'));
$output .= html_writer::start_tag('div', array('class'=>'content'));
if (!empty($attachments)) {
$output .= html_writer::tag('div', $attachments, array('class'=>'attachments'));
}
$options = new stdClass;
$options->para = false;
$options->trusted = $post->messagetrust;
$options->context = $modcontext;
if ($shortenpost) {
// Prepare shortened version
$postclass = 'shortenedpost';
$postcontent = format_text(forum_shorten_post($post->message), $post->messageformat, $options, $course->id);
$postcontent .= html_writer::link($discussionlink, get_string('readtherest', 'forum'));
$postcontent .= html_writer::tag('div', '('.get_string('numwords', 'moodle', count_words($post->message)).')',
array('class'=>'post-word-count'));
} else {
// Prepare whole post
$postclass = 'fullpost';
$postcontent = format_text($post->message, $post->messageformat, $options, $course->id);
if (!empty($highlight)) {
$postcontent = highlight($highlight, $postcontent);
}
if (!empty($forum->displaywordcount)) {
$postcontent .= html_writer::tag('div', get_string('numwords', 'moodle', count_words($post->message)),
array('class'=>'post-word-count'));
}
$postcontent .= html_writer::tag('div', $attachedimages, array('class'=>'attachedimages'));
}
// Output the post content
$output .= html_writer::tag('div', $postcontent, array('class'=>'posting '.$postclass));
$output .= html_writer::end_tag('div'); // Content
$output .= html_writer::end_tag('div'); // Content mask
$output .= html_writer::end_tag('div'); // Row
$output .= html_writer::start_tag('div', array('class'=>'row side'));
$output .= html_writer::tag('div',' ', array('class'=>'left'));
$output .= html_writer::start_tag('div', array('class'=>'options clearfix'));
// Output ratings
if (!empty($post->rating)) {
$output .= html_writer::tag('div', $OUTPUT->render($post->rating), array('class'=>'forum-post-rating'));
}
示例2: forum_print_post
//.........这里部分代码省略.........
$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;
} else {
$mcmd = '&mark=read&postid=' . $post->id;
$mtxt = $strmarkread;
}
if ($displaymode == FORUM_MODE_THREADED) {
$commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>';
} else {
$commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>';
}
}
示例3: forum_print_post
//.........这里部分代码省略.........
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;
} else {
$mcmd = '&mark=read&postid=' . $post->id;
$mtxt = $strmarkread;
}
if ($threadedmode) {
$commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>';
} else {
$commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>';
}
}