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


PHP html2text::set_base_url方法代码示例

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


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

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

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

示例3: isset

 } else {
     // 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);
开发者ID:4Vs,项目名称:oc-server3,代码行数:31,代码来源:removelog.php

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

示例5: send

    public static function send($from, $recipients, $subject, $from_name = false, $text_version = false, $html_version = false, $variables = false)
    {
        global $CFG;
        $reply_to = $from;
        $var_string = '';
        if (is_array($variables)) {
            foreach ($variables as $name => $value) {
                $var_string .= '
					' . ucfirst(str_ireplace('_', ' ', $name)) . ': ' . $value . '<br/>';
            }
        }
        $html_version = str_ireplace('[variables]', $var_string, $html_version);
        $text_version = str_ireplace('[variables]', $var_string, $text_version);
        $html_version = str_ireplace('&amp;', '&', $html_version);
        $text_version = str_ireplace('&amp;', '&', $text_version);
        if (is_array($variables)) {
            foreach ($variables as $key => $val) {
                $html_version = str_ireplace('[' . $key . ']', $val, $html_version);
                $text_version = str_ireplace('[' . $key . ']', $val, $text_version);
                $subject = str_ireplace('[' . $key . ']', $val, $subject);
            }
        }
        if (!$text_version) {
            include_once 'html2text.php';
            $h2t = new html2text($html_version);
            $h2t->set_base_url($CFG->frontend_baseurl);
            $text_version = $h2t->get_text();
        }
        if (!$html_version) {
            $html_version = nl2br($text_version);
        }
        include_once 'phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        $mail->isSMTP();
        $mail->CharSet = 'UTF-8';
        $mail->SMTPDebug = 0;
        $mail->Debugoutput = 'html';
        $mail->Host = $CFG->email_smtp_host;
        $mail->Port = $CFG->email_smtp_port;
        $mail->SMTPSecure = $CFG->email_smtp_security;
        $mail->SMTPAuth = true;
        $mail->Username = $CFG->email_smtp_username;
        $mail->Password = $CFG->email_smtp_password;
        $mail->setFrom($CFG->email_smtp_send_from, $from_name);
        $mail->addReplyTo($from);
        if (is_array($recipients)) {
            foreach ($recipients as $name => $email) {
                if (!self::verifyAddress($email)) {
                    unset($recipients[$name]);
                    continue;
                }
                $mail->addAddress($email, $name);
            }
        } else {
            if (self::verifyAddress($recipients)) {
                $mail->addAddress($recipients);
            }
        }
        $mail->Subject = $subject;
        $mail->msgHTML($html_version);
        $mail->AltBody = $text_version;
        if ($mail->send()) {
            return true;
        } else {
            trigger_error('Email could not be sent: ' . print_r($mail->ErrorInfo, true), E_USER_WARNING);
            return false;
        }
    }
开发者ID:MirellJ,项目名称:wlox-auth,代码行数:68,代码来源:Email.php

示例6: process_log_watch

function process_log_watch($user_id, $log_id)
{
    global $dblink, $logwatch_text, $absolute_server_URI;
    //	echo "process_log_watch($user_id, $log_id)\n";
    $rsLog = sql("SELECT cache_logs.cache_id cache_id, cache_logs.type, cache_logs.text text, cache_logs.text_html text_html, cache_logs.date logdate, user.username username, caches.name cachename, caches.wp_oc wp_oc FROM `cache_logs`, `user`, `caches` WHERE (cache_logs.user_id = user.user_id) AND (cache_logs.cache_id = caches.cache_id) AND (cache_logs.id = '&1')", $log_id);
    $rLog = sql_fetch_array($rsLog);
    mysql_free_result($rsLog);
    $watchtext = $logwatch_text;
    $logtext = $rLog['text'];
    if ($rLog['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 = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
        		$logtext = mb_ereg_replace("\r", '', $logtext);
        		$logtext = mb_ereg_replace("\n", '', $logtext);
        		$logtext = mb_ereg_replace('</p>', "</p>\n", $logtext);
        		$logtext = mb_ereg_replace('<br/>', "<br/>\n", $logtext);
        		$logtext = mb_ereg_replace('<br />', "<br />\n", $logtext);
        		$logtext = strip_tags($logtext);
        */
    }
    if (strpos($rLog['logdate'], '00:00:00') > 0) {
        $dateformat = 'd.m.Y';
    } else {
        $dateformat = 'd.m.Y, H:i';
    }
    $watchtext = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp_oc}', $rLog['wp_oc'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{action}', get_log_action($rLog['type']), $watchtext);
    sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}
开发者ID:4Vs,项目名称:oc-server3,代码行数:37,代码来源:runwatch.php


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