r17480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17479‎ | r17480 | r17481 >
Date:05:23, 8 November 2006
Author:simetrical
Status:old
Tags:
Comment:
* (bug 7405) Change extensions to use static calls to Linker. Patch by Dan Li.
Modified paths:
  • /trunk/extensions/CrossNamespaceLinks/SpecialCrossNamespaceLinks_body.php (modified) (history)
  • /trunk/extensions/LinkSearch/LinkSearch.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialAttributes.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialRelations.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialTypes.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialUnusedAttributes.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialUnusedRelations.php (modified) (history)
  • /trunk/extensions/interact/SpecialInteract.php (modified) (history)

Diff [purge]

Index: trunk/extensions/interact/SpecialInteract.php
@@ -43,9 +43,13 @@
4444 }
4545
4646
47 - function formatResult( $skin, $result) {
 47+ function formatResult( $result, $old = null ) {
 48+ if($old) { // pre-1.9
 49+ $skin = $result;
 50+ $result = $old;
 51+ }
4852 $title = Title::makeTitle( $result->namespace, $result->title );
49 - $link = $skin->makeKnownLinkObj( $title );
 53+ $link = $old ? $skin->makeKnownLinkObj( $title ) : Linker::makeKnownLinkObj( $title );
5054 return "$link";
5155 }
5256 }
Index: trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialTypes.php
@@ -87,9 +87,9 @@
8888 /**
8989 * Returns the info about a type as HTML
9090 */
91 - function getTypeInfo ($label, $skin) {
 91+ function getTypeInfo ($label, $skin = null) { // if $skin is left null, we better be in MW1.9+
9292 $title = Title::makeTitle( SMW_NS_TYPE, $label );
93 - $link = $skin->makeLinkObj( $title, $title->getText() );
 93+ $link = $skin ? $skin->makeLinkObj( $title, $title->getText() ) : Linker::makeLinkObj( $title, $title->getText() );
9494
9595 // Unlike Attributes and Relations, we don't have a count and there's no URL to search by type.
9696 $text = $link;
@@ -117,8 +117,13 @@
118118
119119 }
120120
121 - function formatResult( $skin, $result ) {
122 - return $this->getTypeInfo($result->title, $skin);
 121+ function formatResult( $result, $old = null ) {
 122+ if($old) { // pre-1.9
 123+ $skin = $result;
 124+ $result = $old;
 125+ return $this->getTypeInfo($result->title, $skin);
 126+ }
 127+ return $this->getTypeInfo($result->title);
123128 }
124129
125130 }
Index: trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialUnusedRelations.php
@@ -61,10 +61,15 @@
6262 return false;
6363 }
6464
65 - function formatResult( $skin, $result ) {
 65+ function formatResult( $result, $old = null ) {
 66+ if($old) { // pre-1.9
 67+ $skin = $result;
 68+ $result = $old;
 69+ }
6670 global $wgLang;
6771 $title = Title::makeTitle( SMW_NS_RELATION, $result->title );
68 - return $skin->makeLinkObj( $title, $title->getText() );
 72+ return $old ? $skin->makeLinkObj( $title, $title->getText() )
 73+ : Linker::makeLinkObj( $title, $title->getText() );
6974 }
7075 }
7176
@@ -99,4 +104,4 @@
100105
101106
102107 }
103 -?>
\ No newline at end of file
 108+?>
