当前位置: 首页>>代码示例>>PHP>>正文


PHP forum_shorten_post函数代码示例

本文整理汇总了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'));
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:lib.php

示例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 '&nbsp;';
    }
    // 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 = '&amp;mark=unread&amp;postid=' . $post->id;
                $mtxt = $strmarkunread;
            } else {
                $mcmd = '&amp;mark=read&amp;postid=' . $post->id;
                $mtxt = $strmarkread;
            }
            if ($displaymode == FORUM_MODE_THREADED) {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;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>';
            }
        }
开发者ID:r007,项目名称:PMoodle,代码行数:67,代码来源:lib.php

示例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 . '&amp;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 '&nbsp;';
    }
    // 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 = '&amp;mark=unread&amp;postid=' . $post->id;
                $mtxt = $strmarkunread;
            } else {
                $mcmd = '&amp;mark=read&amp;postid=' . $post->id;
                $mtxt = $strmarkread;
            }
            if ($threadedmode) {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;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>';
            }
        }
开发者ID:njorth,项目名称:marginalia,代码行数:67,代码来源:lib.php


注:本文中的forum_shorten_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。