Index: trunk/phase3/includes/RequestContext.php |
— | — | @@ -10,14 +10,38 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | class RequestContext { |
14 | | - private $mRequest; // / WebRequest object |
15 | | - private $mTitle; // / Title object |
16 | | - private $mOutput; // / OutputPage object |
17 | | - private $mUser; // / User object |
18 | | - private $mLang; // / Language object |
19 | | - private $mSkin; // / Skin object |
20 | 14 | |
21 | 15 | /** |
| 16 | + * @var WebRequest |
| 17 | + */ |
| 18 | + private $mRequest; |
| 19 | + |
| 20 | + /** |
| 21 | + * @var Title |
| 22 | + */ |
| 23 | + private $mTitle; |
| 24 | + |
| 25 | + /** |
| 26 | + * @var OutputPage |
| 27 | + */ |
| 28 | + private $mOutput; |
| 29 | + |
| 30 | + /** |
| 31 | + * @var User |
| 32 | + */ |
| 33 | + private $mUser; |
| 34 | + |
| 35 | + /** |
| 36 | + * @var Language |
| 37 | + */ |
| 38 | + private $mLang; |
| 39 | + |
| 40 | + /** |
| 41 | + * @var Skin |
| 42 | + */ |
| 43 | + private $mSkin; |
| 44 | + |
| 45 | + /** |
22 | 46 | * Set the WebRequest object |
23 | 47 | * |
24 | 48 | * @param $r WebRequest object |
— | — | @@ -189,6 +213,10 @@ |
190 | 214 | * Make these C#-style accessors, so you can do $context->user->getName() which is |
191 | 215 | * internally mapped to $context->__get('user')->getName() which is mapped to |
192 | 216 | * $context->getUser()->getName() |
| 217 | + * |
| 218 | + * @param $name string |
| 219 | + * |
| 220 | + * @return string |
193 | 221 | */ |
194 | 222 | public function __get( $name ) { |
195 | 223 | if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
— | — | @@ -198,6 +226,11 @@ |
199 | 227 | trigger_error( "Undefined property {$name}", E_NOTICE ); |
200 | 228 | } |
201 | 229 | |
| 230 | + /** |
| 231 | + * @param $name string |
| 232 | + * @param $value |
| 233 | + * @return string |
| 234 | + */ |
202 | 235 | public function __set( $name, $value ) { |
203 | 236 | if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
204 | 237 | $fname = 'set' . ucfirst( $name ); |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -517,6 +517,10 @@ |
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
| 521 | + /** |
| 522 | + * @param $user User |
| 523 | + * @param $defaultPreferences Array |
| 524 | + */ |
521 | 525 | static function filesPreferences( $user, &$defaultPreferences ) { |
522 | 526 | ## Files ##################################### |
523 | 527 | $defaultPreferences['imagesize'] = array( |
— | — | @@ -595,6 +599,10 @@ |
596 | 600 | ); |
597 | 601 | } |
598 | 602 | |
| 603 | + /** |
| 604 | + * @param $user User |
| 605 | + * @param $defaultPreferences Array |
| 606 | + */ |
599 | 607 | static function renderingPreferences( $user, &$defaultPreferences ) { |
600 | 608 | ## Page Rendering ############################## |
601 | 609 | global $wgAllowUserCssPrefs; |
— | — | @@ -668,6 +676,10 @@ |
669 | 677 | ); |
670 | 678 | } |
671 | 679 | |
| 680 | + /** |
| 681 | + * @param $user User |
| 682 | + * @param $defaultPreferences Array |
| 683 | + */ |
672 | 684 | static function editingPreferences( $user, &$defaultPreferences ) { |
673 | 685 | global $wgUseExternalEditor, $wgAllowUserCssPrefs; |
674 | 686 | |
— | — | @@ -766,6 +778,10 @@ |
767 | 779 | ); |
768 | 780 | } |
769 | 781 | |
| 782 | + /** |
| 783 | + * @param $user User |
| 784 | + * @param $defaultPreferences Array |
| 785 | + */ |
770 | 786 | static function rcPreferences( $user, &$defaultPreferences ) { |
771 | 787 | global $wgRCMaxAge, $wgUseRCPatrol, $wgLang; |
772 | 788 | |
— | — | @@ -825,7 +841,6 @@ |
826 | 842 | /** |
827 | 843 | * @param $user User |
828 | 844 | * @param $defaultPreferences |
829 | | - * @return void |
830 | 845 | */ |
831 | 846 | static function watchlistPreferences( $user, &$defaultPreferences ) { |
832 | 847 | global $wgUseRCPatrol, $wgEnableAPI; |
— | — | @@ -920,6 +935,10 @@ |
921 | 936 | } |
922 | 937 | } |
923 | 938 | |
| 939 | + /** |
| 940 | + * @param $user User |
| 941 | + * @param $defaultPreferences Array |
| 942 | + */ |
924 | 943 | static function searchPreferences( $user, &$defaultPreferences ) { |
925 | 944 | global $wgContLang; |
926 | 945 | |
— | — | @@ -981,6 +1000,10 @@ |
982 | 1001 | ); |
983 | 1002 | } |
984 | 1003 | |
| 1004 | + /** |
| 1005 | + * @param $user User |
| 1006 | + * @param $defaultPreferences Array |
| 1007 | + */ |
985 | 1008 | static function miscPreferences( $user, &$defaultPreferences ) { |
986 | 1009 | ## Misc ##################################### |
987 | 1010 | $defaultPreferences['diffonly'] = array( |
— | — | @@ -1064,6 +1087,9 @@ |
1065 | 1088 | return $ret; |
1066 | 1089 | } |
1067 | 1090 | |
| 1091 | + /** |
| 1092 | + * @return array |
| 1093 | + */ |
1068 | 1094 | static function getDateOptions() { |
1069 | 1095 | global $wgLang; |
1070 | 1096 | $dateopts = $wgLang->getDatePreferences(); |
— | — | @@ -1095,6 +1121,9 @@ |
1096 | 1122 | return $ret; |
1097 | 1123 | } |
1098 | 1124 | |
| 1125 | + /** |
| 1126 | + * @return array |
| 1127 | + */ |
1099 | 1128 | static function getImageSizes() { |
1100 | 1129 | global $wgImageLimits; |
1101 | 1130 | |
— | — | @@ -1108,6 +1137,9 @@ |
1109 | 1138 | return $ret; |
1110 | 1139 | } |
1111 | 1140 | |
| 1141 | + /** |
| 1142 | + * @return array |
| 1143 | + */ |
1112 | 1144 | static function getThumbSizes() { |
1113 | 1145 | global $wgThumbLimits; |
1114 | 1146 | |
— | — | @@ -1121,6 +1153,11 @@ |
1122 | 1154 | return $ret; |
1123 | 1155 | } |
1124 | 1156 | |
| 1157 | + /** |
| 1158 | + * @param $signature |
| 1159 | + * @param $alldata |
| 1160 | + * @return bool|string |
| 1161 | + */ |
1125 | 1162 | static function validateSignature( $signature, $alldata ) { |
1126 | 1163 | global $wgParser, $wgMaxSigChars, $wgLang; |
1127 | 1164 | if ( mb_strlen( $signature ) > $wgMaxSigChars ) { |
— | — | @@ -1138,6 +1175,11 @@ |
1139 | 1176 | } |
1140 | 1177 | } |
1141 | 1178 | |
| 1179 | + /** |
| 1180 | + * @param $signature |
| 1181 | + * @param $alldata |
| 1182 | + * @return |
| 1183 | + */ |
1142 | 1184 | static function cleanSignature( $signature, $alldata ) { |
1143 | 1185 | global $wgParser; |
1144 | 1186 | if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) { |
— | — | @@ -1150,6 +1192,11 @@ |
1151 | 1193 | return $signature; |
1152 | 1194 | } |
1153 | 1195 | |
| 1196 | + /** |
| 1197 | + * @param $email |
| 1198 | + * @param $alldata |
| 1199 | + * @return bool|String |
| 1200 | + */ |
1154 | 1201 | static function validateEmail( $email, $alldata ) { |
1155 | 1202 | if ( $email && !Sanitizer::validateEmail( $email ) ) { |
1156 | 1203 | return wfMsgExt( 'invalidemailaddress', 'parseinline' ); |
— | — | @@ -1162,6 +1209,11 @@ |
1163 | 1210 | return true; |
1164 | 1211 | } |
1165 | 1212 | |
| 1213 | + /** |
| 1214 | + * @param $user User |
| 1215 | + * @param $formClass string |
| 1216 | + * @return HtmlForm |
| 1217 | + */ |
1166 | 1218 | static function getFormObject( $user, $formClass = 'PreferencesForm' ) { |
1167 | 1219 | $formDescriptor = Preferences::getPreferences( $user ); |
1168 | 1220 | $htmlForm = new $formClass( $formDescriptor, 'prefs' ); |
— | — | @@ -1177,6 +1229,9 @@ |
1178 | 1230 | return $htmlForm; |
1179 | 1231 | } |
1180 | 1232 | |
| 1233 | + /** |
| 1234 | + * @return array |
| 1235 | + */ |
1181 | 1236 | static function getTimezoneOptions() { |
1182 | 1237 | $opt = array(); |
1183 | 1238 | |
— | — | @@ -1239,10 +1294,20 @@ |
1240 | 1295 | return $opt; |
1241 | 1296 | } |
1242 | 1297 | |
| 1298 | + /** |
| 1299 | + * @param $value |
| 1300 | + * @param $alldata |
| 1301 | + * @return int |
| 1302 | + */ |
1243 | 1303 | static function filterIntval( $value, $alldata ){ |
1244 | 1304 | return intval( $value ); |
1245 | 1305 | } |
1246 | 1306 | |
| 1307 | + /** |
| 1308 | + * @param $tz |
| 1309 | + * @param $alldata |
| 1310 | + * @return string |
| 1311 | + */ |
1247 | 1312 | static function filterTimezoneInput( $tz, $alldata ) { |
1248 | 1313 | $data = explode( '|', $tz, 3 ); |
1249 | 1314 | switch ( $data[0] ) { |
— | — | @@ -1268,6 +1333,11 @@ |
1269 | 1334 | } |
1270 | 1335 | } |
1271 | 1336 | |
| 1337 | + /** |
| 1338 | + * @param $formData |
| 1339 | + * @param $entryPoint string |
| 1340 | + * @return bool|Status|string |
| 1341 | + */ |
1272 | 1342 | static function tryFormSubmit( $formData, $entryPoint = 'internal' ) { |
1273 | 1343 | global $wgUser, $wgEmailAuthentication, $wgEnableEmail; |
1274 | 1344 | |
— | — | @@ -1349,6 +1419,10 @@ |
1350 | 1420 | return $result; |
1351 | 1421 | } |
1352 | 1422 | |
| 1423 | + /** |
| 1424 | + * @param $formData |
| 1425 | + * @return Status |
| 1426 | + */ |
1353 | 1427 | public static function tryUISubmit( $formData ) { |
1354 | 1428 | $res = self::tryFormSubmit( $formData, 'ui' ); |
1355 | 1429 | |
— | — | @@ -1391,12 +1465,20 @@ |
1392 | 1466 | |
1393 | 1467 | /** Some tweaks to allow js prefs to work */ |
1394 | 1468 | class PreferencesForm extends HTMLForm { |
| 1469 | + |
| 1470 | + /** |
| 1471 | + * @param $html string |
| 1472 | + * @return String |
| 1473 | + */ |
1395 | 1474 | function wrapForm( $html ) { |
1396 | 1475 | $html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html ); |
1397 | 1476 | |
1398 | 1477 | return parent::wrapForm( $html ); |
1399 | 1478 | } |
1400 | 1479 | |
| 1480 | + /** |
| 1481 | + * @return String |
| 1482 | + */ |
1401 | 1483 | function getButtons() { |
1402 | 1484 | $html = parent::getButtons(); |
1403 | 1485 | |
— | — | @@ -1412,6 +1494,10 @@ |
1413 | 1495 | return $html; |
1414 | 1496 | } |
1415 | 1497 | |
| 1498 | + /** |
| 1499 | + * @param $data array |
| 1500 | + * @return array |
| 1501 | + */ |
1416 | 1502 | function filterDataForSubmit( $data ) { |
1417 | 1503 | // Support for separating MultiSelect preferences into multiple preferences |
1418 | 1504 | // Due to lack of array support. |