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


PHP html2text::get_text方法代码示例

本文整理汇总了PHP中html2text::get_text方法的典型用法代码示例。如果您正苦于以下问题:PHP html2text::get_text方法的具体用法?PHP html2text::get_text怎么用?PHP html2text::get_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在html2text的用法示例。


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

示例1:

 /**
  * @dataProvider data_html2text
  */
 function test_html2text($title, $in, $out)
 {
     $ht = new html2text(null, false, false);
     $ht->set_html($in);
     $res = $ht->get_text();
     $this->assertEquals($out, $res, $title);
 }
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:10,代码来源:HtmlToText.php

示例2: html2plaintext

function html2plaintext($text, $texthtml0, $wrap)
{
    global $opt, $smiley;
    if ($texthtml0) {
        $text = str_replace(['<p>', "\n", "\r"], '', $text);
        $text = str_replace(['<br />', '</p>'], "\n", $text);
        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
    } else {
        // convert smilies ...
        $countSmileyImage = count($smiley['image']);
        for ($n = 0; $n < $countSmileyImage; $n++) {
            $text = mb_ereg_replace("<img [^>]*?src=[^>]+?" . str_replace('.', '\\.', $smiley['file'][$n]) . "[^>]+?>", "[s![" . $smiley['text'][$n] . "]!s]", $text);
            // the [s[ ]s] is needed to protect the spaces around the smileys
        }
        $h2t = new html2text($text);
        $h2t->set_base_url($opt['page']['default_absolute_url']);
        $h2t->width = $wrap;
        $text = $h2t->get_text();
        $text = str_replace(['[s![', ']!s]'], '', $text);
        // remove e.g. trailing \n created from </p> by html2text
        while (substr($text, -2) == "\n\n") {
            $text = substr($text, 0, strlen($text) - 1);
        }
    }
    return $text;
}
开发者ID:kratenko,项目名称:oc-server3,代码行数:26,代码来源:edithelper.inc.php

示例3: array

 function test_html2text()
 {
     $data = array(0 => array('title' => 'Test entry', 'in' => '', 'out' => ''), 1 => array('title' => 'Basic HTML entities', 'in' => '&quot;&amp;', 'out' => '"&'), 2 => array('title' => 'HTML entity string', 'in' => '&amp;quot;', 'out' => '&quot;'), 3 => array('title' => 'HTML entity in STRONG tag', 'in' => '<strong>&#347;</strong>', 'out' => 'Ś'), 4 => array('title' => 'STRONG tag to upper-case conversion', 'in' => '<strong>ś</strong>', 'out' => 'Ś'), 5 => array('title' => 'STRONG inside B tag', 'in' => '<b><strong>&#347;</strong></b>', 'out' => 'Ś'));
     $ht = new html2text(null, false, false);
     foreach ($data as $idx => $item) {
         $ht->set_html($item['in']);
         $res = $ht->get_text();
         $this->assertEqual($item['out'], $res, $item['title'] . "({$idx})");
     }
 }
开发者ID:npk,项目名称:roundcubemail,代码行数:10,代码来源:html_to_text.php

示例4: html2plaintext

function html2plaintext($text, $texthtml0)
{
    global $opt, $absolute_server_URI;
    if ($texthtml0) {
        $text = str_replace(array('<p>', "\n", "\r"), '', $text);
        $text = str_replace(array('<br />', '</p>'), "\n", $text);
        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
    } else {
        $h2t = new html2text($text);
        $h2t->set_base_url(isset($opt['page']['absolute_url']) ? $opt['page']['absolute_url'] : $absolute_server_URI);
        $text = $h2t->get_text();
        // remove e.g. trailing \n created from </p> by html2text
        while (substr($text, -2) == "\n\n") {
            $text = substr($text, 0, strlen($text) - 1);
        }
    }
    return $text;
}
开发者ID:harrieklomp,项目名称:oc-server3,代码行数:18,代码来源:edithelper.inc.php

示例5: htmlmail

