r81798 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81797‎ | r81798 | r81799 >
Date:23:52, 8 February 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Proper linking implementation
Modified paths:
  • /trunk/extensions/SemanticResultFormats/SRF_Messages.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/TagCloud/SRF_TagCloud.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/TagCloud/SRF_TagCloud.php
@@ -20,6 +20,8 @@
2121 protected $maxTags;
2222 protected $minTagSize;
2323
 24+ protected $tagsHtml = array();
 25+
2426 public function getName() {
2527 return wfMsg( 'srf_printername_tagcloud' );
2628 }
@@ -39,12 +41,6 @@
4042
4143 $this->includeName = $params['includename'] == 'yes';
4244
43 - if ( !array_key_exists( 'linkpages', $params ) || !in_array( $params['linkpages'], array( 'yes', 'no' ) ) ) {
44 - $params['linkpages'] = 'yes';
45 - }
46 -
47 - $this->linkPages = $params['linkpages'] == 'yes';
48 -
4945 if ( !array_key_exists( 'increase', $params ) || !in_array( $params['increase'], array( 'linear', 'log' ) ) ) {
5046 $params['increase'] = 'log';
5147 }
@@ -101,10 +97,7 @@
10298 * @return array
10399 */
104100 protected function getTags( SMWQueryResult $results, $outputmode ) {
105 - global $wgUser;
106 -
107101 $tags = array();
108 - $skin = $wgUser->getSkin();
109102
110103 while ( /* array of SMWResultArray */ $row = $results->getNext() ) { // Objects (pages)
111104 for ( $i = 0, $n = count( $row ); $i < $n; $i++ ) { // Properties
@@ -118,14 +111,17 @@
119112
120113 // Get the HTML for the tag content. Pages are linked, other stuff is just plaintext.
121114 if ( $obj->getTypeID() == '_wpg' ) {
122 - $value = $this->linkPages ? $obj->getLongText( $outputmode, $skin ) : $obj->getTitle()->getText();
 115+ $value = $obj->getTitle()->getText();
 116+ $html = $obj->getLongText( $outputmode, $this->getLinker( method_exists( $obj, 'isMainObject' ) && $obj->isMainObject() ) );
123117 }
124118 else {
125 - $value = $obj->getShortText( $outputmode, $skin );
 119+ $html = $obj->getShortText( $outputmode, $this->getLinker( false ) );
 120+ $value = $html;
126121 }
127122
128123 if ( !array_key_exists( $value, $tags ) ) {
129124 $tags[$value] = 0;
 125+ $this->tagsHtml[$value] = $html; // Store the HTML separetely, so sorting can be done easily.
130126 }
131127
132128 $tags[$value]++;
@@ -251,7 +247,7 @@
252248 $htmlTags[] = Html::rawElement(
253249 'span',
254250 array( 'style' => "font-size:$size%" ),
255 - $name
 251+ $this->tagsHtml[$name]
256252 );
257253 }
258254
@@ -273,7 +269,6 @@
274270 $params = parent::getParameters();
275271
276272 $params[] = array( 'name' => 'includename', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_includename' ), 'values' => array( 'yes', 'no' ) );
277 - $params[] = array( 'name' => 'linkpages', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_linkpages' ), 'values' => array( 'yes', 'no' ) );
278273 $params[] = array( 'name' => 'increase', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_increase' ), 'values' => array( 'linear', 'log' ) );
279274 $params[] = array( 'name' => 'tagorder', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_tagorder' ), 'values' => array( 'alphabetic', 'asc', 'desc', 'random', 'unchanged' ) );
280275
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php
@@ -81,7 +81,6 @@
8282 // "tagcloud" format
8383 'srf_printername_tagcloud' => 'Tag cloud',
8484 'srf_paramdesc_includename' => 'If the names of the object themselves should be included',
85 - 'srf_paramdesc_linkpages' => 'If pages should be linked',
8685 'srf_paramdesc_increase' => 'How to increase the size of tags',
8786 'srf_paramdesc_tagorder' => 'The order of the tags',
8887 'srf_paramdesc_mincount' => 'The minimum amount of times a value needs to occur to be listed',

Status & tagging log