r81764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81763‎ | r81764 | r81765 >
Date:17:20, 8 February 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r81762
Modified paths:
  • /trunk/extensions/SemanticResultFormats/TagCloud/SRF_TagCloud.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/TagCloud/SRF_TagCloud.php
@@ -1,6 +1,7 @@
22 <?php
 3+
34 /**
4 - * Print query results as a tag cloud.
 5+ * Result printer that prints query results as a tag cloud.
56 *
67 * @since 1.5.3
78 *
@@ -10,12 +11,6 @@
1112 * @licence GNU GPL v3
1213 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1314 */
14 -
15 -if ( !defined( 'MEDIAWIKI' ) ) die();
16 -
17 -/**
18 - * Result printer that prints query results as a tag cloud.
19 - */
2015 class SRFTagCloud extends SMWResultPrinter {
2116
2217 public function getName() {
@@ -29,25 +24,50 @@
3025 }
3126
3227 public function getResultText( /* SMWQueryResult */ $results, $outputmode ) {
33 - return $this->getTagCloud( $this->getTags( $results ) );
 28+ return $this->getTagCloud( $this->getTags( $results, $outputmode ) );
3429 }
3530
36 - protected function getTags( SMWQueryResult $results ) {
 31+ /**
 32+ * Returns an array with the tags (keys) and the number of times they occur (values).
 33+ *
 34+ * @since 1.5.3
 35+ *
 36+ * @param SMWQueryResult $results
 37+ * @param $outputmode
 38+ *
 39+ * @return array
 40+ */
 41+ protected function getTags( SMWQueryResult $results, $outputmode ) {
3742 $tags = array();
3843
3944 while ( /* array of SMWResultArray */ $row = $results->getNext() ) { // Objects (pages)
4045 for ( $i = 0, $n = count( $row ); $i < $n; $i++ ) { // Properties
4146 while ( ( $obj = $row[$i]->getNextObject() ) !== false ) { // Property values
42 - if ( $obj->getTypeID() == '_wpg' ) {
43 - $images[] = $obj->getTitle();
44 - }
 47+ $value = $obj->getTypeID() == '_wpg' ? $obj->getTitle()->getText() : $obj->getShortText( $outputmode );
 48+
 49+ if ( !array_key_exists( $value, $tags ) ) {
 50+ $tags[$value] = 0;
 51+ }
 52+
 53+ $tags[$value]++;
4554 }
4655 }
4756 }
 57+
 58+ return $tags;
4859 }
4960
 61+ /**
 62+ * Returns the HTML for the tag cloud.
 63+ *
 64+ * @since 1.5.3
 65+ *
 66+ * @param array $tags
 67+ *
 68+ * @return string
 69+ */
5070 protected function getTagCloud( array $tags ) {
51 -
 71+ return '';
5272 }
5373
5474 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81762Added some stuffjeroendedauw16:55, 8 February 2011

Status & tagging log