function htmlmail($to, $subject, $htmlmsg)
{
    require_once 'class.html2text.php';
    $boundary = 'Msg_Boundary--';
    $htmltype = 'text/html; charset="iso-8859-1"';
    $plaintype = str_replace('html', 'plain', $htmltype);
    if (stripos($htmlmsg, '<html') === FALSE) {
        $htmlmsg = "<html>{$htmlmsg}</html>";
    }
    $h2t = new html2text($htmlmsg);
    $plain = $h2t->get_text();
    while (stripos($plain, $boundary) + stripos($htmlmsg, $boundary) > 0) {
        $boundary .= rand();
    }
    // prevent malicious hacking
    $msg = <<<EOF
If you see this message, you may need a newer email program.
--{$boundary}
Content-Type: {$plaintype}
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

{$plain}
--{$boundary}
Mime-Version: 1.0
Content-Type: {$htmltype}
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

{$htmlmsg}
--{$boundary}--
EOF;
    $hdrs = array('From' => 'rC4 <' . SYS_EMAIL . '>', 'Return-Path' => SYS_EMAIL, 'Errors-To' => SYS_EMAIL, 'Content-Type' => "multipart/alternative; boundary=\"{$boundary}\"");
    $smhdrs = '';
    foreach ($hdrs as $key => $value) {
        $smhdrs .= "{$key}: {$value}\n";
    }
    $smhdrs = substr($smhdrs, 0, strlen($smhdrs) - strlen("\n"));
    // omit final EOL
    mail($to, $subject, $msg, $smhdrs, '-f' . SYS_EMAIL);
}
开发者ID:maduhu,项目名称:rCredits,代码行数:41,代码来源:forward.php

示例6: _ff_getListField_gettopic

function _ff_getListField_gettopic($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE;
    global $_FF_CONF, $_SYSTEM, $LANG_GF02, $LANG_GF03;
    USES_lib_html2text();
    $dt = new Date('now', $_USER['tzid']);
    $retval = '';
    switch ($fieldname) {
        case 'author':
            $retval = $A['name'];
            break;
        case 'date':
            $dt->setTimestamp($fieldvalue);
            $retval = $dt->format($_FF_CONF['default_Datetime_format'], true);
            break;
        case 'lastupdated':
            $dt->setTimestamp($fieldvalue);
            $retval = $dt->format($_FF_CONF['default_Datetime_format'], true);
            break;
        case 'subject':
            $testText = FF_formatTextBlock($A['comment'], 'text', 'text', $A['status']);
            $testText = strip_tags($testText);
            $html2txt = new html2text($testText, false);
            $testText = trim($html2txt->get_text());
            $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt());
            $retval = '<span class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" title="' . $A['subject'] . '::' . $lastpostinfogll . '">' . $fieldvalue . '</span>';
            break;
        case 'select':
            $retval = '[&nbsp;<a href="#" onclick="insert_topic(\'' . $A['id'] . '\'); return false;">' . $LANG_GF03['select'] . '</a>&nbsp;]';
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}
开发者ID:spacequad,项目名称:glfusion,代码行数:36,代码来源:gettopic.php

示例7: mailstory

/**
* Email story to a friend
*
* @param    string  $sid        id of story to email
* @param    string  $to         name of person / friend to email
* @param    string  $toemail    friend's email address
* @param    string  $from       name of person sending the email
* @param    string  $fromemail  sender's email address
* @param    string  $shortmsg   short intro text to send with the story
* @return   string              Meta refresh
*
* Modification History
*
* Date        Author        Description
* ----        ------        -----------
* 4/17/01    Tony Bibbs    Code now allows anonymous users to send email
*                and it allows user to input a message as well
*                Thanks to Yngve Wassvik Bergheim for some of
*                this code
*
*/
function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg, $html = 0)
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG08;
    $dt = new Date('now', $_USER['tzid']);
    $storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
    if ($_CONF['url_rewrite']) {
        $retURL = $storyurl . '?msg=85';
    } else {
        $retURL = $storyurl . '&amp;msg=85';
    }
    // check for correct $_CONF permission
    if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) {
        echo COM_refresh($retURL);
        exit;
    }
    // check if emailing of stories is disabled
    if ($_CONF['hideemailicon'] == 1) {
        echo COM_refresh($retURL);
        exit;
    }
    // check mail speedlimit
    COM_clearSpeedlimit($_CONF['speedlimit'], 'mail');
    if (COM_checkSpeedlimit('mail') > 0) {
        echo COM_refresh($retURL);
        exit;
    }
    $filter = sanitizer::getInstance();
    if ($html) {
        $filter->setPostmode('html');
    } else {
        $filter->setPostmode('text');
    }
    $allowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_default']);
    $filter->setAllowedElements($allowedElements);
    $filter->setCensorData(true);
    $filter->setReplaceTags(true);
    $filter->setNamespace('glfusion', 'mail_story');
    $sql = "SELECT uid,title,introtext,bodytext,story_image,commentcode,UNIX_TIMESTAMP(date) AS day,postmode FROM {$_TABLES['stories']} WHERE sid = '" . DB_escapeString($sid) . "'" . COM_getTopicSql('AND') . COM_getPermSql('AND');
    $result = DB_query($sql);
    if (DB_numRows($result) == 0) {
        return COM_refresh($_CONF['site_url'] . '/index.php');
    }
    $A = DB_fetchArray($result);
    $result = PLG_checkforSpam($shortmsg, $_CONF['spamx']);
    if ($result > 0) {
        COM_updateSpeedlimit('mail');
        COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden');
    }
    USES_lib_html2text();
    $T = new Template($_CONF['path_layout'] . 'email/');
    $T->set_file(array('html_msg' => 'mailstory_html.thtml', 'text_msg' => 'mailstory_text.thtml'));
    // filter any HTML from the short message
    $shortmsg = $filter->filterHTML($shortmsg);
    $html2txt = new html2text($shortmsg, false);
    $shortmsg_text = $html2txt->get_text();
    $story_body = COM_truncateHTML($A['introtext'], 512);
    $html2txt = new html2text($story_body, false);
    $story_body_text = $html2txt->get_text();
    $dt->setTimestamp($A['day']);
    $story_date = $dt->format($_CONF['date'], true);
    $story_title = COM_undoSpecialChars($A['title']);
    $story_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
    if ($_CONF['contributedbyline'] == 1) {
        $author = COM_getDisplayName($A['uid']);
    } else {
        $author = '';
    }
    if ($A['story_image'] != '') {
        $story_image = $_CONF['site_url'] . $A['story_image'];
    } else {
        $story_image = '';
    }
    $T->set_var(array('shortmsg_html' => $shortmsg, 'shortmsg_text' => $shortmsg_text, 'story_title' => $story_title, 'story_date' => $story_date, 'story_url' => $story_url, 'author' => $author, 'story_image' => $story_image, 'story_body_html' => $story_body, 'story_body_text' => $story_body_text, 'lang_by' => $LANG01[1], 'site_name' => $_CONF['site_name'], 'from_name' => $from, 'disclaimer' => sprintf($LANG08[23], $from, $fromemail)));
    $T->parse('message_body_html', 'html_msg');
    $message_body_html = $T->finish($T->get_var('message_body_html'));
    $T->parse('message_body_text', 'text_msg');
    $message_body_text = $T->finish($T->get_var('message_body_text'));
    $msgData = array('htmlmessage' => $message_body_html, 'textmessage' => $message_body_text, 'subject' => $story_title, 'from' => array('email' => $_CONF['site_mail'], 'name' => $from), 'to' => array('email' => $toemail, 'name' => $to));
    $mailto = array();
//.........这里部分代码省略.........
开发者ID:spacequad,项目名称:glfusion,代码行数:101,代码来源:profiles.php

示例8: foreach

 /**
  * Return the first text part of this message
  *
  * @param rcube_message_part $part Reference to the part if found
  * @return string Plain text message/part content
  */
 function first_text_part(&$part = null)
 {
     // no message structure, return complete body
     if (empty($this->parts)) {
         return $this->body;
     }
     // check all message parts
     foreach ($this->mime_parts as $mime_id => $part) {
         if ($part->mimetype == 'text/plain') {
             return $this->get_part_content($mime_id);
         } else {
             if ($part->mimetype == 'text/html') {
                 $out = $this->get_part_content($mime_id);
                 // remove special chars encoding
                 $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
                 $out = strtr($out, $trans);
                 // create instance of html2text class
                 $txt = new html2text($out);
                 return $txt->get_text();
             }
         }
     }
     $part = null;
     return null;
 }
开发者ID:rockchow2002,项目名称:roundcubemail,代码行数:31,代码来源:rcube_message.php

