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


PHP message_get_fragment函数代码示例

本文整理汇总了PHP中message_get_fragment函数的典型用法代码示例。如果您正苦于以下问题:PHP message_get_fragment函数的具体用法?PHP message_get_fragment怎么用?PHP message_get_fragment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了message_get_fragment函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: message_print_search_results


//.........这里部分代码省略.........
            echo $headertdstart.get_string('timesent', 'message').$headertdend;
            echo html_writer::end_tag('tr');

            $blockedcount = 0;
            $dateformat = get_string('strftimedatetimeshort');
            $strcontext = get_string('context', 'message');
            foreach ($messages as $message) {

            /// ignore messages to and from blocked users unless $frm->includeblocked is set
                if (!optional_param('includeblocked', 0, PARAM_BOOL) and (
                      ( isset($contacts[$message->useridfrom]) and ($contacts[$message->useridfrom]->blocked == 1)) or
                      ( isset($contacts[$message->useridto]  ) and ($contacts[$message->useridto]->blocked   == 1))
                                                )
                   ) {
                    $blockedcount ++;
                    continue;
                }

            /// load up user to record
                if ($message->useridto !== $USER->id) {
                    $userto = $DB->get_record('user', array('id' => $message->useridto));
                    $tocontact = (array_key_exists($message->useridto, $contacts) and
                                    ($contacts[$message->useridto]->blocked == 0) );
                    $toblocked = (array_key_exists($message->useridto, $contacts) and
                                    ($contacts[$message->useridto]->blocked == 1) );
                } else {
                    $userto = false;
                    $tocontact = false;
                    $toblocked = false;
                }

            /// load up user from record
                if ($message->useridfrom !== $USER->id) {
                    $userfrom = $DB->get_record('user', array('id' => $message->useridfrom));
                    $fromcontact = (array_key_exists($message->useridfrom, $contacts) and
                                    ($contacts[$message->useridfrom]->blocked == 0) );
                    $fromblocked = (array_key_exists($message->useridfrom, $contacts) and
                                    ($contacts[$message->useridfrom]->blocked == 1) );
                } else {
                    $userfrom = false;
                    $fromcontact = false;
                    $fromblocked = false;
                }

            /// find date string for this message
                $date = usergetdate($message->timecreated);
                $datestring = $date['year'].$date['mon'].$date['mday'];

            /// print out message row
                echo html_writer::start_tag('tr', array('valign' => 'top'));

                echo html_writer::start_tag('td', array('class' => 'contact'));
                message_print_user($userfrom, $fromcontact, $fromblocked, $showicontext);
                echo html_writer::end_tag('td');

                echo html_writer::start_tag('td', array('class' => 'contact'));
                message_print_user($userto, $tocontact, $toblocked, $showicontext);
                echo html_writer::end_tag('td');

                echo html_writer::start_tag('td', array('class' => 'summary'));
                echo message_get_fragment($message->fullmessage, $keywords);
                echo html_writer::start_tag('div', array('class' => 'link'));

                //find the user involved that isn't the current user
                $user2id = null;
                if ($user1->id == $message->useridto) {
                    $user2id = $message->useridfrom;
                } else {
                    $user2id = $message->useridto;
                }
                message_history_link($user1->id, $user2id, false,
                                     $messagesearchstring, 'm'.$message->id, $strcontext);
                echo html_writer::end_tag('div');
                echo html_writer::end_tag('td');

                echo html_writer::tag('td', userdate($message->timecreated, $dateformat), array('class' => 'date'));

                echo html_writer::end_tag('tr');
            }


            if ($blockedcount > 0) {
                echo html_writer::start_tag('tr');
                echo html_writer::tag('td', get_string('blockedmessages', 'message', $blockedcount), array('colspan' => 4, 'align' => 'center'));
                echo html_writer::end_tag('tr');
            }
            echo html_writer::end_tag('table');

        } else {
            echo html_writer::tag('p', get_string('keywordssearchresults', 'message', 0), array('class' => 'heading'));
        }
    }

    if (!$personsearch && !$messagesearch) {
        //they didn't enter any search terms
        echo $OUTPUT->notification(get_string('emptysearchstring', 'message'));
    }

    echo html_writer::end_tag('div');
}
开发者ID:nfreear,项目名称:moodle,代码行数:101,代码来源:lib.php

示例2: message_print_search_results


