Completed
Branch master (939199)
by
unknown
39:35
created

includes/installer/WebInstallerComplete.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 * http://www.gnu.org/copyleft/gpl.html
17
 *
18
 * @file
19
 * @ingroup Deployment
20
 */
21
22
class WebInstallerComplete extends WebInstallerPage {
23
24
	public function execute() {
0 ignored issues
show
execute uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
25
		// Pop up a dialog box, to make it difficult for the user to forget
26
		// to download the file
27
		$lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getUrl( [ 'localsettings' => 1 ] );
28
		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
29
			strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false
30
		) {
31
			// JS appears to be the only method that works consistently with IE7+
32
			$this->addHTML( "\n<script>jQuery( function () { location.href = " .
33
				Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
34
		} else {
35
			$this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
36
		}
37
38
		$this->startForm();
39
		$this->parent->disableLinkPopups();
40
		$location = $this->parent->getLocalSettingsLocation();
41
		$msg = 'config-install-done';
42
		if ( $location !== false ) {
43
			// config-install-done-path
44
			$msg .= '-path';
45
		}
46
		$this->addHTML(
47
			$this->parent->getInfoBox(
48
				wfMessage( $msg,
49
					$lsUrl,
50
					$this->getVar( 'wgServer' ) .
51
					$this->getVar( 'wgScriptPath' ) . '/index.php',
52
					'<downloadlink/>',
53
					$location ?: ''
54
				)->plain(), 'tick-32.png'
55
			)
56
		);
57
		$this->addHTML( $this->parent->getInfoBox(
58
			wfMessage( 'config-extension-link' )->text() ) );
59
60
		$this->parent->restoreLinkPopups();
61
		$this->endForm( false, false );
62
	}
63
64
}
65