Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -1593,24 +1593,20 @@ |
1594 | 1594 | |
1595 | 1595 | list( $definingExpressionId, $definingExpression, $definingExpressionLanguage ) = definingExpressionRow( $definedMeaningId ); |
1596 | 1596 | |
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 ); |
1604 | 1605 | |
1605 | 1606 | 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 ); |
1608 | 1608 | |
1609 | | - if ( $result == "" ) { |
1610 | | - $result = definedMeaningExpressionForAnyLanguage( $definedMeaningId ); |
1611 | | - |
1612 | | - if ( $result == "" ) |
1613 | | - $result = $definingExpression; |
1614 | | - } |
| 1609 | + if ( $result == "" ) |
| 1610 | + $result = $definingExpression; |
1615 | 1611 | } |
1616 | 1612 | } |
1617 | 1613 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialOWStatistics.php |
— | — | @@ -20,7 +20,8 @@ |
21 | 21 | . $this->linkHeader ( wfMsg('ow_DefinedMeaning'), "dm", $showstat ) . " — " |
22 | 22 | . $this->linkHeader ( wfMsg('ow_Definition'), "def", $showstat ) . " — " |
23 | 23 | . $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 ) |
25 | 26 | . "</big></div><br /><br />" ; |
26 | 27 | |
27 | 28 | $wgOut->addHTML( $headerText ) ; |
— | — | @@ -33,6 +34,8 @@ |
34 | 35 | $wgOut->addHTML( $this->getSyntransPerLanguage () ); |
35 | 36 | else if ( $showstat == 'exp' ) |
36 | 37 | $wgOut->addHTML ( $this->getExpressionPerLanguage () ) ; |
| 38 | + else if ( $showstat == 'annot' ) |
| 39 | + $wgOut->addHTML ( $this->getAnnotationStats () ) ; |
37 | 40 | } |
38 | 41 | |
39 | 42 | function linkHeader ( $text, $val , $showstat ) { |
— | — | @@ -251,4 +254,33 @@ |
252 | 255 | return $output ; |
253 | 256 | } |
254 | 257 | |
| 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 | + } |
255 | 287 | } |