wfMsgForContentNoTrans() was removed
[mediawiki.git] / includes / tidy / RaggettBase.php
bloba3717b2bf06b6ca6acd17fd9af381848d3dfae5c
1 <?php
3 namespace MediaWiki\Tidy;
5 abstract class RaggettBase extends TidyDriverBase {
6 /**
7 * Generic interface for wrapping and unwrapping HTML for Dave Raggett's tidy.
9 * @param string $text Hideous HTML input
10 * @return string Corrected HTML output
12 public function tidy( $text ) {
13 $wrapper = new RaggettWrapper;
14 $wrappedtext = $wrapper->getWrapped( $text );
16 $retVal = null;
17 $correctedtext = $this->cleanWrapped( $wrappedtext, false, $retVal );
19 if ( $retVal < 0 ) {
20 wfDebug( "Possible tidy configuration error!\n" );
21 return $text . "\n<!-- Tidy was unable to run -->\n";
22 } elseif ( is_null( $correctedtext ) ) {
23 wfDebug( "Tidy error detected!\n" );
24 return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
27 $correctedtext = $wrapper->postprocess( $correctedtext ); // restore any hidden tokens
29 return $correctedtext;
32 public function validate( $text, &$errorStr ) {
33 $retval = 0;
34 $errorStr = $this->cleanWrapped( $text, true, $retval );
35 return ( $retval < 0 && $errorStr == '' ) || $retval == 0;
38 /**
39 * Perform a clean/repair operation
40 * @param string $text HTML to check
41 * @param bool $stderr Whether to read result from STDERR rather than STDOUT
42 * @param int &$retval Exit code (-1 on internal error)
43 * @return null|string
44 * @throws MWException
46 abstract protected function cleanWrapped( $text, $stderr = false, &$retval = null );