Index: trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialAttributes.php
@@ -53,11 +53,16 @@
5454 return false;
5555 }
5656
57 - function formatResult( $skin, $result ) {
 57+ function formatResult( $result, $old = null ) {
 58+ if($old) { // pre-1.9
 59+ $skin = $result;
 60+ $result = $old;
 61+ }
5862 global $wgLang, $wgExtraNamespaces;
5963 // The attribute title is in value, see getSQL().
6064 $attrtitle = Title::makeTitle( SMW_NS_ATTRIBUTE, $result->value );
61 - $attrlink = $skin->makeLinkObj( $attrtitle, $attrtitle->getText() );
 65+ $attrlink = $old ? $skin->makeLinkObj( $attrtitle, $attrtitle->getText() )
 66+ : Linker::makeLinkObj( $attrtitle, $attrtitle->getText() );
6267 // The value_datatype is in title, see getSQL().
6368 if (strncmp($result->title, $wgExtraNamespaces[SMW_NS_TYPE], count($wgExtraNamespaces[SMW_NS_TYPE])) == 0) {
6469 // The value_datatype is a Type: page name.
@@ -72,10 +77,10 @@
7378 $typetitle = NULL;
7479 }
7580 }
76 - $typelink = $skin->makeLinkObj( $typetitle);
 81+ $typelink = $old ? $skin->makeLinkObj( $typetitle ) : Linker::makeLinkObj( $typetitle );
7782 // Note: It doesn't seem possible to reuse this infolink object.
7883 $searchlink = new SMWInfolink(
79 - SMWInfolink::makeAttributeSearchURL($attrtitle->getText(),'',$skin),
 84+ SMWInfolink::makeAttributeSearchURL($attrtitle->getText(),''),
8085 '+','smwsearch');
8186
8287 return "$attrlink ($result->count)" . wfMsg('smw_attr_type_join', $typelink) . ' ' . $searchlink->getHTML();
@@ -92,4 +97,4 @@
9398 SpecialPage::addPage( new SpecialPage('Attributes','',true,'doSpecialAttributes',false) );
9499 }
95100
96 -?>
\ No newline at end of file
 101+?>
Index: trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialUnusedAttributes.php
@@ -60,10 +60,15 @@
6161 return false;
6262 }
6363
64 - function formatResult( $skin, $result ) {
 64+ function formatResult( $result, $old = null ) {
 65+ if($old) { // pre-1.9
 66+ $skin = $result;
 67+ $result = $old;
 68+ }
6569 global $wgLang;
6670 $title = Title::makeTitle( SMW_NS_ATTRIBUTE, $result->title );
67 - return $skin->makeLinkObj( $title, $title->getText() );
 71+ return $old ? $skin->makeLinkObj( $title, $title->getText() )
 72+ : Linker::makeLinkObj( $title, $title->getText() );
6873 }
6974 }
7075
@@ -77,4 +82,4 @@
7883 SpecialPage::addPage( new SpecialPage('UnusedAttributes','',true,'doSpecialUnsusedAttributes',false) );
7984 }
8085
81 -?>
\ No newline at end of file
 86+?>
