Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -294,15 +294,19 @@ |
295 | 295 | */ |
296 | 296 | static protected function prepareValue( &$value, &$comparator ) { |
297 | 297 | global $smwgQComparators; |
| 298 | + |
298 | 299 | $list = preg_split( '/^(' . $smwgQComparators . ')/u', $value, 2, PREG_SPLIT_DELIM_CAPTURE ); |
299 | 300 | $comparator = SMW_CMP_EQ; |
| 301 | + |
300 | 302 | if ( count( $list ) == 3 ) { // initial comparator found ($list[0] should be empty) |
301 | 303 | $value = $list[2]; |
| 304 | + |
302 | 305 | switch ( $list[1] ) { |
303 | 306 | case '<': $comparator = SMW_CMP_LEQ; break; |
304 | 307 | case '>': $comparator = SMW_CMP_GEQ; break; |
305 | 308 | case '!': $comparator = SMW_CMP_NEQ; break; |
306 | 309 | case '~': $comparator = SMW_CMP_LIKE; break; |
| 310 | + case '!~': $comparator = SMW_CMP_NLKE; break; |
307 | 311 | // default: not possible |
308 | 312 | } |
309 | 313 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -378,6 +378,7 @@ |
379 | 379 | case SMW_CMP_GEQ: $comparator = '>'; break; |
380 | 380 | case SMW_CMP_NEQ: $comparator = '!'; break; |
381 | 381 | case SMW_CMP_LIKE: $comparator = '~'; break; |
| 382 | + case SMW_CMP_NLKE: $comparator = '!~'; break; |
382 | 383 | default: case SMW_CMP_EQ: |
383 | 384 | $comparator = ''; |
384 | 385 | break; |
— | — | @@ -388,7 +389,7 @@ |
389 | 390 | return '[[' . $comparator . $this->m_datavalue->getWikiValue() . ']]'; |
390 | 391 | } |
391 | 392 | } else { |
392 | | - return $asvalue ? '+':''; // the else case may result in an error here (query without proper condition) |
| 393 | + return $asvalue ? '+' : ''; // the else case may result in an error here (query without proper condition) |
393 | 394 | } |
394 | 395 | } |
395 | 396 | |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -469,8 +469,9 @@ |
470 | 470 | case SMW_CMP_LEQ: $comp = '<='; break; |
471 | 471 | case SMW_CMP_GEQ: $comp = '>='; break; |
472 | 472 | case SMW_CMP_NEQ: $comp = '!='; break; |
473 | | - case SMW_CMP_LIKE: |
| 473 | + case SMW_CMP_LIKE: case SMW_CMP_NLKE: |
474 | 474 | $comp = ' LIKE '; |
| 475 | + if ( $description->getComparator() == SMW_CMP_NLKE ) $comp = " NOT{$comp}"; |
475 | 476 | $value = str_replace( array( '%', '_', '*', '?' ), array( '\%', '\_', '%', '_' ), $value ); |
476 | 477 | break; |
477 | 478 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -47,12 +47,13 @@ |
48 | 48 | define( 'SMW_OUTPUT_WIKI', 2 ); |
49 | 49 | define( 'SMW_OUTPUT_FILE', 3 ); |
50 | 50 | |
51 | | -// comparators for datavalues: |
52 | | -define( 'SMW_CMP_EQ', 1 ); // matches only datavalues that are equal to the given value |
53 | | -define( 'SMW_CMP_LEQ', 2 ); // matches only datavalues that are less or equal than the given value |
54 | | -define( 'SMW_CMP_GEQ', 3 ); // matches only datavalues that are greater or equal to the given value |
55 | | -define( 'SMW_CMP_NEQ', 4 ); // matches only datavalues that are unequal to the given value |
56 | | -define( 'SMW_CMP_LIKE', 5 ); // matches only datavalues that are LIKE the given value |
| 51 | +// Comparators for datavalues: |
| 52 | +define( 'SMW_CMP_EQ', 1 ); // Matches only datavalues that are equal to the given value. |
| 53 | +define( 'SMW_CMP_LEQ', 2 ); // Matches only datavalues that are less or equal than the given value. |
| 54 | +define( 'SMW_CMP_GEQ', 3 ); // Matches only datavalues that are greater or equal to the given value. |
| 55 | +define( 'SMW_CMP_NEQ', 4 ); // Matches only datavalues that are unequal to the given value. |
| 56 | +define( 'SMW_CMP_LIKE', 5 ); // Matches only datavalues that are LIKE the given value. |
| 57 | +define( 'SMW_CMP_NLKE', 6 ); // Matches only datavalues that are not LIKE the given value. |
57 | 58 | |
58 | 59 | // constants for date formats (using binary encoding of nine bits: 3 positions x 3 interpretations) |
59 | 60 | define( 'SMW_MDY', 785 ); // Month-Day-Year |
Index: trunk/extensions/SemanticMediaWiki/SMW_Settings.php |
— | — | @@ -190,11 +190,23 @@ |
191 | 191 | $smwgQDefaultNamespaces = null; // Which namespaces should be searched by default? |
192 | 192 | // (value NULL switches off default restrictions on searching -- this is faster) |
193 | 193 | // Example with namespaces: $smwgQDefaultNamespaces = array(NS_MAIN, NS_IMAGE); |
194 | | -$smwgQComparators = '<|>|!|~'; // List of comparator characters supported by queries, separated by '|' |
195 | | - // Available entries: < (smaller than), < (greater than), ! (unequal to), |
196 | | - // ~ (pattern with '*' as wildcard, only for Type:String) |
197 | | - // If unsupported comparators are used, they are treated as part of the queried value |
198 | 194 | |
| 195 | +/** |
| 196 | + * List of comparator characters supported by queries, separated by '|', for use in a regex. |
| 197 | + * |
| 198 | + * Available entries: |
| 199 | + * < (smaller than) |
| 200 | + * < (greater than) |
| 201 | + * ! (unequal to) |
| 202 | + * ~ (pattern with '*' as wildcard, only for Type:String) |
| 203 | + * !~ (not a pattern with '*' as wildcard, only for Type:String, need to be placed before ! and ~ to work correctly) |
| 204 | + * |
| 205 | + * If unsupported comparators are used, they are treated as part of the queried value |
| 206 | + * |
| 207 | + * @var string |
| 208 | + */ |
| 209 | +$smwgQComparators = '<|>|!~|!|~'; |
| 210 | + |
199 | 211 | ### |
200 | 212 | # Further settings for queries. The following settings affect inline queries |
201 | 213 | # and querying special pages. Essentially they should mirror the kind of |