MediaWiki REL1_30
TidySupport.php
Go to the documentation of this file.
1<?php
2
27 private $enabled;
28 private $config;
29
34 public function __construct( $useConfiguration = false ) {
37
38 $this->enabled = true;
39 if ( $useConfiguration ) {
40 if ( $wgTidyConfig !== null ) {
41 $this->config = $wgTidyConfig;
42 } elseif ( $wgUseTidy ) {
43 $this->config = [
44 'tidyConfigFile' => $wgTidyConf,
45 'debugComment' => false,
46 'tidyBin' => $wgTidyBin,
47 'tidyCommandLine' => $wgTidyOpts
48 ];
49 if ( $wgTidyInternal ) {
50 $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP';
51 } else {
52 $this->config['driver'] = 'RaggettExternal';
53 }
54 } else {
55 $this->enabled = false;
56 }
57 } else {
58 $this->config = [
59 'tidyConfigFile' => "$IP/includes/tidy/tidy.conf",
60 'tidyCommandLine' => '',
61 ];
62 if ( extension_loaded( 'tidy' ) && ( wfIsHHVM() || class_exists( 'tidy' ) ) ) {
63 $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP';
64 } else {
65 if ( is_executable( $wgTidyBin ) ) {
66 $this->config['driver'] = 'RaggettExternal';
67 $this->config['tidyBin'] = $wgTidyBin;
68 } else {
70 if ( $path !== false ) {
71 $this->config['driver'] = 'RaggettExternal';
72 $this->config['tidyBin'] = $wgTidyBin;
73 } else {
74 $this->enabled = false;
75 }
76 }
77 }
78 }
79 if ( !$this->enabled ) {
80 $this->config = [ 'driver' => 'disabled' ];
81 }
82 }
83
89 public function isEnabled() {
90 return $this->enabled;
91 }
92
93 public function getConfig() {
94 return $this->config;
95 }
96}
$wgTidyConf
The path to the tidy config file.
$wgTidyInternal
Set this to true to use the tidy extension.
$wgUseTidy
Set this to true to use the deprecated tidy configuration parameters.
$wgTidyBin
The path to the tidy binary.
$wgTidyOpts
The command line options to the tidy binary.
$wgTidyConfig
Configuration for HTML postprocessing tool.
wfIsHHVM()
Check if we are running under HHVM.
static locateExecutableInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Initialize and detect the tidy support.
isEnabled()
Returns true if tidy is usable.
__construct( $useConfiguration=false)
Determine if there is a usable tidy.
$IP
Definition update.php:3