MediaWiki  1.30.0
TidySupport.php
Go to the documentation of this file.
1 <?php
2 
26 class TidySupport {
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 }
TidySupport\getConfig
getConfig()
Definition: TidySupport.php:93
TidySupport\__construct
__construct( $useConfiguration=false)
Determine if there is a usable tidy.
Definition: TidySupport.php:34
TidySupport\$enabled
$enabled
Definition: TidySupport.php:27
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Installer\locateExecutableInDefaultPaths
static locateExecutableInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Definition: Installer.php:1265
TidySupport
Initialize and detect the tidy support.
Definition: TidySupport.php:26
TidySupport\$config
$config
Definition: TidySupport.php:28
$IP
$IP
Definition: update.php:3
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$wgTidyConf
$wgTidyConf
The path to the tidy config file.
Definition: DefaultSettings.php:4322
$wgTidyInternal
$wgTidyInternal
Set this to true to use the tidy extension.
Definition: DefaultSettings.php:4334
$wgUseTidy
$wgUseTidy
Set this to true to use the deprecated tidy configuration parameters.
Definition: DefaultSettings.php:4310
$wgTidyOpts
$wgTidyOpts
The command line options to the tidy binary.
Definition: DefaultSettings.php:4328
$wgTidyConfig
$wgTidyConfig
Configuration for HTML postprocessing tool.
Definition: DefaultSettings.php:4304
$path
$path
Definition: NoLocalSettings.php:26
$wgTidyBin
$wgTidyBin
The path to the tidy binary.
Definition: DefaultSettings.php:4316
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2092
TidySupport\isEnabled
isEnabled()
Returns true if tidy is usable.
Definition: TidySupport.php:89