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


PHP tidy::getStatus方法代码示例

本文整理汇总了PHP中tidy::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP tidy::getStatus方法的具体用法?PHP tidy::getStatus怎么用?PHP tidy::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tidy的用法示例。


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

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

示例2: execute

 /**
  * Execute this filter.
  *
  * @param      AgaviFilterChain        The filter chain.
  * @param      AgaviExecutionContainer The current execution container.
  *
  * @throws     <b>AgaviFilterException</b> If an error occurs during execution.
  *
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @since      1.0.0
  */
 public function execute(AgaviFilterChain $filterChain, AgaviExecutionContainer $container)
 {
     // nothing to do so far. let's carry on in the chain
     $filterChain->execute($container);
     // fetch some prerequisites
     $response = $container->getResponse();
     $ot = $response->getOutputType();
     $cfg = $this->getParameters();
     if (!$response->isContentMutable() || !($output = $response->getContent())) {
         // content empty or response not mutable; it's over!
         return;
     }
     if (is_array($cfg['methods']) && !in_array($container->getRequestMethod(), $cfg['methods'])) {
         // we're not allowed to run for this request method
         return;
     }
     if (is_array($cfg['output_types']) && !in_array($ot->getName(), $cfg['output_types'])) {
         // we're not allowed to run for this output type
         return;
     }
     $tidy = new tidy();
     $tidy->parseString($output, $cfg['tidy_options'], $cfg['tidy_encoding']);
     $tidy->cleanRepair();
     if ($tidy->getStatus()) {
         // warning or error occurred
         $emsg = sprintf('Tidy Filter encountered the following problems while parsing and cleaning the document: ' . "\n\n%s", $tidy->errorBuffer);
         if (AgaviConfig::get('core.use_logging') && $cfg['log_errors']) {
             $lmsg = $emsg . "\n\nResponse content:\n\n" . $response->getContent();
             $lm = $this->context->getLoggerManager();
             $mc = $lm->getDefaultMessageClass();
             $m = new $mc($lmsg, $cfg['logging_severity']);
             $lm->log($m, $cfg['logging_logger']);
         }
         // all in all, that didn't go so well. let's see if we should just silently abort instead of throwing an exception
         if (!$cfg['ignore_errors']) {
             throw new AgaviParseException($emsg);
         }
     }
     $response->setContent((string) $tidy);
 }
开发者ID:horros,项目名称:agavi,代码行数:51,代码来源:AgaviTidyFilter.class.php

示例3: execInternalTidy

 /**
  * Use the HTML tidy PECL extension to use the tidy library in-process,
  * saving the overhead of spawning a new process.
  *
  * 'pear install tidy' should be able to compile the extension module.
  */
 private static function execInternalTidy($text, $stderr = false, &$retval = null)
 {
     global $wgTidyConf, $IP, $wgDebugTidy;
     wfProfileIn(__METHOD__);
     $tidy = new tidy();
     $tidy->parseString($text, $wgTidyConf, 'utf8');
     if ($stderr) {
         $retval = $tidy->getStatus();
         return $tidy->errorBuffer;
     } else {
         $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 ($wgDebugTidy && $retval > 0) {
             $cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '--&gt;', $tidy->errorBuffer) . "\n-->";
         }
         wfProfileOut(__METHOD__);
         return $cleansource;
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:32,代码来源:Tidy.php

示例4: internalTidy

 /**
  * Use the HTML tidy PECL extension to use the tidy library in-process,
  * saving the overhead of spawning a new process. 
  *
  * 'pear install tidy' should be able to compile the extension module.
  *
  * @private
  * @static
  */
 function internalTidy($text)
 {
     global $wgTidyConf, $IP, $wgDebugTidy;
     $fname = 'Parser::internalTidy';
     wfProfileIn($fname);
     $tidy = new tidy();
     $tidy->parseString($text, $wgTidyConf, 'utf8');
     $tidy->cleanRepair();
     if ($tidy->getStatus() == 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 ($wgDebugTidy && $tidy->getStatus() > 0) {
         $cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '--&gt;', $tidy->errorBuffer) . "\n-->";
     }
     wfProfileOut($fname);
     return $cleansource;
 }
开发者ID:renemilk,项目名称:spring-website,代码行数:30,代码来源:Parser.php

示例5: phpClean

 /**
  * 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
  */
 private static function phpClean($text, $stderr = false, &$retval = null)
 {
     global $wgTidyConf, $wgDebugTidy;
     if (!wfIsHHVM() && !class_exists('tidy') || wfIsHHVM() && !function_exists('tidy_repair_string')) {
         wfWarn("Unable to load internal tidy class.");
         $retval = -1;
         return null;
     }
     $tidy = new tidy();
     $tidy->parseString($text, $wgTidyConf, '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 ($wgDebugTidy && $retval > 0) {
             $cleansource .= "<!--\nTidy reports:\n" . str_replace('-->', '--&gt;', $tidy->errorBuffer) . "\n-->";
         }
     }
     return $cleansource;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:37,代码来源:MWTidy.php

示例6: internalTidy

 /**
  * Use the HTML tidy PECL extension to use the tidy library in-process,
  * saving the overhead of spawning a new process.
  *
  * 'pear install tidy' should be able to compile the extension module.
  *
  * @private
  * @static
  */
 function internalTidy($text)
 {
     global $wgTidyConf, $IP;
     $fname = 'Parser::internalTidy';
     wfProfileIn($fname);
     $tidy = new tidy();
     $tidy->parseString($text, $wgTidyConf, 'utf8');
     $tidy->cleanRepair();
     if ($tidy->getStatus() == 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);
     }
     wfProfileOut($fname);
     return $cleansource;
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:27,代码来源:Parser_OldPP.php

示例7: wfHtmlValidationHandler

/**
 * Replace the output with an error if the HTML is not valid
 */
function wfHtmlValidationHandler($s)
{
    global $IP;
    $tidy = new tidy();
    $tidy->parseString($s, "{$IP}/includes/tidy.conf", 'utf8');
    if ($tidy->getStatus() == 0) {
        return $s;
    }
    header('Cache-Control: no-cache');
    $out = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML validation error</title>
<style>
.highlight { background-color: #ffc }
li { white-space: pre }
</style>
</head>
<body>
<h1>HTML validation error</h1>
<ul>
EOT;
    $error = strtok($tidy->errorBuffer, "\n");
    $badLines = array();
    while ($error !== false) {
        if (preg_match('/^line (\\d+)/', $error, $m)) {
            $lineNum = intval($m[1]);
            $badLines[$lineNum] = true;
            $out .= "<li><a href=\"#line-{$lineNum}\">" . htmlspecialchars($error) . "</a></li>\n";
        }
        $error = strtok("\n");
    }
    $out .= '<pre>' . htmlspecialchars($tidy->errorBuffer) . '</pre>';
    $out .= '<ol>';
    $line = strtok($s, "\n");
    $i = 1;
    while ($line !== false) {
        if (isset($badLines[$i])) {
            $out .= "<li class=\"highlight\" id=\"line-{$i}\">";
        } else {
            $out .= '<li>';
        }
        $out .= htmlspecialchars($line) . '</li>';
        $line = strtok("\n");
        $i++;
    }
    $out .= '</ol></body></html>';
    return $out;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:53,代码来源:OutputHandler.php


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