r12924 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12923‎ | r12924 | r12925 >
Date:04:34, 1 February 2006
Author:timstarling
Status:old
Tags:
Comment:
documentation, code cleanup
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -77,8 +77,15 @@
7878 }
7979
8080 /**
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.
8390 */
8491 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
8592 wfProfileIn( 'Linker::makeLink' );
@@ -94,7 +101,17 @@
95102 return $result;
96103 }
97104
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+ */
99116 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
100117 $nt = Title::newFromText( $title );
101118 if ($nt) {
@@ -105,7 +122,17 @@
106123 }
107124 }
108125
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+ */
110137 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
111138 $nt = Title::newFromText( $title );
112139 if ($nt) {
@@ -116,7 +143,17 @@
117144 }
118145 }
119146
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+ */
121158 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
122159 $nt = Title::newFromText( $title );
123160 if ($nt) {
@@ -128,7 +165,16 @@
129166 }
130167
131168 /**
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.
133179 */
134180 function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
135181 global $wgUser;
@@ -220,7 +266,10 @@
221267 }
222268
223269 /**
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+ *
225274 * @param object Title of target page
226275 * @param string Text to replace the title
227276 * @param string Link target
@@ -268,7 +317,14 @@
269318 }
270319
271320 /**
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.
273329 */
274330 function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
275331 # Fail gracefully
@@ -300,7 +356,14 @@
301357 }
302358
303359 /**
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.
305368 */
306369 function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
307370 $link = $nt->getPrefixedURL();
@@ -339,9 +402,12 @@
340403 }
341404 }
342405
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+ */
344411 function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
345 - $u = $nt->escapeLocalURL( $query );
346412 if ( '' == $text ) {
347413 $text = htmlspecialchars( $nt->getPrefixedText() );
348414 }
@@ -811,9 +877,9 @@
812878 function editSectionLinkForOther( $title, $section ) {
813879 global $wgContLang;
814880
815 - $title = Title::newFromText($title);
 881+ $title = Title::newFromText( $title );
816882 $editurl = '&section='.$section;
817 - $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
 883+ $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl );
818884
819885 if( $wgContLang->isRTL() ) {
820886 $farside = 'left';
@@ -831,7 +897,7 @@
832898 global $wgContLang;
833899
834900 $editurl = '&section='.$section;
835 - $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
 901+ $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl );
836902
837903 if( $wgContLang->isRTL() ) {
838904 $farside = 'left';

Follow-up revisions

RevisionCommit summaryAuthorDate
r17371Fix documentation that confused me. Bad Tim, copy-pasting in r12924!simetrical06:02, 3 November 2006

Status & tagging log