Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -239,53 +239,7 @@ |
240 | 240 | wfProfileOut( __METHOD__ ); |
241 | 241 | } |
242 | 242 | |
243 | | - function setOutputType( $ot ) { |
244 | | - $this->mOutputType = $ot; |
245 | | - # Shortcut alias |
246 | | - $this->ot = array( |
247 | | - 'html' => $ot == self::OT_HTML, |
248 | | - 'wiki' => $ot == self::OT_WIKI, |
249 | | - 'pre' => $ot == self::OT_PREPROCESS, |
250 | | - 'plain' => $ot == self::OT_PLAIN, |
251 | | - ); |
252 | | - } |
253 | | - |
254 | 243 | /** |
255 | | - * Set the context title |
256 | | - */ |
257 | | - function setTitle( $t ) { |
258 | | - if ( !$t || $t instanceof FakeTitle ) { |
259 | | - $t = Title::newFromText( 'NO TITLE' ); |
260 | | - } |
261 | | - |
262 | | - if ( strval( $t->getFragment() ) !== '' ) { |
263 | | - # Strip the fragment to avoid various odd effects |
264 | | - $this->mTitle = clone $t; |
265 | | - $this->mTitle->setFragment( '' ); |
266 | | - } else { |
267 | | - $this->mTitle = $t; |
268 | | - } |
269 | | - } |
270 | | - |
271 | | - /** |
272 | | - * Accessor for mUniqPrefix. |
273 | | - * |
274 | | - * @public |
275 | | - */ |
276 | | - function uniqPrefix() { |
277 | | - if ( !isset( $this->mUniqPrefix ) ) { |
278 | | - # @todo Fixme: this is probably *horribly wrong* |
279 | | - # LanguageConverter seems to want $wgParser's uniqPrefix, however |
280 | | - # if this is called for a parser cache hit, the parser may not |
281 | | - # have ever been initialized in the first place. |
282 | | - # Not really sure what the heck is supposed to be going on here. |
283 | | - return ''; |
284 | | - # throw new MWException( "Accessing uninitialized mUniqPrefix" ); |
285 | | - } |
286 | | - return $this->mUniqPrefix; |
287 | | - } |
288 | | - |
289 | | - /** |
290 | 244 | * Convert wikitext to HTML |
291 | 245 | * Do not call this function recursively. |
292 | 246 | * |
— | — | @@ -481,7 +435,7 @@ |
482 | 436 | * If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded |
483 | 437 | * |
484 | 438 | * @param $text String: text extension wants to have parsed |
485 | | - * @param PPFrame $frame: The frame to use for expanding any template variables |
| 439 | + * @param $frame PPFrame: The frame to use for expanding any template variables |
486 | 440 | */ |
487 | 441 | function recursiveTagParse( $text, $frame=false ) { |
488 | 442 | wfProfileIn( __METHOD__ ); |
— | — | @@ -541,12 +495,118 @@ |
542 | 496 | return dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ); |
543 | 497 | } |
544 | 498 | |
545 | | - function &getTitle() { return $this->mTitle; } |
546 | | - function getOptions() { return $this->mOptions; } |
547 | | - function getRevisionId() { return $this->mRevisionId; } |
548 | | - function getOutput() { return $this->mOutput; } |
549 | | - function nextLinkID() { return $this->mLinkID++; } |
| 499 | + /** |
| 500 | + * Accessor for mUniqPrefix. |
| 501 | + * |
| 502 | + * @return String |
| 503 | + */ |
| 504 | + public function uniqPrefix() { |
| 505 | + if ( !isset( $this->mUniqPrefix ) ) { |
| 506 | + # @todo Fixme: this is probably *horribly wrong* |
| 507 | + # LanguageConverter seems to want $wgParser's uniqPrefix, however |
| 508 | + # if this is called for a parser cache hit, the parser may not |
| 509 | + # have ever been initialized in the first place. |
| 510 | + # Not really sure what the heck is supposed to be going on here. |
| 511 | + return ''; |
| 512 | + # throw new MWException( "Accessing uninitialized mUniqPrefix" ); |
| 513 | + } |
| 514 | + return $this->mUniqPrefix; |
| 515 | + } |
550 | 516 | |
| 517 | + /** |
| 518 | + * Set the context title |
| 519 | + */ |
| 520 | + function setTitle( $t ) { |
| 521 | + if ( !$t || $t instanceof FakeTitle ) { |
| 522 | + $t = Title::newFromText( 'NO TITLE' ); |
| 523 | + } |
| 524 | + |
| 525 | + if ( strval( $t->getFragment() ) !== '' ) { |
| 526 | + # Strip the fragment to avoid various odd effects |
| 527 | + $this->mTitle = clone $t; |
| 528 | + $this->mTitle->setFragment( '' ); |
| 529 | + } else { |
| 530 | + $this->mTitle = $t; |
| 531 | + } |
| 532 | + } |
| 533 | + |
| 534 | + /** |
| 535 | + * Accessor for the Title object |
| 536 | + * |
| 537 | + * @return Title object |
| 538 | + */ |
| 539 | + function &getTitle() { |
| 540 | + return $this->mTitle; |
| 541 | + } |
| 542 | + |
| 543 | + /** |
| 544 | + * Accessor/mutator for the Title object |
| 545 | + * |
| 546 | + * @param $x New Title object or null to just get the current one |
| 547 | + * @return Title object |
| 548 | + */ |
| 549 | + function Title( $x = null ) { |
| 550 | + return wfSetVar( $this->mTitle, $x ); |
| 551 | + } |
| 552 | + |
| 553 | + /** |
| 554 | + * Set the output type |
| 555 | + * |
| 556 | + * @param $ot Integer: new value |
| 557 | + */ |
| 558 | + function setOutputType( $ot ) { |
| 559 | + $this->mOutputType = $ot; |
| 560 | + # Shortcut alias |
| 561 | + $this->ot = array( |
| 562 | + 'html' => $ot == self::OT_HTML, |
| 563 | + 'wiki' => $ot == self::OT_WIKI, |
| 564 | + 'pre' => $ot == self::OT_PREPROCESS, |
| 565 | + 'plain' => $ot == self::OT_PLAIN, |
| 566 | + ); |
| 567 | + } |
| 568 | + |
| 569 | + /** |
| 570 | + * Accessor/mutator for the output type |
| 571 | + * |
| 572 | + * @param $x New value or null to just get the current one |
| 573 | + * @return Integer |
| 574 | + */ |
| 575 | + function OutputType( $x = null ) { |
| 576 | + return wfSetVar( $this->mOutputType, $x ); |
| 577 | + } |
| 578 | + |
| 579 | + /** |
| 580 | + * Get the ParserOutput object |
| 581 | + * |
| 582 | + * @return ParserOutput object |
| 583 | + */ |
| 584 | + function getOutput() { |
| 585 | + return $this->mOutput; |
| 586 | + } |
| 587 | + |
| 588 | + /** |
| 589 | + * Get the ParserOptions object |
| 590 | + * |
| 591 | + * @return ParserOptions object |
| 592 | + */ |
| 593 | + function getOptions() { |
| 594 | + return $this->mOptions; |
| 595 | + } |
| 596 | + |
| 597 | + /** |
| 598 | + * Accessor/mutator for the ParserOptions object |
| 599 | + * |
| 600 | + * @param $x New value or null to just get the current one |
| 601 | + * @return Current ParserOptions object |
| 602 | + */ |
| 603 | + function Options( $x = null ) { |
| 604 | + return wfSetVar( $this->mOptions, $x ); |
| 605 | + } |
| 606 | + |
| 607 | + function nextLinkID() { |
| 608 | + return $this->mLinkID++; |
| 609 | + } |
| 610 | + |
551 | 611 | function getFunctionLang() { |
552 | 612 | global $wgLang, $wgContLang; |
553 | 613 | |
— | — | @@ -560,6 +620,8 @@ |
561 | 621 | |
562 | 622 | /** |
563 | 623 | * Get a preprocessor object |
| 624 | + * |
| 625 | + * @return Preprocessor instance |
564 | 626 | */ |
565 | 627 | function getPreprocessor() { |
566 | 628 | if ( !isset( $this->mPreprocessor ) ) { |
— | — | @@ -582,12 +644,13 @@ |
583 | 645 | * |
584 | 646 | * @param $elements list of element names. Comments are always extracted. |
585 | 647 | * @param $text Source text string. |
| 648 | + * @param $matches Out parameter, Array: extarcted tags |
586 | 649 | * @param $uniq_prefix |
| 650 | + * @return String: stripped text |
587 | 651 | * |
588 | | - * @public |
589 | 652 | * @static |
590 | 653 | */ |
591 | | - function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) { |
| 654 | + public function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) { |
592 | 655 | static $n = 1; |
593 | 656 | $stripped = ''; |
594 | 657 | $matches = array(); |
— | — | @@ -1388,9 +1451,9 @@ |
1389 | 1452 | * (depending on configuration, namespace, and the URL's domain) and/or a |
1390 | 1453 | * target attribute (depending on configuration). |
1391 | 1454 | * |
1392 | | - * @param string $url Optional URL, to extract the domain from for rel => |
| 1455 | + * @param $url String: optional URL, to extract the domain from for rel => |
1393 | 1456 | * nofollow if appropriate |
1394 | | - * @return array Associative array of HTML attributes |
| 1457 | + * @return Array: associative array of HTML attributes |
1395 | 1458 | */ |
1396 | 1459 | function getExternalLinkAttribs( $url = false ) { |
1397 | 1460 | $attribs = array(); |
— | — | @@ -1421,9 +1484,10 @@ |
1422 | 1485 | |
1423 | 1486 | /** |
1424 | 1487 | * Replace unusual URL escape codes with their equivalent characters |
1425 | | - * @param string |
1426 | | - * @return string |
1427 | | - * @static |
| 1488 | + * |
| 1489 | + * @param $url String |
| 1490 | + * @return String |
| 1491 | + * |
1428 | 1492 | * @todo This can merge genuinely required bits in the path or query string, |
1429 | 1493 | * breaking legit URLs. A proper fix would treat the various parts of |
1430 | 1494 | * the URL differently; as a workaround, just use the output for |
— | — | @@ -1437,8 +1501,6 @@ |
1438 | 1502 | /** |
1439 | 1503 | * Callback function used in replaceUnusualEscapes(). |
1440 | 1504 | * Replaces unusual URL escape codes with their equivalent character |
1441 | | - * @static |
1442 | | - * @private |
1443 | 1505 | */ |
1444 | 1506 | private static function replaceUnusualEscapesCallback( $matches ) { |
1445 | 1507 | $char = urldecode( $matches[0] ); |
— | — | @@ -1864,12 +1926,12 @@ |
1865 | 1927 | * breaking URLs in the following text without breaking trails on the |
1866 | 1928 | * wiki links, it's been made into a horrible function. |
1867 | 1929 | * |
1868 | | - * @param Title $nt |
1869 | | - * @param string $text |
1870 | | - * @param string $query |
1871 | | - * @param string $trail |
1872 | | - * @param string $prefix |
1873 | | - * @return string HTML-wikitext mix oh yuck |
| 1930 | + * @param $nt Title |
| 1931 | + * @param $text String |
| 1932 | + * @param $query String |
| 1933 | + * @param $trail String |
| 1934 | + * @param $prefix String |
| 1935 | + * @return String: HTML-wikitext mix oh yuck |
1874 | 1936 | */ |
1875 | 1937 | function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
1876 | 1938 | list( $inside, $trail ) = Linker::splitTrail( $trail ); |
— | — | @@ -1886,8 +1948,8 @@ |
1887 | 1949 | * Not needed quite as much as it used to be since free links are a bit |
1888 | 1950 | * more sensible these days. But bracketed links are still an issue. |
1889 | 1951 | * |
1890 | | - * @param string more-or-less HTML |
1891 | | - * @return string less-or-more HTML with NOPARSE bits |
| 1952 | + * @param $text String: more-or-less HTML |
| 1953 | + * @return String: less-or-more HTML with NOPARSE bits |
1892 | 1954 | */ |
1893 | 1955 | function armorLinks( $text ) { |
1894 | 1956 | return preg_replace( '/\b(' . wfUrlProtocols() . ')/', |
— | — | @@ -1896,7 +1958,7 @@ |
1897 | 1959 | |
1898 | 1960 | /** |
1899 | 1961 | * Return true if subpage links should be expanded on this page. |
1900 | | - * @return bool |
| 1962 | + * @return Boolean |
1901 | 1963 | */ |
1902 | 1964 | function areSubpagesAllowed() { |
1903 | 1965 | # Some namespaces don't allow subpages |
— | — | @@ -1905,8 +1967,9 @@ |
1906 | 1968 | |
1907 | 1969 | /** |
1908 | 1970 | * Handle link to subpage if necessary |
1909 | | - * @param string $target the source of the link |
1910 | | - * @param string &$text the link text, modified as necessary |
| 1971 | + * |
| 1972 | + * @param $target String: the source of the link |
| 1973 | + * @param &$text String: the link text, modified as necessary |
1911 | 1974 | * @return string the full name of the link |
1912 | 1975 | * @private |
1913 | 1976 | */ |
— | — | @@ -1927,6 +1990,7 @@ |
1928 | 1991 | $this->mLastSection = ''; |
1929 | 1992 | return $result; |
1930 | 1993 | } |
| 1994 | + |
1931 | 1995 | /** |
1932 | 1996 | * getCommon() returns the length of the longest common substring |
1933 | 1997 | * of both arguments, starting at the beginning of both. |
— | — | @@ -1946,6 +2010,7 @@ |
1947 | 2011 | } |
1948 | 2012 | return $i; |
1949 | 2013 | } |
| 2014 | + |
1950 | 2015 | /** |
1951 | 2016 | * These next three functions open, continue, and close the list |
1952 | 2017 | * element appropriate to the prefix character passed into them. |
— | — | @@ -2021,7 +2086,8 @@ |
2022 | 2087 | /** |
2023 | 2088 | * Make lists from lines starting with ':', '*', '#', etc. (DBL) |
2024 | 2089 | * |
2025 | | - * @param $linestart bool whether or not this is at the start of a line. |
| 2090 | + * @param $text String |
| 2091 | + * @param $linestart Boolean: whether or not this is at the start of a line. |
2026 | 2092 | * @private |
2027 | 2093 | * @return string the lists rendered as HTML |
2028 | 2094 | */ |
— | — | @@ -2210,10 +2276,11 @@ |
2211 | 2277 | /** |
2212 | 2278 | * Split up a string on ':', ignoring any occurences inside tags |
2213 | 2279 | * to prevent illegal overlapping. |
2214 | | - * @param string $str the string to split |
2215 | | - * @param string &$before set to everything before the ':' |
2216 | | - * @param string &$after set to everything after the ':' |
2217 | | - * return string the position of the ':', or false if none found |
| 2280 | + * |
| 2281 | + * @param $str String: the string to split |
| 2282 | + * @param &$before String: set to everything before the ':' |
| 2283 | + * @param &$after String: set to everything after the ':' |
| 2284 | + * return String: the position of the ':', or false if none found |
2218 | 2285 | */ |
2219 | 2286 | function findColonNoLinks( $str, &$before, &$after ) { |
2220 | 2287 | wfProfileIn( __METHOD__ ); |
— | — | @@ -2700,8 +2767,8 @@ |
2701 | 2768 | * Preprocess some wikitext and return the document tree. |
2702 | 2769 | * This is the ghost of replace_variables(). |
2703 | 2770 | * |
2704 | | - * @param string $text The text to parse |
2705 | | - * @param integer flags Bitwise combination of: |
| 2771 | + * @param $text String: The text to parse |
| 2772 | + * @param $flags Integer: bitwise combination of: |
2706 | 2773 | * self::PTD_FOR_INCLUSION Handle <noinclude>/<includeonly> as if the text is being |
2707 | 2774 | * included. Default is to assume a direct page view. |
2708 | 2775 | * |
— | — | @@ -2749,11 +2816,11 @@ |
2750 | 2817 | * self::OT_PREPROCESS: templates but not extension tags |
2751 | 2818 | * self::OT_HTML: all templates and extension tags |
2752 | 2819 | * |
2753 | | - * @param string $tex The text to transform |
2754 | | - * @param PPFrame $frame Object describing the arguments passed to the template. |
| 2820 | + * @param $text String: the text to transform |
| 2821 | + * @param $frame PPFrame Object describing the arguments passed to the template. |
2755 | 2822 | * Arguments may also be provided as an associative array, as was the usual case before MW1.12. |
2756 | 2823 | * Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly. |
2757 | | - * @param bool $argsOnly Only do argument (triple-brace) expansion, not double-brace expansion |
| 2824 | + * @param $argsOnly Boolean: only do argument (triple-brace) expansion, not double-brace expansion |
2758 | 2825 | * @private |
2759 | 2826 | */ |
2760 | 2827 | function replaceVariables( $text, $frame = false, $argsOnly = false ) { |
— | — | @@ -2805,7 +2872,7 @@ |
2806 | 2873 | * Warn the user when a parser limitation is reached |
2807 | 2874 | * Will warn at most once the user per limitation type |
2808 | 2875 | * |
2809 | | - * @param string $limitationType, should be one of: |
| 2876 | + * @param $limitationType String: should be one of: |
2810 | 2877 | * 'expensive-parserfunction' (corresponding messages: |
2811 | 2878 | * 'expensive-parserfunction-warning', |
2812 | 2879 | * 'expensive-parserfunction-category') |
— | — | @@ -2815,7 +2882,8 @@ |
2816 | 2883 | * 'post-expand-template-inclusion' (corresponding messages: |
2817 | 2884 | * 'post-expand-template-inclusion-warning', |
2818 | 2885 | * 'post-expand-template-inclusion-category') |
2819 | | - * @params int $current, $max When an explicit limit has been |
| 2886 | + * @param $current Current value |
| 2887 | + * @param $max Maximum allowed, when an explicit limit has been |
2820 | 2888 | * exceeded, provide the values (optional) |
2821 | 2889 | */ |
2822 | 2890 | function limitationWarn( $limitationType, $current=null, $max=null) { |
— | — | @@ -2829,12 +2897,12 @@ |
2830 | 2898 | * Return the text of a template, after recursively |
2831 | 2899 | * replacing any variables or templates within the template. |
2832 | 2900 | * |
2833 | | - * @param array $piece The parts of the template |
| 2901 | + * @param $piece Array: the parts of the template |
2834 | 2902 | * $piece['title']: the title, i.e. the part before the | |
2835 | 2903 | * $piece['parts']: the parameter array |
2836 | 2904 | * $piece['lineStart']: whether the brace was at the start of a line |
2837 | | - * @param PPFrame The current frame, contains template arguments |
2838 | | - * @return string the text of the template |
| 2905 | + * @param $frame PPFrame The current frame, contains template arguments |
| 2906 | + * @return String: the text of the template |
2839 | 2907 | * @private |
2840 | 2908 | */ |
2841 | 2909 | function braceSubstitution( $piece, $frame ) { |
— | — | @@ -3366,13 +3434,13 @@ |
3367 | 3435 | * Return the text to be used for a given extension tag. |
3368 | 3436 | * This is the ghost of strip(). |
3369 | 3437 | * |
3370 | | - * @param array $params Associative array of parameters: |
| 3438 | + * @param $params Associative array of parameters: |
3371 | 3439 | * name PPNode for the tag name |
3372 | 3440 | * attr PPNode for unparsed text where tag attributes are thought to be |
3373 | 3441 | * attributes Optional associative array of parsed attributes |
3374 | 3442 | * inner Contents of extension element |
3375 | 3443 | * noClose Original text did not have a close tag |
3376 | | - * @param PPFrame $frame |
| 3444 | + * @param $frame PPFrame |
3377 | 3445 | */ |
3378 | 3446 | function extensionSubstitution( $params, $frame ) { |
3379 | 3447 | global $wgRawHtml, $wgContLang; |
— | — | @@ -3455,9 +3523,9 @@ |
3456 | 3524 | /** |
3457 | 3525 | * Increment an include size counter |
3458 | 3526 | * |
3459 | | - * @param string $type The type of expansion |
3460 | | - * @param integer $size The size of the text |
3461 | | - * @return boolean False if this inclusion would take it over the maximum, true otherwise |
| 3527 | + * @param $type String: the type of expansion |
| 3528 | + * @param $size Integer: the size of the text |
| 3529 | + * @return Boolean: false if this inclusion would take it over the maximum, true otherwise |
3462 | 3530 | */ |
3463 | 3531 | function incrementIncludeSize( $type, $size ) { |
3464 | 3532 | if ( $this->mIncludeSizes[$type] + $size > $this->mOptions->getMaxIncludeSize( $type ) ) { |
— | — | @@ -3471,7 +3539,7 @@ |
3472 | 3540 | /** |
3473 | 3541 | * Increment the expensive function count |
3474 | 3542 | * |
3475 | | - * @return boolean False if the limit has been exceeded |
| 3543 | + * @return Boolean: false if the limit has been exceeded |
3476 | 3544 | */ |
3477 | 3545 | function incrementExpensiveFunctionCount() { |
3478 | 3546 | global $wgExpensiveParserFunctionLimit; |
— | — | @@ -3536,8 +3604,9 @@ |
3537 | 3605 | /** |
3538 | 3606 | * Add a tracking category, getting the title from a system message, |
3539 | 3607 | * or print a debug message if the title is invalid. |
3540 | | - * @param $msg String message key |
3541 | | - * @return Bool whether the addition was successful |
| 3608 | + * |
| 3609 | + * @param $msg String: message key |
| 3610 | + * @return Boolean: whether the addition was successful |
3542 | 3611 | */ |
3543 | 3612 | protected function addTrackingCategory( $msg ) { |
3544 | 3613 | $cat = wfMsgForContent( $msg ); |
— | — | @@ -3567,9 +3636,9 @@ |
3568 | 3637 | * It loops through all headlines, collects the necessary data, then splits up the |
3569 | 3638 | * string and re-inserts the newly formatted headlines. |
3570 | 3639 | * |
3571 | | - * @param string $text |
3572 | | - * @param string $origText Original, untouched wikitext |
3573 | | - * @param boolean $isMain |
| 3640 | + * @param $text String |
| 3641 | + * @param $origText String: original, untouched wikitext |
| 3642 | + * @param $isMain Boolean |
3574 | 3643 | * @private |
3575 | 3644 | */ |
3576 | 3645 | function formatHeadings( $text, $origText, $isMain=true ) { |
— | — | @@ -3913,12 +3982,13 @@ |
3914 | 3983 | * $section in $tree1 and its descendants with the sections in $tree2. |
3915 | 3984 | * Note that in the returned section tree, only the 'index' and |
3916 | 3985 | * 'byteoffset' fields are guaranteed to be correct. |
3917 | | - * @param $tree1 array Section tree from ParserOutput::getSectons() |
3918 | | - * @param $tree2 array Section tree |
3919 | | - * @param $section int Section index |
3920 | | - * @param $title Title Title both section trees come from |
3921 | | - * @param $len2 int Length of the original wikitext for $tree2 |
3922 | | - * @return array Merged section tree |
| 3986 | + * |
| 3987 | + * @param $tree1 Array: section tree from ParserOutput::getSectons() |
| 3988 | + * @param $tree2 Array: section tree |
| 3989 | + * @param $section Integer: section index |
| 3990 | + * @param $title Title: Title both section trees come from |
| 3991 | + * @param $len2 Integer: length of the original wikitext for $tree2 |
| 3992 | + * @return Array: merged section tree |
3923 | 3993 | */ |
3924 | 3994 | public static function mergeSectionTrees( $tree1, $tree2, $section, $title, $len2 ) { |
3925 | 3995 | global $wgContLang; |
— | — | @@ -3984,9 +4054,10 @@ |
3985 | 4055 | |
3986 | 4056 | /** |
3987 | 4057 | * Increment a section number. Helper function for mergeSectionTrees() |
3988 | | - * @param $number array Array representing a section number |
3989 | | - * @param $level int Current TOC level (depth) |
3990 | | - * @param $lastLevel int Level of previous TOC entry |
| 4058 | + * |
| 4059 | + * @param $number Array representing a section number |
| 4060 | + * @param $level Integer: current TOC level (depth) |
| 4061 | + * @param $lastLevel Integer: level of previous TOC entry |
3991 | 4062 | */ |
3992 | 4063 | private static function incrementNumbering( &$number, $level, $lastLevel ) { |
3993 | 4064 | if ( $level > $lastLevel ) { |
— | — | @@ -4006,15 +4077,14 @@ |
4007 | 4078 | * Transform wiki markup when saving a page by doing \r\n -> \n |
4008 | 4079 | * conversion, substitting signatures, {{subst:}} templates, etc. |
4009 | 4080 | * |
4010 | | - * @param string $text the text to transform |
4011 | | - * @param Title &$title the Title object for the current article |
4012 | | - * @param User $user the User object describing the current user |
4013 | | - * @param ParserOptions $options parsing options |
4014 | | - * @param bool $clearState whether to clear the parser state first |
4015 | | - * @return string the altered wiki markup |
4016 | | - * @public |
| 4081 | + * @param $text String: the text to transform |
| 4082 | + * @param &$title Title: the Title object for the current article |
| 4083 | + * @param $user User: the User object describing the current user |
| 4084 | + * @param $options ParserOptions: parsing options |
| 4085 | + * @param $clearState Boolean: whether to clear the parser state first |
| 4086 | + * @return String: the altered wiki markup |
4017 | 4087 | */ |
4018 | | - function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) { |
| 4088 | + public function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) { |
4019 | 4089 | $this->mOptions = $options; |
4020 | 4090 | $this->setTitle( $title ); |
4021 | 4091 | $this->setOutputType( self::OT_WIKI ); |
— | — | @@ -4120,7 +4190,10 @@ |
4121 | 4191 | * If you have pre-fetched the nickname or the fancySig option, you can |
4122 | 4192 | * specify them here to save a database query. |
4123 | 4193 | * |
4124 | | - * @param User $user |
| 4194 | + * @param $user User |
| 4195 | + * @param $nickname String: nickname to use or false to use user's default nickname |
| 4196 | + * @param $fancySig Boolean: whether the nicknname is the complete signature |
| 4197 | + * or null to use default value |
4125 | 4198 | * @return string |
4126 | 4199 | */ |
4127 | 4200 | function getUserSig( &$user, $nickname = false, $fancySig = null ) { |
— | — | @@ -4169,7 +4242,7 @@ |
4170 | 4243 | /** |
4171 | 4244 | * Check that the user's signature contains no bad XML |
4172 | 4245 | * |
4173 | | - * @param string $text |
| 4246 | + * @param $text String |
4174 | 4247 | * @return mixed An expanded string, or false if invalid. |
4175 | 4248 | */ |
4176 | 4249 | function validateSig( $text ) { |
— | — | @@ -4182,9 +4255,9 @@ |
4183 | 4256 | * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig |
4184 | 4257 | * 2) Substitute all transclusions |
4185 | 4258 | * |
4186 | | - * @param string $text |
| 4259 | + * @param $text String |
4187 | 4260 | * @param $parsing Whether we're cleaning (preferences save) or parsing |
4188 | | - * @return string Signature text |
| 4261 | + * @return String: signature text |
4189 | 4262 | */ |
4190 | 4263 | function cleanSig( $text, $parsing = false ) { |
4191 | 4264 | if ( !$parsing ) { |
— | — | @@ -4221,8 +4294,9 @@ |
4222 | 4295 | |
4223 | 4296 | /** |
4224 | 4297 | * Strip ~~~, ~~~~ and ~~~~~ out of signatures |
4225 | | - * @param string $text |
4226 | | - * @return string Signature text with /~{3,5}/ removed |
| 4298 | + * |
| 4299 | + * @param $text String |
| 4300 | + * @return String: signature text with /~{3,5}/ removed |
4227 | 4301 | */ |
4228 | 4302 | function cleanSigInSig( $text ) { |
4229 | 4303 | $text = preg_replace( '/~{3,5}/', '', $text ); |
— | — | @@ -4232,9 +4306,8 @@ |
4233 | 4307 | /** |
4234 | 4308 | * Set up some variables which are usually set up in parse() |
4235 | 4309 | * so that an external function can call some class members with confidence |
4236 | | - * @public |
4237 | 4310 | */ |
4238 | | - function startExternalParse( &$title, $options, $outputType, $clearState = true ) { |
| 4311 | + public function startExternalParse( &$title, $options, $outputType, $clearState = true ) { |
4239 | 4312 | $this->setTitle( $title ); |
4240 | 4313 | $this->mOptions = $options; |
4241 | 4314 | $this->setOutputType( $outputType ); |
— | — | @@ -4246,12 +4319,11 @@ |
4247 | 4320 | /** |
4248 | 4321 | * Wrapper for preprocess() |
4249 | 4322 | * |
4250 | | - * @param string $text the text to preprocess |
4251 | | - * @param ParserOptions $options options |
4252 | | - * @return string |
4253 | | - * @public |
| 4323 | + * @param $text String: the text to preprocess |
| 4324 | + * @param $options ParserOptions: options |
| 4325 | + * @return String |
4254 | 4326 | */ |
4255 | | - function transformMsg( $text, $options ) { |
| 4327 | + public function transformMsg( $text, $options ) { |
4256 | 4328 | global $wgTitle; |
4257 | 4329 | static $executing = false; |
4258 | 4330 | |
— | — | @@ -4277,14 +4349,11 @@ |
4278 | 4350 | * Transform and return $text. Use $parser for any required context, e.g. use |
4279 | 4351 | * $parser->getTitle() and $parser->getOptions() not $wgTitle or $wgOut->mParserOptions |
4280 | 4352 | * |
4281 | | - * @public |
4282 | | - * |
4283 | | - * @param mixed $tag The tag to use, e.g. 'hook' for <hook> |
4284 | | - * @param mixed $callback The callback function (and object) to use for the tag |
4285 | | - * |
| 4353 | + * @param $tag Mixed: the tag to use, e.g. 'hook' for <hook> |
| 4354 | + * @param $callback Mixed: the callback function (and object) to use for the tag |
4286 | 4355 | * @return The old value of the mTagHooks array associated with the hook |
4287 | 4356 | */ |
4288 | | - function setHook( $tag, $callback ) { |
| 4357 | + public function setHook( $tag, $callback ) { |
4289 | 4358 | $tag = strtolower( $tag ); |
4290 | 4359 | $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null; |
4291 | 4360 | $this->mTagHooks[$tag] = $callback; |
— | — | @@ -4327,11 +4396,9 @@ |
4328 | 4397 | * nowiki Wiki markup in the return value should be escaped |
4329 | 4398 | * isHTML The returned text is HTML, armour it against wikitext transformation |
4330 | 4399 | * |
4331 | | - * @public |
4332 | | - * |
4333 | | - * @param string $id The magic word ID |
4334 | | - * @param mixed $callback The callback function (and object) to use |
4335 | | - * @param integer $flags a combination of the following flags: |
| 4400 | + * @param $id String: The magic word ID |
| 4401 | + * @param $callback Mixed: the callback function (and object) to use |
| 4402 | + * @param $flags Integer: a combination of the following flags: |
4336 | 4403 | * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} |
4337 | 4404 | * |
4338 | 4405 | * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This |
— | — | @@ -4355,7 +4422,7 @@ |
4356 | 4423 | * |
4357 | 4424 | * @return The old callback function for this name, if any |
4358 | 4425 | */ |
4359 | | - function setFunctionHook( $id, $callback, $flags = 0 ) { |
| 4426 | + public function setFunctionHook( $id, $callback, $flags = 0 ) { |
4360 | 4427 | global $wgContLang; |
4361 | 4428 | |
4362 | 4429 | $oldVal = isset( $this->mFunctionHooks[$id] ) ? $this->mFunctionHooks[$id][0] : null; |
— | — | @@ -4390,7 +4457,7 @@ |
4391 | 4458 | /** |
4392 | 4459 | * Get all registered function hook identifiers |
4393 | 4460 | * |
4394 | | - * @return array |
| 4461 | + * @return Array |
4395 | 4462 | */ |
4396 | 4463 | function getFunctionHooks() { |
4397 | 4464 | return array_keys( $this->mFunctionHooks ); |
— | — | @@ -4427,8 +4494,9 @@ |
4428 | 4495 | /** |
4429 | 4496 | * Replace <!--LINK--> link placeholders with plain text of links |
4430 | 4497 | * (not HTML-formatted). |
4431 | | - * @param string $text |
4432 | | - * @return string |
| 4498 | + * |
| 4499 | + * @param $text String |
| 4500 | + * @return String |
4433 | 4501 | */ |
4434 | 4502 | function replaceLinkHoldersText( $text ) { |
4435 | 4503 | return $this->mLinkHolders->replaceText( $text ); |
— | — | @@ -4557,9 +4625,10 @@ |
4558 | 4626 | |
4559 | 4627 | /** |
4560 | 4628 | * Parse image options text and use it to make an image |
4561 | | - * @param Title $title |
4562 | | - * @param string $options |
4563 | | - * @param LinkHolderArray $holders |
| 4629 | + * |
| 4630 | + * @param $title Title |
| 4631 | + * @param $options String |
| 4632 | + * @param $holders LinkHolderArray |
4564 | 4633 | */ |
4565 | 4634 | function makeImage( $title, $options, $holders = false ) { |
4566 | 4635 | # Check if the options text is of the form "options|alt text" |
— | — | @@ -4791,12 +4860,13 @@ |
4792 | 4861 | $this->mOutput->updateCacheExpiry( 0 ); // new style, for consistency |
4793 | 4862 | } |
4794 | 4863 | |
4795 | | - /**#@+ |
| 4864 | + /** |
4796 | 4865 | * Callback from the Sanitizer for expanding items found in HTML attribute |
4797 | 4866 | * values, so they can be safely tested and escaped. |
4798 | | - * @param string $text |
4799 | | - * @param PPFrame $frame |
4800 | | - * @return string |
| 4867 | + * |
| 4868 | + * @param $text String |
| 4869 | + * @param $frame PPFrame |
| 4870 | + * @return String |
4801 | 4871 | * @private |
4802 | 4872 | */ |
4803 | 4873 | function attributeStripCallback( &$text, $frame = false ) { |
— | — | @@ -4805,33 +4875,21 @@ |
4806 | 4876 | return $text; |
4807 | 4877 | } |
4808 | 4878 | |
4809 | | - /**#@-*/ |
4810 | | - |
4811 | | - /**#@+ |
4812 | | - * Accessor/mutator |
4813 | | - */ |
4814 | | - function Title( $x = null ) { return wfSetVar( $this->mTitle, $x ); } |
4815 | | - function Options( $x = null ) { return wfSetVar( $this->mOptions, $x ); } |
4816 | | - function OutputType( $x = null ) { return wfSetVar( $this->mOutputType, $x ); } |
4817 | | - /**#@-*/ |
4818 | | - |
4819 | | - /**#@+ |
| 4879 | + /** |
4820 | 4880 | * Accessor |
4821 | 4881 | */ |
4822 | 4882 | function getTags() { |
4823 | 4883 | return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) ); |
4824 | 4884 | } |
4825 | | - /**#@-*/ |
4826 | 4885 | |
4827 | | - |
4828 | 4886 | /** |
4829 | 4887 | * Break wikitext input into sections, and either pull or replace |
4830 | 4888 | * some particular section's text. |
4831 | 4889 | * |
4832 | 4890 | * External callers should use the getSection and replaceSection methods. |
4833 | 4891 | * |
4834 | | - * @param string $text Page wikitext |
4835 | | - * @param string $section A section identifier string of the form: |
| 4892 | + * @param $text String: Page wikitext |
| 4893 | + * @param $section String: a section identifier string of the form: |
4836 | 4894 | * <flag1> - <flag2> - ... - <section number> |
4837 | 4895 | * |
4838 | 4896 | * Currently the only recognised flag is "T", which means the target section number |
— | — | @@ -4844,10 +4902,10 @@ |
4845 | 4903 | * pull the given section along with its lower-level subsections. If the section is |
4846 | 4904 | * not found, $mode=get will return $newtext, and $mode=replace will return $text. |
4847 | 4905 | * |
4848 | | - * @param string $mode One of "get" or "replace" |
4849 | | - * @param string $newText Replacement text for section data. |
4850 | | - * @return string for "get", the extracted section text. |
4851 | | - * for "replace", the whole page with the section replaced. |
| 4906 | + * @param $mode String: one of "get" or "replace" |
| 4907 | + * @param $newText String: replacement text for section data. |
| 4908 | + * @return String: for "get", the extracted section text. |
| 4909 | + * for "replace", the whole page with the section replaced. |
4852 | 4910 | */ |
4853 | 4911 | private function extractSections( $text, $section, $mode, $newText='' ) { |
4854 | 4912 | global $wgTitle; |
— | — | @@ -4879,11 +4937,11 @@ |
4880 | 4938 | # Section zero doesn't nest, level=big |
4881 | 4939 | $targetLevel = 1000; |
4882 | 4940 | } else { |
4883 | | - while ( $node ) { |
4884 | | - if ( $node->getName() === 'h' ) { |
4885 | | - $bits = $node->splitHeading(); |
| 4941 | + while ( $node ) { |
| 4942 | + if ( $node->getName() === 'h' ) { |
| 4943 | + $bits = $node->splitHeading(); |
4886 | 4944 | if ( $bits['i'] == $sectionIndex ) { |
4887 | | - $targetLevel = $bits['level']; |
| 4945 | + $targetLevel = $bits['level']; |
4888 | 4946 | break; |
4889 | 4947 | } |
4890 | 4948 | } |
— | — | @@ -4949,9 +5007,9 @@ |
4950 | 5008 | * |
4951 | 5009 | * If a section contains subsections, these are also returned. |
4952 | 5010 | * |
4953 | | - * @param string $text text to look in |
4954 | | - * @param string $section section identifier |
4955 | | - * @param string $deftext default to return if section is not found |
| 5011 | + * @param $text String: text to look in |
| 5012 | + * @param $section String: section identifier |
| 5013 | + * @param $deftext String: default to return if section is not found |
4956 | 5014 | * @return string text of the requested section |
4957 | 5015 | */ |
4958 | 5016 | public function getSection( $text, $section, $deftext='' ) { |
— | — | @@ -4963,6 +5021,15 @@ |
4964 | 5022 | } |
4965 | 5023 | |
4966 | 5024 | /** |
| 5025 | + * Get the ID of the revision we are parsing |
| 5026 | + * |
| 5027 | + * @return Mixed: integer or null |
| 5028 | + */ |
| 5029 | + function getRevisionId() { |
| 5030 | + return $this->mRevisionId; |
| 5031 | + } |
| 5032 | + |
| 5033 | + /** |
4967 | 5034 | * Get the timestamp associated with the current revision, adjusted for |
4968 | 5035 | * the default server-local timestamp |
4969 | 5036 | */ |
— | — | @@ -4995,6 +5062,8 @@ |
4996 | 5063 | |
4997 | 5064 | /** |
4998 | 5065 | * Get the name of the user that edited the last revision |
| 5066 | + * |
| 5067 | + * @return String: user name |
4999 | 5068 | */ |
5000 | 5069 | function getRevisionUser() { |
5001 | 5070 | # if this template is subst: the revision id will be blank, |
— | — | @@ -5080,7 +5149,7 @@ |
5081 | 5150 | * to create valid section anchors by mimicing the output of the |
5082 | 5151 | * parser when headings are parsed. |
5083 | 5152 | * |
5084 | | - * @param $text string Text string to be stripped of wikitext |
| 5153 | + * @param $text String: text string to be stripped of wikitext |
5085 | 5154 | * for use in a Section anchor |
5086 | 5155 | * @return Filtered text string |
5087 | 5156 | */ |
Index: trunk/phase3/includes/parser/Parser_LinkHooks.php |
— | — | @@ -78,9 +78,9 @@ |
79 | 79 | * |
80 | 80 | * @public |
81 | 81 | * |
82 | | - * @param integer|string $ns The Namespace ID or regex pattern if SLH_PATTERN is set |
83 | | - * @param mixed $callback The callback function (and object) to use |
84 | | - * @param integer $flags a combination of the following flags: |
| 82 | + * @param $ns Integer or String: the Namespace ID or regex pattern if SLH_PATTERN is set |
| 83 | + * @param $callback Mixed: the callback function (and object) to use |
| 84 | + * @param $flags Integer: a combination of the following flags: |
85 | 85 | * SLH_PATTERN Use a regex link pattern rather than a namespace |
86 | 86 | * |
87 | 87 | * @return The old callback function for this name, if any |