本文整理汇总了PHP中wcf\util\StringUtil::decodeHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::decodeHTML方法的具体用法?PHP StringUtil::decodeHTML怎么用?PHP StringUtil::decodeHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\util\StringUtil
的用法示例。
在下文中一共展示了StringUtil::decodeHTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
$src = '';
if (isset($openingTag['attributes'][0])) {
$src = $openingTag['attributes'][0];
}
if ($parser->getOutputType() == 'text/html') {
$float = '';
if (isset($openingTag['attributes'][1])) {
$float = $openingTag['attributes'][1];
}
$style = '';
if ($float == 'left' || $float == 'right') {
$style = 'float: ' . $float . '; margin: ' . ($float == 'left' ? '0 15px 7px 0' : '0 0 7px 15px') . ';';
}
$width = 0;
if (isset($openingTag['attributes'][2])) {
$width = $openingTag['attributes'][2];
$style .= 'width: ' . $width . 'px;';
}
return '<img src="' . $src . '" class="jsResizeImage" alt=""' . ($style ? ' style="' . $style . '"' : '') . ' />';
} else {
if ($parser->getOutputType() == 'text/simplified-html') {
$src = StringUtil::decodeHTML($src);
$path = parse_url($src, PHP_URL_PATH);
if ($path !== false) {
return StringUtil::encodeHTML(basename($path));
}
return '';
}
}
}
示例2: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
if ($parser->getOutputType() == 'text/html') {
$quoteLink = !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '';
$externalQuoteLink = !empty($openingTag['attributes'][1]) ? !ApplicationHandler::getInstance()->isInternalURL($openingTag['attributes'][1]) : false;
if (!$externalQuoteLink) {
$quoteLink = preg_replace('~^https?://~', RouteHandler::getProtocol(), $quoteLink);
}
$quoteAuthor = !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '';
$quoteAuthorObject = null;
if ($quoteAuthor && !$externalQuoteLink) {
$quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($quoteAuthor));
foreach (MessageEmbeddedObjectManager::getInstance()->getObjects('com.woltlab.wcf.quote') as $user) {
if (mb_strtolower($user->username) == $quoteAuthorLC) {
$quoteAuthorObject = $user;
break;
}
}
}
WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => $quoteLink, 'quoteAuthor' => $quoteAuthor, 'quoteAuthorObject' => $quoteAuthorObject, 'isExternalQuoteLink' => $externalQuoteLink));
return WCF::getTPL()->fetch('quoteBBCodeTag');
} else {
if ($parser->getOutputType() == 'text/simplified-html') {
return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', array('content' => $content, 'cite' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')) . "\n";
}
}
}
示例3: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
$email = '';
if (isset($openingTag['attributes'][0])) {
$email = $openingTag['attributes'][0];
}
$email = StringUtil::decodeHTML($email);
return '<a href="mailto:' . StringUtil::encodeAllChars($email) . '">' . $content . '</a>';
}
示例4: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
$url = '';
if (isset($openingTag['attributes'][0])) {
$url = $openingTag['attributes'][0];
}
$noTitle = $content == $url;
$url = StringUtil::decodeHTML($url);
// add protocol if necessary
if (!preg_match("/[a-z]:\\/\\//si", $url)) {
$url = 'http://' . $url;
}
return StringUtil::getAnchorTag($url, !$noTitle ? $content : '', false);
}
示例5: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
// copyright
TeraliosBBCodesCopyright::callCopyright();
$tag = mb_strtolower($openingTag['name']);
// heading and subheading tag html.
if ($parser->getOutputType() == 'text/html') {
// map attributes
$this->mapAttributes($openingTag);
// assign attributes
$anchor = $this->anchor;
$noIndex = $this->noIndex;
// check anchor and set automark
if (BBCODES_HEADLINE_AUTOMARK == 1 && empty($anchor)) {
$anchor = substr(md5($content), 0, 10);
} else {
if (empty($anchor)) {
$anchor = '';
}
}
// check anchor
if (!empty($anchor)) {
$anchor = sprintf(static::$anchorPrefix, static::anchorExists($anchor, $anchor));
if ($noIndex != true) {
$anchor = Directory::getInstance()->addEntry($anchor, StringUtil::decodeHTML($content), $tag == 'h1' ? true : false);
} else {
$anchor = new Entry($anchor, StringUtil::decodeHTML($content));
}
}
// assign to template
WCF::getTPL()->assign(array('hsTag' => $tag, 'hsEntry' => $anchor, 'hsHeading' => $content, 'hsLinkTitle' => StringUtil::stripHTML($content)));
return WCF::getTPL()->fetch('headingBBCode');
} else {
if ($parser->getOutputType('text/simplified-html')) {
switch ($tag) {
case 'h1':
$return = '--- ' . $content . ' ---<br />';
break;
default:
$return = '-- ' . $content . ' --<br />';
break;
}
return $return;
}
}
}
示例6: parse
/**
* Formats a message for search result output.
*
* @param string $text
* @return string
*/
public function parse($text)
{
// remove nonessentials
$text = Regex::compile('<!-- begin:parser_nonessential -->.*?<!-- end:parser_nonessential -->', Regex::DOT_ALL)->replace($text, '');
// remove html codes
$text = StringUtil::stripHTML($text);
// decode html
$text = StringUtil::decodeHTML($text);
// get abstract
$text = $this->getMessageAbstract($text);
// encode html
$text = StringUtil::encodeHTML($text);
// do highlighting
return KeywordHighlighter::getInstance()->doHighlight($text);
}
示例7: stripHTML
/**
* Returns a text-only version of given message.
*
* @param string $message
* @return string
*/
public function stripHTML($message)
{
// remove img tags (smilies)
$message = preg_replace('~<img src="[^"]+" alt="([^"]+)" />~', '\\1', $message);
// strip other HTML tags
$message = StringUtil::stripHTML($message);
// decode HTML entities
$message = StringUtil::decodeHTML($message);
return $message;
}
示例8: readData
public function readData()
{
parent::readData();
VisitCountHandler::getInstance()->count();
WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.page.news'), LinkHandler::getInstance()->getLink('NewsCategoryList', array('application' => 'cms'))));
$this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.codequake.cms.news.comment');
$this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor();
$this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->newsID);
$newsEditor = new NewsEditor($this->news->getDecoratedObject());
$newsEditor->update(array('clicks' => $this->news->clicks + 1));
// get Tags
if (MODULE_TAGGING) {
$this->tags = $this->news->getTags();
}
if ($this->news->teaser != '') {
MetaTagHandler::getInstance()->addTag('description', 'description', $this->news->teaser);
} else {
MetaTagHandler::getInstance()->addTag('description', 'description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())));
}
if (!empty($this->tags)) {
MetaTagHandler::getInstance()->addTag('keywords', 'keywords', implode(',', $this->tags));
}
MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->news->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true);
MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news->getDecoratedObject())), true);
MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true);
if ($this->news->getImage() != null) {
MetaTagHandler::getInstance()->addTag('og:image', 'og:image', $this->news->getImage()->getLink(), true);
}
if ($this->news->getUserProfile()->facebook != '') {
MetaTagHandler::getInstance()->addTag('article:author', 'article:author', 'https://facebook.com/' . $this->news->getUserProfile()->facebook, true);
}
if (FACEBOOK_PUBLIC_KEY != '') {
MetaTagHandler::getInstance()->addTag('fb:app_id', 'fb:app_id', FACEBOOK_PUBLIC_KEY, true);
}
MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())), true);
if ($this->news->isNew()) {
$newsAction = new NewsAction(array($this->news->getDecoratedObject()), 'markAsRead', array('viewableNews' => $this->news));
$newsAction->executeAction();
}
// fetch likes
if (MODULE_LIKE) {
$objectType = LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews');
LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->newsID));
$this->likeData = LikeHandler::getInstance()->getLikeObjects($objectType);
}
}
示例9: fixStatusUpdate
private static function fixStatusUpdate($string)
{
// <br /> to newline
$string = str_ireplace('<br />', "\n", $string);
$string = str_ireplace('<br>', "\n", $string);
// decode html entities
$string = StringUtil::decodeHTML($string);
// replace single quote entity
$string = str_replace(''', "'", $string);
return $string;
}
示例10: exportUsers
/**
* Exports users.
*/
public function exportUsers($offset, $limit)
{
// prepare password update
$sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpassword = ?\n\t\t\tWHERE\tuserID = ?";
$passwordUpdateStatement = WCF::getDB()->prepareStatement($sql);
$userIDs = $this->database->zrange('users:joindate', $offset, $offset + $limit);
if (!$userIDs) {
throw new SystemException('Could not fetch userIDs');
}
foreach ($userIDs as $userID) {
$row = $this->database->hgetall('user:' . $userID);
if (!$row) {
throw new SystemException('Invalid user');
}
$data = array('username' => $row['username'], 'password' => '', 'email' => $row['email'], 'registrationDate' => intval($row['joindate'] / 1000), 'banned' => $row['banned'] ? 1 : 0, 'banReason' => '', 'lastActivityTime' => intval($row['lastonline'] / 1000), 'signature' => self::convertMarkdown($row['signature']));
static $gravatarRegex = null;
if ($gravatarRegex === null) {
$gravatarRegex = new Regex('https://(?:secure\\.)?gravatar\\.com/avatar/([a-f0-9]{32})');
}
if ($gravatarRegex->match($row['picture'])) {
$matches = $gravatarRegex->getMatches();
if ($matches[1] === md5($row['email'])) {
$data['enableGravatar'] = 1;
}
}
$birthday = \DateTime::createFromFormat('m/d/Y', StringUtil::decodeHTML($row['birthday']));
// get user options
$options = array('birthday' => $birthday ? $birthday->format('Y-m-d') : '', 'homepage' => StringUtil::decodeHTML($row['website']), 'location' => StringUtil::decodeHTML($row['location']));
$additionalData = array('options' => $options);
$newUserID = ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user')->import($row['uid'], $data, $additionalData);
// update password hash
if ($newUserID) {
$password = PasswordUtil::getSaltedHash($row['password'], $row['password']);
$passwordUpdateStatement->execute(array($password, $newUserID));
}
}
}
示例11: setShareLink
/**
* Set base link.
*
* @param string $shareLink
*/
public function setShareLink($shareLink, $isHTMLEncoded = false)
{
$this->shareLink = StringUtil::trim($shareLink);
if ($isHTMLEncoded == true) {
$this->shareLink = StringUtil::decodeHTML($this->shareLink);
}
}
示例12: fixMessage
private static function fixMessage($string)
{
// align
$string = preg_replace('~<p style="text-align:(left|center|right);">(.*?)</p>~is', "[align=\\1]\\2[/align]\n\n", $string);
// <p> to newline
$string = str_ireplace('<p>', "", $string);
$string = str_ireplace('</p>', "\n\n", $string);
$string = str_ireplace('<br>', "\n", $string);
// strike
$string = str_ireplace('<s>', '[s]', $string);
$string = str_ireplace('</s>', '[/s]', $string);
// super
$string = str_ireplace('<sup>', '[sup]', $string);
$string = str_ireplace('</sup>', '[/sup]', $string);
// subscript
$string = str_ireplace('<sub>', '[sub]', $string);
$string = str_ireplace('</sub>', '[/sub]', $string);
// bold
$string = str_ireplace('<strong>', '[b]', $string);
$string = str_ireplace('</strong>', '[/b]', $string);
$string = str_ireplace('<b>', '[b]', $string);
$string = str_ireplace('</b>', '[/b]', $string);
// italic
$string = str_ireplace('<em>', '[i]', $string);
$string = str_ireplace('</em>', '[/i]', $string);
$string = str_ireplace('<i>', '[i]', $string);
$string = str_ireplace('</i>', '[/i]', $string);
// underline
$string = str_ireplace('<u>', '[u]', $string);
$string = str_ireplace('</u>', '[/u]', $string);
// font color
$string = preg_replace('~<span style="color:(.*?);?">(.*?)</span>~is', '[color=\\1]\\2[/color]', $string);
// font size
$string = preg_replace('~<span style="font-size:(\\d+)px;">(.*?)</span>~is', '[size=\\1]\\2[/size]', $string);
// font face
$string = preg_replace_callback('~<span style="font-family:(.*?)">(.*?)</span>~is', function ($matches) {
return "[font='" . str_replace(";", '', str_replace("'", '', $matches[1])) . "']" . $matches[2] . "[/font]";
}, $string);
// embedded attachments
$string = preg_replace('~<a class="ipsAttachLink" (?:rel="[^"]*" )?href="[^"]*id=(\\d+)[^"]*".*?</a>~i', '[attach]\\1[/attach]', $string);
$string = preg_replace('~<a.*?><img data-fileid="(\\d+)".*?</a>~i', '[attach]\\1[/attach]', $string);
// urls
$string = preg_replace('~<a.*?href=(?:"|\')mailto:([^"]*)(?:"|\')>(.*?)</a>~is', '[email=\'\\1\']\\2[/email]', $string);
$string = preg_replace('~<a.*?href=(?:"|\')([^"]*)(?:"|\')>(.*?)</a>~is', '[url=\'\\1\']\\2[/url]', $string);
// quotes
$string = preg_replace('~<blockquote[^>]*>(.*?)</blockquote>~is', '[quote]\\1[/quote]', $string);
// code
$string = preg_replace('~<pre[^>]*>(.*?)</pre>~is', '[code]\\1[/code]', $string);
// smileys
$string = preg_replace('~<img title="([^"]*)" alt="[^"]*" src="<fileStore.core_Emoticons>[^"]*">~is', '\\1', $string);
$string = preg_replace('~<img src="<fileStore.core_Emoticons>[^"]*" alt="[^"]*" title="([^"]*)">~is', '\\1', $string);
// list
$string = str_ireplace('</ol>', '[/list]', $string);
$string = str_ireplace('</ul>', '[/list]', $string);
$string = str_ireplace('<ul>', '[list]', $string);
$string = str_ireplace("<ol type='1'>", '[list=1]', $string);
$string = str_ireplace("<ol>", '[list=1]', $string);
$string = str_ireplace('<li>', '[*]', $string);
$string = str_ireplace('</li>', '', $string);
// images
$string = preg_replace('~<img[^>]+src=["\']([^"\']+)["\'][^>]*/?>~is', '[img]\\1[/img]', $string);
// strip tags
$string = StringUtil::stripHTML($string);
// decode html entities
$string = StringUtil::decodeHTML($string);
return StringUtil::trim($string);
}
示例13: exportBlogComments
/**
* Exports blog comments.
*/
public function exportBlogComments($offset, $limit)
{
$sql = "SELECT\tcomment_ID, comment_parent\n\t\t\tFROM\t" . $this->databasePrefix . "comments\n\t\t\tWHERE\tcomment_ID = ?";
$parentCommentStatement = $this->database->prepareStatement($sql, $limit, $offset);
$sql = "SELECT\t\t*\n\t\t\tFROM\t\t" . $this->databasePrefix . "comments\n\t\t\tWHERE\tcomment_approved = ?\n\t\t\tORDER BY\tcomment_parent, comment_ID";
$statement = $this->database->prepareStatement($sql, $limit, $offset);
$statement->execute(array(1));
while ($row = $statement->fetchArray()) {
if (!$row['comment_parent']) {
ImportHandler::getInstance()->getImporter('com.woltlab.blog.entry.comment')->import($row['comment_ID'], array('objectID' => $row['comment_post_ID'], 'userID' => $row['user_id'] ?: null, 'username' => $row['comment_author'], 'message' => StringUtil::decodeHTML($row['comment_content']), 'time' => @strtotime($row['comment_date_gmt'])));
} else {
$parentID = $row['comment_parent'];
do {
$parentCommentStatement->execute(array($parentID));
$row2 = $parentCommentStatement->fetchArray();
if (!$row2['comment_parent']) {
ImportHandler::getInstance()->getImporter('com.woltlab.blog.entry.comment.response')->import($row['comment_ID'], array('commentID' => $row2['comment_ID'], 'userID' => $row['user_id'] ?: null, 'username' => $row['comment_author'], 'message' => StringUtil::decodeHTML($row['comment_content']), 'time' => @strtotime($row['comment_date_gmt'])));
break;
}
$parentID = $row2['comment_parent'];
} while (true);
}
}
}
示例14: exportPosts
/**
* Exports posts.
*/
public function exportPosts($offset, $limit)
{
$sql = "SELECT\t\tchild.*, IF(parent.contenttypeid = child.contenttypeid, 0, 1) AS isFirstPost, text.*\n\t\t\tFROM\t\t" . $this->databasePrefix . "node child\n\t\t\tINNER JOIN\t" . $this->databasePrefix . "text text\n\t\t\tON\t\tchild.nodeid = text.nodeid\n\t\t\tINNER JOIN\t" . $this->databasePrefix . "node parent\n\t\t\tON\t\tchild.parentid = parent.nodeid\n\t\t\t\n\t\t\tINNER JOIN\t(SELECT contenttypeid FROM " . $this->databasePrefix . "contenttype WHERE class IN(?, ?)) x\n\t\t\tON\t\tx.contenttypeid = child.contenttypeid\n\t\t\t\n\t\t\tWHERE\t\tchild.nodeid BETWEEN ? AND ?\n\t\t\tORDER BY\tchild.nodeid ASC";
$statement = $this->database->prepareStatement($sql);
$statement->execute(array('Text', 'Poll', $offset + 1, $offset + $limit));
while ($row = $statement->fetchArray()) {
ImportHandler::getInstance()->getImporter('com.woltlab.wbb.post')->import($row['nodeid'], array('threadID' => $row['isFirstPost'] ? $row['nodeid'] : $row['parentid'], 'userID' => $row['userid'], 'username' => $row['authorname'], 'subject' => StringUtil::decodeHTML($row['title']), 'message' => self::fixBBCodes($row['rawtext']), 'time' => $row['created'], 'isDeleted' => $row['deleteuserid'] !== null ? 1 : 0, 'deleteTime' => $row['deleteuserid'] !== null ? TIME_NOW : 0, 'isDisabled' => $row['approved'] ? 0 : 1, 'isClosed' => 0, 'editorID' => null, 'editor' => '', 'lastEditTime' => 0, 'editCount' => 0, 'editReason' => '', 'enableSmilies' => $row['allowsmilie'], 'enableHtml' => isset($row['htmlState']) && $row['htmlState'] != 'off' ? 1 : 0, 'enableBBCodes' => 1, 'showSignature' => $row['showsignature'], 'ipAddress' => UserUtil::convertIPv4To6($row['ipaddress'])));
}
}
示例15: exportThreads
/**
* Exports threads.
*/
public function exportThreads($offset, $limit)
{
$sql = "SELECT\t\tthread.*,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\tMAX(dateline)\n\t\t\t\t\t\tFROM\t" . $this->databasePrefix . "moderatorlog moderatorlog\n\t\t\t\t\t\tWHERE\t\tthread.threadid = moderatorlog.threadid\n\t\t\t\t\t\t\tAND\ttype = ?\n\t\t\t\t\t) AS deleteTime\n\t\t\tFROM\t\t" . $this->databasePrefix . "thread thread\n\t\t\tWHERE\t\tthread.threadid BETWEEN ? AND ?\n\t\t\tORDER BY\tthread.threadid";
$statement = $this->database->prepareStatement($sql);
$statement->execute(array(14, $offset + 1, $offset + $limit));
// 14 = soft delete
while ($row = $statement->fetchArray()) {
$data = array('boardID' => $row['forumid'], 'topic' => StringUtil::decodeHTML($row['title']), 'time' => $row['dateline'], 'userID' => $row['postuserid'], 'username' => $row['postusername'], 'views' => $row['views'], 'isAnnouncement' => 0, 'isSticky' => $row['sticky'], 'isDisabled' => $row['visible'] == 1 ? 0 : 1, 'isClosed' => $row['open'] == 1 ? 0 : 1, 'isDeleted' => $row['visible'] == 2 ? 1 : 0, 'movedThreadID' => $row['open'] == 10 && $row['pollid'] ? $row['pollid'] : null, 'movedTime' => 0, 'isDone' => 0, 'deleteTime' => $row['deleteTime'] ?: 0, 'lastPostTime' => $row['lastpost']);
$additionalData = array();
if ($row['prefixid']) {
$additionalData['labels'] = array($row['prefixid']);
}
if ($row['taglist'] !== null) {
$tags = ArrayUtil::trim(explode(',', $row['taglist']));
$additionalData['tags'] = $tags;
}
ImportHandler::getInstance()->getImporter('com.woltlab.wbb.thread')->import($row['threadid'], $data, $additionalData);
}
}