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
|
|
|
abstract class StatisticsPage |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Creates a statistics page. |
19
|
|
|
* |
20
|
|
|
* @param $pageName string Name of the page |
21
|
|
|
* @return StatisticsPage Object of type dependant on the name specified. |
22
|
|
|
*/ |
23
|
|
|
public static function Create($pageName) |
24
|
|
|
{ |
25
|
|
|
// calculate the name of the statistics page |
26
|
|
|
$statsPage = "Stats" . $pageName; |
27
|
|
|
|
28
|
|
|
global $filepath; |
29
|
|
|
// check the stats page definition exists... |
30
|
|
|
if (file_exists($filepath . "/includes/statistics/Stats" . $pageName . ".php")) { |
31
|
|
|
// and include it. |
32
|
|
|
require_once($filepath . "/includes/statistics/Stats" . $pageName . ".php"); |
33
|
|
|
} |
34
|
|
|
else { |
35
|
|
|
// class def doesn't exist: error |
36
|
|
|
die("Unknown statistics page"); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
// ok, so the file where the class def should be exists, but we need to check the class |
40
|
|
|
// itself exists. |
41
|
|
|
if (class_exists($statsPage)) { |
42
|
|
|
// the class exists, all is ok. |
43
|
|
|
|
44
|
|
|
// create the stats page object |
45
|
|
|
$object = new $statsPage; |
46
|
|
|
|
47
|
|
|
// check the newly created object has inherits from StatisticsPage class |
48
|
|
|
if (get_parent_class($object) == "StatisticsPage") { |
49
|
|
|
// all is good, return the new statistics page object |
50
|
|
|
return $object; |
51
|
|
|
} |
52
|
|
|
else { |
53
|
|
|
// oops. this is our class, named correctly, but it's a bad definition. |
54
|
|
|
die("Unrecognised statistics page definition."); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
else { |
58
|
|
|
// file exists, but no definition of the class |
59
|
|
|
die("No definition for statistics page: " . $statsPage); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Abstract method provides the content of the statistics page |
65
|
|
|
* @return string content of stats page. |
66
|
|
|
*/ |
67
|
|
|
abstract protected function execute(); |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Returns the title of the page (initial header, and name in menu) |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
abstract public function getPageTitle(); |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns the name of the page (used in urls, and class defs) |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
abstract public function getPageName(); |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Determines if the stats page is only available to logged-in users, or everyone. |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
|
|
abstract public function isProtected(); |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Determines if the statistics page requires the wiki database. Defaults to true |
89
|
|
|
* @return bool |
90
|
|
|
*/ |
91
|
|
|
public function requiresWikiDatabase() |
92
|
|
|
{ |
93
|
|
|
return true; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Determines if the statistics page requires a simple HTML environment. Defaults to true |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function requiresSimpleHtmlEnvironment() |
101
|
|
|
{ |
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Determines if the statistics page should be hidden from the main menu. Defaults to false. |
107
|
|
|
* @return boolean |
108
|
|
|
*/ |
109
|
|
|
public function hideFromMenu() |
110
|
|
|
{ |
111
|
|
|
return false; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Shows the statistics page. |
116
|
|
|
*/ |
117
|
|
|
public function Show() |
118
|
|
|
{ |
119
|
|
|
// Get the needed objects. |
120
|
|
|
|
121
|
|
|
// fetch and show page header |
122
|
|
|
global $dontUseWikiDb; |
123
|
|
|
|
124
|
|
|
BootstrapSkin::displayInternalHeader(); |
125
|
|
|
|
126
|
|
|
if ($this->requiresWikiDatabase() && ($dontUseWikiDb == 1)) { |
127
|
|
|
// wiki database unavailable, don't show stats page |
128
|
|
|
BootstrapSkin::displayAlertBox("This statistics page is currently unavailable.", "alert-error", "Database unavailable", true, false); |
129
|
|
|
BootstrapSkin::displayInternalFooter(); |
130
|
|
|
die(); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
// wiki database available OR stats page doesn't need wiki database |
134
|
|
|
|
135
|
|
|
// check protection level |
136
|
|
|
if ($this->isProtected()) { |
137
|
|
|
if (User::getCurrent()->isCommunityUser()) { |
138
|
|
|
showlogin(); |
139
|
|
|
BootstrapSkin::displayInternalFooter(); |
140
|
|
|
die(); |
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
$session = new session(); |
144
|
|
|
$session->checksecurity(); |
|
|
|
|
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// not protected or access allowed |
148
|
|
|
echo '<div class="page-header"><h1>' . $this->getPageTitle() . '</h1></div>'; |
149
|
|
|
|
150
|
|
|
if ($this->requiresSimpleHtmlEnvironment()) { |
151
|
|
|
echo '<div class="row-fluid"><div class="span12">'; |
152
|
|
|
BootstrapSkin::pushTagStack("</div>"); |
153
|
|
|
BootstrapSkin::pushTagStack("</div>"); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
echo $this->execute(); |
157
|
|
|
|
158
|
|
|
// Display the footer of the interface. |
159
|
|
|
BootstrapSkin::displayInternalFooter(); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.