Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -568,6 +568,25 @@ |
569 | 569 | |
570 | 570 | |
571 | 571 | /** |
| 572 | + * Show an "add new section" link? |
| 573 | + * |
| 574 | + * @return Boolean |
| 575 | + */ |
| 576 | + public function showNewSectionLink() { |
| 577 | + return $this->mNewSectionLink; |
| 578 | + } |
| 579 | + |
| 580 | + /** |
| 581 | + * Forcibly hide the new section link? |
| 582 | + * |
| 583 | + * @return Boolean |
| 584 | + */ |
| 585 | + public function forceHideNewSectionLink() { |
| 586 | + return $this->mHideNewSectionLink; |
| 587 | + } |
| 588 | + |
| 589 | + |
| 590 | + /** |
572 | 591 | * Add or remove feed links in the page header |
573 | 592 | * This is mainly kept for backward compatibility, see OutputPage::addFeedLink() |
574 | 593 | * for the new version |
— | — | @@ -625,6 +644,14 @@ |
626 | 645 | } |
627 | 646 | |
628 | 647 | /** |
| 648 | + * Return URLs for each supported syndication format for this page. |
| 649 | + * @return array associating format keys with URLs |
| 650 | + */ |
| 651 | + public function getSyndicationLinks() { |
| 652 | + return $this->mFeedLinks; |
| 653 | + } |
| 654 | + |
| 655 | + /** |
629 | 656 | * Will currently always return null |
630 | 657 | * |
631 | 658 | * @return null |
— | — | @@ -798,24 +825,102 @@ |
799 | 826 | return $this->mCategories; |
800 | 827 | } |
801 | 828 | |
802 | | - public function suppressQuickbar() { $this->mSuppressQuickbar = true; } |
803 | | - public function isQuickbarSuppressed() { return $this->mSuppressQuickbar; } |
804 | 829 | |
805 | | - public function disallowUserJs() { $this->mAllowUserJs = false; } |
806 | | - public function isUserJsAllowed() { return $this->mAllowUserJs; } |
| 830 | + /** |
| 831 | + * Suppress the quickbar from the output, only for skin supporting |
| 832 | + * the quickbar |
| 833 | + */ |
| 834 | + public function suppressQuickbar() { |
| 835 | + $this->mSuppressQuickbar = true; |
| 836 | + } |
807 | 837 | |
808 | | - public function prependHTML( $text ) { $this->mBodytext = $text . $this->mBodytext; } |
809 | | - public function addHTML( $text ) { $this->mBodytext .= $text; } |
810 | | - public function clearHTML() { $this->mBodytext = ''; } |
811 | | - public function getHTML() { return $this->mBodytext; } |
812 | | - public function debug( $text ) { $this->mDebugtext .= $text; } |
| 838 | + /** |
| 839 | + * Return whether the quickbar should be suppressed from the output |
| 840 | + * |
| 841 | + * @return Boolean |
| 842 | + */ |
| 843 | + public function isQuickbarSuppressed() { |
| 844 | + return $this->mSuppressQuickbar; |
| 845 | + } |
813 | 846 | |
814 | | - /* @deprecated */ |
| 847 | + |
| 848 | + /** |
| 849 | + * Remove user JavaScript from scripts to load |
| 850 | + */ |
| 851 | + public function disallowUserJs() { |
| 852 | + $this->mAllowUserJs = false; |
| 853 | + } |
| 854 | + |
| 855 | + /** |
| 856 | + * Return whether user JavaScript is allowed for this page |
| 857 | + * |
| 858 | + * @return Boolean |
| 859 | + */ |
| 860 | + public function isUserJsAllowed() { |
| 861 | + return $this->mAllowUserJs; |
| 862 | + } |
| 863 | + |
| 864 | + |
| 865 | + /** |
| 866 | + * Prepend $text to the body HTML |
| 867 | + * |
| 868 | + * @param $text String: HTML |
| 869 | + */ |
| 870 | + public function prependHTML( $text ) { |
| 871 | + $this->mBodytext = $text . $this->mBodytext; |
| 872 | + } |
| 873 | + |
| 874 | + /** |
| 875 | + * Append $text to the body HTML |
| 876 | + * |
| 877 | + * @param $text String: HTML |
| 878 | + */ |
| 879 | + public function addHTML( $text ) { |
| 880 | + $this->mBodytext .= $text; |
| 881 | + } |
| 882 | + |
| 883 | + /** |
| 884 | + * Clear the body HTML |
| 885 | + */ |
| 886 | + public function clearHTML() { |
| 887 | + $this->mBodytext = ''; |
| 888 | + } |
| 889 | + |
| 890 | + /** |
| 891 | + * Get the body HTML |
| 892 | + * |
| 893 | + * @return String: HTML |
| 894 | + */ |
| 895 | + public function getHTML() { |
| 896 | + return $this->mBodytext; |
| 897 | + } |
| 898 | + |
| 899 | + |
| 900 | + /** |
| 901 | + * Add $text to the debug output |
| 902 | + * |
| 903 | + * @param $text String: debug text |
| 904 | + */ |
| 905 | + public function debug( $text ) { |
| 906 | + $this->mDebugtext .= $text; |
| 907 | + } |
| 908 | + |
| 909 | + |
| 910 | + /** |
| 911 | + * @deprecated use parserOptions() instead |
| 912 | + */ |
815 | 913 | public function setParserOptions( $options ) { |
816 | 914 | wfDeprecated( __METHOD__ ); |
817 | 915 | return $this->parserOptions( $options ); |
818 | 916 | } |
819 | 917 | |
| 918 | + /** |
| 919 | + * Get/set the ParserOptions object to use for wikitext parsing |
| 920 | + * |
| 921 | + * @param $options either the ParserOption to use or null to only get the |
| 922 | + * current ParserOption object |
| 923 | + * @return current ParserOption object |
| 924 | + */ |
820 | 925 | public function parserOptions( $options = null ) { |
821 | 926 | if ( !$this->mParserOptions ) { |
822 | 927 | $this->mParserOptions = new ParserOptions; |
— | — | @@ -826,40 +931,78 @@ |
827 | 932 | /** |
828 | 933 | * Set the revision ID which will be seen by the wiki text parser |
829 | 934 | * for things such as embedded {{REVISIONID}} variable use. |
830 | | - * @param mixed $revid an integer, or NULL |
831 | | - * @return mixed previous value |
| 935 | + * |
| 936 | + * @param $revid Mixed: an positive integer, or null |
| 937 | + * @return Mixed: previous value |
832 | 938 | */ |
833 | 939 | public function setRevisionId( $revid ) { |
834 | 940 | $val = is_null( $revid ) ? null : intval( $revid ); |
835 | 941 | return wfSetVar( $this->mRevisionId, $val ); |
836 | 942 | } |
837 | 943 | |
| 944 | + /** |
| 945 | + * Get the current revision ID |
| 946 | + * |
| 947 | + * @return Integer |
| 948 | + */ |
838 | 949 | public function getRevisionId() { |
839 | 950 | return $this->mRevisionId; |
840 | 951 | } |
841 | 952 | |
842 | 953 | /** |
843 | 954 | * Convert wikitext to HTML and add it to the buffer |
844 | | - * Default assumes that the current page title will |
845 | | - * be used. |
| 955 | + * Default assumes that the current page title will be used. |
846 | 956 | * |
847 | | - * @param string $text |
848 | | - * @param bool $linestart |
| 957 | + * @param $text String |
| 958 | + * @param $linestart Boolean: is this the start of a line? |
849 | 959 | */ |
850 | 960 | public function addWikiText( $text, $linestart = true ) { |
851 | 961 | $title = $this->getTitle(); // Work arround E_STRICT |
852 | 962 | $this->addWikiTextTitle( $text, $title, $linestart ); |
853 | 963 | } |
854 | 964 | |
855 | | - public function addWikiTextWithTitle($text, &$title, $linestart = true) { |
856 | | - $this->addWikiTextTitle($text, $title, $linestart); |
| 965 | + /** |
| 966 | + * Add wikitext with a custom Title object |
| 967 | + * |
| 968 | + * @param $text String: wikitext |
| 969 | + * @param $title Title object |
| 970 | + * @param $linestart Boolean: is this the start of a line? |
| 971 | + */ |
| 972 | + public function addWikiTextWithTitle( $text, &$title, $linestart = true ) { |
| 973 | + $this->addWikiTextTitle( $text, $title, $linestart ); |
857 | 974 | } |
858 | 975 | |
859 | | - function addWikiTextTitleTidy($text, &$title, $linestart = true) { |
| 976 | + /** |
| 977 | + * Add wikitext with a custom Title object and |
| 978 | + * |
| 979 | + * @param $text String: wikitext |
| 980 | + * @param $title Title object |
| 981 | + * @param $linestart Boolean: is this the start of a line? |
| 982 | + */ |
| 983 | + function addWikiTextTitleTidy( $text, &$title, $linestart = true ) { |
860 | 984 | $this->addWikiTextTitle( $text, $title, $linestart, true ); |
861 | 985 | } |
862 | 986 | |
863 | | - public function addWikiTextTitle($text, &$title, $linestart, $tidy = false) { |
| 987 | + /** |
| 988 | + * Add wikitext with tidy enabled |
| 989 | + * |
| 990 | + * @param $text String: wikitext |
| 991 | + * @param $linestart Boolean: is this the start of a line? |
| 992 | + */ |
| 993 | + public function addWikiTextTidy( $text, $linestart = true ) { |
| 994 | + $title = $this->getTitle(); |
| 995 | + $this->addWikiTextTitleTidy($text, $title, $linestart); |
| 996 | + } |
| 997 | + |
| 998 | + /** |
| 999 | + * Add wikitext with a custom Title object |
| 1000 | + * |
| 1001 | + * @param $text String: wikitext |
| 1002 | + * @param $title Title object |
| 1003 | + * @param $linestart Boolean: is this the start of a line? |
| 1004 | + * @param $tidy Boolean: whether to use tidy |
| 1005 | + */ |
| 1006 | + public function addWikiTextTitle( $text, &$title, $linestart, $tidy = false ) { |
864 | 1007 | global $wgParser; |
865 | 1008 | |
866 | 1009 | wfProfileIn( __METHOD__ ); |
— | — | @@ -880,9 +1023,46 @@ |
881 | 1024 | } |
882 | 1025 | |
883 | 1026 | /** |
884 | | - * @todo document |
885 | | - * @param ParserOutput object &$parserOutput |
| 1027 | + * Add wikitext to the buffer, assuming that this is the primary text for a page view |
| 1028 | + * Saves the text into the parser cache if possible. |
| 1029 | + * |
| 1030 | + * @param $text String: wikitext |
| 1031 | + * @param $article Article object |
| 1032 | + * @param $cache Boolean |
| 1033 | + * @deprecated Use Article::outputWikitext |
886 | 1034 | */ |
| 1035 | + public function addPrimaryWikiText( $text, $article, $cache = true ) { |
| 1036 | + global $wgParser; |
| 1037 | + |
| 1038 | + wfDeprecated( __METHOD__ ); |
| 1039 | + |
| 1040 | + $popts = $this->parserOptions(); |
| 1041 | + $popts->setTidy(true); |
| 1042 | + $parserOutput = $wgParser->parse( $text, $article->mTitle, |
| 1043 | + $popts, true, true, $this->mRevisionId ); |
| 1044 | + $popts->setTidy(false); |
| 1045 | + if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) { |
| 1046 | + $parserCache = ParserCache::singleton(); |
| 1047 | + $parserCache->save( $parserOutput, $article, $popts); |
| 1048 | + } |
| 1049 | + |
| 1050 | + $this->addParserOutput( $parserOutput ); |
| 1051 | + } |
| 1052 | + |
| 1053 | + /** |
| 1054 | + * @deprecated use addWikiTextTidy() |
| 1055 | + */ |
| 1056 | + public function addSecondaryWikiText( $text, $linestart = true ) { |
| 1057 | + wfDeprecated( __METHOD__ ); |
| 1058 | + $this->addWikiTextTitleTidy($text, $this->getTitle(), $linestart); |
| 1059 | + } |
| 1060 | + |
| 1061 | + |
| 1062 | + /** |
| 1063 | + * Add a ParserOutput object, but without Html |
| 1064 | + * |
| 1065 | + * @param $parserOutput ParserOutput object |
| 1066 | + */ |
887 | 1067 | public function addParserOutputNoText( &$parserOutput ) { |
888 | 1068 | global $wgExemptFromUserRobotsControl, $wgContentNamespaces; |
889 | 1069 | |
— | — | @@ -924,8 +1104,9 @@ |
925 | 1105 | } |
926 | 1106 | |
927 | 1107 | /** |
928 | | - * @todo document |
929 | | - * @param ParserOutput &$parserOutput |
| 1108 | + * Add a ParserOutput object |
| 1109 | + * |
| 1110 | + * @param $parserOutput ParserOutput |
930 | 1111 | */ |
931 | 1112 | function addParserOutput( &$parserOutput ) { |
932 | 1113 | $this->addParserOutputNoText( $parserOutput ); |
— | — | @@ -934,54 +1115,11 @@ |
935 | 1116 | $this->addHTML( $text ); |
936 | 1117 | } |
937 | 1118 | |
938 | | - /** |
939 | | - * Add wikitext to the buffer, assuming that this is the primary text for a page view |
940 | | - * Saves the text into the parser cache if possible. |
941 | | - * |
942 | | - * @param string $text |
943 | | - * @param Article $article |
944 | | - * @param bool $cache |
945 | | - * @deprecated Use Article::outputWikitext |
946 | | - */ |
947 | | - public function addPrimaryWikiText( $text, $article, $cache = true ) { |
948 | | - global $wgParser; |
949 | 1119 | |
950 | | - wfDeprecated( __METHOD__ ); |
951 | | - |
952 | | - $popts = $this->parserOptions(); |
953 | | - $popts->setTidy(true); |
954 | | - $parserOutput = $wgParser->parse( $text, $article->mTitle, |
955 | | - $popts, true, true, $this->mRevisionId ); |
956 | | - $popts->setTidy(false); |
957 | | - if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) { |
958 | | - $parserCache = ParserCache::singleton(); |
959 | | - $parserCache->save( $parserOutput, $article, $popts); |
960 | | - } |
961 | | - |
962 | | - $this->addParserOutput( $parserOutput ); |
963 | | - } |
964 | | - |
965 | 1120 | /** |
966 | | - * @deprecated use addWikiTextTidy() |
967 | | - */ |
968 | | - public function addSecondaryWikiText( $text, $linestart = true ) { |
969 | | - wfDeprecated( __METHOD__ ); |
970 | | - $this->addWikiTextTitleTidy($text, $this->getTitle(), $linestart); |
971 | | - } |
972 | | - |
973 | | - /** |
974 | | - * Add wikitext with tidy enabled |
975 | | - */ |
976 | | - public function addWikiTextTidy( $text, $linestart = true ) { |
977 | | - $title = $this->getTitle(); |
978 | | - $this->addWikiTextTitleTidy($text, $title, $linestart); |
979 | | - } |
980 | | - |
981 | | - |
982 | | - /** |
983 | 1121 | * Add the output of a QuickTemplate to the output buffer |
984 | 1122 | * |
985 | | - * @param QuickTemplate $template |
| 1123 | + * @param $template QuickTemplate |
986 | 1124 | */ |
987 | 1125 | public function addTemplate( &$template ) { |
988 | 1126 | ob_start(); |
— | — | @@ -993,9 +1131,10 @@ |
994 | 1132 | /** |
995 | 1133 | * Parse wikitext and return the HTML. |
996 | 1134 | * |
997 | | - * @param string $text |
998 | | - * @param bool $linestart Is this the start of a line? |
999 | | - * @param bool $interface ?? |
| 1135 | + * @param $text String |
| 1136 | + * @param $linestart Boolean: is this the start of a line? |
| 1137 | + * @param $interface Boolean: ?? |
| 1138 | + * @return String: HTML |
1000 | 1139 | */ |
1001 | 1140 | public function parse( $text, $linestart = true, $interface = false ) { |
1002 | 1141 | global $wgParser; |
— | — | @@ -1010,7 +1149,14 @@ |
1011 | 1150 | return $parserOutput->getText(); |
1012 | 1151 | } |
1013 | 1152 | |
1014 | | - /** Parse wikitext, strip paragraphs, and return the HTML. */ |
| 1153 | + /** |
| 1154 | + * Parse wikitext, strip paragraphs, and return the HTML. |
| 1155 | + * |
| 1156 | + * @param $text String |
| 1157 | + * @param $linestart Boolean: is this the start of a line? |
| 1158 | + * @param $interface Boolean: ?? |
| 1159 | + * @return String: HTML |
| 1160 | + */ |
1015 | 1161 | public function parseInline( $text, $linestart = true, $interface = false ) { |
1016 | 1162 | $parsed = $this->parse( $text, $linestart, $interface ); |
1017 | 1163 | |
— | — | @@ -1023,12 +1169,10 @@ |
1024 | 1170 | } |
1025 | 1171 | |
1026 | 1172 | /** |
1027 | | - * @param Article $article |
1028 | | - * @param User $user |
1029 | | - * |
1030 | 1173 | * @deprecated |
1031 | 1174 | * |
1032 | | - * @return bool True if successful, else false. |
| 1175 | + * @param $article Article |
| 1176 | + * @return Boolean: true if successful, else false. |
1033 | 1177 | */ |
1034 | 1178 | public function tryParserCache( &$article ) { |
1035 | 1179 | wfDeprecated( __METHOD__ ); |
— | — | @@ -1043,7 +1187,9 @@ |
1044 | 1188 | } |
1045 | 1189 | |
1046 | 1190 | /** |
1047 | | - * @param int $maxage Maximum cache time on the Squid, in seconds. |
| 1191 | + * Set the value of the "s-maxage" part of the "Cache-control" HTTP header |
| 1192 | + * |
| 1193 | + * @param $maxage Integer: maximum cache time on the Squid, in seconds. |
1048 | 1194 | */ |
1049 | 1195 | public function setSquidMaxage( $maxage ) { |
1050 | 1196 | $this->mSquidMaxage = $maxage; |
— | — | @@ -1051,12 +1197,18 @@ |
1052 | 1198 | |
1053 | 1199 | /** |
1054 | 1200 | * Use enableClientCache(false) to force it to send nocache headers |
| 1201 | + * |
1055 | 1202 | * @param $state ?? |
1056 | 1203 | */ |
1057 | 1204 | public function enableClientCache( $state ) { |
1058 | 1205 | return wfSetVar( $this->mEnableClientCache, $state ); |
1059 | 1206 | } |
1060 | 1207 | |
| 1208 | + /** |
| 1209 | + * Get the list of cookies that will influence on the cache |
| 1210 | + * |
| 1211 | + * @return Array |
| 1212 | + */ |
1061 | 1213 | function getCacheVaryCookies() { |
1062 | 1214 | global $wgCookiePrefix, $wgCacheVaryCookies; |
1063 | 1215 | static $cookies; |
— | — | @@ -1074,15 +1226,23 @@ |
1075 | 1227 | return $cookies; |
1076 | 1228 | } |
1077 | 1229 | |
| 1230 | + /** |
| 1231 | + * Return whether this page is not cacheable because "useskin" or "uselang" |
| 1232 | + * url parameters were passed |
| 1233 | + * |
| 1234 | + * @return Boolean |
| 1235 | + */ |
1078 | 1236 | function uncacheableBecauseRequestVars() { |
1079 | 1237 | global $wgRequest; |
1080 | | - return $wgRequest->getText('useskin', false) === false |
| 1238 | + return $wgRequest->getText('useskin', false) === false |
1081 | 1239 | && $wgRequest->getText('uselang', false) === false; |
1082 | 1240 | } |
1083 | 1241 | |
1084 | 1242 | /** |
1085 | 1243 | * Check if the request has a cache-varying cookie header |
1086 | 1244 | * If it does, it's very important that we don't allow public caching |
| 1245 | + * |
| 1246 | + * @return Boolean |
1087 | 1247 | */ |
1088 | 1248 | function haveCacheVaryCookies() { |
1089 | 1249 | global $wgRequest; |
— | — | @@ -1102,6 +1262,12 @@ |
1103 | 1263 | return false; |
1104 | 1264 | } |
1105 | 1265 | |
| 1266 | + /** |
| 1267 | + * Add an HTTP header that will influence on the cache |
| 1268 | + * |
| 1269 | + * @param $header String: header name |
| 1270 | + * @param $option either an Array or null |
| 1271 | + */ |
1106 | 1272 | public function addVaryHeader( $header, $option = null ) { |
1107 | 1273 | if ( !array_key_exists( $header, $this->mVaryHeader ) ) { |
1108 | 1274 | $this->mVaryHeader[$header] = $option; |
— | — | @@ -1117,7 +1283,11 @@ |
1118 | 1284 | $this->mVaryHeader[$header] = array_unique( $this->mVaryHeader[$header] ); |
1119 | 1285 | } |
1120 | 1286 | |
1121 | | - /** Get a complete X-Vary-Options header */ |
| 1287 | + /** |
| 1288 | + * Get a complete X-Vary-Options header |
| 1289 | + * |
| 1290 | + * @return String |
| 1291 | + */ |
1122 | 1292 | public function getXVO() { |
1123 | 1293 | $cvCookies = $this->getCacheVaryCookies(); |
1124 | 1294 | |
— | — | @@ -1139,14 +1309,16 @@ |
1140 | 1310 | return $xvo; |
1141 | 1311 | } |
1142 | 1312 | |
1143 | | - /** bug 21672: Add Accept-Language to Vary and XVO headers |
1144 | | - if there's no 'variant' parameter existed in GET. |
1145 | | - |
1146 | | - For example: |
1147 | | - /w/index.php?title=Main_page should always be served; but |
1148 | | - /w/index.php?title=Main_page&variant=zh-cn should never be served. |
1149 | | - |
1150 | | - patched by Liangent and Philip */ |
| 1313 | + /** |
| 1314 | + * bug 21672: Add Accept-Language to Vary and XVO headers |
| 1315 | + *if there's no 'variant' parameter existed in GET. |
| 1316 | + * |
| 1317 | + * For example: |
| 1318 | + * /w/index.php?title=Main_page should always be served; but |
| 1319 | + * /w/index.php?title=Main_page&variant=zh-cn should never be served. |
| 1320 | + * |
| 1321 | + * patched by Liangent and Philip |
| 1322 | + */ |
1151 | 1323 | function addAcceptLanguage() { |
1152 | 1324 | global $wgRequest, $wgContLang; |
1153 | 1325 | if( !$wgRequest->getCheck('variant') && $wgContLang->hasVariants() ) { |
— | — | @@ -1162,6 +1334,9 @@ |
1163 | 1335 | } |
1164 | 1336 | } |
1165 | 1337 | |
| 1338 | + /** |
| 1339 | + * Send cache control HTTP headers |
| 1340 | + */ |
1166 | 1341 | public function sendCacheControl() { |
1167 | 1342 | global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest, $wgUseXVO; |
1168 | 1343 | |
— | — | @@ -1394,7 +1569,8 @@ |
1395 | 1570 | /** |
1396 | 1571 | * Actually output something with print(). Performs an iconv to the |
1397 | 1572 | * output encoding, if needed. |
1398 | | - * @param string $ins The string to output |
| 1573 | + * |
| 1574 | + * @param $ins String: the string to output |
1399 | 1575 | */ |
1400 | 1576 | public function out( $ins ) { |
1401 | 1577 | global $wgInputEncoding, $wgOutputEncoding, $wgContLang; |
— | — | @@ -1424,9 +1600,9 @@ |
1425 | 1601 | } |
1426 | 1602 | |
1427 | 1603 | /** |
1428 | | - * Deprecated, use wfReportTime() instead. |
1429 | | - * @return string |
1430 | | - * @deprecated |
| 1604 | + * @deprecated use wfReportTime() instead. |
| 1605 | + * |
| 1606 | + * @return String |
1431 | 1607 | */ |
1432 | 1608 | public function reportTime() { |
1433 | 1609 | wfDeprecated( __METHOD__ ); |
— | — | @@ -1437,7 +1613,7 @@ |
1438 | 1614 | /** |
1439 | 1615 | * Produce a "user is blocked" page. |
1440 | 1616 | * |
1441 | | - * @param bool $return Whether to have a "return to $wgTitle" message or not. |
| 1617 | + * @param $return Boolean: whether to have a "return to $wgTitle" message or not. |
1442 | 1618 | * @return nothing |
1443 | 1619 | */ |
1444 | 1620 | function blockedPage( $return = true ) { |
— | — | @@ -1499,9 +1675,9 @@ |
1500 | 1676 | /** |
1501 | 1677 | * Output a standard error page |
1502 | 1678 | * |
1503 | | - * @param string $title Message key for page title |
1504 | | - * @param string $msg Message key for page text |
1505 | | - * @param array $params Message parameters |
| 1679 | + * @param $title String: message key for page title |
| 1680 | + * @param $msg String: message key for page text |
| 1681 | + * @param $params Array: message parameters |
1506 | 1682 | */ |
1507 | 1683 | public function showErrorPage( $title, $msg, $params = array() ) { |
1508 | 1684 | if ( $this->getTitle() ) { |
— | — | @@ -1525,10 +1701,10 @@ |
1526 | 1702 | /** |
1527 | 1703 | * Output a standard permission error page |
1528 | 1704 | * |
1529 | | - * @param array $errors Error message keys |
| 1705 | + * @param $errors Array: error message keys |
| 1706 | + * @param $action String: action that was denied or null if unknown |
1530 | 1707 | */ |
1531 | | - public function showPermissionsErrorPage( $errors, $action = null ) |
1532 | | - { |
| 1708 | + public function showPermissionsErrorPage( $errors, $action = null ) { |
1533 | 1709 | $this->mDebugtext .= 'Original title: ' . |
1534 | 1710 | $this->getTitle()->getPrefixedText() . "\n"; |
1535 | 1711 | $this->setPageTitle( wfMsg( 'permissionserrors' ) ); |
— | — | @@ -1541,17 +1717,11 @@ |
1542 | 1718 | $this->addWikiText( $this->formatPermissionsErrorMessage( $errors, $action ) ); |
1543 | 1719 | } |
1544 | 1720 | |
1545 | | - /** @deprecated */ |
1546 | | - public function errorpage( $title, $msg ) { |
1547 | | - wfDeprecated( __METHOD__ ); |
1548 | | - throw new ErrorPageError( $title, $msg ); |
1549 | | - } |
1550 | | - |
1551 | 1721 | /** |
1552 | 1722 | * Display an error page indicating that a given version of MediaWiki is |
1553 | 1723 | * required to use it |
1554 | 1724 | * |
1555 | | - * @param mixed $version The version of MediaWiki needed to use the page |
| 1725 | + * @param $version Mixed: the version of MediaWiki needed to use the page |
1556 | 1726 | */ |
1557 | 1727 | public function versionRequired( $version ) { |
1558 | 1728 | $this->setPageTitle( wfMsg( 'versionrequired', $version ) ); |
— | — | @@ -1567,7 +1737,7 @@ |
1568 | 1738 | /** |
1569 | 1739 | * Display an error page noting that a given permission bit is required. |
1570 | 1740 | * |
1571 | | - * @param string $permission key required |
| 1741 | + * @param $permission String: key required |
1572 | 1742 | */ |
1573 | 1743 | public function permissionRequired( $permission ) { |
1574 | 1744 | global $wgLang; |
— | — | @@ -1591,16 +1761,14 @@ |
1592 | 1762 | } |
1593 | 1763 | |
1594 | 1764 | /** |
1595 | | - * Use permissionRequired. |
1596 | | - * @deprecated |
| 1765 | + * @deprecated use permissionRequired() |
1597 | 1766 | */ |
1598 | 1767 | public function sysopRequired() { |
1599 | 1768 | throw new MWException( "Call to deprecated OutputPage::sysopRequired() method\n" ); |
1600 | 1769 | } |
1601 | 1770 | |
1602 | 1771 | /** |
1603 | | - * Use permissionRequired. |
1604 | | - * @deprecated |
| 1772 | + * @deprecated use permissionRequired() |
1605 | 1773 | */ |
1606 | 1774 | public function developerRequired() { |
1607 | 1775 | throw new MWException( "Call to deprecated OutputPage::developerRequired() method\n" ); |
— | — | @@ -1642,14 +1810,12 @@ |
1643 | 1811 | $this->returnToMain( null, $mainPage ); |
1644 | 1812 | } |
1645 | 1813 | |
1646 | | - /** @deprecated */ |
1647 | | - public function databaseError( $fname, $sql, $error, $errno ) { |
1648 | | - throw new MWException( "OutputPage::databaseError is obsolete\n" ); |
1649 | | - } |
1650 | | - |
1651 | 1814 | /** |
1652 | | - * @param array $errors An array of arrays returned by Title::getUserPermissionsErrors |
1653 | | - * @return string The wikitext error-messages, formatted into a list. |
| 1815 | + * Format a list of error messages |
| 1816 | + * |
| 1817 | + * @param $errors An array of arrays returned by Title::getUserPermissionsErrors |
| 1818 | + * @param $action String: action that was denied or null if unknown |
| 1819 | + * @return String: the wikitext error-messages, formatted into a list. |
1654 | 1820 | */ |
1655 | 1821 | public function formatPermissionsErrorMessage( $errors, $action = null ) { |
1656 | 1822 | if ($action == null) { |
— | — | @@ -1692,9 +1858,10 @@ |
1693 | 1859 | * |
1694 | 1860 | * @todo Needs to be split into multiple functions. |
1695 | 1861 | * |
1696 | | - * @param string $source Source code to show (or null). |
1697 | | - * @param bool $protected Is this a permissions error? |
1698 | | - * @param array $reasons List of reasons for this error, as returned by Title::getUserPermissionsErrors(). |
| 1862 | + * @param $source String: source code to show (or null). |
| 1863 | + * @param $protected Boolean: is this a permissions error? |
| 1864 | + * @param $reasons Array: list of reasons for this error, as returned by Title::getUserPermissionsErrors(). |
| 1865 | + * @param $action String: action that was denied or null if unknown |
1699 | 1866 | */ |
1700 | 1867 | public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { |
1701 | 1868 | global $wgUser; |
— | — | @@ -1767,6 +1934,17 @@ |
1768 | 1935 | } |
1769 | 1936 | |
1770 | 1937 | /** @deprecated */ |
| 1938 | + public function errorpage( $title, $msg ) { |
| 1939 | + wfDeprecated( __METHOD__ ); |
| 1940 | + throw new ErrorPageError( $title, $msg ); |
| 1941 | + } |
| 1942 | + |
| 1943 | + /** @deprecated */ |
| 1944 | + public function databaseError( $fname, $sql, $error, $errno ) { |
| 1945 | + throw new MWException( "OutputPage::databaseError is obsolete\n" ); |
| 1946 | + } |
| 1947 | + |
| 1948 | + /** @deprecated */ |
1771 | 1949 | public function fatalError( $message ) { |
1772 | 1950 | wfDeprecated( __METHOD__ ); |
1773 | 1951 | throw new FatalError( $message ); |
— | — | @@ -1881,9 +2059,9 @@ |
1882 | 2060 | } |
1883 | 2061 | |
1884 | 2062 | /** |
1885 | | - * @return string The doctype, opening <html>, and head element. |
1886 | | - * |
1887 | 2063 | * @param $sk Skin The given Skin |
| 2064 | + * @param $includeStyle Unused (?) |
| 2065 | + * @return String: The doctype, opening <html>, and head element. |
1888 | 2066 | */ |
1889 | 2067 | public function headElement( Skin $sk, $includeStyle = true ) { |
1890 | 2068 | global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; |
— | — | @@ -1986,11 +2164,13 @@ |
1987 | 2165 | return $ret; |
1988 | 2166 | } |
1989 | 2167 | |
1990 | | - /* |
1991 | | - * gets the global variables and mScripts |
| 2168 | + /** |
| 2169 | + * Gets the global variables and mScripts; also adds userjs to the end if |
| 2170 | + * enabled |
1992 | 2171 | * |
1993 | | - * also adds userjs to the end if enabled: |
1994 | | - */ |
| 2172 | + * @param $sk Skin object to use |
| 2173 | + * @return String: HTML fragment |
| 2174 | + */ |
1995 | 2175 | function getHeadScripts( Skin $sk ) { |
1996 | 2176 | global $wgUser, $wgRequest, $wgJsMimeType, $wgUseSiteJs; |
1997 | 2177 | global $wgStylePath, $wgStyleVersion; |
— | — | @@ -2031,6 +2211,9 @@ |
2032 | 2212 | return $scripts; |
2033 | 2213 | } |
2034 | 2214 | |
| 2215 | + /** |
| 2216 | + * Add default \<meta\> tags |
| 2217 | + */ |
2035 | 2218 | protected function addDefaultMeta() { |
2036 | 2219 | global $wgVersion, $wgHtml5; |
2037 | 2220 | |
— | — | @@ -2135,16 +2318,13 @@ |
2136 | 2319 | } |
2137 | 2320 | |
2138 | 2321 | /** |
2139 | | - * Return URLs for each supported syndication format for this page. |
2140 | | - * @return array associating format keys with URLs |
| 2322 | + * Generate a <link rel/> for a feed. |
| 2323 | + * |
| 2324 | + * @param $type String: feed type |
| 2325 | + * @param $url String: URL to the feed |
| 2326 | + * @param $text String: value of the "title" attribute |
| 2327 | + * @return String: HTML fragment |
2141 | 2328 | */ |
2142 | | - public function getSyndicationLinks() { |
2143 | | - return $this->mFeedLinks; |
2144 | | - } |
2145 | | - |
2146 | | - /** |
2147 | | - * Generate a <link rel/> for an RSS feed. |
2148 | | - */ |
2149 | 2329 | private function feedLink( $type, $url, $text ) { |
2150 | 2330 | return Html::element( 'link', array( |
2151 | 2331 | 'rel' => 'alternate', |
— | — | @@ -2157,9 +2337,10 @@ |
2158 | 2338 | * Add a local or specified stylesheet, with the given media options. |
2159 | 2339 | * Meant primarily for internal use... |
2160 | 2340 | * |
2161 | | - * @param $media -- to specify a media type, 'screen', 'printable', 'handheld' or any. |
2162 | | - * @param $conditional -- for IE conditional comments, specifying an IE version |
2163 | | - * @param $dir -- set to 'rtl' or 'ltr' for direction-specific sheets |
| 2341 | + * @param $style String: URL to the file |
| 2342 | + * @param $media String: to specify a media type, 'screen', 'printable', 'handheld' or any. |
| 2343 | + * @param $condition String: for IE conditional comments, specifying an IE version |
| 2344 | + * @param $dir String: set to 'rtl' or 'ltr' for direction-specific sheets |
2164 | 2345 | */ |
2165 | 2346 | public function addStyle( $style, $media='', $condition='', $dir='' ) { |
2166 | 2347 | $options = array(); |
— | — | @@ -2197,6 +2378,14 @@ |
2198 | 2379 | return implode( "\n", $links ); |
2199 | 2380 | } |
2200 | 2381 | |
| 2382 | + /** |
| 2383 | + * Generate \<link\> tags for stylesheets |
| 2384 | + * |
| 2385 | + * @param $style String: URL to the file |
| 2386 | + * @param $options Array: option, can contain 'condition', 'dir', 'media' |
| 2387 | + * keys |
| 2388 | + * @return String: HTML fragment |
| 2389 | + */ |
2201 | 2390 | protected function styleLink( $style, $options ) { |
2202 | 2391 | global $wgRequest; |
2203 | 2392 | |
— | — | @@ -2234,6 +2423,12 @@ |
2235 | 2424 | return $link; |
2236 | 2425 | } |
2237 | 2426 | |
| 2427 | + /** |
| 2428 | + * Transform "media" attribute based on request parameters |
| 2429 | + * |
| 2430 | + * @param $media String: current value of the "media" attribute |
| 2431 | + * @return String: modified value of the "media" attribute |
| 2432 | + */ |
2238 | 2433 | function transformCssMedia( $media ) { |
2239 | 2434 | global $wgRequest, $wgHandheldForIPhone; |
2240 | 2435 | |
— | — | @@ -2272,7 +2467,6 @@ |
2273 | 2468 | * for when rate limiting has triggered. |
2274 | 2469 | */ |
2275 | 2470 | public function rateLimited() { |
2276 | | - |
2277 | 2471 | $this->setPageTitle(wfMsg('actionthrottled')); |
2278 | 2472 | $this->setRobotPolicy( 'noindex,follow' ); |
2279 | 2473 | $this->setArticleRelated( false ); |
— | — | @@ -2286,31 +2480,13 @@ |
2287 | 2481 | } |
2288 | 2482 | |
2289 | 2483 | /** |
2290 | | - * Show an "add new section" link? |
2291 | | - * |
2292 | | - * @return bool |
2293 | | - */ |
2294 | | - public function showNewSectionLink() { |
2295 | | - return $this->mNewSectionLink; |
2296 | | - } |
2297 | | - |
2298 | | - /** |
2299 | | - * Forcibly hide the new section link? |
2300 | | - * |
2301 | | - * @return bool |
2302 | | - */ |
2303 | | - public function forceHideNewSectionLink() { |
2304 | | - return $this->mHideNewSectionLink; |
2305 | | - } |
2306 | | - |
2307 | | - /** |
2308 | 2484 | * Show a warning about slave lag |
2309 | 2485 | * |
2310 | 2486 | * If the lag is higher than $wgSlaveLagCritical seconds, |
2311 | 2487 | * then the warning is a bit more obvious. If the lag is |
2312 | 2488 | * lower than $wgSlaveLagWarning, then no warning is shown. |
2313 | 2489 | * |
2314 | | - * @param int $lag Slave lag |
| 2490 | + * @param $lag Integer: slave lag |
2315 | 2491 | */ |
2316 | 2492 | public function showLagWarning( $lag ) { |
2317 | 2493 | global $wgSlaveLagWarning, $wgSlaveLagCritical, $wgLang; |
— | — | @@ -2368,7 +2544,7 @@ |
2369 | 2545 | * |
2370 | 2546 | * Is equivalent to: |
2371 | 2547 | * |
2372 | | - * $wgOut->addWikiText( "<div class='error'>\n" . wfMsgNoTrans( 'some-error' ) . '</div>' ); |
| 2548 | + * $wgOut->addWikiText( "<div class='error'>\n" . wfMsgNoTrans( 'some-error' ) . "</div>" ); |
2373 | 2549 | * |
2374 | 2550 | * The newline after opening div is needed in some wikitext. See bug 19226. |
2375 | 2551 | */ |
— | — | @@ -2399,9 +2575,8 @@ |
2400 | 2576 | * Include jQuery core. Use this to avoid loading it multiple times |
2401 | 2577 | * before we get a usable script loader. |
2402 | 2578 | * |
2403 | | - * @param array $modules List of jQuery modules which should be loaded |
2404 | | - * |
2405 | | - * Returns the list of modules which were not loaded. |
| 2579 | + * @param $modules Array: list of jQuery modules which should be loaded |
| 2580 | + * @return Array: the list of modules which were not loaded. |
2406 | 2581 | */ |
2407 | 2582 | public function includeJQuery( $modules = array() ) { |
2408 | 2583 | global $wgScriptPath, $wgStyleVersion, $wgJsMimeType; |