本文整理汇总了PHP中Safe::html_entity_decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::html_entity_decode方法的具体用法?PHP Safe::html_entity_decode怎么用?PHP Safe::html_entity_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::html_entity_decode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
//.........这里部分代码省略.........
// the end of line string for mail messages
if (!defined('M_EOL')) {
define('M_EOL', "\n");
}
// encode the subject line
$subject = Mailer::encode_subject($subject);
// make some text out of an array
if (is_array($headers)) {
$headers = implode(M_EOL, $headers);
}
// From: header
if (!preg_match('/^From: /im', $headers)) {
$headers .= M_EOL . 'From: ' . $from;
}
// Reply-To: header
if (!preg_match('/^Reply-To: /im', $headers)) {
$headers .= M_EOL . 'Reply-To: ' . $from;
}
// Return-Path: header --to process errors
if (!preg_match('/^Return-Path: /im', $headers)) {
$headers .= M_EOL . 'Return-Path: ' . $from;
}
// Message-ID: header --helps to avoid spam filters
if (!preg_match('/^Message-ID: /im', $headers)) {
$headers .= M_EOL . 'Message-ID: <uniqid.' . uniqid() . '@' . $context['host_name'] . '>';
}
// MIME-Version: header
if (!preg_match('/^MIME-Version: /im', $headers)) {
$headers .= M_EOL . 'MIME-Version: 1.0';
}
// arrays are easier to manage
if (is_string($message)) {
// turn HTML entities to UTF-8
$message = Safe::html_entity_decode($message, ENT_QUOTES, 'UTF-8');
$copy = $message;
$message = array();
$message['text/plain; charset=utf-8'] = $copy;
unset($copy);
}
// turn attachments to some array too
if (is_string($attachments)) {
$attachments = array($attachments);
} elseif (!is_array($attachments)) {
$attachments = array();
}
// we only consider objects from this server
$my_prefix = $context['url_to_home'] . $context['url_to_root'];
// transcode objects that will be transmitted along the message (i.e., images)
foreach ($message as $type => $part) {
// search throughout the full text
$head = 0;
while ($head = strpos($part, ' src="', $head)) {
$head += strlen(' src="');
// a link has been found
if ($tail = strpos($part, '"', $head + 1)) {
$reference = substr($part, $head, $tail - $head);
// remember local links only
if (!strncmp($reference, $my_prefix, strlen($my_prefix))) {
// local name
$name = urldecode(substr($reference, strlen($my_prefix)));
// content-id to be used instead of the link
$cid = sprintf('%u@%s', crc32($name), $context['host_name']);
// transcode the link in this part
$part = substr($part, 0, $head) . 'cid:' . $cid . substr($part, $tail);
// remember to put content in attachments of this message, if not done yet
if (!in_array($name, $attachments)) {
示例2: encode
/**
* encode a sequence of HTML tags, or plain text, to PDF
*
* @param string the text to append
* @return the content of PDF
* @see articles/fetch_as_pdf.php
*/
function encode($text)
{
global $context;
//
// meta information
//
// encode it to iso8859 -- sorry
// document title
if ($context['page_title']) {
$this->SetTitle(utf8::to_iso8859(Safe::html_entity_decode($context['page_title'], ENT_COMPAT, 'ISO-8859-15')));
}
// document author
if ($context['page_author']) {
$this->SetAuthor(utf8::to_iso8859(Safe::html_entity_decode($context['page_author'], ENT_COMPAT, 'ISO-8859-15')));
}
// document subject
if ($context['subject']) {
$this->SetSubject(utf8::to_iso8859(Safe::html_entity_decode($context['subject'], ENT_COMPAT, 'ISO-8859-15')));
}
// document creator (typically, the tool used to produce the document)
$this->SetCreator('yacs');
//
// PDF content
//
// start the rendering engine
$this->AliasNbPages();
$this->AddPage();
$this->SetFont('Arial', 'B', 16);
// reference view.php instead of ourself to achieve correct links
$text = str_replace('/fetch_as_pdf.php', '/view.php', $text);
// remove all unsupported tags
$text = strip_tags($text, "<a><b><blockquote><br><code><div><em><font><h1><h2><h3><h4><hr><i><img><li><p><pre><strong><table><tr><tt><u><ul>");
// spaces instead of carriage returns
$text = str_replace("\n", ' ', $text);
// transcode to ISO8859-15 characters
$text = utf8::to_iso8859(Safe::html_entity_decode($text, ENT_COMPAT, 'ISO-8859-15'));
// locate every HTML/XML tag
$areas = preg_split('/<(.*)>/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$height = 5;
$link = '';
foreach ($areas as $index => $entity) {
// a tag entity
if ($index % 2) {
@(list($tag, $attributes) = explode(' ', $entity, 2));
switch (strtolower($tag)) {
case 'a':
if (preg_match('/href="(.*)"/i', $attributes, $matches)) {
$link = $matches[1];
// suppress local references (eg, in table of content)
if (preg_match('/(#.*)/', $link)) {
$link = '';
} elseif ($link[0] == '/') {
$link = $context['url_to_home'] . $link;
}
}
break;
case 'b':
$this->SetFont('', 'B');
break;
case '/b':
$this->SetFont('', '');
break;
case 'blockquote':
$this->Ln($height);
break;
case '/blockquote':
$this->Ln($height);
break;
case 'br':
$this->Ln($height);
break;
case 'code':
$this->SetFont('Courier', '', 11);
$this->SetFontSize(11);
break;
case '/code':
$this->SetFont('Times', '', 12);
$this->SetFontSize(12);
break;
case 'div':
case '/div':
$this->Ln($height);
break;
case 'em':
$this->SetFont('', 'I');
break;
case '/em':
$this->SetFont('', '');
break;
case 'font':
if (preg_match('/color="#(.{6})"/i', $attributes, $matches)) {
$color = $matches[1];
$r = hexdec($color[0] . $color[1]);
//.........这里部分代码省略.........
示例3: array
return;
}
// keep only titles and ISO8859-1 labels
$titles = array();
$links = array();
$count = 0;
foreach ($items as $url => $label) {
// we are not interested into all attributes
if (is_array($label)) {
$label = $label[1];
}
// strip codes
include_once '../../codes/codes.php';
$label = Codes::strip($label);
// remove every html tag
$label = strip_tags(Safe::html_entity_decode($label));
// remember this
$titles[$count] = $label;
$links[$count] = $url;
$count++;
}
// cache handling --except on scripts/validate.php
if (!headers_sent() && (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET')) {
// this is a schockwave object
Safe::header('Content-Type: application/x-shockwave-flash');
// enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
http::expire(1800);
// the original content
$page = '';
for ($index = 0; $index < $count; $index++) {
$page .= $titles[$index] . ':' . $links[$index] . ':';