• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP html2text类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sl_send_email

function sl_send_email($to, $subject, $html, $plain = null, $attachment = null)
{
    if (empty($to)) {
        return false;
    }
    $hash = md5(date('r', time()));
    $headers['From'] = 'The LoveMachine <[email protected]>';
    $headers['To'] = $to;
    if (!empty($html)) {
        if (empty($plain)) {
            $h2t = new html2text($html, 75);
            $plain = $h2t->convert();
        }
        $headers["Content-Type"] = "multipart/alternative; boundary=\"PHP-alt-{$hash}\"";
        $body = "\n--PHP-alt-{$hash}\nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n\n" . $plain . "\n\n--PHP-alt-{$hash}\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n\n" . $html . "\n\n--PHP-alt-{$hash}--";
        if ($attachment != null && !empty($attachment['name']) && !empty($attachment['content'])) {
            $headers["Content-Type"] = "multipart/mixed; boundary=\"PHP-mixed-{$hash}\"";
            //encode it with MIME base64,
            //and split it into smaller chunks
            $attachmentContent = chunk_split(base64_encode($attachment['content']));
            $body = "\n--PHP-mixed-{$hash}\nContent-Type: multipart/alternative; boundary=\"PHP-alt-{$hash}\"\n\n" . $body . "\n--PHP-mixed-{$hash}  \nContent-Type: {$attachment['type']}; name=\"{$attachment['name']}\"  \nContent-Transfer-Encoding: base64  \nContent-Disposition: attachment  \n\n{$attachmentContent}\n--PHP-mixed-{$hash}-- \n";
        }
    } else {
        $body = $plain;
    }
    send_authmail(array('sender' => 'authuser', 'server' => 'gmail-ssl'), $to, $subject, $body, $headers);
    return true;
}
开发者ID:highfidelity,项目名称:love,代码行数:28,代码来源:send_email.php


示例2: test_html2text

 /**
  * @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


示例3: 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


示例4: convert

 public function convert()
 {
     require_once AK_VENDOR_DIR . DS . 'TextParsers' . DS . 'html2text.php';
     $Converter = new html2text(true, 0, false);
     $markdown = str_replace('__AK:AMP__', '&', $Converter->load_string(str_replace('&', '__AK:AMP__', $this->source)));
     require_once AK_VENDOR_DIR . DS . 'TextParsers' . DS . 'smartypants.php';
     $Smartypants = new SmartyPantsTypographer_Parser();
     $markdown = Ak::html_entity_decode(strip_tags($Smartypants->transform($markdown)));
     return trim($this->_simplifyMarkdown($markdown));
 }
开发者ID:joeymetal,项目名称:v1,代码行数:10,代码来源:AkHtmlToText.php


示例5: test_html2text

 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


示例6: 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


示例7: 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


示例8:

 /**
  * Override parent function to make links unique
  * @see html2text::_build_link_list()
  */
 function _build_link_list($link, $display)
 {
     // If links already exists, return its existing reference
     if (array_key_exists($link, $this->links)) {
         return $display . ' [' . $this->links[$link] . ']';
     } else {
         $result = parent::_build_link_list($link, $display);
         preg_match('/\\[(\\d+)\\]$/', $result, $m);
         $reference = $m[1];
         $this->links[$link] = $reference;
         return $result;
     }
 }
开发者ID:stephankellermayr,项目名称:newsletter,代码行数:17,代码来源:Builtin.php


示例9: _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


示例10: first_text_part

 /**
  * Return the first text part of this message
  *
  * @return string Plain text message/part content
  */
 function first_text_part()
 {
     // no message structure, return complete body
     if (empty($this->parts)) {
         return $this->body;
     }
     $out = null;
     // check all message parts
     foreach ($this->mime_parts as $mime_id => $part) {
         $mimetype = strtolower($part->ctype_primary . '/' . $part->ctype_secondary);
         if ($mimetype == 'text/plain') {
             $out = $this->imap->get_message_part($this->uid, $mime_id, $part);
             break;
         } else {
             if ($mimetype == 'text/html') {
                 $html_part = $this->imap->get_message_part($this->uid, $mime_id, $part);
                 // remove special chars encoding
                 $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
                 $html_part = strtr($html_part, $trans);
                 // create instance of html2text class
                 $txt = new html2text($html_part);
                 $out = $txt->get_text();
                 break;
             }
         }
     }
     return $out;
 }