示例9: phpmailerAppException

     $body = file_get_contents('contents.html');
 } else {
     $body = $_POST['Message'];
 }
 $example_code .= "\n\$body = \"" . $body . '";';
 $mail->WordWrap = 80;
 // set word wrap
 $mail->IsHTML(true);
 // send as HTML
 $mail->Body = $body;
 $example_code .= "\n\$mail->WordWrap = 80;";
 $example_code .= "\n\$mail->IsHTML(true); // send as HTML";
 $example_code .= "\n\$mail->Body = \"{$body}\";";
 // for non-HTML mail clients
 $h2t = new html2text($body);
 $mail->AltBody = $h2t->get_text();
 $example_code .= "\n\$h2t =& new html2text(\$body);";
 $example_code .= "\n\$mail->AltBody = \$h2t->get_text();";
 $mail->AddAttachment("images/aikido.gif", "aikido.gif");
 // optional name
 $mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif");
 // optional name
 $example_code .= "\n\$mail->AddAttachment(\"images/aikido.gif\", \"aikido.gif\");  // optional name";
 $example_code .= "\n\$mail->AddAttachment(\"images/phpmailer.gif\", \"phpmailer.gif\");  // optional name";
 try {
     if (!$mail->Send()) {
         $error = "Unable to send to: " . $to . "<br />";
         throw new phpmailerAppException($error);
     } else {
         $results_messages[] = "Message has been sent using " . strtoupper($_POST["test_type"]);
     }
开发者ID:Lanou94,项目名称:intranet,代码行数:31,代码来源:index.php

示例10: htmlToText

 /**
  * Convert a HTML string into a text one using html2text
  *
  * @param string $html  the tring to be converted
  * @return string       the converted string
  * @access public
  * @static
  */
 static function htmlToText($html)
 {
     require_once 'packages/html2text/class.html2text.inc';
     $converter = new html2text($html);
     return $converter->get_text();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:14,代码来源:String.php

示例11: isset

 // we are the cache-owner
 $tplname = 'removelog_cacheowner';
 if ($commit == 1) {
     //send email to logowner
     $email_content = read_file($stylepath . '/email/removed_log.email');
     $message = isset($_POST['logowner_message']) ? $_POST['logowner_message'] : '';
     if ($message != '') {
         //message to logowner
         $message = $removed_message_title . "\n" . $message . "\n" . $removed_message_end;
     }
     $logtext = $log_record['log_text'];
     if ($log_record['text_html'] != 0) {
         $logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
         $h2t = new html2text($logtext);
         $h2t->set_base_url($absolute_server_URI);
         $logtext = $h2t->get_text();
     }
     $logtext = $removed_text_title . "\n" . trim($logtext) . "\n" . $removed_text_end;
     //get cache owner name
     $cache_owner_rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $log_record['cache_owner_id']);
     $cache_owner_record = sql_fetch_array($cache_owner_rs);
     mysql_free_result($cache_owner_rs);
     //get email address of logowner
     $log_user_rs = sql("SELECT `email`, `username` FROM `user` WHERE `user_id`='&1'", $log_record['log_user_id']);
     $log_user_record = sql_fetch_array($log_user_rs);
     mysql_free_result($log_user_rs);
     // insert log data
     $email_content = mb_ereg_replace('%log_owner%', $log_user_record['username'], $email_content);
     $email_content = mb_ereg_replace('%cache_owner%', $cache_owner_record['username'], $email_content);
     $email_content = mb_ereg_replace('%cache_name%', $log_record['cache_name'], $email_content);
     $email_content = mb_ereg_replace('%cache_wp%', $log_record['wp_oc'], $email_content);
开发者ID:4Vs,项目名称:oc-server3,代码行数:31,代码来源:removelog.php

示例12: html2text

 /**
  * Convert an HTML string into plain text.
  * @param string $html The HTML text to convert
  * @param bool $advanced Should this use the more complex html2text converter or just a simple one?
  * @return string
  */
 public function html2text($html, $advanced = false)
 {
     if ($advanced) {
         require_once 'extras/class.html2text.php';
         $h = new html2text($html);
         return $h->get_text();
     }
     return html_entity_decode(trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet);
 }
开发者ID:Toney,项目名称:xmcms,代码行数:15,代码来源:class.phpmailer.php

示例13: buildmsg


//.........这里部分代码省略.........
                $this->EmailSubject = MIME_Words::encode_mimeword($this->EmailSubject, "Q", $this->Charset);
            }
            if ($this->_check_if_contain_utf8($self->RealName)) {
                $this->RealName = MIME_Words::encode_mimeword($this->RealName, "Q", $this->Charset);
            }
            $this->EmailMessage = GetMail::encode_language($this->Charset, $this->EmailMessage);
        } else {
            if ($this->_check_if_contain_utf8($this->EmailSubject)) {
                $this->EmailSubject = MIME_Words::encode_mimeword($this->EmailSubject, "B", $this->Charset);
            }
            if ($this->_check_if_contain_utf8($this->RealName)) {
                $this->RealName = MIME_Words::encode_mimeword($this->RealName, "B", $this->Charset);
            }
            $this->EmailMessage = GetMail::encode_language($this->Charset, $this->EmailMessage);
        }
        $this->mime->setSubject($this->EmailSubject);
        $this->RealName = trim($this->RealName);
        if (strlen($this->RealName) > 0 && $pref['allow_FullName']) {
            $this->mime->setFrom("{$this->RealName} <{$this->EmailFrom}>");
        } else {
            $this->mime->setFrom($this->EmailFrom);
        }
        // Convert back any @Mail created links that redirect through parse.php
        // and javascript.opencompose() (only if replying to or forwarding a msg)
        if ($this->ReplyFwd == 'reply' || $this->ReplyFwd == 'forward') {
            $this->_cleanLinks();
        }
        // If user is using the HTML editor, send a HTML message otherwise plain txt
        if (strpos($this->ContentType, 'html') !== false) {
            $this->mime->headers(array('To' => str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailTo), 'Reply-To' => $this->ReplyTo, 'Content-Type' => "multipart/related; charset=\"{$this->Charset}\"", 'X-Mailer' => $this->XMailer, 'X-Origin' => $this->X_Origin, 'X-Atmail-Account' => $this->Account, 'Date' => $this->Date));
            // Now create the text/plain part also
            require_once 'class.html2text.inc';
            $html2text = new html2text($this->EmailMessage);
            $txt = $html2text->get_text();
            $txt = preg_replace('/^\\s*BODY\\s*\\{.+?\\}/s', '', $txt);
            $html = $this->EmailMessage;
            // Cleanup PGP block if one exists
            if (strpos($this->EmailMessage, '-----BEGIN PGP MESSAGE-----') !== false) {
                $html = PGP::cleanPgpBlock($this->EmailMessage, 'message');
                $txt = PGP::cleanPgpBlock($txt, 'message');
            }
            // Cleanup PGP block if one exists
            if (strpos($this->EmailMessage, '-----BEGIN PGP PUBLIC KEY BLOCK-----') !== false) {
                $html = PGP::cleanPgpBlock($this->EmailMessage, 'pubkey');
                $txt = PGP::cleanPgpBlock($txt, 'pubkey');
            }
            // add the text/html part
            $this->mime->setHTMLBody($html);
            $this->mime->setTXTBody($txt);
        } else {
            $this->mime->headers(array('To' => str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailTo), 'Reply-To' => $this->ReplyTo, 'Content-Type' => "text/plain; charset=\"{$this->Charset}\"", 'X-Origin' => $this->X_Origin, 'X-Atmail-Account' => $this->Account, 'Date' => $this->Date));
            $this->mime->setTXTBody($this->EmailMessage);
        }
        // Append our X-Video mail message
        if (strlen($this->VideoStream) > 0) {
            $this->mime->headers(array('X-VideoMail' => "http://{$pref['videomail_server']}/videomail/view/{$this->VideoStream}"));
        }
        // Added support for CC / BCC messages
        if ($this->EmailCC) {
            $this->mime->addCc(str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailCC));
        }
        $messageid = "<{$_SERVER['REMOTE_PORT']}." . time() . "@{$this->Pop3host}>";
        $this->mime->headers(array('Message-ID' => $messageid));
        // Replace the X-Mailer with our custom copy
        $this->mime->headers(array('X-Mailer' => $this->XMailer));
        if ($this->ReadReceipt) {
开发者ID:BigBlueHat,项目名称:atmailopen,代码行数:67,代码来源:SendMsg.php

示例14: html_to_text

/**
 * Given HTML text, make it into plain text using external function
 *
 * @uses $CFG
 * @param string $html The text to be converted.
 * @return string
 */
function html_to_text($html)
{
    global $CFG;
    require_once $CFG->libdir . '/html2text.php';
    $h2t = new html2text($html);
    $result = $h2t->get_text();
    return $result;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:15,代码来源:weblib.php

示例15: html_to_text

/**
 * Given HTML text, make it into plain text using external function
 *
 * @uses $CFG
 * @param string $html The text to be converted.
 * @return string
 */
function html_to_text($html)
{
    global $CFG;
    require_once $CFG->libdir . '/html2text.php';
    $h2t = new html2text($html);
    $result = $h2t->get_text();
    // html2text does not fix HTML entities so handle those here.
    $result = trim(html_entity_decode($result, ENT_NOQUOTES, 'UTF-8'));
    return $result;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:17,代码来源:weblib.php


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