Index: trunk/extensions/SemanticMediaWiki/specials/Relations/SMW_SpecialRelations.php
@@ -53,13 +53,18 @@
5454 return false;
5555 }
5656
57 - function formatResult( $skin, $result ) {
 57+ function formatResult( $result, $old = null ) {
 58+ if($old) { // pre-1.9
 59+ $skin = $result;
 60+ $result = $old;
 61+ }
5862 global $wgLang;
5963 $title = Title::makeTitle( SMW_NS_RELATION, $result->title );
60 - $rlink = $skin->makeLinkObj( $title, $title->getText() );
 64+ $rlink = $old ? $skin->makeLinkObj( $title, $title->getText() )
 65+ : Linker::makeLinkObj( $title, $title->getText() );
6166 // Note: It doesn't seem possible to reuse this infolink object.
6267 $searchlink = new SMWInfolink(
63 - SMWInfolink::makeRelationSearchURL($title->getText(),'',$skin),
 68+ SMWInfolink::makeRelationSearchURL($title->getText(),''),
6469 '+','smwsearch');
6570
6671 return "$rlink ($result->count) " . $searchlink->getHTML();
@@ -77,4 +82,4 @@
7883 SpecialPage::addPage( new SpecialPage('Relations','',true,'doSpecialRelations',false) );
7984 }
8085
81 -?>
\ No newline at end of file
 86+?>
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php
@@ -324,9 +324,9 @@
325325 * @access public
326326 * @static
327327 */
328 - static function makeAttributeSearchURL($attribute,$value,$skin) {
 328+ static function makeAttributeSearchURL($attribute,$value) {
329329 global $wgServer;
330 - return $wgServer . $skin->makeSpecialUrl('SearchTriple','attribute=' . urlencode($attribute) . '&value=' . urlencode($value) . '&do=' . urlencode('Search Attributes'));
 330+ return $wgServer . Skin::makeSpecialUrl('SearchTriple','attribute=' . urlencode($attribute) . '&value=' . urlencode($value) . '&do=' . urlencode('Search Attributes'));
331331 }
332332
333333 /**
@@ -334,9 +334,9 @@
335335 * @access public
336336 * @static
337337 */
338 - static function makeRelationSearchURL($relation,$object,$skin) {
 338+ static function makeRelationSearchURL($relation,$object) {
339339 global $wgServer;
340 - return $wgServer . $skin->makeSpecialUrl('SearchTriple','relation=' . urlencode($relation) . '&object=' . urlencode($object) . '&do=' . urlencode('Search Relations'));
 340+ return $wgServer . Skin::makeSpecialUrl('SearchTriple','relation=' . urlencode($relation) . '&object=' . urlencode($object) . '&do=' . urlencode('Search Relations'));
341341 }
342342
343343 /**
Index: trunk/extensions/LinkSearch/LinkSearch.php
@@ -75,12 +75,16 @@
7676 AND el_index LIKE $encSearch";
7777 }
7878
79 - function formatResult( $skin, $result ) {
 79+ function formatResult( $result, $old = null ) {
 80+ if($old) { // pre-1.9
 81+ $skin = $result;
 82+ $result = $old;
 83+ }
8084 $title = Title::makeTitle( $result->namespace, $result->title );
8185 $url = $result->url;
8286
83 - $pageLink = $skin->makeKnownLinkObj( $title );
84 - $urlLink = $skin->makeExternalLink( $url, $url );
 87+ $pageLink = $old ? $skin->makeKnownLinkObj( $title ) : Linker::makeKnownLinkObj( $title );
 88+ $urlLink = $old ? $skin->makeExternalLink( $url, $url ) : Linker::makeExternalLink( $url, $url );
8589
8690 return wfMsgHtml( 'linksearch-line', $urlLink, $pageLink );
8791 }
Index: trunk/extensions/CrossNamespaceLinks/SpecialCrossNamespaceLinks_body.php
@@ -102,13 +102,18 @@
103103
104104 function sortDescending() { return false; }
105105
106 - function formatResult( $skin, $result ) {
 106+ function formatResult( $result, $old = null ) {
 107+ if($old) { // pre-1.9
 108+ $skin = $result;
 109+ $result = $old;
 110+ }
107111 global $wgContLang, $wgLang;
108112
109113 $nt = Title::makeTitle( NS_MAIN, $result->title );
110114 $text = $wgContLang->convert( $nt->getPrefixedText() );
111115
112 - $plink = $skin->makeKnownLink( $nt->getPrefixedText(), htmlspecialchars( $text ) );
 116+ $plink = $old ? $skin->makeKnownLink( $nt->getPrefixedText(), htmlspecialchars( $text ) )
 117+ : Linker::makeKnownLink( $nt->getPrefixedText(), htmlspecialchars( $text ) );
113118
114119 return wfMsgExt( 'crossnamespacelinkstext', array( 'parsemag' ), $plink, $wgLang->formatNum( $result->namespace ), htmlspecialchars( $wgLang->getNsText( $result->value ) ) );
115120 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r17484Reverting 17479/17480, breaks subclassing of Linker methods by skins. See my ...tstarling07:12, 8 November 2006

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r17479* (bug 7405) Make Linker methods static. Patch by Dan Li.nickj05:21, 8 November 2006