當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tidy_parse_string函數代碼示例

本文整理匯總了PHP中tidy_parse_string函數的典型用法代碼示例。如果您正苦於以下問題:PHP tidy_parse_string函數的具體用法?PHP tidy_parse_string怎麽用?PHP tidy_parse_string使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了tidy_parse_string函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __destruct

 public function __destruct()
 {
     try {
         if (!self::$html_set || !self::$head_set) {
             throw new PageException("<b>HTML class exception.</b><br />Either &lt;html&gt; or &lt;head&gt; or &lt;body&gt; is not set.</b><br />\n\t\t\t\t\tAll these tags need to be used in order to generate valid html forms.");
         }
         self::$output .= "</body>\n</html>";
         if (self::$debug) {
             echo '<b>Tidy messages</b><br />';
             $tidy = tidy_parse_string(self::$output);
             echo nl2br(htmlentities(tidy_get_error_buffer($tidy)));
             echo '<hr />';
             $linedump = explode("\n", nl2br(htmlentities(str_replace("<br />", "\n", self::$output))));
             // var_dump($linedump);
             for ($i = 0; $i < sizeof($linedump); ++$i) {
                 if (trim(str_replace("<br>", "", $linedump[$i])) == '') {
                     continue;
                 }
                 $il = strlen($i);
                 $il4 = 4 - $il;
                 $j = $i + 1;
                 $linenr = str_repeat("&nbsp;", $il4) . $j;
                 echo $linenr . ' : ' . $linedump[$i];
             }
             echo '<hr />';
             self::$output = '';
         } else {
             echo self::$output;
             self::$output = '';
         }
     } catch (PageException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:broozer,項目名稱:psa,代碼行數:34,代碼來源:Page.php

示例2: tidy_html

function tidy_html($html)
{
    $tidy_config = array('output-xhtml' => true, 'show-body-only' => true);
    $tidy = tidy_parse_string($html, $tidy_config, 'UTF8');
    $tidy->cleanRepair();
    return tidy_get_output($tidy);
}
開發者ID:WhoJave,項目名稱:PopClip-Extensions,代碼行數:7,代碼來源:tidy.php

示例3: afterRender

 public function afterRender($event, $view)
 {
     $tidyConfig = array('clean' => true, 'output-xhtml' => true, 'show-body-only' => true, 'wrap' => 0);
     $tidy = tidy_parse_string($view->getContent(), $tidyConfig, 'UTF8');
     $tidy->cleanRepair();
     $view->setContent((string) $tidy);
 }
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:7,代碼來源:views-837.php

示例4: tidy

 protected function tidy($content)
 {
     $config = array('output-xhtml' => true);
     $tidy = tidy_parse_string($content, $config, 'utf8');
     $tidy->cleanRepair();
     return (string) $tidy;
 }
開發者ID:gauthierm,項目名稱:Spider,代碼行數:7,代碼來源:TidyParser.php

示例5: get_url

/**
 * @param $url
 * @param bool $use_tidy
 * @return array
 */
function get_url($url, $use_tidy = TRUE)
{
    global $cookies;
    $smarty = TikiLib::lib('smarty');
    $result = array();
    $get = get_from_dom($url->getElementsByTagName('get')->item(0));
    $post = get_from_dom($url->getElementsByTagName('post')->item(0));
    $xpath = $url->getElementsByTagName('xpath')->item(0)->textContent;
    $data = $url->getElementsByTagName('data')->item(0)->textContent;
    $urlstr = $url->getAttribute("src");
    $referer = $url->getAttribute("referer");
    $result['data'] = $data;
    if (extension_loaded("tidy")) {
        $data = tidy_parse_string($data, array(), 'utf8');
        tidy_diagnose($data);
        if ($use_tidy) {
            $result['ref_error_count'] = tidy_error_count($data);
            $result['ref_error_msg'] = tidy_get_error_buffer($data);
        }
    } else {
        $result['ref_error_msg'] = tra("Tidy Extension not present");
    }
    $result['url'] = $urlstr;
    $result['xpath'] = $xpath;
    $result['method'] = $url->getAttribute("method");
    $result['post'] = $post;
    $result['get'] = $get;
    $result['referer'] = $referer;
    return $result;
}
開發者ID:linuxwhy,項目名稱:tiki-1,代碼行數:35,代碼來源:tiki-tests_edit.php

示例6: filter

 /**
  * Filter a content item's content
  *
  * @return string
  */
 function filter($item, $field = "content", $length = 0)
 {
     $nodefilters = array();
     if (is_a($item, 'Zoo_Content_Interface')) {
         $txt = $item->{$field};
         $nodefilters = Zoo::getService('content')->getFilters($item);
     } else {
         $txt = $item;
     }
     if ($length > 0) {
         $txt = substr($txt, 0, $length);
     }
     if (count($nodefilters)) {
         $ids = array();
         foreach ($nodefilters as $nodefilter) {
             $ids[] = $nodefilter->filter_id;
         }
         $filters = Zoo::getService('filter')->getFilters($ids);
         foreach ($filters as $filter) {
             $txt = $filter->filter($txt);
         }
         if (extension_loaded('tidy')) {
             $config = array('indent' => TRUE, 'show-body-only' => TRUE, 'output-xhtml' => TRUE, 'wrap' => 0);
             $tidy = tidy_parse_string($txt, $config, 'UTF8');
             $tidy->cleanRepair();
             $txt = tidy_get_output($tidy);
         }
     } else {
         $txt = htmlspecialchars($txt);
     }
     return $txt;
 }
開發者ID:BGCX261,項目名稱:zoocms-svn-to-git,代碼行數:37,代碼來源:Filter.php

示例7: tidy

 public function tidy($html, $encoding = 'utf-8')
 {
     if ($html == '') {
         return false;
     }
     $output = '';
     $html = trim($html);
     //對於非utf-8編輯處理
     if ($encoding !== 'utf-8') {
         $html = BaseModelCommon::convertEncoding($html, 'utf-8', $encoding);
     }
     $html = preg_replace("|\\/\\*(.*)\\*\\/|sU", "", $html);
     //過濾掉全部注釋內容
     $html = preg_replace("/<!\\[CDATA\\[(.*?)\\]\\]>/is", "\\1", $html);
     //過濾掉CDATA標簽
     $html = $this->_escapeUnicode($html);
     //轉義Unicode字符
     $tidy_conf = array('output-xhtml' => true, 'show-body-only' => true, 'join-classes' => true);
     $html = str_replace("&", "&amp;", $html);
     $dom = tidy_parse_string($html, $tidy_conf, 'utf8');
     $body = $dom->body();
     if ($body->child) {
         foreach ($body->child as $child) {
             $this->_filterNode($child, $output);
         }
     }
     $html = $this->_unEscapeUnicode($output);
     //反轉義Unicode字符
     if ($encoding !== 'utf-8') {
         $html = BaseModelCommon::convertEncoding($html, $encoding, 'utf-8');
     }
     $html = $this->_insertVideo($html);
     return $html;
 }
開發者ID:az0ne,項目名稱:diaoyu,代碼行數:34,代碼來源:BaseModelFilter.php

示例8: load_html

 function load_html($html)
 {
     $tidy = tidy_parse_string($html);
     tidy_clean_repair($tidy);
     $html = tidy_get_html($tidy);
     phpQuery::unloadDocuments();
     return phpQuery::newDocumentHTML($html);
 }
開發者ID:richthegeek,項目名稱:Misc,代碼行數:8,代碼來源:tidyPQ.php

示例9: cleanHtml

 public function cleanHtml($html, $encoding = 'utf8')
 {
     $tidy = tidy_parse_string($html, $this->options(), $encoding = 'utf8');
     $tidy->cleanRepair();
     $html = join('', $tidy->body()->child ?: []);
     $html = str_replace(PHP_EOL, '', $html);
     return $html;
 }
開發者ID:ankhzet,項目名稱:Ankh,代碼行數:8,代碼來源:TidyCleaner.php

示例10: prepareHtmlInput

 public function prepareHtmlInput($html)
 {
     $config = array('wrap' => false, 'show-body-only' => true);
     $tidyNode = tidy_parse_string($html, $config, 'utf8')->body();
     $htmlArray = $this->toArray($tidyNode);
     $html = implode("\n", $htmlArray);
     return $html;
 }
開發者ID:gathercontent,項目名稱:htmldiff,代碼行數:8,代碼來源:Processor.php

示例11: getPrettyHtml

 /**
  * Return pretty html.
  *
  * @param $html
  * @return mixed
  */
 public function getPrettyHtml($html)
 {
     // TODO without tidy support
     $params = ['show-body-only' => true, 'indent' => true, 'output-html' => true, 'wrap' => 200];
     $tidy = tidy_parse_string($html, $params, 'UTF8');
     $tidy->cleanRepair();
     $this->htmlOutput = $tidy;
     return $tidy;
 }
開發者ID:alcodo,項目名稱:alpaca,代碼行數:15,代碼來源:Image.php

示例12: tidy

 private function tidy($html)
 {
     if (function_exists('tidy_parse_string')) {
         $tidy = tidy_parse_string($html, array(), 'UTF8');
         $tidy->cleanRepair();
         $html = $tidy->value;
     }
     return $html;
 }
開發者ID:rjsmelo,項目名稱:tiki,代碼行數:9,代碼來源:pagecontentlib.php

示例13: parse

 /**
  *    Reads the raw content the page using HTML Tidy.
  *    @param $response SimpleHttpResponse  Fetched response.
  *    @return SimplePage                   Newly parsed page.
  */
 function parse($response)
 {
     $this->page = new SimplePage($response);
     $tidied = tidy_parse_string($input = $this->insertGuards($response->getContent()), array('output-xml' => false, 'wrap' => '0', 'indent' => 'no'), 'latin1');
     $this->walkTree($tidied->html());
     $this->attachLabels($this->widgets_by_id, $this->labels);
     $this->page->setForms($this->forms);
     $page = $this->page;
     $this->free();
     return $page;
 }
開發者ID:ngugijames,項目名稱:ThinkUp,代碼行數:16,代碼來源:tidy_parser.php

示例14: __construct

 public function __construct($fileName)
 {
     $tidy = tidy_parse_string(utf8_encode(file_get_contents($fileName)));
     $tidy->cleanRepair();
     $html = $tidy->html();
     $html = $html->value;
     $html = $this->removeTags($html, ["script", "style"]);
     $this->dom = new DOMDocument();
     $this->dom->preserveWhiteSpace = false;
     $this->dom->loadHTML($html);
 }
開發者ID:hadihkhan,項目名稱:is,代碼行數:11,代碼來源:WebPageFilter.php

示例15: render

 /**
  * Straight forward string replacement template engine, could be replaced by a full
  * template engine if scope increased.
  * @return  string
  */
 public function render()
 {
     $template_copy = $this->template;
     $template_copy = str_replace('{DESTINATION NAME}', $this->destination->title, $template_copy);
     $template_copy = str_replace('{CONTENT}', $this->destination->getBodyHtml(), $template_copy);
     $template_copy = str_replace('{NAVIGATION}', $this->renderNavigation(), $template_copy);
     //clean up the html to make reviewing easier
     $tidy = tidy_parse_string($template_copy, ['indent' => true, 'output-xhtml' => true, 'wrap' => 0], 'utf8');
     $tidy->cleanRepair();
     return (string) $tidy;
 }
開發者ID:nodefortytwo,項目名稱:lp-test,代碼行數:16,代碼來源:template.php


注:本文中的tidy_parse_string函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。