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


PHP lesser_entity_decode函数代码示例

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


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

示例1: WriteHTML

 function WriteHTML($html)
 {
     //! @desc HTML parser
     //! @return void
     /* $e == content */
     $this->ReadMetaTags($html);
     $html = AdjustHTML($html, $this->usepre);
     //Try to make HTML look more like XHTML
     if ($this->usecss) {
         $html = $this->ReadCSS($html);
     }
     //Add new supported tags in the DisableTags function
     $html = str_replace('<?php', '< ', $html);
     //Fix '<?XML' bug from HTML code generated by MS Word
     //$html = str_replace ("%2", "/", $html);
     $html = strip_tags($html, $this->enabledtags);
     //remove all unsupported tags, but the ones inside the 'enabledtags' string
     //Explode the string in order to parse the HTML code
     $a = preg_split('/<(.*?)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($a as $i => $e) {
         if ($i % 2 == 0) {
             //TEXT
             //Adjust lineheight
             //            $this->lineheight = (5*$this->FontSizePt)/11; //should be inside printbuffer?
             //Adjust text, if needed
             if (strpos($e, "&") !== false) {
                 if (strpos($e, "#") !== false) {
                     $e = value_entity_decode($e);
                 }
                 // Decode value entities
                 //Avoid crashing the script on PHP 4.0
                 $version = phpversion();
                 $version = str_replace('.', '', $version);
                 if ($version >= 430) {
                     $e = html_entity_decode($e, ENT_QUOTES, 'cp1252');
                 } else {
                     $e = lesser_entity_decode($e);
                 }
             }
             $e = str_replace(chr(160), chr(32), $e);
             //unify ascii code of spaces (in order to recognize all of them correctly)
             if (strlen($e) == 0) {
                 continue;
             }
             if ($this->divrevert) {
                 $e = strrev($e);
             }
             if ($this->toupper) {
                 $e = strtoupper($e);
             }
             if ($this->tolower) {
                 $e = strtolower($e);
             }
             //Start of 'if/elseif's
             if ($this->titulo) {
                 $this->SetTitle($e);
             } elseif ($this->specialcontent) {
                 if ($this->specialcontent == "type=select" and $this->selectoption['ACTIVE'] == true) {
                     $stringwidth = $this->GetStringWidth($e);
                     if (!isset($this->selectoption['MAXWIDTH']) or $stringwidth > $this->selectoption['MAXWIDTH']) {
                         $this->selectoption['MAXWIDTH'] = $stringwidth;
                     }
                     if (!isset($this->selectoption['SELECTED']) or $this->selectoption['SELECTED'] == '') {
                         $this->selectoption['SELECTED'] = $e;
                     }
                 } else {
                     $this->textbuffer[] = array("???" . $this->specialcontent . "???" . $e);
                 }
             } elseif ($this->tablestart) {
                 if ($this->tdbegin) {
                     $this->cell[$this->row][$this->col]['textbuffer'][] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray);
                     $this->cell[$this->row][$this->col]['text'][] = $e;
                     $this->cell[$this->row][$this->col]['s'] += $this->GetStringWidth($e);
                 }
                 //Ignore content between <table>,<tr> and a <td> tag (this content is usually only a bunch of spaces)
             } elseif ($this->pbegin or $this->HREF or $this->divbegin or $this->SUP or $this->SUB or $this->strike or $this->buffer_on) {
                 $this->textbuffer[] = array($e, $this->HREF, $this->currentstyle, $this->colorarray, $this->currentfont, $this->SUP, $this->SUB, '', $this->strike, $this->outlineparam, $this->bgcolorarray);
             } else {
                 if ($this->blockjustfinished) {
                     $e = ltrim($e);
                 }
                 if ($e != '') {
                     $this->Write($this->lineheight, $e);
                     //Write text directly in the PDF
                     if ($this->pjustfinished) {
                         $this->pjustfinished = false;
                     }
                 }
             }
         } else {
             $this->colorarray = array();
             $this->strike = false;
             //Tag
             if ($e[0] == '/') {
                 $this->CloseTag(strtoupper(substr($e, 1)));
             } else {
                 $regexp = '|=\'(.*?)\'|s';
                 // eliminate single quotes, if any
                 $e = preg_replace($regexp, "=\"\$1\"", $e);
                 $regexp = '| (\\w+?)=([^\\s>"]+)|si';
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:owaspbwa,代码行数:101,代码来源:html2fpdf.php

示例2: AdjustHTML

function AdjustHTML(&$html, $usepre = true)
{
    //Try to make the html text more manageable (turning it into XHTML)
    $html = str_replace("\r\n", "\n", $html);
    //replace carriagereturn-linefeed-combo by a simple linefeed
    if ($usepre) {
        // Preserve '\n's between the tags <pre> and </pre>
        $regexp = '/<pre(.*?)>(.+?)<\\/pre>/si';
        $thereispre = preg_match_all($regexp, $html, $temp);
        // Preserve '\n's between the tags <textarea> and </textarea>
        $regexp2 = '/<textarea(.*?)>(.+?)<\\/textarea>/si';
        $thereistextarea = preg_match_all($regexp2, $html, $temp2);
        $iterator = 0;
        $html = str_replace("\f", '', $html);
        //replace formfeed by nothing
        $html = str_replace("\r", '', $html);
        //replace carriage return by nothing
        $html = str_replace("\n", '', $html);
        //replace linefeed by nothing
        $html = str_replace("\t", ' ', $html);
        //replace tabs by spaces
        while ($thereispre != 0) {
            $html = preg_replace($regexp, '<erp' . $temp[1][$iterator] . '>' . $temp[2][$iterator] . '</erp>', $html, 1);
            $thereispre--;
            $iterator++;
        }
        while ($thereistextarea != 0) {
            $html = preg_replace($regexp2, '<aeratxet' . $temp2[1][$iterator] . '>' . trim($temp2[2][$iterator]) . '</aeratxet>', $html, 1);
            $thereistextarea--;
            $iterator++;
        }
        $html = str_replace("<erp", "<pre", $html);
        //restore
        $html = str_replace("</erp>", "</pre>", $html);
        //restore
        $html = str_replace("<aeratxet", "<textarea", $html);
        //restore
        $html = str_replace("</aeratxet>", "</textarea>", $html);
        //restore
        // (the code above might slowdown overall performance?)
    } else {
        $html = str_replace("\f", '', $html);
        //replace formfeed by nothing
        $html = str_replace("\r", '', $html);
        //replace carriage return by nothing
        $html = str_replace("\n", '', $html);
        //replace linefeed by nothing
        $html = str_replace("\t", ' ', $html);
        //replace tabs by spaces
    }
    $html = str_replace("< IMPRIMIR >", '', $html);
    //remover especial desta versão
    $regexp = '/\\s{2,}/s';
    // turn 2+ consecutive spaces into one
    $html = preg_replace($regexp, ' ', $html);
    //Avoid crashing the script on PHP 4.0
    $version = phpversion();
    $version = str_replace('.', '', $version);
    if ($version >= 430) {
        $html = html_entity_decode($html);
    } else {
        $html = lesser_entity_decode($html);
    }
    // remove redundant <br>'s before </div>, avoiding huge leaps between text blocks
    // they appear on computer-generated HTML code
    $regexp = '/(<br[ \\/]?[\\/]?>)+?<\\/div>/si';
    $html = preg_replace($regexp, '</div>', $html);
}
开发者ID:jacquesbagui,项目名称:ofuz,代码行数:68,代码来源:htmltoolkit.php


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