6aed02f304d9aa525bbaae472e63ef2bba5c4f34
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
24 * Initialize and detect the tidy support
31 * Determine if there is a usable tidy.
32 * @param bool $useConfiguration
34 public function __construct( $useConfiguration = false ) {
35 global $IP, $wgUseTidy, $wgTidyBin, $wgTidyInternal, $wgTidyConfig,
36 $wgTidyConf, $wgTidyOpts;
38 $this->enabled
= true;
39 if ( $useConfiguration ) {
40 if ( $wgTidyConfig !== null ) {
41 $this->config
= $wgTidyConfig;
42 } elseif ( $wgUseTidy ) {
44 'tidyConfigFile' => $wgTidyConf,
45 'debugComment' => false,
46 'tidyBin' => $wgTidyBin,
47 'tidyCommandLine' => $wgTidyOpts
49 if ( $wgTidyInternal ) {
50 $this->config
['driver'] = wfIsHHVM() ?
'RaggettInternalHHVM' : 'RaggettInternalPHP';
52 $this->config
['driver'] = 'RaggettExternal';
55 $this->enabled
= false;
59 'tidyConfigFile' => "$IP/includes/tidy/tidy.conf",
60 'tidyCommandLine' => '',
62 if ( extension_loaded( 'tidy' ) && ( wfIsHHVM() ||
class_exists( 'tidy' ) ) ) {
63 $this->config
['driver'] = wfIsHHVM() ?
'RaggettInternalHHVM' : 'RaggettInternalPHP';
65 if ( is_executable( $wgTidyBin ) ) {
66 $this->config
['driver'] = 'RaggettExternal';
67 $this->config
['tidyBin'] = $wgTidyBin;
69 $path = Installer
::locateExecutableInDefaultPaths( $wgTidyBin );
70 if ( $path !== false ) {
71 $this->config
['driver'] = 'RaggettExternal';
72 $this->config
['tidyBin'] = $wgTidyBin;
74 $this->enabled
= false;
79 if ( !$this->enabled
) {
80 $this->config
= [ 'driver' => 'disabled' ];
85 * Returns true if tidy is usable
89 public function isEnabled() {
90 return $this->enabled
;
93 public function getConfig() {