Completed
Pull Request — master (#526)
by Michael
16:45 queued 06:57
created

Offline   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
eloc 21
c 2
b 2
f 0
dl 0
loc 54
ccs 0
cts 32
cp 0
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isOffline() 0 5 1
A getOfflineMessage() 0 12 2
A check() 0 16 3
1
<?php
2
/**************************************************************************
3
**********      English Wikipedia Account Request Interface      **********
4
***************************************************************************
5
** Wikipedia Account Request Graphic Design by Charles Melbye,           **
6
** which is licensed under a Creative Commons                            **
7
** Attribution-Noncommercial-Share Alike 3.0 United States License.      **
8
**                                                                       **
9
** All other code are released under the Public Domain                   **
10
** by the ACC Development Team.                                          **
11
**                                                                       **
12
** See CREDITS for the list of developers.                               **
13
***************************************************************************/
14
15
/**
16
 * Handles the tool offline messages
17
 */
18
class Offline
19
{
20
	/**
21
	 * Summary of check
22
	 * @param bool $external External interface
23
	 * @deprecated Do checking within the entry point.
24
	 */
25
	public static function check($external)
26
	{
27
		global $smarty, $dontUseDb, $dontUseDbCulprit, $dontUseDbReason;
28
29
		if ($dontUseDb) {
30
			if ($external) {
31
				$smarty->display("offline/external.tpl");
32
			}
33
			else {
34
				$smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
35
				$smarty->assign("dontUseDbReason", $dontUseDbReason);
36
				$smarty->assign("alerts", array());
37
				$smarty->display("offline/internal.tpl");
38
			}
39
40
			die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
41
		}
42
	}
43
44
	/**
45
	 * Determines if the tool is offline
46
	 * @return bool
47
	 */
48
	public static function isOffline()
49
	{
50
		global $dontUseDb;
51
52
		return (bool)$dontUseDb;
53
	}
54
55
	/**
56
	 * Gets the offline message
57
	 * @param bool $external
58
	 * @return string
59
	 */
60
	public static function getOfflineMessage($external)
61
	{
62
		global $smarty, $dontUseDbCulprit, $dontUseDbReason;
63
64
		if ($external) {
65
			return $smarty->fetch("offline/external.tpl");
66
		}
67
		else {
68
			$smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
69
			$smarty->assign("dontUseDbReason", $dontUseDbReason);
70
			$smarty->assign("alerts", array());
71
			return $smarty->fetch("offline/internal.tpl");
72
		}
73
	}
74
}
75