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


PHP tidy_get_output函数代码示例

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


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

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

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

示例3: cleanWrapped

 /**
  * Use the HTML tidy extension to use the tidy library in-process,
  * saving the overhead of spawning a new process.
  *
  * @param string $text HTML to check
  * @param bool $stderr Whether to read result from error status instead of output
  * @param int &$retval Exit code (-1 on internal error)
  * @return string|null
  */
 protected function cleanWrapped($text, $stderr = false, &$retval = null)
 {
     if (!class_exists('tidy')) {
         wfWarn("Unable to load internal tidy class.");
         $retval = -1;
         return null;
     }
     $tidy = new \tidy();
     $tidy->parseString($text, $this->config['tidyConfigFile'], 'utf8');
     if ($stderr) {
         $retval = $tidy->getStatus();
         return $tidy->errorBuffer;
     }
     $tidy->cleanRepair();
     $retval = $tidy->getStatus();
     if ($retval == 2) {
         // 2 is magic number for fatal error
         // http://www.php.net/manual/en/function.tidy-get-status.php
         $cleansource = null;
     } else {
         $cleansource = tidy_get_output($tidy);
         if (!empty($this->config['debugComment']) && $retval > 0) {
             $cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '--&gt;', $tidy->errorBuffer) . "\n-->";
         }
     }
     return $cleansource;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:36,代码来源:RaggettInternalPHP.php

示例4: tidy

 /**
  * Filter through Tidy
  * 
  * @param  array
  * @param  string
  * @param  bool
  * @return bool
  */
 public static function tidy(array &$headers, &$body, $uncached)
 {
     $tidy = new tidy();
     $tidy->parseString($body, array('clean' => 1, 'bare' => 1, 'hide-comments' => 1, 'doctype' => 'omit', 'indent-spaces' => 0, 'tab-size' => 0, 'wrap' => 0, 'quote-ampersand' => 0, 'output-xhtml' => true, 'quiet' => 1), 'utf8');
     $tidy->cleanRepair();
     $body = tidy_get_output($tidy);
 }
开发者ID:rsms,项目名称:phpab,代码行数:15,代码来源:ResponseFilters.php

示例5: run_loop

function run_loop($aHtml, $aCount)
{
    for ($i = 0; $i < $aCount; $i++) {
        $tidy = new tidy();
        $tidy->parseString($aHtml, array('output-xml' => true, 'clean' => true, 'numeric-entities' => true), 'utf8');
        $tidy->cleanRepair();
        //echo tidy_get_output( $tidy );
        $xml = simplexml_load_string(tidy_get_output($tidy));
        if ($xml === false) {
            file_put_contents('php://stderr', 'Unable to parse file');
            return;
        }
        unset($xml);
        unset($tidy);
    }
}
开发者ID:Totalboy,项目名称:html-parsers-benchmark,代码行数:16,代码来源:tidy_simplexml.php

示例6: tidy

/**
 * Turn a string or array into valid, standards-compliant (x)HTML
 *
 * Uses configuraton options in tidy.conf - which should minimally have show-body-only set to yes
 *
 * @param mixed $text The data to be tidied up
 * @return mixed $result Tidied data
 */
function tidy($text)
{
    static $tidy_funcs;
    static $tidy_conf;
    if (!isset($tidy_conf)) {
        $tidy_conf = SETTINGS_INC . 'tidy.conf';
    }
    if (is_array($text)) {
        $result = array();
        foreach (array_keys($text) as $key) {
            $result[$key] = tidy($text[$key]);
        }
        return $result;
    }
    // determine what tidy libraries are available
    if (empty($tidy_funcs)) {
        $tidy_funcs = get_extension_funcs('tidy');
    }
    $tidy_1_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) !== false;
    $tidy_2_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) === false;
    $tidy_command_line_available = TIDY_EXE ? file_exists(TIDY_EXE) : false;
    $text = protect_string_from_tidy($text);
    $text = '<html><body>' . $text . '</body></html>';
    if ($tidy_2_lib_available) {
        $tidy = new tidy();
        $tidy->parseString($text, $tidy_conf, 'utf8');
        $tidy->cleanRepair();
        $result = $tidy;
    } elseif ($tidy_1_lib_available) {
        tidy_load_config($tidy_conf);
        tidy_set_encoding('utf8');
        tidy_parse_string($text);
        tidy_clean_repair();
        $result = tidy_get_output();
    } elseif ($tidy_command_line_available) {
        $arg = escapeshellarg($text);
        // escape the bad stuff in the text
        $cmd = 'echo ' . $arg . ' | ' . TIDY_EXE . ' -q -config ' . $tidy_conf . ' 2> /dev/null';
        // the actual command - pipes the input to tidy which diverts its output to the random file
        $result = shell_exec($cmd);
        // execute the command
    } else {
        trigger_error('tidy does not appear to be available within php or at the command line - no tidying is taking place.');
        $result = $text;
    }
    return trim($result);
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:55,代码来源:tidy.php

