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


PHP html_to_text函数代码示例

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


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

示例1: readquestions

 protected function readquestions($lines)
 {
     // For this class the method has been simplified as
     // there can never be more than one question for a
     // multianswer import
     $questions = array();
     $questiontext = array();
     $questiontext['text'] = implode('', $lines);
     $questiontext['format'] = 0;
     $questiontext['itemid'] = '';
     $question = qtype_multianswer_extract_question($questiontext);
     $question->questiontext = $question->questiontext['text'];
     $question->questiontextformat = 0;
     $question->qtype = MULTIANSWER;
     $question->generalfeedback = '';
     $question->course = $this->course;
     if (!empty($question)) {
         $name = html_to_text(implode(' ', $lines));
         $name = preg_replace('/{[^}]*}/', '', $name);
         $name = trim($name);
         if ($name) {
             $question->name = shorten_text($name, 45);
         } else {
             // We need some name, so use the current time, since that will be
             // reasonably unique.
             $question->name = userdate(time());
         }
         $questions[] = $question;
     }
     return $questions;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:format.php

示例2: direct

 function direct($to_email, $subject = '', $body_html = '')
 {
     $body_text = html_to_text($body_html);
     $this->CI->load->library('composer/lib_aws');
     $ses_client = $this->CI->lib_aws->get_ses();
     try {
         $result = $ses_client->sendEmail(['Destination' => ['ToAddresses' => [$to_email]], 'Message' => ['Body' => ['Html' => ['Data' => $body_html], 'Text' => ['Data' => $body_text]], 'Subject' => ['Data' => $subject]], 'Source' => '"' . app_name() . '" <' . getenv('email_postmaster') . '>']);
     } catch (AwsException $e) {
         // handle the error.
         $error_msg = 'getAwsRequestId: ' . $e->getAwsRequestId() . ', getAwsErrorType:' . $e->getAwsErrorType() . ', getAwsErrorCode:' . $e->getAwsErrorCode() . "\n\n";
         $error_msg .= $e->getMessage() . "\n";
         $error_msg .= $e->getTraceAsString();
     }
     if (empty($result)) {
         $this->error = ['message' => $error_msg];
         return NULL;
     } else {
         if (!empty($result['MessageId'])) {
             $result = $result->toArray();
             return $result;
         } else {
             $this->error = ['message' => 'Result missing MessageId', 'result' => $result];
             return NULL;
         }
     }
 }
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:26,代码来源:Lib_send_email.php

示例3: php_report_schedule_export_instance

/**
 * Runs and exports, through email, the report instance specified by the
 * provided report schedule
 *
 * @param   stdClass  $report_schedule  The PHP report schedule containing the information
 *                                      about the specific report to be exported
 *
 * @return  boolean                     true on success, otherwise false
 */
function php_report_schedule_export_instance($report_schedule, $now = 0) {
    global $CFG, $USER;

    if ($now == 0) {
        $now = time();
    }

    $data = unserialize($report_schedule->config);

    // Create report to be emailed to recipient
    $shortname = $report_schedule->report;
    $format = $data['format'];
    // Initialize a temp path name
    $tmppath = '/temp';
    // Create a unique temporary filename to use for this schedule
    $filename = tempnam($CFG->dataroot.$tmppath, 'php_report_');

    $parameterdata = $data['parameters'];

    // Generate the report file
    $result = php_report::export_default_instance($shortname, $format, $filename, $parameterdata, $report_schedule->userid, php_report::EXECUTION_MODE_SCHEDULED);

    if (!$result) {
        //handle failure case
        unlink($filename);
        return false;
    }

    // Attach filename to an email - so get recipient...
    $recipients_array = explode(',',$data['recipients']);
    $from = get_string('noreplyname');
    $subject = get_string('email_subject','local_elisreports').$data['label'];
    $messagetext = html_to_text($data['message']);
    $messagehtml = $data['message'];
    $start = strlen($CFG->dataroot);
    $attachment = substr($filename,$start);
    $attachname = $report_schedule->report.$now.'.'.$data['format'];

    // $user->id & all other fields now required by Moodle 2.6+ email_to_user() API which also calls fullname($user)
    $user = new stdClass;
    $allfields = get_all_user_name_fields();
    foreach ($allfields as $field) {
        $user->$field = null;
    }
    $user->id = $USER->id; // let's just use this user as default (TBD)
    $user->mailformat = 1;

    // Attach the file to the recipients
    foreach ($recipients_array as $recipient) {
        $user->email = trim($recipient);
        email_to_user($user, $from, $subject, $messagetext, $messagehtml, $attachment, $attachname);
    }

    // Remove the file that was created for this report
    unlink($filename);

    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:67,代码来源:runschedule.php

示例4: summarise_response

 public function summarise_response(array $response)
 {
     if (isset($response['answer'])) {
         $formatoptions = new stdClass();
         $formatoptions->para = false;
         return html_to_text(format_text($response['answer'], FORMAT_HTML, $formatoptions), 0, false);
     } else {
         return null;
     }
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:10,代码来源:question.php

示例5: send_welcome

/**
 * This plugin sends users a welcome message after logging in
 * and notify a moderator a new user has been added
 * it has a settings page that allow you to configure the messages
 * send.
 *
 * @package    local
 * @subpackage welcome
 * @copyright  2014 Bas Brands, basbrands.nl, bas@sonsbeekmedia.nl
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function send_welcome($user)
{
    global $CFG, $SITE;
    $moderator = get_admin();
    $sender = get_admin();
    if (!empty($user->email)) {
        $config = get_config('local_welcome');
        if (!empty($config->auth_plugins)) {
            $auths = explode(',', $config->auth_plugins);
            if (!in_array($user->auth, $auths)) {
                return '';
            }
        } else {
            return '';
        }
        $moderator->email = $config->moderator_email;
        $sender->email = $config->sender_email;
        $sender->firstname = $config->sender_firstname;
        $sender->lastname = $config->sender_lastname;
        $message_user_enabled = $config->message_user_enabled;
        $message_user = $config->message_user;
        $message_user_subject = $config->message_user_subject;
        $message_moderator_enabled = $config->message_moderator_enabled;
        $message_moderator = $config->message_moderator;
        $message_moderator_subject = $config->message_moderator_subject;
        if (!empty($user->country)) {
            $user->country = get_string($user->country, 'countries');
        } else {
            $user->country = '';
        }
        $sitelink = html_writer::link(new moodle_url('/'), $SITE->fullname);
        $resetpasswordlink = html_writer::link(new moodle_url('/login/forgot_password.php'), get_string('resetpass', 'local_welcome'));
        $fields = array('[[fullname]]', '[[username]]', '[[firstname]]', '[[lastname]]', '[[email]]', '[[city]]', '[[country]]', '[[sitelink]]', '[[sitename]]', '[[resetpasswordlink]]');
        $values = array(fullname($user), $user->username, $user->firstname, $user->lastname, $user->email, $user->city, $user->country, $sitelink, $SITE->fullname, $resetpasswordlink);
        $message_user = str_replace($fields, $values, $message_user);
        $message_user_subject = str_replace($fields, $values, $message_user_subject);
        $message_moderator = str_replace($fields, $values, $message_moderator);
        $message_moderator_subject = str_replace($fields, $values, $message_moderator_subject);
        if (!empty($message_user) && !empty($sender->email) && $message_user_enabled) {
            email_to_user($user, $sender, $message_user_subject, html_to_text($message_user), $message_user);
        }
        if (!empty($message_moderator) && !empty($sender->email) && $message_moderator_enabled) {
            email_to_user($moderator, $sender, $message_moderator_subject, html_to_text($message_moderator), $message_moderator);
        }
    }
}
开发者ID:RicardoMaurici,项目名称:moodle-local_welcome,代码行数:57,代码来源:event_handlers.php

示例6: php_report_schedule_export_instance

/**
 * Runs and exports, through email, the report instance specified by the
 * provided report schedule
 *
 * @param   stdClass  $report_schedule  The PHP report schedule containing the information
 *                                      about the specific report to be exported
 *
 * @return  boolean                     true on success, otherwise false
 */
function php_report_schedule_export_instance($report_schedule, $now = 0)
{
    global $CFG;
    if ($now == 0) {
        $now = gmmktime();
        // time();
    }
    $data = unserialize($report_schedule->config);
    // Create report to be emailed to recipient
    $shortname = $report_schedule->report;
    $format = $data['format'];
    // Initialize a temp path name
    $tmppath = '/temp';
    // Create a unique temporary filename to use for this schedule
    $filename = tempnam($CFG->dataroot . $tmppath, 'php_report_');
    $parameterdata = $data['parameters'];
    // Generate the report file
    $result = php_report::export_default_instance($shortname, $format, $filename, $parameterdata, $report_schedule->userid, php_report::EXECUTION_MODE_SCHEDULED);
    if (!$result) {
        //handle failure case
        unlink($filename);
        return false;
    }
    // Attach filename to an email - so get recipient...
    $recipients_array = explode(',', $data['recipients']);
    $from = get_string('noreplyname');
    $subject = get_string('email_subject', 'block_php_report') . $data['label'];
    $messagetext = html_to_text($data['message']);
    $messagehtml = $data['message'];
    $start = strlen($CFG->dataroot);
    $attachment = substr($filename, $start);
    $attachname = $report_schedule->report . $now . '.' . $data['format'];
    // Attach the file to the recipients
    foreach ($recipients_array as $recipient) {
        $user = new stdClass();
        $user->email = $recipient;
        $user->mailformat = 1;
        email_to_user($user, $from, $subject, $messagetext, $messagehtml, $attachment, $attachname);
    }
    // Remove the file that was created for this report
    unlink($filename);
    return true;
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:52,代码来源:runschedule.php

示例7: readquestions

    public function readquestions($lines) {
        question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded.

        // For this class the method has been simplified as
        // there can never be more than one question for a
        // multianswer import.
        $questions = array();

        $questiontext = array();
        $questiontext['text'] = implode('', $lines);
        $questiontext['format'] = FORMAT_MOODLE;
        $questiontext['itemid'] = '';
        $question = qtype_multianswer_extract_question($questiontext);
        $question->questiontext = $question->questiontext['text'];
        $question->questiontextformat = 0;

        $question->qtype = 'multianswer';
        $question->generalfeedback = '';
        $question->generalfeedbackformat = FORMAT_MOODLE;
        $question->length = 1;
        $question->penalty = 0.3333333;

        if (!empty($question)) {
            $name = html_to_text(implode(' ', $lines));
            $name = preg_replace('/{[^}]*}/', '', $name);
            $name = trim($name);

            if ($name) {
                $question->name = shorten_text($name, 45);
            } else {
                // We need some name, so use the current time, since that will be
                // reasonably unique.
                $question->name = userdate(time());
            }

            $questions[] = $question;
        }

        return $questions;
    }
开发者ID:netspotau,项目名称:moodle-mod_assign,代码行数:40,代码来源:format.php

示例8: replacements

 /**
  *
  */
 protected function replacements(array $patterns, $entry, array $options = null)
 {
     $field = $this->_field;
     $fieldname = $field->name;
     $edit = !empty($options['edit']);
     $haseditreplacement = false;
     $editablepatterns = array("[[{$fieldname}]]", "[[{$fieldname}:text]]", "[[{$fieldname}:textlinks]]");
     $replacements = array_fill_keys(array_keys($patterns), '');
     foreach ($patterns as $pattern => $cleanpattern) {
         if ($edit and !$haseditreplacement) {
             $patterneditable = in_array($cleanpattern, $editablepatterns);
             if ($patterneditable and !($noedit = $this->is_noedit($pattern))) {
                 $required = $this->is_required($pattern);
                 $editparams = array($entry, array('required' => $required));
                 $replacements[$pattern] = array(array($this, 'display_edit'), $editparams);
                 $haseditreplacement = true;
                 continue;
             }
         }
         switch ($cleanpattern) {
             case "[[{$fieldname}]]":
                 $replacements[$pattern] = $this->display_browse($entry);
                 break;
                 // Plain text, no links.
             // Plain text, no links.
             case "[[{$fieldname}:text]]":
                 $replacements[$pattern] = html_to_text($this->display_browse($entry, array('text' => true)));
                 break;
                 // Plain text, with links.
             // Plain text, with links.
             case "[[{$fieldname}:textlinks]]":
                 $replacements[$pattern] = $this->display_browse($entry, array('text' => true, 'links' => true));
                 break;
             case "[[{$fieldname}:wordcount]]":
                 $replacements[$pattern] = $this->word_count($entry);
                 break;
         }
     }
     return $replacements;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:43,代码来源:renderer.php

示例9: atom_add_items

function atom_add_items($items)
{
    global $CFG;
    $result = '';
    $xhtmlattr = array('type' => 'xhtml');
    if (!empty($items)) {
        foreach ($items as $item) {
            $result .= atom_start_tag('entry', 1, true);
            $result .= atom_full_tag('title', 2, false, htmlspecialchars(html_to_text($item->title)));
            $result .= atom_full_tag('link', 2, false, null, array('href' => $item->link, 'rel' => 'alternate'));
            $result .= atom_full_tag('updated', 2, false, date_format_rfc3339($item->pubdate));
            //Include the author if exists
            if (isset($item->author)) {
                $result .= atom_start_tag('author', 2, true);
                $result .= atom_full_tag('name', 3, false, $item->author);
                $result .= atom_end_tag('author', 2, true);
            }
            $result .= atom_full_tag('content', 2, false, '<div xmlns="http://www.w3.org/1999/xhtml">' . clean_text($item->description, FORMAT_HTML) . '</div>', $xhtmlattr);
            $result .= atom_full_tag('id', 2, false, $item->link);
            if (isset($item->tags)) {
                $tagdata = array();
                if (isset($item->tagscheme)) {
                    $tagdata['scheme'] = $item->tagscheme;
                }
                foreach ($item->tags as $tag) {
                    $tagdata['term'] = $tag;
                    $result .= atom_full_tag('category', 2, true, false, $tagdata);
                }
            }
            $result .= atom_end_tag('entry', 1, true);
        }
    } else {
        $result = false;
    }
    return $result;
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:36,代码来源:atomlib.php

示例10: summarise_manual_comment

    /**
     * @return string a summary of a manual comment action.
     * @param unknown_type $step
     */
    protected function summarise_manual_comment($step) {
        $a = new stdClass();
        if ($step->has_behaviour_var('comment')) {
            $a->comment = shorten_text(html_to_text($this->format_comment(
                    $step->get_behaviour_var('comment')), 0, false), 200);
        } else {
            $a->comment = '';
        }

        $mark = $step->get_behaviour_var('mark');
        if (is_null($mark) || $mark === '') {
            return get_string('commented', 'question', $a->comment);
        } else {
            $a->mark = $mark / $step->get_behaviour_var('maxmark') * $this->qa->get_max_mark();
            return get_string('manuallygraded', 'question', $a);
        }
    }
开发者ID:nigeli,项目名称:moodle,代码行数:21,代码来源:behaviourbase.php

示例11: message_post_message

/**
 * Send a message from one user to another. Will be delivered according to the message recipients messaging preferences
 *
 * @param object $userfrom the message sender
 * @param object $userto the message recipient
 * @param string $message the message
 * @param int $format message format such as FORMAT_PLAIN or FORMAT_HTML
 * @return int|false the ID of the new message or false
 */
function message_post_message($userfrom, $userto, $message, $format) {
    global $SITE, $CFG, $USER;

    $eventdata = new stdClass();
    $eventdata->component        = 'moodle';
    $eventdata->name             = 'instantmessage';
    $eventdata->userfrom         = $userfrom;
    $eventdata->userto           = $userto;

    //using string manager directly so that strings in the message will be in the message recipients language rather than the senders
    $eventdata->subject          = get_string_manager()->get_string('unreadnewmessage', 'message', fullname($userfrom), $userto->lang);

    if ($format == FORMAT_HTML) {
        $eventdata->fullmessagehtml  = $message;
        //some message processors may revert to sending plain text even if html is supplied
        //so we keep both plain and html versions if we're intending to send html
        $eventdata->fullmessage = html_to_text($eventdata->fullmessagehtml);
    } else {
        $eventdata->fullmessage      = $message;
        $eventdata->fullmessagehtml  = '';
    }

    $eventdata->fullmessageformat = $format;
    $eventdata->smallmessage     = $message;//store the message unfiltered. Clean up on output.

    $s = new stdClass();
    $s->sitename = format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
    $s->url = $CFG->wwwroot.'/message/index.php?user='.$userto->id.'&id='.$userfrom->id;

    $emailtagline = get_string_manager()->get_string('emailtagline', 'message', $s, $userto->lang);
    if (!empty($eventdata->fullmessage)) {
        $eventdata->fullmessage .= "\n\n---------------------------------------------------------------------\n".$emailtagline;
    }
    if (!empty($eventdata->fullmessagehtml)) {
        $eventdata->fullmessagehtml .= "<br /><br />---------------------------------------------------------------------<br />".$emailtagline;
    }

    $eventdata->timecreated     = time();
    $eventdata->notification    = 0;
    return message_send($eventdata);
}
开发者ID:nickbert77,项目名称:moodle,代码行数:50,代码来源:lib.php

示例12: format_text_email

/**
 * Given text in a variety of format codings, this function returns the text as plain text suitable for plain email.
 *
 * @param string $text The text to be formatted. This is raw text originally from user input.
 * @param int $format Identifier of the text format to be used
 *            [FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN]
 * @return string
 */
function format_text_email($text, $format)
{
    switch ($format) {
        case FORMAT_PLAIN:
            return $text;
            break;
        case FORMAT_WIKI:
            // There should not be any of these any more!
            $text = wikify_links($text);
            return core_text::entities_to_utf8(strip_tags($text), true);
            break;
        case FORMAT_HTML:
            return html_to_text($text);
            break;
        case FORMAT_MOODLE:
        case FORMAT_MARKDOWN:
        default:
            $text = wikify_links($text);
            return core_text::entities_to_utf8(strip_tags($text), true);
            break;
    }
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:30,代码来源:weblib.php

示例13: format_column_name

 /**
  * Returns the name of column in export
  * @param object $grade_item
  * @param boolean $feedback feedback colum
  * @param string $gradedisplayname grade display name.
  * @return string
  */
 public function format_column_name($grade_item, $feedback = false, $gradedisplayname = null)
 {
     $column = new stdClass();
     if ($grade_item->itemtype == 'mod') {
         $column->name = get_string('modulename', $grade_item->itemmodule) . get_string('labelsep', 'langconfig') . $grade_item->get_name();
     } else {
         $column->name = $grade_item->get_name();
     }
     // We can't have feedback and display type at the same time.
     $column->extra = $feedback ? get_string('feedback') : get_string($gradedisplayname, 'grades');
     return html_to_text(get_string('gradeexportcolumntype', 'grades', $column), 0, false);
 }
开发者ID:elie89,项目名称:moodle,代码行数:19,代码来源:lib.php

示例14: environment_get_errors

/**
 * Returns array of critical errors in plain text format
 * @param array $environment_results array of results gathered
 * @return array errors
 */
function environment_get_errors($environment_results)
{
    global $CFG;
    $errors = array();
    // Iterate over each environment_result
    foreach ($environment_results as $environment_result) {
        $type = $environment_result->getPart();
        $info = $environment_result->getInfo();
        $status = $environment_result->getStatus();
        $error_code = $environment_result->getErrorCode();
        $a = new stdClass();
        if ($error_code) {
            $a->error_code = $error_code;
            $errors[] = array($info, get_string('environmentxmlerror', 'admin', $a));
            return $errors;
        }
        /// Calculate the status value
        if ($environment_result->getBypassStr() != '') {
            // not interesting
            continue;
        } else {
            if ($environment_result->getRestrictStr() != '') {
                // error
            } else {
                if ($status) {
                    // ok
                    continue;
                } else {
                    if ($environment_result->getLevel() == 'optional') {
                        // just a warning
                        continue;
                    } else {
                        // error
                    }
                }
            }
        }
        // We are comparing versions
        $rec = new stdClass();
        if ($rec->needed = $environment_result->getNeededVersion()) {
            $rec->current = $environment_result->getCurrentVersion();
            if ($environment_result->getLevel() == 'required') {
                $stringtouse = 'environmentrequireversion';
            } else {
                $stringtouse = 'environmentrecommendversion';
            }
            // We are checking installed & enabled things
        } else {
            if ($environment_result->getPart() == 'custom_check') {
                if ($environment_result->getLevel() == 'required') {
                    $stringtouse = 'environmentrequirecustomcheck';
                } else {
                    $stringtouse = 'environmentrecommendcustomcheck';
                }
            } else {
                if ($environment_result->getPart() == 'php_setting') {
                    if ($status) {
                        $stringtouse = 'environmentsettingok';
                    } else {
                        if ($environment_result->getLevel() == 'required') {
                            $stringtouse = 'environmentmustfixsetting';
                        } else {
                            $stringtouse = 'environmentshouldfixsetting';
                        }
                    }
                } else {
                    if ($environment_result->getLevel() == 'required') {
                        $stringtouse = 'environmentrequireinstall';
                    } else {
                        $stringtouse = 'environmentrecommendinstall';
                    }
                }
            }
        }
        $report = get_string($stringtouse, 'admin', $rec);
        // Here we'll store all the feedback found
        $feedbacktext = '';
        // Append  the feedback if there is some
        $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), 'error');
        // Append the restrict if there is some
        $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
        $report .= html_to_text($feedbacktext);
        if ($environment_result->getPart() == 'custom_check') {
            $errors[] = array($info, $report);
        } else {
            $errors[] = array($info !== '' ? "{$type} {$info}" : $type, $report);
        }
    }
    return $errors;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:95,代码来源:environmentlib.php

示例15: bootstrap_process_message

 protected function bootstrap_process_message($message)
 {
     global $DB;
     $messagecontent = new stdClass();
     if ($message->notification) {
         $messagecontent->text = get_string('unreadnewnotification', 'message');
     } else {
         if ($message->fullmessageformat == FORMAT_HTML) {
             $message->smallmessage = html_to_text($message->smallmessage);
         }
         if (core_text::strlen($message->smallmessage) > 15) {
             $messagecontent->text = core_text::substr($message->smallmessage, 0, 15) . '...';
         } else {
             $messagecontent->text = $message->smallmessage;
         }
     }
     if (time() - $message->timecreated <= 3600 * 3) {
         $messagecontent->date = format_time(time() - $message->timecreated);
     } else {
         $messagecontent->date = userdate($message->timecreated, get_string('strftimetime', 'langconfig'));
     }
     $messagecontent->from = $DB->get_record('user', array('id' => $message->useridfrom));
     return $messagecontent;
 }
开发者ID:noelchavez,项目名称:moodle-theme_elegance,代码行数:24,代码来源:core_renderer.php


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