Admin interface to site parameters, UI part.
[lhc/web/wiklou.git] / includes / SpecialSitesettings.php
1 <?php
2
3 function wfSpecialSiteSettings()
4 {
5 global $wgRequest;
6
7 $form = new SiteSettingsForm( $wgRequest );
8 $form->execute();
9 }
10
11 class SiteSettingsForm {
12 var $mPosted, $mRequest, $mReset, $mSaveprefs;
13
14 function SiteSettingsForm ( &$request ) {
15 $this->mPosted = $request->wasPosted();
16 $this->mRequest = $request;
17 }
18
19 function execute() {
20 if ( wfReadOnly() ) {
21 $wgOut->readOnlyPage();
22 return;
23 }
24 if ( $this->mReset ) {
25 $this->resetPrefs();
26 $this->mainPrefsForm( wfMsg( "prefsreset" ) );
27 } else if ( $this->mSaveprefs ) {
28 $this->savePreferences();
29 } else {
30 $this->resetPrefs();
31 $this->mainPrefsForm( "" );
32 }
33 }
34
35 /* private */ function resetPrefs() {
36 return;
37 }
38
39 /* private */ function fieldset( $name, $content ) {
40 return "<fieldset><legend>".wfMsg($name)."</legend>\n" .
41 $content . "\n</fieldset>\n";
42 }
43
44 /* private */ function checkbox( $varname, $checked=false ) {
45 $checked = isset( $GLOBALS[$varname] ) && $GLOBALS[$varname] ;
46 return "<div><input type='checkbox' value=\"1\" id=\"{$varname}\" name=\"wpOp{$varname}\"" .
47 ( $checked ? ' checked="checked"' : '' ) .
48 " /><label for=\"{$varname}\">". wfMsg( "sitesettings-".$varname ) .
49 "</label></div>\n";
50 }
51
52 /* private */ function textbox( $varname, $value='', $size=20 ) {
53 $value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : '';
54 return "<div><label>". wfMsg( "sitesettings-".$varname ) .
55 "<input type='text' name=\"wpOp{$varname}\" value=\"{$value}\" size=\"{$size}\" /></label></div>\n";
56 }
57 /* private */ function radiobox( $varname, $fields ) {
58 foreach ( $fields as $value => $checked ) {
59 $s .= "<div><label><input type='radio' name=\"wpOp{$varname}\" value=\"{$value}\"" .
60 ( $checked ? ' checked="checked"' : '' ) . " />" . wfMsg( 'sitesettings-'.$varname.'-'.$value ) .
61 "</label></div>\n";
62 }
63 return $this->fieldset( 'sitesettings-'.$varname, $s );
64 }
65
66 /* private */ function arraybox( $varname , $size=20 ) {
67 $s = '';
68 if ( isset( $GLOBALS[$varname] ) && is_array( $GLOBALS[$varname] ) ) {
69 foreach ( $GLOBALS[$varname] as $index=>$element ) {
70 $s .= $element."\n";
71 }
72 }
73 return "<div><label>".wfMsg( 'sitesettings-'.$varname ).
74 "<textarea name=\"wpOp{$varname}\" rows=\"5\" cols=\"{$size}\">{$s}</textarea>\n";
75 }
76
77 /* private */ function mainPrefsForm( $err ) {
78 global $wgOut;
79
80 $wgOut->setPageTitle( wfMsg( "sitesettings" ) );
81 $wgOut->setArticleRelated( false );
82 $wgOut->setRobotpolicy( "noindex,nofollow" );
83
84 if ( "" != $err ) {
85 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
86 }
87
88 $titleObj = Title::makeTitle( NS_SPECIAL, "SiteSettings" );
89 $action = $titleObj->escapeLocalURL();
90
91 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
92 method=\"post\">" );
93 $wgOut->addHTML( $this->fieldset( "sitesettings-features",
94 $this->checkbox( 'wgShowIPinHeader' ) .
95 $this->checkbox( 'wgUseDatabaseMessages' ) .
96 $this->checkbox( 'wgUseCategoryMagic' ) .
97 $this->checkbox( 'wgUseCategoryBrowser' ) .
98 $this->textbox( 'wgHitcounterUpdateFreq' ) .
99 $this->textbox( 'wgExtraSubtitle' ).
100 $this->textbox( 'wgSiteSupportPage' ) .
101 $this->textbox( 'wgSiteNotice' ) .
102 $this->checkbox( 'wgDisableAnonTalk' ).
103 $this->checkbox( 'wgRCSeconds' ) .
104 $this->checkbox( 'wgCapitalLinks' ).
105 $this->checkbox( 'wgShowCreditsIfMax' ) .
106 $this->textbox( 'wgMaxCredits' ).
107 $this->checkbox( 'wgGoToEdit' ).
108 $this->checkbox( 'wgAllowRealName' ) .
109 $this->checkbox( 'wgAllowUserJs' ) .
110 $this->checkbox( 'wgAllowUserCss' ).
111 $this->checkbox( 'wgAllowPageInfo' ).
112 $this->textbox( 'wgMaxTocLevel' ) .
113 $this->checkbox( 'wgUseGeoMode' ) .
114 $this->checkbox( 'wgUseValidation' ) .
115 $this->checkbox( 'wgUseExternalDiffEngine' ) .
116 $this->checkbox( 'wgUseRCPatrol' )
117 ) );
118 $wgOut->addHTML( $this->fieldset( "sitesettings-permissions",
119 $this->fieldset( 'sitesettings-permissions-readonly' ,
120 $this->checkbox( 'wgReadOnly' ) .
121 $this->textbox( 'wgReadOnlyFile','',50 )
122 ) .
123 $this->fieldset( 'sitesettings-permissions-whitelist' ,
124 $this->checkbox( 'wgWhitelistEdit' ) .
125 $this->arraybox( 'wgWhitelistRead' ) .
126 $this->checkbox( 'wgWhitelistAccount-user' ) .
127 $this->checkbox( 'wgWhitelistAccount-sysop' ) .
128 $this->checkbox( 'wgWhitelistAccount-developer' )
129 ) .
130 $this->fieldset( 'sitesettings-permissions-banning' ,
131 $this->checkbox( 'wgSysopUserBans' ) .
132 $this->checkbox( 'wgSysopRangeBans' ) .
133 $this->textbox( 'wgDefaultBlockExpiry', "24 hours" )
134 ) .
135 $this->checkbox( 'wgAllowAnonymousMinor' ).
136 $this->checkbox( 'wgPutIPinRC' ) .
137 $this->textbox( 'wgSpamRegex' ).
138 $this->checkbox( 'wgUserHtml' ).
139 $this->checkbox( 'wgRawHtml' )
140 ) );
141 $wgOut->addHTML( $this->fieldset( "sitesettings-images" ,
142 $this->checkbox( 'wgAllowExternalImages' ) .
143 $this->fieldset( 'sitesettings-images-upload' ,
144 $this->checkbox( 'wgDisableUploads' ) .
145 $this->checkbox( 'wgRemoteUploads' ) .
146 $this->arraybox( 'wgFileExtensions' ) .
147 $this->arraybox( 'wgFileBlacklist' ) .
148 $this->checkbox( 'wgCheckFileExtensions' ) .
149 $this->checkbox( 'wgStrictFileExtensions' ) .
150 $this->textbox( 'wgUploadSizeWarning' ) .
151 $this->checkbox( 'wgUseCopyrightUpload' ) .
152 $this->checkbox( 'wgCheckCopyrightUpload' )
153 ) .
154 $this->fieldset( 'sitesettings-images-resize' ,
155 $this->checkbox( 'wgUseImageResize' ) .
156 $this->checkbox( 'wgUseImageMagick' ) .
157 $this->textbox( 'wgImageMagickConvertCommand' )
158 )
159 ) );
160 $wgOut->addHTML( $this->fieldset( "sitesettings-performance",
161 $this->fieldset( 'sitesettings-permissions-miser' ,
162 $this->checkbox( 'wgMiserMode' ) .
163 $this->checkbox( 'wgDisableQueryPages' ) .
164 $this->checkbox( 'wgUseWatchlistCache' ) .
165 $this->textbox( 'wgWLCacheTimeout', '3600' )
166 ) .
167 $this->checkbox( 'wgDisableCounters' ) .
168 $this->checkbox( 'wgDisableTextSearch' ) .
169 $this->checkbox( 'wgDisableFuzzySearch' ) .
170 $this->checkbox( 'wgDisableSearchUpdate' )
171 ) );
172 $wgOut->addHTML( $this->fieldset( "sitesettings-memcached",
173 $this->checkbox( 'wgMemCachedDebug' ) .
174 $this->checkbox( 'wgUseMemCached' ) .
175 $this->textbox( 'wgMemCachedServers' ) .
176 $this->checkbox( 'wgSessionsInMemcached' ).
177 $this->checkbox( 'wgLinkCacheMemcached' ) .
178 $this->textbox( 'wgAccountCreationThrottle' )
179 ) );
180 $wgOut->addHTML( $this->fieldset( "sitesettings-caching",
181 $this->checkbox( 'wgCachePages' ).
182 $this->checkbox( 'wgUseFileCache' ).
183 $this->textbox( 'wgFileCacheDirectory' ) .
184 $this->textbox( 'wgCookieExpiration' ) .
185 $this->fieldset( 'sitesettings-caching-squid' ,
186 $this->checkbox( 'wgUseSquid' ) .
187 $this->checkbox( 'wgUseESI' ) .
188 $this->textbox( 'wgInternalServer' ) .
189 $this->textbox( 'wgSquidMaxage' ) .
190 $this->textbox( 'wgMaxSquidPurgeTitles' )
191 )
192 ) );
193 $wgOut->addHTML( $this->fieldset( "sitesettings-cookies",
194 $this->textbox( 'wgCookieDomain' ) .
195 $this->textbox( 'wgCookiePath' ) .
196 $this->checkbox( 'wgDisableCookieCheck' )
197 ) );
198 $wgOut->addHTML( $this->fieldset( "sitesettings-debugging",
199 $this->textbox( 'wgDebugLogFile','',50 ) .
200 $this->checkbox( 'wgDebugRedirects' ) .
201 $this->checkbox( 'wgDebugRawPage' ) .
202 $this->checkbox( 'wgDebugComments' ) .
203 $this->checkbox( 'wgLogQueries' ) .
204 $this->checkbox( 'wgDebugDumpSql' ) .
205 $this->checkbox( 'wgIgnoreSQLErrors' ) .
206 $this->fieldset( 'sitesettings-debugging-profiling',
207 $this->checkbox( 'wgProfiling' ) .
208 $this->textbox( 'wgProfileLimit' ) .
209 $this->checkbox( 'wgProfileOnly' ) .
210 $this->checkbox( 'wgProfileToDatabase' ) .
211 $this->textbox( 'wgProfileSampleRate' ) .
212 $this->checkbox( 'wgDebugProfiling' ) .
213 $this->checkbox( 'wgDebugFunctionEntry')
214 ) .
215 $this->checkbox( 'wgDebugSquid' )
216 ) );
217 $wgOut->addHTML( "</form>" );
218 }
219
220 }
221
222 ?>