MediaWiki REL1_31
RaggettInternalPHP.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Tidy;
4
15 protected function cleanWrapped( $text, $stderr = false, &$retval = null ) {
16 if ( !class_exists( 'tidy' ) ) {
17 wfWarn( "Unable to load internal tidy class." );
18 $retval = -1;
19
20 return null;
21 }
22
23 $tidy = new \tidy;
24 $tidy->parseString( $text, $this->config['tidyConfigFile'], 'utf8' );
25
26 if ( $stderr ) {
27 $retval = $tidy->getStatus();
28 return $tidy->errorBuffer;
29 }
30
31 $tidy->cleanRepair();
32 $retval = $tidy->getStatus();
33 if ( $retval == 2 ) {
34 // 2 is magic number for fatal error
35 // https://secure.php.net/manual/en/tidy.getstatus.php
36 $cleansource = null;
37 } else {
38 $cleansource = tidy_get_output( $tidy );
39 if ( !empty( $this->config['debugComment'] ) && $retval > 0 ) {
40 $cleansource .= "<!--\nTidy reports:\n" .
41 str_replace( '-->', '--&gt;', $tidy->errorBuffer ) .
42 "\n-->";
43 }
44 }
45
46 return $cleansource;
47 }
48
49 public function supportsValidate() {
50 return true;
51 }
52}
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
supportsValidate()
Return true if validate() can be used.
cleanWrapped( $text, $stderr=false, &$retval=null)
Use the HTML tidy extension to use the tidy library in-process, saving the overhead of spawning a new...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval
Definition hooks.txt:266