Topic on User talk:Magnus Manske

Jump to navigation Jump to search

QuickStatement doesn't seems to support amount[lower,upper] syntax

2
Ghuron (talkcontribs)

None of examples provided in Help:QuickStatements#Add_simple_statement seems to work except for 1.2~0.3 (which doesn't work very well because of fp errors). I also cannot find corresponding code in quickstatements.php either. It should be quite trivial to implement, do you want me to submit patch?

Ghuron (talkcontribs)

Something like

                if ( preg_match ( '/^([\+\-]{0,1}\d+(\.\d+){0,1})\[([\+\-]{0,1}\d+(\.\d+){0,1}),([\+\-]{0,1}\d+(\.\d+){0,1})\](U(\d+)){0,1}$/' , $v , $m ) ) { // Quantity with bounds
                        if ( count($m) == 7 )
                                if ( 1*$m[3] < 1*$m[1] && 1*$m[1] < $m[5] ) {
                                        $cmd['datavalue'] = array ( "type"=>"quantity" , "value"=>array(
                                                "amount" => $m[1],
                                                "upperBound" => $m[5],
                                                "lowerBound" => $m[3] ,
                                        "unit" => isset( $m[6] ) ? "http://www.wikidata.org/entity/Q{$m[6]}" : "1"
                                        ) ) ;
                                        return true ;
                                }
                }
Reply to "QuickStatement doesn't seems to support amount[lower,upper] syntax"