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


PHP message_format_message_text函数代码示例

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


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

示例1: export_for_template

 public function export_for_template(\renderer_base $output)
 {
     global $USER;
     $context = clone $this->notification;
     if ($context->useridto == $USER->id && $context->timeusertodeleted) {
         $context->deleted = true;
     } else {
         $context->deleted = false;
     }
     $context->timecreatedpretty = get_string('ago', 'message', format_time(time() - $context->timecreated));
     $context->text = message_format_message_text($context);
     $context->read = $context->timeread ? true : false;
     $context->shortenedsubject = shorten_text($context->subject, 125);
     if (!empty($context->component) && substr($context->component, 0, 4) == 'mod_') {
         $iconurl = $output->pix_url('icon', $context->component);
     } else {
         $iconurl = $output->pix_url('i/marker', 'core');
     }
     $context->iconurl = $iconurl->out();
     return $context;
 }
开发者ID:dg711,项目名称:moodle,代码行数:21,代码来源:popup_notification.php

示例2: get_messages


//.........这里部分代码省略.........
     $newestfirst = $params['newestfirst'];
     $limitfrom = $params['limitfrom'];
     $limitnum = $params['limitnum'];
     $allowedvalues = array('notifications', 'conversations', 'both');
     if (!in_array($type, $allowedvalues)) {
         throw new invalid_parameter_exception('Invalid value for type parameter (value: ' . $type . '),' . 'allowed values are: ' . implode(',', $allowedvalues));
     }
     // Check if private messaging between users is allowed.
     if (empty($CFG->messaging)) {
         // If we are retreiving only conversations, and messaging is disabled, throw an exception.
         if ($type == "conversations") {
             throw new moodle_exception('disabled', 'message');
         }
         if ($type == "both") {
             $warning = array();
             $warning['item'] = 'message';
             $warning['itemid'] = $USER->id;
             $warning['warningcode'] = '1';
             $warning['message'] = 'Private messages (conversations) are not enabled in this site.
                 Only notifications will be returned';
             $warnings[] = $warning;
         }
     }
     if (!empty($useridto)) {
         if (core_user::is_real_user($useridto)) {
             $userto = core_user::get_user($useridto, '*', MUST_EXIST);
         } else {
             throw new moodle_exception('invaliduser');
         }
     }
     if (!empty($useridfrom)) {
         // We use get_user here because the from user can be the noreply or support user.
         $userfrom = core_user::get_user($useridfrom, '*', MUST_EXIST);
     }
     // Check if the current user is the sender/receiver or just a privileged user.
     if ($useridto != $USER->id and $useridfrom != $USER->id and !has_capability('moodle/site:readallmessages', $context)) {
         throw new moodle_exception('accessdenied', 'admin');
     }
     // Which type of messages to retrieve.
     $notifications = -1;
     if ($type != 'both') {
         $notifications = $type == 'notifications' ? 1 : 0;
     }
     $orderdirection = $newestfirst ? 'DESC' : 'ASC';
     $sort = "mr.timecreated {$orderdirection}";
     if ($messages = message_get_messages($useridto, $useridfrom, $notifications, $read, $sort, $limitfrom, $limitnum)) {
         $canviewfullname = has_capability('moodle/site:viewfullnames', $context);
         // In some cases, we don't need to get the to/from user objects from the sql query.
         $userfromfullname = '';
         $usertofullname = '';
         // In this case, the useridto field is not empty, so we can get the user destinatary fullname from there.
         if (!empty($useridto)) {
             $usertofullname = fullname($userto, $canviewfullname);
             // The user from may or may not be filled.
             if (!empty($useridfrom)) {
                 $userfromfullname = fullname($userfrom, $canviewfullname);
             }
         } else {
             // If the useridto field is empty, the useridfrom must be filled.
             $userfromfullname = fullname($userfrom, $canviewfullname);
         }
         foreach ($messages as $mid => $message) {
             // Do not return deleted messages.
             if ($useridto == $USER->id and $message->timeusertodeleted or $useridfrom == $USER->id and $message->timeuserfromdeleted) {
                 unset($messages[$mid]);
                 continue;
             }
             // We need to get the user from the query.
             if (empty($userfromfullname)) {
                 // Check for non-reply and support users.
                 if (core_user::is_real_user($message->useridfrom)) {
                     $user = new stdClass();
                     $user = username_load_fields_from_object($user, $message, 'userfrom');
                     $message->userfromfullname = fullname($user, $canviewfullname);
                 } else {
                     $user = core_user::get_user($message->useridfrom);
                     $message->userfromfullname = fullname($user, $canviewfullname);
                 }
             } else {
                 $message->userfromfullname = $userfromfullname;
             }
             // We need to get the user from the query.
             if (empty($usertofullname)) {
                 $user = new stdClass();
                 $user = username_load_fields_from_object($user, $message, 'userto');
                 $message->usertofullname = fullname($user, $canviewfullname);
             } else {
                 $message->usertofullname = $usertofullname;
             }
             // This field is only available in the message_read table.
             if (!isset($message->timeread)) {
                 $message->timeread = 0;
             }
             $message->text = message_format_message_text($message);
             $messages[$mid] = (array) $message;
         }
     }
     $results = array('messages' => $messages, 'warnings' => $warnings);
     return $results;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:externallib.php

