Hi,

using SMW 1.6 alpha (r91069) 

I have the property [[NameId::Name2;Source2]] defined for the record
property NameId
Using an #ask query I get a result which looks like this:  Source2
(Source2) instead of the correct result: Name2 (Source2)

The reason is, as far as I can see, the following:

in file
SemanticMediaWiki/includes/queryprinters/datavalues/SMW_DV_Record.php

        protected function makeOutputText( $type = 0, $linker = null ) {
                if ( !$this->isValid() ) {
                        return ( ( $type == 0 ) || ( $type == 1 ) ) ? '' :
$this->getErrorText();
                }

                $result = '';
                $i = 0;

                foreach ( $this->getPropertyDataItems() as
$propertyDataItem ) {
                        if ( $i == 1 ) {
                                $result .= ( $type == 4 ) ? '; ' : ' (';
                        } elseif ( $i > 1 ) {
                                $result .= ( $type == 4 ) ? '; ' : ', ';
                        }
                        ++$i;
                        $propertyValues =
$this->m_dataitem->getSemanticData()->getPropertyValues( $propertyDataItem
); // combining this with next line violates PHP strict standards
                        $dataItem = reset( $propertyValues );

                        if ( $dataItem !== false ) {
                                $dataValue =
SMWDataValueFactory::newDataItemValue( $dataItem, $propertyDataItem );
                                $result .= $this->makeValueOutputText(
$type, $dataValue, $linker );
                        } else {
                                $result .= '?';
                        }
                }
                if ( ( $i > 1 ) && ( $type != 4 ) ) $result .= ')';

                return $result;
        }

I get for $propertyValues the following array returned
 Array ( [Source2] => SMWDIString Object ( [m_string:protected] => Source2
) [Name2] => SMWDIString Object ( [m_string:protected] => Name2 ) ) 

Due to the line '$dataItem = reset( $propertyValues );' $dataItem is
always set to the first element in the array, which is 'Source2'


The following change works better:

                       ++$i;
                       $propertyValues =
$this->m_dataitem->getSemanticData()->getPropertyValues( $propertyDataItem
); // combining this with next line violates PHP strict standards
                       $dataItem = reset( $propertyValues );
>>> add a for loop
                       for ($j=1; $j<$i; $j++)
                            $dataItem = next( $propertyValues );
>>> end of addition

                       if ( $dataItem !== false ) {


It gives the result: Source2 (Name2) 
which at least shows correctly all fields of this (and all other tested)
record property.

However, the displayed order of the fields of such record properties is
still random, so in this example it really should be: 'Name2 (Source2)' to
reflect the original property (probably related to my last email about the
loss of the field ordering information for record properties in the DB
table atts2).

Is this a bug or is my SMW 1.6 setup somehow corrupt?

Cheers,
Gu


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to