//.........这里部分代码省略.........
            switch ($frm->keywordsoption) {
                case 'tome':
                    $tome = true;
                    break;
                case 'fromme':
                    $fromme = true;
                    break;
                case 'allmine':
                    $tome = true;
                    $fromme = true;
                    break;
                case 'allusers':
                    $courseid = SITEID;
                    break;
                case 'courseusers':
                    $courseid = $frm->courseid;
                    break;
                default:
                    $tome = true;
                    $fromme = true;
            }
            if (($messages = message_search($keywords, $fromme, $tome, $courseid)) !== false) {
                /// get a list of contacts
                if (($contacts = get_records('message_contacts', 'userid', $USER->id, '', 'contactid, blocked')) === false) {
                    $contacts = array();
                }
                /// print heading with number of results
                echo '<p class="heading">' . get_string('keywordssearchresults', 'message', count($messages)) . ' ("' . s($keywordstring) . '")</p>';
                /// print table headings
                echo '<table class="searchresults" cellspacing="0">';
                echo '<tr>';
                echo '<td><strong>' . get_string('from') . '</strong></td>';
                echo '<td><strong>' . get_string('to') . '</strong></td>';
                echo '<td><strong>' . get_string('message', 'message') . '</strong></td>';
                echo '<td><strong>' . get_string('timesent', 'message') . '</strong></td>';
                echo "</tr>\n";
                $blockedcount = 0;
                $dateformat = get_string('strftimedatetimeshort');
                $strcontext = get_string('context', 'message');
                foreach ($messages as $message) {
                    /// ignore messages to and from blocked users unless $frm->includeblocked is set
                    if (!optional_param('includeblocked', 0, PARAM_BOOL) and (isset($contacts[$message->useridfrom]) and $contacts[$message->useridfrom]->blocked == 1 or isset($contacts[$message->useridto]) and $contacts[$message->useridto]->blocked == 1)) {
                        $blockedcount++;
                        continue;
                    }
                    /// load up user to record
                    if ($message->useridto !== $USER->id) {
                        $userto = get_record('user', 'id', $message->useridto);
                        $tocontact = (array_key_exists($message->useridto, $contacts) and $contacts[$message->useridto]->blocked == 0);
                        $toblocked = (array_key_exists($message->useridto, $contacts) and $contacts[$message->useridto]->blocked == 1);
                    } else {
                        $userto = false;
                        $tocontact = false;
                        $toblocked = false;
                    }
                    /// load up user from record
                    if ($message->useridfrom !== $USER->id) {
                        $userfrom = get_record('user', 'id', $message->useridfrom);
                        $fromcontact = (array_key_exists($message->useridfrom, $contacts) and $contacts[$message->useridfrom]->blocked == 0);
                        $fromblocked = (array_key_exists($message->useridfrom, $contacts) and $contacts[$message->useridfrom]->blocked == 1);
                    } else {
                        $userfrom = false;
                        $fromcontact = false;
                        $fromblocked = false;
                    }
                    /// find date string for this message
                    $date = usergetdate($message->timecreated);
                    $datestring = $date['year'] . $date['mon'] . $date['mday'];
                    /// print out message row
                    echo '<tr valign="top">';
                    echo '<td class="contact">';
                    message_print_user($userfrom, $fromcontact, $fromblocked);
                    echo '</td>';
                    echo '<td class="contact">';
                    message_print_user($userto, $tocontact, $toblocked);
                    echo '</td>';
                    echo '<td class="summary">' . message_get_fragment($message->message, $keywords);
                    echo '<br /><div class="link">';
                    message_history_link($message->useridto, $message->useridfrom, false, $keywordstring, 'm' . $message->id, $strcontext);
                    echo '</div>';
                    echo '</td>';
                    echo '<td class="date">' . userdate($message->timecreated, $dateformat) . '</td>';
                    echo "</tr>\n";
                }
                if ($blockedcount > 0) {
                    echo '<tr><td colspan="4" align="center">' . get_string('blockedmessages', 'message', $blockedcount) . '</td></tr>';
                }
                echo '</table>';
            } else {
                notify(get_string('nosearchresults', 'message'));
            }
            /// what the ????, probably an empty search string, duh!
        } else {
            notify(get_string('emptysearchstring', 'message'));
        }
    }
    echo '<br />';
    print_single_button('index.php', array('tab' => 'search'), get_string('newsearch', 'message'));
    echo '</div>';
}
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:lib.php


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