示例7: process

 public function process($html)
 {
     if (!$this->enabled) {
         return $html;
     }
     if ($this->addTimeMark) {
         Debugger::timer('tidy');
     }
     $this->parseString($html, $this->config, 'utf8');
     if ($this->runCleanRepair) {
         $this->cleanRepair();
     }
     $output = tidy_get_output($this);
     if ($this->addTimeMark) {
         $elapsed = Debugger::timer('tidy');
         $output .= "\n\n<!-- Tidy formatting took: " . number_format($elapsed * 1000, 2) . " ms -->";
     }
     return $output;
 }
开发者ID:mike227,项目名称:n-tidy,代码行数:19,代码来源:Tidy.php

示例8: read

 /**
  * Reads input and returns Tidy-filtered output.
  *
  * @param null $len
  *
  * @throws BuildException
  * @return the resulting stream, or -1 if the end of the resulting stream has been reached
  *
  */
 public function read($len = null)
 {
     if (!class_exists('Tidy')) {
         throw new BuildException("You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter.");
     }
     if (!$this->getInitialized()) {
         $this->_initialize();
         $this->setInitialized(true);
     }
     $buffer = $this->in->read($len);
     if ($buffer === -1) {
         return -1;
     }
     $config = $this->getDistilledConfig();
     $tidy = new Tidy();
     $tidy->parseString($buffer, $config, $this->encoding);
     $tidy->cleanRepair();
     return tidy_get_output($tidy);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:28,代码来源:TidyFilter.php

示例9: executeFilter

 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // htmltidy must be enabled in configuration
     if ($this->config['htmltidy']['enabled'] === 1 and extension_loaded('tidy')) {
         // bypass
         return;
     }
     // get output from response
     $content = $response->getContent();
     // init tidy
     $tidy = new tidy();
     /*
     $tidyoptions = array(
        'indent-spaces'    => 4,
         'wrap'             => 120,
         'indent'           => auto,
         'tidy-mark'        => true,
         'show-body-only'   => true,
         'force-output'     => true,
         'output-xhtml'     => true,
         'clean'            => true,
         'hide-comments'    => false,
         'join-classes'     => false,
         'join-styles'      => false,
         'doctype'          => 'strict',
         'lower-literals'   => true,
         'quote-ampersand'  => true,
         'wrap'             => 0,
         'drop-font-tags'   => true,
         'drop-empty-paras' => true,
         'drop-proprietary-attributes' => true);
     */
     $tidyoptions = ['clean' => true, 'doctype' => 'transitional', 'output-xhtml' => true, 'drop-proprietary-attributes' => true, 'lower-literals' => true, 'show-body-only' => false, 'indent-spaces' => 4, 'wrap' => 130, 'indent' => 'auto'];
     // tidy the output
     $tidy->parseString($content, $tidyoptions, 'utf8');
     $tidy->cleanRepair();
     // @todo diagnose? errorreport?
     // set output to response
     $response->setContent(tidy_get_output($tidy), true);
 }
开发者ID:ksst,项目名称:kf,代码行数:40,代码来源:HtmlTidy.php

