Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -398,7 +398,7 @@ |
399 | 399 | * @param string $comparator |
400 | 400 | */ |
401 | 401 | static protected function prepareValue( &$value, &$comparator ) { |
402 | | - global $smwgQComparators; |
| 402 | + global $smwgQComparators, $smwStrictComparators; |
403 | 403 | |
404 | 404 | $list = preg_split( '/^(' . $smwgQComparators . ')/u', $value, 2, PREG_SPLIT_DELIM_CAPTURE ); |
405 | 405 | $comparator = SMW_CMP_EQ; |
— | — | @@ -408,10 +408,10 @@ |
409 | 409 | |
410 | 410 | switch ( $list[1] ) { |
411 | 411 | case '<': |
412 | | - $comparator = SMW_CMP_LEQ; |
| 412 | + $comparator = $smwStrictComparators ? SMW_CMP_LESS : SMW_CMP_LEQ; |
413 | 413 | break; |
414 | 414 | case '>': |
415 | | - $comparator = SMW_CMP_GEQ; |
| 415 | + $comparator = $smwStrictComparators ? SMW_CMP_GRTR : SMW_CMP_GEQ; |
416 | 416 | break; |
417 | 417 | case '!': |
418 | 418 | $comparator = SMW_CMP_NEQ; |
— | — | @@ -422,6 +422,12 @@ |
423 | 423 | case '!~': |
424 | 424 | $comparator = SMW_CMP_NLKE; |
425 | 425 | break; |
| 426 | + case '>=': |
| 427 | + $comparator = SMW_CMP_GEQ; |
| 428 | + break; |
| 429 | + case '<=': |
| 430 | + $comparator = SMW_CMP_LEQ; |
| 431 | + break; |
426 | 432 | // default: not possible |
427 | 433 | } |
428 | 434 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -386,16 +386,21 @@ |
387 | 387 | |
388 | 388 | public function getQueryString( $asvalue = false ) { |
389 | 389 | if ( $this->m_datavalue !== null ) { |
| 390 | + global $smwStrictComparators; |
| 391 | + |
390 | 392 | switch ( $this->m_comparator ) { |
391 | | - case SMW_CMP_LEQ: $comparator = '<'; break; |
392 | | - case SMW_CMP_GEQ: $comparator = '>'; break; |
| 393 | + case SMW_CMP_LEQ: $comparator = $smwStrictComparators ? '<=' : '<'; break; |
| 394 | + case SMW_CMP_GEQ: $comparator = $smwStrictComparators ? '>=' : '>'; break; |
393 | 395 | case SMW_CMP_NEQ: $comparator = '!'; break; |
394 | 396 | case SMW_CMP_LIKE: $comparator = '~'; break; |
395 | 397 | case SMW_CMP_NLKE: $comparator = '!~'; break; |
| 398 | + case SMW_CMP_LESS: $comparator = '<'; break; |
| 399 | + case SMW_CMP_GRTR: $comparator = '>'; break; |
396 | 400 | default: case SMW_CMP_EQ: |
397 | 401 | $comparator = ''; |
398 | 402 | break; |
399 | 403 | } |
| 404 | + |
400 | 405 | if ( $asvalue ) { |
401 | 406 | return $comparator . $this->m_datavalue->getWikiValue(); |
402 | 407 | } else { // this only is possible for values of Type:Page |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -500,6 +500,8 @@ |
501 | 501 | switch ( $description->getComparator() ) { |
502 | 502 | case SMW_CMP_LEQ: $comp = '<='; break; |
503 | 503 | case SMW_CMP_GEQ: $comp = '>='; break; |
| 504 | + case SMW_CMP_LESS: $comp = '<'; break; |
| 505 | + case SMW_CMP_GRTR: $comp = '>'; break; |
504 | 506 | case SMW_CMP_NEQ: $comp = '!='; break; |
505 | 507 | case SMW_CMP_LIKE: case SMW_CMP_NLKE: |
506 | 508 | $comp = ' LIKE '; |
— | — | @@ -507,7 +509,6 @@ |
508 | 510 | $value = str_replace( array( '%', '_', '*', '?' ), array( '\%', '\_', '%', '_' ), $value ); |
509 | 511 | break; |
510 | 512 | } |
511 | | - |
512 | 513 | $query->where = "$query->alias.smw_sortkey$comp" . $this->m_dbs->addQuotes( $value ); |
513 | 514 | } |
514 | 515 | } |
— | — | @@ -767,8 +768,10 @@ |
768 | 769 | |
769 | 770 | switch ( $description->getComparator() ) { |
770 | 771 | case SMW_CMP_EQ: $comparator = '='; break; |
| 772 | + case SMW_CMP_LESS: $comparator = '<'; break; |
| 773 | + case SMW_CMP_GRTR: $comparator = '>'; break; |
771 | 774 | case SMW_CMP_LEQ: $comparator = '<='; break; |
772 | | - case SMW_CMP_GEQ: $comparator = '>='; break; |
| 775 | + case SMW_CMP_GEQ: $comparator = '>='; break; |
773 | 776 | case SMW_CMP_NEQ: $comparator = '!='; break; |
774 | 777 | case SMW_CMP_LIKE: case SMW_CMP_NLKE: |
775 | 778 | $comparator = ' LIKE '; |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -54,6 +54,8 @@ |
55 | 55 | define( 'SMW_CMP_NEQ', 4 ); // Matches only datavalues that are unequal to the given value. |
56 | 56 | define( 'SMW_CMP_LIKE', 5 ); // Matches only datavalues that are LIKE the given value. |
57 | 57 | define( 'SMW_CMP_NLKE', 6 ); // Matches only datavalues that are not LIKE the given value. |
| 58 | +define( 'SMW_CMP_LESS', 7 ); // Matches only datavalues that are less than the given value. |
| 59 | +define( 'SMW_CMP_GRTR', 8 ); // Matches only datavalues that are greater than the given value. |
58 | 60 | |
59 | 61 | // Constants for date formats (using binary encoding of nine bits: 3 positions x 3 interpretations). |
60 | 62 | define( 'SMW_MDY', 785 ); // Month-Day-Year |
Index: trunk/extensions/SemanticMediaWiki/SMW_Settings.php |
— | — | @@ -198,19 +198,28 @@ |
199 | 199 | * List of comparator characters supported by queries, separated by '|', for use in a regex. |
200 | 200 | * |
201 | 201 | * Available entries: |
202 | | - * < (smaller than) |
203 | | - * < (greater than) |
| 202 | + * < (smaller than) if $smwStrictComparators is false, it's actually smaller than or equal to |
| 203 | + * > (greater than) if $smwStrictComparators is false, it's actually bigger than or equal to |
204 | 204 | * ! (unequal to) |
205 | 205 | * ~ (pattern with '*' as wildcard, only for Type:String) |
206 | 206 | * !~ (not a pattern with '*' as wildcard, only for Type:String, need to be placed before ! and ~ to work correctly) |
| 207 | + * <= (smaller than or equal to) |
| 208 | + * >= (greater than or equal to) |
207 | 209 | * |
208 | 210 | * If unsupported comparators are used, they are treated as part of the queried value |
209 | 211 | * |
210 | 212 | * @var string |
211 | 213 | */ |
212 | | -$smwgQComparators = '<|>|!~|!|~'; |
| 214 | +$smwgQComparators = '<|>|!~|!|~|<=|>='; |
213 | 215 | |
214 | 216 | ### |
| 217 | +# Sets whether the > and < comparators should be strict or not. If they are strict, |
| 218 | +# values that are equal will not be accepted. |
| 219 | +## |
| 220 | +$smwStrictComparators = false; |
| 221 | +## |
| 222 | + |
| 223 | +### |
215 | 224 | # Further settings for queries. The following settings affect inline queries |
216 | 225 | # and querying special pages. Essentially they should mirror the kind of |
217 | 226 | # queries that should immediately be answered by the wiki, using whatever |