开发者ID:jin255ff,项目名称:company_website,代码行数:33,代码来源:rcube_message.php


示例11: 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


示例12: free_categorizeSave

 public function free_categorizeSave($PostedDatas = null, $category, $ForceCat = 0, $ForceExt = 0)
 {
     include_once dirname(__FILE__) . "/class.html2text.inc";
     $sock = new sockets();
     if (!isset($GLOBALS["uuid"])) {
         $sock = new sockets();
         $GLOBALS["uuid"] = base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes"));
     }
     $uuid = $GLOBALS["uuid"];
     $f = array();
     $ExtractAllUris = $this->ExtractAllUris($PostedDatas);
     if (count($ExtractAllUris) > 0) {
         while (list($num, $ligne) = each($ExtractAllUris)) {
             $f[] = $num;
         }
         $PostedDatas = null;
     }
     $h2t = new html2text($PostedDatas);
     $h2t->get_text();
     while (list($num, $ligne) = each($h2t->_link_array)) {
         if (trim($ligne) == null) {
             continue;
         }
         $ligne = strtolower($ligne);
         $ligne = str_replace("(whois)", "", $ligne);
         $ligne = str_replace("||", "", $ligne);
         $ligne = str_replace("^", "", $ligne);
         $ligne = trim($ligne);
         if (preg_match("#^([0-9\\.]+):[0-9]+#", $ligne, $re)) {
             $websitesToscan[] = $re[1];
             continue;
         }
         if (strpos(" {$ligne}", "http") == 0) {
             $ligne = "http://{$ligne}";
         }
         $hostname = parse_url($ligne, PHP_URL_HOST);
         if (preg_match("#^www\\.(.+)#", $hostname, $re)) {
             $hostname = $re[1];
         }
         if (preg_match("#^\\.(.+)#", $hostname, $re)) {
             $hostname = $re[1];
         }
         if (preg_match("#^\\*\\.(.+)#", $hostname, $re)) {
             $hostname = $re[1];
         }
         writelogs("{$ligne} = {$hostname}", __FUNCTION__, __FILE__, __LINE__);
         $websitesToscan[] = $ligne;
     }
     $PostedDatas = str_replace("<", "\n<", $PostedDatas);
     $PostedDatas = str_replace(' rel="nofollow"', "", $PostedDatas);
     $PostedDatas = str_replace("\r", "\n", $PostedDatas);
     $PostedDatas = str_replace("https:", "http:", $PostedDatas);
     if ($PostedDatas != null) {
         $f = explode("\n", $PostedDatas);
     }
     if (!is_numeric($ForceExt)) {
         $ForceExt = 0;
     }
     if (!is_numeric($ForceCat)) {
         $ForceCat = 0;
     }
     $ipClass = new IP();
     while (list($num, $www) = each($f)) {
         $www = trim($www);
         if ($www == null) {
             continue;
         }
         if (preg_match("#--------------#", $www)) {
             continue;
         }
         if (preg_match("#No extension#", $www)) {
             continue;
         }
         if (preg_match("#no website#i", $www)) {
             continue;
         }
         if (preg_match("#^analyze\\s+[0-9]+\\s+#", $www)) {
             continue;
         }
         if (preg_match("#(false|true):\\s+(.+?)\\s+already#i", $www, $re)) {
             $www = $re[2];
         }
         writelogs("Scanning {$www}", __FUNCTION__, __FILE__, __LINE__);
         if (preg_match("#^(.+?)\"\\s+#", $www, $re)) {
             $www = $re[1];
         }
         if (preg_match("#^([0-9\\.]+):[0-9]+#", $www, $re)) {
             $www = $re[1];
         }
         $www = str_replace("(whois)", "", $www);
         $www = str_replace("\r", "", $www);
         $www = str_replace("||", "", $www);
         $www = str_replace("^", "", $www);
         $www = trim(strtolower($www));
         if ($ipClass->isValid($www)) {
             $www = ip2long($www) . ".addr";
             $websitesToscan[] = $www;
             continue;
         }
         if ($www == null) {
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:class.mysql.squid.builder.php


示例13: silcc_submit_post

/**
 * Get a blog and add tags from the silcc API
 */
function silcc_submit_post($post_id)
{
    global $wpdb;
    $post_id = (int) $post_id;
    $blog = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = '{$post_id}' ");
    if (!$blog) {
        // it was deleted
        return;
    }
    // This is where we extract the text to tag
    // TODO: Make sure this text is not HTML (To avoid HTML tagging)
    // Include the html to text conversion library
    require dirname(__FILE__) . "/class.html2text.inc";
    $html_text = stripslashes($blog->post_content);
    $html_to_text_class = new html2text($html_text);
    $text_content = $html_to_text_class->get_text();
    $tags = array();
    if (!is_null($text_content)) {
        if (strlen($text_content) > 240) {
            $tags = tagthe_http_get($text_content);
        } else {
            if (strlen($text_content) > 0 && strlen($text_content) < 240) {
                $query_string = '' . urlencode($text_content) . '&';
                $response = silcc_http_get($query_string);
                $clean_response = str_replace('[', '', $response);
                $clean_response = str_replace(']', '', $clean_response);
                $clean_response = str_replace(' ', '', $clean_response);
                $clean_response = str_replace('"', '', $clean_response);
                $tags = explode(',', $clean_response);
            }
        }
    }
    wp_set_post_terms($post_id, $tags);
    if (count($tags) > 0) {
        silcc_update_options(count($tags));
    }
}
开发者ID:ushahidi,项目名称:wp-silcc,代码行数:40,代码来源:wp-silcc.php


示例14: html2text

/**
 * Given HTML, converts and formats it as text
 *
 * @param string $html The html to be formatted
 * @return string The formatted text
 */
function html2text($html)
{
    require_once 'html2text/class.html2text.php';
    $h2t = new html2text($html);
    $h2t->set_base_url(get_config('wwwroot'));
    return $h2t->get_text();
}
开发者ID:Br3nda,项目名称:mahara,代码行数:13,代码来源:web.php


示例15: COM_buildUrl

 // Set page title
 $pagetitle = $story->DisplayElements('title');
 $outputHandle = outputHandler::getInstance();
 $permalink = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid());
 $outputHandle->addLink('canonical', $permalink);
 if ($story->DisplayElements('trackbackcode') == 0) {
     if ($_CONF['trackback_enabled']) {
         $trackbackurl = TRB_makeTrackbackUrl($story->getSid());
         $outputHandle->addRaw(LB . '<!--' . LB . TRB_trackbackRdf($permalink, $pagetitle, $trackbackurl) . LB . '-->' . LB);
     }
     $pingback = true;
 }
 USES_lib_html2text();
 $metaDesc = $story->DisplayElements('introtext');
 $metaDesc = strip_tags($metaDesc);
 $html2txt = new html2text($metaDesc, false);
 $metaDesc = trim($html2txt->get_text());
 $shortComment = '';
 $metaArray = explode(' ', $metaDesc);
 $wordCount = count($metaArray);
 $lengthCount = 0;
 $tailString = '';
 foreach ($metaArray as $word) {
     $lengthCount = $lengthCount + strlen($word);
     $shortComment .= $word . ' ';
     if ($lengthCount >= 100) {
         $tailString = '...';
         break;
     }
 }
 $metaDesc = trim($shortComment) . $tailString;
开发者ID:NewRoute,项目名称:glfusion,代码行数:31,代码来源:article.php


示例16: send_mail_phpmailer

 function send_mail_phpmailer($email, $subject, $message = "", $from = "", $reply_to = "", $html_template = "", $templatevars = null, $from_name = "", $cc = "", $bcc = "")
 {
     # if ($use_phpmailer==true) this function is used instead.
     # Mail templates can include lang, server, site_text, and POST variables by default
     # ex ( [lang_mycollections], [server_REMOTE_ADDR], [text_footer] , [message]
     # additional values must be made available through $templatevars
     # For example, a complex url or image path that may be sent in an
     # email should be added to the templatevars array and passed into send_mail.
     # available templatevars need to be well-documented, and sample templates
     # need to be available.
     # Include footer
     global $email_footer, $storagedir;
     $phpversion = phpversion();
     if ($phpversion >= '5.3') {
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/extras/class.html2text.php";
         }
     } else {
         // less than 5.3
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.html2text.php";
         }
     }
     global $email_from;
     if ($from == "") {
         $from = $email_from;
     }
     if ($reply_to == "") {
         $reply_to = $email_from;
     }
     global $applicationname;
     if ($from_name == "") {
         $from_name = $applicationname;
     }
     #check for html template. If exists, attempt to include vars into message
     if ($html_template != "") {
         # Attempt to verify users by email, which allows us to get the email template by lang and usergroup
         $to_usergroup = sql_query("select lang,usergroup from user where email ='" . escape_check($email) . "'", "");
         if (count($to_usergroup) != 0) {
             $to_usergroupref = $to_usergroup[0]['usergroup'];
             $to_usergrouplang = $to_usergroup[0]['lang'];
         } else {
             $to_usergrouplang = "";
         }
         if ($to_usergrouplang == "") {
             global $defaultlanguage;
             $to_usergrouplang = $defaultlanguage;
         }
         if (isset($to_usergroupref)) {
             $modified_to_usergroupref = hook("modifytousergroup", "", $to_usergroupref);
             if ($modified_to_usergroupref !== null) {
                 $to_usergroupref = $modified_to_usergroupref;
             }
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group='{$to_usergroupref}'");
         } else {
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group is null");
         }
         global $site_text;
         for ($n = 0; $n < count($results); $n++) {
             $site_text[$results[$n]["language"] . "-" . $results[$n]["name"]] = $results[$n]["text"];
         }
         $language = $to_usergrouplang;
         if (array_key_exists($language . "-" . $html_template, $site_text)) {
             $template = $site_text[$language . "-" . $html_template];
         } else {
             global $languages;
             # Can't find the language key? Look for it in other languages.
             reset($languages);
             foreach ($languages as $key => $value) {
                 if (array_key_exists($key . "-" . $html_template, $site_text)) {
                     $template = $site_text[$key . "-" . $html_template];
                     break;
                 }
             }
             // Fall back to language file if not in site text
             global $lang;
             if (isset($lang[$html_template])) {
                 $template = $lang[$html_template];
             }
         }
         if (isset($template) && $template != "") {
             preg_match_all('/\\[[^\\]]*\\]/', $template, $test);
             foreach ($test[0] as $variable) {
                 $variable = str_replace("[", "", $variable);
                 $variable = str_replace("]", "", $variable);
                 # get lang variables (ex. [lang_mycollections])
                 if (substr($variable, 0, 5) == "lang_") {
                     global $lang;
                     ${$variable} = $lang[substr($variable, 5)];
                 } else {
                     if (substr($variable, 0, 7) == "server_") {
                         ${$variable} = $_SERVER[substr($variable, 7)];
                     } else {
                         if (substr($variable, 0, 15) == "embed_thumbnail") {
                             $thumbcid = uniqid('thumb');
                             ${$variable} = "<img style='border:1px solid #d1d1d1;' src='cid:{$thumbcid}' />";
                         } else {
                             if (substr($variable, 0, 15) == "img_storagedir_") {
//.........这里部分代码省略.........
开发者ID:artsmia,项目名称:mia_resourcespace,代码行数:101,代码来源:general.php


示例17: 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


示例18: html_to_text

 function html_to_text($html)
 {
     include_once ROOT . "/library/html2text/class.html2text.inc";
     $h2t = new html2text($html);
     return $h2t->get_text();
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:6,代码来源:functions.php


示例19: _ff_getListField_forum

function _ff_getListField_forum($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE;
    global $_FF_CONF, $_SYSTEM, $LANG_GF02;
    if (!isset($A['status'])) {
        $A['status'] = 0;
    }
    USES_lib_html2text();
    $retval = '';
    $dt = new Date('now', $_USER['tzid']);
    switch ($fieldname) {
        case 'date':
        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 = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . ($A['pid'] == 0 ? $A['id'] : $A['pid']) . '&amp;topic=' . $A['id'] . '#' . $A['id'] . '" title="' . $A['subject'] . '::' . $lastpostinfogll . '" rel="nofollow">' . $fieldvalue . '</a>';
            break;
        case 'bookmark':
            $bm_icon_on = '<img src="' . _ff_getImage('star_on_sm') . '" title="' . $LANG_GF02['msg204'] . '" alt=""/>';
            $retval = '<span id="forumbookmark' . $A['topic_id'] . '"><a href="#" onclick="ajax_toggleForumBookmark(' . $A['topic_id'] . ');return false;">' . $bm_icon_on . '</a></span>';
            break;
        case 'replies':
        case 'views':
            if ($fieldvalue != '') {
                $retval = $fieldvalue;
            } else {
                $retval = '0';
            }
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}
开发者ID:spacequad,项目名称:glfusion,代码行数:42,代码来源:list.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP htmlMimeMail类代码示例发布时间:2022-05-23
下一篇:
PHP html类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap