r88257 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88256‎ | r88257 | r88258 >
Date:19:05, 16 May 2011
Author:kipcool
Status:deferred
Tags:
Comment:
Added annotation statistics
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialOWStatistics.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -1593,24 +1593,20 @@
15941594
15951595 list( $definingExpressionId, $definingExpression, $definingExpressionLanguage ) = definingExpressionRow( $definedMeaningId );
15961596
1597 - if ( $definingExpressionLanguage == $userLanguageId && expressionIsBoundToDefinedMeaning( $definedMeaningId, $definingExpressionId ) )
1598 - return $definingExpression;
1599 - else {
1600 - if ( $userLanguageId > 0 )
1601 - $result = definedMeaningExpressionForLanguage( $definedMeaningId, $userLanguageId );
1602 - else
1603 - $result = "";
 1597+ if ( $userLanguageId > 0 )
 1598+ $result = definedMeaningExpressionForLanguage( $definedMeaningId, $userLanguageId );
 1599+ else
 1600+ $result = "";
 1601+
 1602+ if ( $result == "" ) {
 1603+ // if no expression exists for the specified language : look for an expression in English
 1604+ $result = definedMeaningExpressionForLanguage( $definedMeaningId, 85 );
16041605
16051606 if ( $result == "" ) {
1606 - // if no expression exists for the specified language : look for an expression in English
1607 - $result = definedMeaningExpressionForLanguage( $definedMeaningId, 85 );
 1607+ $result = definedMeaningExpressionForAnyLanguage( $definedMeaningId );
16081608
1609 - if ( $result == "" ) {
1610 - $result = definedMeaningExpressionForAnyLanguage( $definedMeaningId );
1611 -
1612 - if ( $result == "" )
1613 - $result = $definingExpression;
1614 - }
 1609+ if ( $result == "" )
 1610+ $result = $definingExpression;
16151611 }
16161612 }
16171613
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialOWStatistics.php
@@ -20,7 +20,8 @@
2121 . $this->linkHeader ( wfMsg('ow_DefinedMeaning'), "dm", $showstat ) . " — "
2222 . $this->linkHeader ( wfMsg('ow_Definition'), "def", $showstat ) . " — "
2323 . $this->linkHeader ( wfMsg('ow_Expression'), "exp", $showstat ) . " — "
24 - . $this->linkHeader ( "Syntrans", "syntrans", $showstat )
 24+ . $this->linkHeader ( "Syntrans", "syntrans", $showstat ) . " — "
 25+ . $this->linkHeader ( wfMsg('ow_Annotation'), "annot", $showstat )
2526 . "</big></div><br /><br />" ;
2627
2728 $wgOut->addHTML( $headerText ) ;
@@ -33,6 +34,8 @@
3435 $wgOut->addHTML( $this->getSyntransPerLanguage () );
3536 else if ( $showstat == 'exp' )
3637 $wgOut->addHTML ( $this->getExpressionPerLanguage () ) ;
 38+ else if ( $showstat == 'annot' )
 39+ $wgOut->addHTML ( $this->getAnnotationStats () ) ;
3740 }
3841
3942 function linkHeader ( $text, $val , $showstat ) {
@@ -251,4 +254,33 @@
252255 return $output ;
253256 }
254257
 258+ function getAnnotationStats () {
 259+ $dc = wdGetDataSetContext();
 260+ $dbr = wfGetDB( DB_SLAVE );
 261+
 262+ // at the moment only link attributes
 263+ $sql = "SELECT attribute_mid, count(DISTINCT value_id) as tot ";
 264+ $sql .= " FROM {$dc}_url_attribute_values" ;
 265+ $sql .= " WHERE remove_transaction_id IS NULL " ;
 266+ $sql .= " group by attribute_mid " ;
 267+
 268+ $queryResult = $dbr->query( $sql );
 269+
 270+ while ( $row = $dbr->fetchObject( $queryResult ) ) {
 271+ $att = $row->attribute_mid ;
 272+ $nbAtt[$att] = $row->tot ;
 273+ }
 274+ arsort ( $nbAtt ) ;
 275+
 276+ $table = "<center><table class=\"sortable\">" ;
 277+ $table .= "<tr><th><b>" . wfMsg('ow_Annotation') . "</b></th><th><b>" . '#' . "</b></th></tr>\n";
 278+ foreach ($nbAtt as $att => $nb) {
 279+ $attname = definedMeaningExpression ( $att ) ;
 280+ if ( $attname == "" ) $attname = $att ;
 281+ $table .= "<tr><td alt=$att>$attname</td><td align=right>$nb</td></tr>\n" ;
 282+ }
 283+ $table .= "</table></center>" ;
 284+ $output = "<p>$table</p>" ;
 285+ return $output ;
 286+ }
255287 }

Status & tagging log