http://www.mediawiki.org/wiki/Special:Code/MediaWiki/67007

Revision: 67007
Author:   mkroetzsch
Date:     2010-05-28 13:17:07 +0000 (Fri, 28 May 2010)

Log Message:
-----------
allow the use of "-n" and "-u" for getting only the number or only the unit 
string of some property value in query results (relates to Bug 23679)

Modified Paths:
--------------
    trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Linear.php
    trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php

Modified: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Linear.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Linear.php       
2010-05-28 13:16:40 UTC (rev 67006)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Linear.php       
2010-05-28 13:17:07 UTC (rev 67007)
@@ -131,10 +131,16 @@
                        $printunit = $unit;
                }
 
-               $this->m_caption = ( $this->m_outformat != '-' ? 
smwfNumberFormat( $value ) : $value );
-               if ( $printunit != '' ) {
-                       $this->m_caption .= ( $this->m_outformat != '-' ? 
' ' : ' ' ) . $printunit;
+               $this->m_caption = '';
+               if ( $this->m_outformat != '-u' ) { // -u is the format for 
displaying the unit only
+                       $this->m_caption .= ( ( $this->m_outformat != '-' ) && 
( $this->m_outformat != '-n' ) ? smwfNumberFormat( $value ) : $value );
                }
+               if ( ( $printunit != '' ) && ( $this->m_outformat != '-n' ) ) { 
// -n is the format for displaying the number only
+                       if ( $this->m_outformat != '-u' ) {
+                               $this->m_caption .=  ( $this->m_outformat != 
'-' ? ' ' : ' ' );
+                       }
+                       $this->m_caption .= $printunit;
+               }
                $this->m_wikivalue = $this->m_caption;
                $this->m_unitin = $unit;
        }

Modified: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php       
2010-05-28 13:16:40 UTC (rev 67006)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Number.php       
2010-05-28 13:17:07 UTC (rev 67007)
@@ -94,7 +94,7 @@
 
        public function getShortWikiText( $linked = null ) {
                $this->unstub();
-               if ( ( $linked === null ) || ( $linked === false ) || ( 
$this->m_outformat == '-' ) ) {
+               if ( ( $linked === null ) || ( $linked === false ) || ( 
$this->m_outformat == '-' ) || ( $this->m_outformat == '-u' ) || ( 
$this->m_outformat == '-n' ) ) {
                        return $this->m_caption;
                }
                $this->makeConversionValues();
@@ -273,10 +273,16 @@
         */
        protected function makeUserValue() {
                $this->convertToMainUnit();
-               $this->m_caption = ( $this->m_outformat != '-' ? 
smwfNumberFormat( $this->m_value ) : $this->m_value );
-               if ( $this->m_unit != '' ) {
-                       $this->m_caption .= ( $this->m_outformat != '-' ? 
' ' : ' ' ) . $this->m_unit;
+               $this->m_caption = '';
+               if ( $this->m_outformat != '-u' ) { // -u is the format for 
displaying the unit only
+                       $this->m_caption .= ( ( $this->m_outformat != '-' ) && 
( $this->m_outformat != '-n' ) ? smwfNumberFormat( $this->m_value ) : 
$this->m_value );
                }
+               if ( ( $this->m_unit != '' ) && ( $this->m_outformat != '-n' ) 
) { // -n is the format for displaying the number only
+                       if ( $this->m_outformat != '-u' ) {
+                               $this->m_caption .=  ( $this->m_outformat != 
'-' ? ' ' : ' ' );
+                       }
+                       $this->m_caption .= $this->m_unit;
+               }
                $this->m_wikivalue = $this->m_caption;
                $this->m_unitin = $this->m_unit;
        }



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to