示例3: message_format_message

/**
 * Format a message for display in the message history
 *
 * @param object $message the message object
 * @param string $format optional date format
 * @param string $keywords keywords to highlight
 * @param string $class CSS class to apply to the div around the message
 * @return string the formatted message
 */
function message_format_message($message, $format='', $keywords='', $class='other') {

    static $dateformat;

    //if we haven't previously set the date format or they've supplied a new one
    if ( empty($dateformat) || (!empty($format) && $dateformat != $format) ) {
        if ($format) {
            $dateformat = $format;
        } else {
            $dateformat = get_string('strftimedatetimeshort');
        }
    }
    $time = userdate($message->timecreated, $dateformat);

    $messagetext = message_format_message_text($message, false);

    if ($keywords) {
        $messagetext = highlight($keywords, $messagetext);
    }

    $messagetext .= message_format_contexturl($message);

    $messagetext = clean_text($messagetext, FORMAT_HTML);

    return <<<TEMPLATE
<div class='message $class'>
    <a name="m{$message->id}"></a>
    <span class="message-meta"><span class="time">$time</span></span>: <span class="text">$messagetext</span>
</div>
TEMPLATE;
}
开发者ID:nickbert77,项目名称:moodle,代码行数:40,代码来源:lib.php

示例4: create_messages

 /**
  * Helper function to return an array of messages.
  *
  * @param int $userid
  * @param array $messages
  * @return array
  */
 public static function create_messages($userid, $messages)
 {
     // Store the messages.
     $arrmessages = array();
     // We always view messages from oldest to newest, ensure we have it in that order.
     $lastmessage = end($messages);
     $firstmessage = reset($messages);
     if ($lastmessage->timecreated < $firstmessage->timecreated) {
         $messages = array_reverse($messages);
     }
     // Keeps track of the last day, month and year combo we were viewing.
     $day = '';
     $month = '';
     $year = '';
     foreach ($messages as $message) {
         // Check if we are now viewing a different block period.
         $displayblocktime = false;
         $date = usergetdate($message->timecreated);
         if ($day != $date['mday'] || $month != $date['month'] || $year != $date['year']) {
             $day = $date['mday'];
             $month = $date['month'];
             $year = $date['year'];
             $displayblocktime = true;
         }
         // Store the message to pass to the renderable.
         $msg = new \stdClass();
         $msg->id = $message->id;
         $msg->text = message_format_message_text($message);
         $msg->currentuserid = $userid;
         $msg->useridfrom = $message->useridfrom;
         $msg->useridto = $message->useridto;
         $msg->displayblocktime = $displayblocktime;
         $msg->timecreated = $message->timecreated;
         $msg->timeread = $message->timeread;
         $arrmessages[] = $msg;
     }
     return $arrmessages;
 }
开发者ID:dg711,项目名称:moodle,代码行数:45,代码来源:helper.php


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