Index: trunk/phase3/includes/Linker.php |
— | — | @@ -77,8 +77,15 @@ |
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | | - * Note: This function MUST call getArticleID() on the link, |
82 | | - * otherwise the cache won't get updated properly. See LINKCACHE.DOC. |
| 81 | + * This function is a shortcut to makeLinkObj(Title::newFromText($title),...). Do not call |
| 82 | + * it if you already have a title object handy. See makeLinkObj for further documentation. |
| 83 | + * |
| 84 | + * @param string $title The text of the title |
| 85 | + * @param string $text Link text |
| 86 | + * @param string $query Optional query part |
| 87 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 88 | + * be included in the link text. Other characters will be appended after |
| 89 | + * the end of the link. |
83 | 90 | */ |
84 | 91 | function makeLink( $title, $text = '', $query = '', $trail = '' ) { |
85 | 92 | wfProfileIn( 'Linker::makeLink' ); |
— | — | @@ -94,7 +101,17 @@ |
95 | 102 | return $result; |
96 | 103 | } |
97 | 104 | |
98 | | - /** @todo document */ |
| 105 | + /** |
| 106 | + * This function is a shortcut to makeKnownLinkObj(Title::newFromText($title),...). Do not call |
| 107 | + * it if you already have a title object handy. See makeKnownLinkObj for further documentation. |
| 108 | + * |
| 109 | + * @param string $title The text of the title |
| 110 | + * @param string $text Link text |
| 111 | + * @param string $query Optional query part |
| 112 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 113 | + * be included in the link text. Other characters will be appended after |
| 114 | + * the end of the link. |
| 115 | + */ |
99 | 116 | function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') { |
100 | 117 | $nt = Title::newFromText( $title ); |
101 | 118 | if ($nt) { |
— | — | @@ -105,7 +122,17 @@ |
106 | 123 | } |
107 | 124 | } |
108 | 125 | |
109 | | - /** @todo document */ |
| 126 | + /** |
| 127 | + * This function is a shortcut to makeBrokenLinkObj(Title::newFromText($title),...). Do not call |
| 128 | + * it if you already have a title object handy. See makeBrokenLinkObj for further documentation. |
| 129 | + * |
| 130 | + * @param string $title The text of the title |
| 131 | + * @param string $text Link text |
| 132 | + * @param string $query Optional query part |
| 133 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 134 | + * be included in the link text. Other characters will be appended after |
| 135 | + * the end of the link. |
| 136 | + */ |
110 | 137 | function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) { |
111 | 138 | $nt = Title::newFromText( $title ); |
112 | 139 | if ($nt) { |
— | — | @@ -116,7 +143,17 @@ |
117 | 144 | } |
118 | 145 | } |
119 | 146 | |
120 | | - /** @todo document */ |
| 147 | + /** |
| 148 | + * This function is a shortcut to makeStubLinkObj(Title::newFromText($title),...). Do not call |
| 149 | + * it if you already have a title object handy. See makeStubLinkObj for further documentation. |
| 150 | + * |
| 151 | + * @param string $title The text of the title |
| 152 | + * @param string $text Link text |
| 153 | + * @param string $query Optional query part |
| 154 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 155 | + * be included in the link text. Other characters will be appended after |
| 156 | + * the end of the link. |
| 157 | + */ |
121 | 158 | function makeStubLink( $title, $text = '', $query = '', $trail = '' ) { |
122 | 159 | $nt = Title::newFromText( $title ); |
123 | 160 | if ($nt) { |
— | — | @@ -128,7 +165,16 @@ |
129 | 166 | } |
130 | 167 | |
131 | 168 | /** |
132 | | - * Pass a title object, not a title string |
| 169 | + * Make a link for a title which may or may not be in the database. If you need to |
| 170 | + * call this lots of times, pre-fill the link cache with a LinkBatch, otherwise each |
| 171 | + * call to this will result in a DB query. |
| 172 | + * |
| 173 | + * @param string $title The text of the title |
| 174 | + * @param string $text Link text |
| 175 | + * @param string $query Optional query part |
| 176 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 177 | + * be included in the link text. Other characters will be appended after |
| 178 | + * the end of the link. |
133 | 179 | */ |
134 | 180 | function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { |
135 | 181 | global $wgUser; |
— | — | @@ -220,7 +266,10 @@ |
221 | 267 | } |
222 | 268 | |
223 | 269 | /** |
224 | | - * Pass a title object, not a title string |
| 270 | + * Make a link for a title which definitely exists. This is faster than makeLinkObj because |
| 271 | + * it doesn't have to do a database query. It's also valid for interwiki titles and special |
| 272 | + * pages. |
| 273 | + * |
225 | 274 | * @param object Title of target page |
226 | 275 | * @param string Text to replace the title |
227 | 276 | * @param string Link target |
— | — | @@ -268,7 +317,14 @@ |
269 | 318 | } |
270 | 319 | |
271 | 320 | /** |
272 | | - * Pass a title object, not a title string |
| 321 | + * Make a red link to the edit page of a given title. |
| 322 | + * |
| 323 | + * @param string $title The text of the title |
| 324 | + * @param string $text Link text |
| 325 | + * @param string $query Optional query part |
| 326 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 327 | + * be included in the link text. Other characters will be appended after |
| 328 | + * the end of the link. |
273 | 329 | */ |
274 | 330 | function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
275 | 331 | # Fail gracefully |
— | — | @@ -300,7 +356,14 @@ |
301 | 357 | } |
302 | 358 | |
303 | 359 | /** |
304 | | - * Pass a title object, not a title string |
| 360 | + * Make a brown link to a short article. |
| 361 | + * |
| 362 | + * @param string $title The text of the title |
| 363 | + * @param string $text Link text |
| 364 | + * @param string $query Optional query part |
| 365 | + * @param string $trail Optional trail. Alphabetic characters at the start of this string will |
| 366 | + * be included in the link text. Other characters will be appended after |
| 367 | + * the end of the link. |
305 | 368 | */ |
306 | 369 | function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
307 | 370 | $link = $nt->getPrefixedURL(); |
— | — | @@ -339,9 +402,12 @@ |
340 | 403 | } |
341 | 404 | } |
342 | 405 | |
343 | | - /** @todo document */ |
| 406 | + /** |
| 407 | + * Make appropriate markup for a link to the current article. This is currently rendered |
| 408 | + * as the bold link text. The calling sequence is the same as the other make*LinkObj functions, |
| 409 | + * despite $query not being used. |
| 410 | + */ |
344 | 411 | function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
345 | | - $u = $nt->escapeLocalURL( $query ); |
346 | 412 | if ( '' == $text ) { |
347 | 413 | $text = htmlspecialchars( $nt->getPrefixedText() ); |
348 | 414 | } |
— | — | @@ -811,9 +877,9 @@ |
812 | 878 | function editSectionLinkForOther( $title, $section ) { |
813 | 879 | global $wgContLang; |
814 | 880 | |
815 | | - $title = Title::newFromText($title); |
| 881 | + $title = Title::newFromText( $title ); |
816 | 882 | $editurl = '§ion='.$section; |
817 | | - $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl); |
| 883 | + $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); |
818 | 884 | |
819 | 885 | if( $wgContLang->isRTL() ) { |
820 | 886 | $farside = 'left'; |
— | — | @@ -831,7 +897,7 @@ |
832 | 898 | global $wgContLang; |
833 | 899 | |
834 | 900 | $editurl = '§ion='.$section; |
835 | | - $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl); |
| 901 | + $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl ); |
836 | 902 | |
837 | 903 | if( $wgContLang->isRTL() ) { |
838 | 904 | $farside = 'left'; |