示例10: apply

 /**
  * tidy the data
  *
  * @access	public
  * @param	string		data
  * @return	string		compressed data
  */
 function apply($data)
 {
     if (!function_exists('tidy_parse_string')) {
         return $data;
     }
     /**
      * tidy 1.0
      */
     if (function_exists('tidy_setopt') && is_array($this->_params)) {
         foreach ($this->_params as $opt => $value) {
             tidy_setopt($opt, $value);
         }
         tidy_parse_string($data);
         tidy_clean_repair();
         $data = tidy_get_output();
     } else {
         $tidy = tidy_parse_string($data, $this->_params);
         tidy_clean_repair($tidy);
         $data = tidy_get_output($tidy);
     }
     return $data;
 }
开发者ID:jwest00724,项目名称:Joomla-1.0,代码行数:29,代码来源:Tidy.php

示例11: return_parsed_bbcode

function return_parsed_bbcode($message, $nowrap = false)
{
    // never strip_tags here, see Page.Talks for details
    $message = str_replace("[b]", "<b>", $message);
    $message = str_replace("[/b]", "</b>", $message);
    $message = str_replace("[i]", "<i>", $message);
    $message = str_replace("[/i]", "</i>", $message);
    $message = str_replace("[u]", "<u>", $message);
    $message = str_replace("[/u]", "</u>", $message);
    $message = str_replace("[center]", "<div align=\"center\">", $message);
    $message = str_replace("[/center]", "</div>", $message);
    $message = str_replace("[left]", "<div align=\"left\">", $message);
    $message = str_replace("[/left]", "</div>", $message);
    $message = str_replace("[right]", "<div align=\"right\">", $message);
    $message = str_replace("[/right]", "</div>", $message);
    $message = str_replace("[ol]", "<ol>", $message);
    $message = str_replace("[ul]", "<ul>", $message);
    $message = str_replace("[li]", "<li>", $message);
    $message = str_replace("[/ol]", "</ol>", $message);
    $message = str_replace("[/ul]", "</ul>", $message);
    $message = str_replace("[br]", "<br>", $message);
    $message = eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]", "<img src=\"\\1\" border=\"0\">", $message);
    $message = eregi_replace("\\[url\\](https?://[^\\[]*)\\[/url\\]", "<a href=\"\\1\">\\1</a>", $message);
    if (function_exists("tidy_get_output")) {
        if (!$nowrap) {
            $config = array('indent' => FALSE, 'output-xhtml' => TRUE, 'show-body-only' => TRUE, 'wrap' => 80);
        } else {
            $config = array('indent' => FALSE, 'output-xhtml' => TRUE, 'show-body-only' => TRUE);
        }
        tidy_set_encoding('UTF8');
        foreach ($config as $key => $value) {
            tidy_setopt($key, $value);
        }
        tidy_parse_string($message);
        tidy_clean_repair();
        $message = tidy_get_output();
    }
    return $message;
}
开发者ID:esokullu,项目名称:grou.ps,代码行数:39,代码来源:bbcode.php

示例12: TidyClean

 function TidyClean()
 {
     if (!class_exists('tidy')) {
         if (function_exists('tidy_parse_string')) {
             //use procedural style for compatibility with PHP 4.3
             tidy_set_encoding($this->Encoding);
             foreach ($this->TidyConfig as $key => $value) {
                 tidy_setopt($key, $value);
             }
             tidy_parse_string($this->html);
             tidy_clean_repair();
             $this->html = tidy_get_output();
         } else {
             print "<b>No tidy support. Please enable it in your php.ini.\r\nOnly basic cleaning is beeing applied\r\n</b>";
         }
     } else {
         //PHP 5 only !!!
         $tidy = new tidy();
         $tidy->parseString($this->html, $this->TidyConfig, $this->Encoding);
         $tidy->cleanRepair();
         $this->html = $tidy;
     }
 }
开发者ID:ergun805,项目名称:eOgr,代码行数:23,代码来源:HTMLCleaner.php

