本文整理汇总了PHP中tidy::cleanRepair方法的典型用法代码示例。如果您正苦于以下问题:PHP tidy::cleanRepair方法的具体用法?PHP tidy::cleanRepair怎么用?PHP tidy::cleanRepair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tidy
的用法示例。
在下文中一共展示了tidy::cleanRepair方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tidyClean
function tidyClean()
{
$tidy = new tidy();
$tidy->parseString(self::$html, self::$tidy_config, self::$encoding);
$tidy->cleanRepair();
self::$html = $tidy;
}
示例2: build
/**
* Detects feed types and instantiate appropriate objects.
*
* Our constructor takes care of detecting feed types and instantiating
* appropriate classes. For now we're going to treat Atom 0.3 as Atom 1.0
* but raise a warning. I do not intend to introduce full support for
* Atom 0.3 as it has been deprecated, but others are welcome to.
*
* @param string $feed XML serialization of the feed
* @param bool $strict Whether or not to validate the feed
* @param bool $suppressWarnings Trigger errors for deprecated feed types?
* @param bool $tidy Whether or not to try and use the tidy library on input
*/
function build(DOMDocument $model, $feed, $strict = false, $suppressWarnings = false, $tidy = false)
{
$options = 0;
if ($suppressWarnings) {
$options |= LIBXML_NOWARNING;
$options |= LIBXML_NOERROR;
}
if (empty($feed)) {
throw new XML_Feed_Parser_Exception('Invalid input: file is empty');
}
if (!$model->loadXML($feed, $options)) {
if (extension_loaded('tidy') && $tidy) {
$tidy = new tidy();
$tidy->parseString($feed, array('input-xml' => true, 'output-xml' => true));
$tidy->cleanRepair();
if (!$model->loadXML((string) $tidy)) {
throw new XML_Feed_Parser_Exception('Invalid input: this is not ' . 'valid XML');
}
} else {
throw new XML_Feed_Parser_Exception('Invalid input: this is not valid XML');
}
}
/* detect feed type */
$doc_element = $model->documentElement;
$class = $this->determineClass($doc_element, $suppressWarnings);
/* Instantiate feed object */
$feed = new $class($model, $strict);
$feed->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
return $feed;
}
示例3: repair
public function repair($markup)
{
$tidy = new \tidy();
$tidy->parseString($markup, self::$config, 'utf8');
$tidy->cleanRepair();
return $tidy . '';
}
示例4: 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('-->', '-->', $tidy->errorBuffer) . "\n-->";
}
}
return $cleansource;
}
示例5: send_mail
private static function send_mail($server_cfg, $game_cfg, $report)
{
$to = "";
$random_hash = md5(date('r', time()));
$mime_boundary = "==Multipart_Boundary_x{$random_hash}x";
if ($game_cfg === null) {
$subject = "Instance Utilization Summary";
$bcc = $server_cfg["instance_report_mail_recipients"];
$headers = 'From: ' . $server_cfg["sender"] . "\r\n" . 'Bcc: ' . $bcc . "\r\n" . "Content-Type: multipart/mixed;" . " boundary=\"{$mime_boundary}\"" . 'X-Mailer: PHP/' . phpversion();
$HTMLMessage = file_get_contents($report);
$tidy = new tidy();
$tidy->parseString($HTMLMessage);
$tidy->cleanRepair();
$message = "\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $tidy . "\n\n";
$reportClass = new ReportCollector($server_cfg);
$data = $reportClass->generateCSV();
$message .= "--{$mime_boundary}\n" . "Content-Type:text/csv; \n" . " name=zPerfmonUtilTrend_" . date("MjY") . ".csv \n" . "Content-Transfer-Encoding: 7bit\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
mail($to, $subject, $message, $headers);
} else {
$subject = "Instance Utilization report for {$game_cfg['name']}";
$bcc = $game_cfg["instance_report_mail_recipients"];
$headers = 'From: ' . $server_cfg["sender"] . "\r\n" . 'Bcc: ' . $bcc . "\r\n" . 'Content-Type: text/HTML' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$message = file_get_contents($report);
$tidy = new tidy();
$tidy->parseString($message);
$tidy->cleanRepair();
mail($to, $subject, $tidy, $headers);
}
}
示例6: 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);
}
示例7: __construct
public function __construct($content)
{
if (extension_loaded('tidy')) {
// using the tidy php extension
$tidy = new tidy();
$tidy->parseString($content, array('output-xhtml' => true, 'numeric-entities' => true, 'wrap' => 0), 'utf8');
$tidy->cleanRepair();
$tidy = str_replace('xmlns="http://www.w3.org/1999/xhtml"', '', $tidy);
$tidy = str_replace(' ', '', $tidy);
} elseif (@shell_exec('which tidy')) {
// using tiny through cli
$CLI_content = escapeshellarg($content);
$tidy = `echo {$CLI_content} | tidy --force-output 1 -n -q -utf8 -asxhtml -w 0 2> /dev/null`;
$tidy = str_replace('xmlns="http://www.w3.org/1999/xhtml"', '', $tidy);
$tidy = str_replace(' ', '', $tidy);
} else {
// no tidy library found, hence no sanitizing
$tidy = $content;
}
$this->simpleXML = @simplexml_load_string($tidy, 'SimpleXMLElement', LIBXML_NOWARNING);
if (!$this->simpleXML) {
throw new Exception('CSSContentParser::__construct(): Could not parse content.' . ' Please check the PHP extension tidy is installed.');
}
parent::__construct();
}
示例8: apply
public function apply($str)
{
if (extension_loaded('tidy') && class_exists('tidy')) {
$config = array('doctype' => 'strict', 'drop-proprietary-attributes' => true, 'drop-font-tags' => true, 'escape-cdata' => true, 'indent' => false, 'join-classes' => false, 'join-styles' => true, 'lower-literals' => true, 'output-xhtml' => true, 'show-body-only' => true, 'wrap' => 80);
$str = '<p>tt</p>' . $str;
// Fixes a big issue
$tidy = new tidy();
$tidy->parseString($str, $config, 'utf8');
$tidy->cleanRepair();
$str = (string) $tidy;
$str = preg_replace('#^<p>tt</p>\\s?#', '', $str);
} else {
$str = $this->miniTidy($str);
}
# Removing open comments, open CDATA and processing instructions
$str = preg_replace('%<!--.*?-->%msu', '', $str);
$str = str_replace('<!--', '', $str);
$str = preg_replace('%<!\\[CDATA\\[.*?\\]\\]>%msu', '', $str);
$str = str_replace('<![CDATA[', '', $str);
# Transform processing instructions
$str = str_replace('<?', '>?', $str);
$str = str_replace('?>', '?<', $str);
$str = html::decodeEntities($str, true);
$this->content = '';
xml_parse($this->parser, '<all>' . $str . '</all>');
return $this->content;
}
示例9: sphsc3
function sphsc3()
{
$results = array();
$i = 0;
do {
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsaud.asp'; //7-8
// 'https://content.sphsc.washington.edu/sphintra/web2/res_blurb.asp'; // 11
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 14
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsphd.asp'; //15
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidspb.asp'; // 16, 19
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsmed.asp'; // 17, 20
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsug.asp'; // 18
// 'https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp';
//$uri = 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 19
// No's:
// http://content.sphsc.washington.edu/sphintra/web2/clinic_msg.asp
// http://content.sphsc.washington.edu/sphintra/web2/home_right.asp
// https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp
// http://content.sphsc.washington.edu/sphintra/web2/outreach_msg.asp
$tids = array();
$c = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200, 'hide-comments' => true);
$response = get_page($uri);
$tidy = new tidy();
$tidy->parseString($response, $c, 'utf8');
$tidy->cleanRepair();
preg_match("/<body[^>]*>(.*?)<\\/body>/is", $tidy, $a);
$body = str_replace(array("\n", "\r"), '', $a[1]);
$title = some_words(strip_tags($body));
$results[$title] = $body;
} while ($i++ < 20);
foreach ($results as $k => $v) {
save_item($k, $v, $tids);
}
}
示例10: filter
/**
*
* Uses the tidy library to tidy HTML output.
*
* @access public
*
* @param string $buffer The source text to be filtered.
*
*/
public function filter($buffer)
{
$tidy = new tidy();
$config = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200);
$tidy->parseString($buffer, $config);
$tidy->cleanRepair();
return $tidy->get_output();
}
示例11: tidy_html
function tidy_html($html)
{
$config = array('indent' => 2, 'output-xhtml' => true, 'doctype' => 'strict', 'wrap' => 120);
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
return $tidy;
}
示例12: filter
public function filter(&$content)
{
$config = array('clean' => true, 'enclose-block-text' => true, 'enclose-text' => true, 'preserve-entities' => true, 'logical-emphasis' => true, 'char-encoding' => 'utf8', 'indent' => 'auto', 'output-xhtml' => true, 'wrap' => 200);
$tidy = new tidy();
$tidy->parseString($this->gethtml($content), $config, 'utf8');
$tidy->cleanRepair();
$content = $this->getbody((string) $tidy);
}
示例13: Clean
/**
*
* Cleans the html
* @param string $html String cotaining the html to clean
* @return string Cleaned an tidyed
*/
public static function Clean($html)
{
$html = Html::BurnerClean($html);
$config = array("show-body-only" => true, "alt-text" => "Pic without description", "hide-endtags" => false, "output-xhtml" => true);
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
return $tidy;
}
示例14: tidy
protected function tidy($response)
{
$response = str_replace(' ', ' ', $response);
$config = array('output-xhtml' => true);
$tidy = new tidy();
$tidy->parseString($response, $config, 'utf8');
$tidy->cleanRepair();
return (string) $tidy;
}
示例15: getURL
public function getURL($url)
{
$data = "awerawer";
// in my code, $data is downloaded from a site
$tidy = new tidy();
$tidy->parseString($data, $this->tidyconfig, 'utf8');
$tidy->cleanRepair();
return $tidy;
}