示例13: tidyCleaner

 /**
  * Tidyfication of the strings
  *
  * @param string $str
  * @return string
  */
 public function tidyCleaner($str)
 {
     eZDebug::accumulatorStart('eztidytemplateoperator', 'Tidy', 'Tidy template operator');
     if (!class_exists('tidy')) {
         eZDebug::writeError("phpTidy isn't installed", 'eZTidy::tidyCleaner()');
         return $str;
     }
     $str = trim($str);
     if ($str == "") {
         return "";
     }
     $this->tidy = new tidy();
     $this->tidy->parseString($str, $this->config, $this->options['charset']);
     $this->tidy->cleanRepair();
     $this->isTidyfied = true;
     $this->reportWarning();
     $output = tidy_get_output($this->tidy);
     if (strtolower($this->options['showTidyElement']) == 'enabled') {
         return "<!-- Tidy - Begin -->\n" . $output . "\n<!-- Tidy - End -->";
     }
     eZDebug::accumulatorStop('eztidytemplateoperator');
     return $output;
 }
开发者ID:philandteds,项目名称:eztidy,代码行数:29,代码来源:eztidy.php

示例14: deliverPDFfromHTML

 /**
  * Delivers a PDF file from XHTML
  *
  * @param string $html The XHTML string
  * @access public
  */
 public function deliverPDFfromHTML($content, $title = NULL)
 {
     $content = preg_replace("/href=\".*?\"/", "", $content);
     $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
     $printbody->setVariable("TITLE", ilUtil::prepareFormOutput($this->getTitle()));
     $printbody->setVariable("ADM_CONTENT", $content);
     $printbody->setCurrentBlock("css_file");
     $printbody->setVariable("CSS_FILE", $this->getTestStyleLocation("filesystem"));
     $printbody->parseCurrentBlock();
     $printbody->setCurrentBlock("css_file");
     $printbody->setVariable("CSS_FILE", ilUtil::getStyleSheetLocation("filesystem", "delos.css"));
     $printbody->parseCurrentBlock();
     $printoutput = $printbody->get();
     $html = str_replace("href=\"./", "href=\"" . ILIAS_HTTP_PATH . "/", $printoutput);
     $html = preg_replace("/<div id=\"dontprint\">.*?<\\/div>/ims", "", $html);
     if (extension_loaded("tidy")) {
         $config = array("indent" => false, "output-xml" => true, "numeric-entities" => true);
         $tidy = new tidy();
         $tidy->parseString($html, $config, 'utf8');
         $tidy->cleanRepair();
         $html = tidy_get_output($tidy);
         $html = preg_replace("/^.*?(<html)/", "\\1", $html);
     } else {
         $html = str_replace("&nbsp;", "&#160;", $html);
         $html = str_replace("&otimes;", "X", $html);
     }
     $html = preg_replace("/src=\".\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
     $this->deliverPDFfromFO($this->processPrintoutput2FO($html), $title);
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:35,代码来源:class.ilObjTest.php

示例15: tidy

         $node->appendChild($dom->createTextNode('.1'));
         //hack to trigger an update for 4.1.10 release due translations not being loaded on updates
     }
 }
 $results = $xpath->query('//*[@locale]');
 for ($i = 0; $i < $results->length; $i++) {
     $results->item($i)->setAttribute('locale', $locale);
 }
 $out = $dom->saveXML();
 if (function_exists('tidy_get_output')) {
     $tidy = new tidy();
     $tidy_config = array('input-xml' => true, 'output-xml' => true, 'indent' => true, 'wrap' => 0);
     $tidy->isXML();
     $tidy->parseString($out, $tidy_config, 'UTF8');
     $tidy->cleanRepair();
     $out = tidy_get_output($tidy);
 }
 if ($booleans['create_archive']) {
     $cwd = realpath(getcwd());
     $c_path = realpath($configs[$module]);
     if (strpos($c_path, $cwd) !== 0) {
         I2CE::raiseError("Cannot determine module sub-directory structure for {$module}", E_USER_ERROR);
     }
     $target_dir = $archive_dir . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . substr($c_path, strlen($cwd)) . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR;
 } else {
     $target_dir = $configs[$module] . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR;
 }
 if (!is_dir($target_dir)) {
     if (!mkdir($target_dir, 0775, true)) {
         I2CE::raiseError("Could not created {$target_dir}", E_USER_ERROR);
     }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:31,代码来源:translate_templates.php


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