Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -160,6 +160,7 @@ |
161 | 161 | * Abstract base class for all descriptions. |
162 | 162 | */ |
163 | 163 | abstract class SMWDescription { |
| 164 | + |
164 | 165 | protected $m_printreqs = array(); |
165 | 166 | // add code for managing printouts, including iteration |
166 | 167 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -980,6 +980,27 @@ |
981 | 981 | * also be changed (if it was non-NULL). |
982 | 982 | */ |
983 | 983 | protected function addDescription($curdesc, $newdesc, $conjunction = true) { |
| 984 | + global $smwgQFeatures; |
| 985 | + $notallowedmessage = 'smw_noqueryfeature'; |
| 986 | + if ($newdesc instanceof SMWSomeProperty) { |
| 987 | + $allowed = $smwgQFeatures & SMW_PROPERTY_QUERY; |
| 988 | + } elseif ($newdesc instanceof SMWClassDescription) { |
| 989 | + $allowed = $smwgQFeatures & SMW_CATEGORY_QUERY; |
| 990 | + } elseif ($newdesc instanceof SMWConceptDescription) { |
| 991 | + $allowed = $smwgQFeatures & SMW_CONCEPT_QUERY; |
| 992 | + } elseif ($newdesc instanceof SMWConjunction) { |
| 993 | + $allowed = $smwgQFeatures & SMW_CONJUNCTION_QUERY; |
| 994 | + $notallowedmessage = 'smw_noconjunctions'; |
| 995 | + } elseif ($newdesc instanceof SMWDisjunction) { |
| 996 | + $allowed = $smwgQFeatures & SMW_DISJUNCTION_QUERY; |
| 997 | + $notallowedmessage = 'smw_nodisjunctions'; |
| 998 | + } else { |
| 999 | + $allowed = true; |
| 1000 | + } |
| 1001 | + if (!$allowed) { |
| 1002 | + $this->m_errors[] = wfMsgForContent($notallowedmessage, str_replace('[', '[', $newdesc->getQueryString())); |
| 1003 | + return $curdesc; |
| 1004 | + } |
984 | 1005 | if ($newdesc === NULL) { |
985 | 1006 | return $curdesc; |
986 | 1007 | } elseif ($curdesc === NULL) { |
— | — | @@ -990,13 +1011,17 @@ |
991 | 1012 | $curdesc->addDescription($newdesc); |
992 | 1013 | return $curdesc; |
993 | 1014 | } elseif ($conjunction) { // make new conjunction |
994 | | - return new SMWConjunction(array($curdesc,$newdesc)); |
| 1015 | + if ($smwgQFeatures & SMW_CONJUNCTION_QUERY) { |
| 1016 | + return new SMWConjunction(array($curdesc,$newdesc)); |
| 1017 | + } else { |
| 1018 | + $this->m_errors[] = wfMsgForContent('smw_noconjunctions', str_replace('[', '[', $newdesc->getQueryString())); |
| 1019 | + return $curdesc; |
| 1020 | + } |
995 | 1021 | } else { // make new disjunction |
996 | | - global $smwgQDisjunctionSupport; |
997 | | - if ($smwgQDisjunctionSupport) { |
| 1022 | + if ($smwgQFeatures & SMW_DISJUNCTION_QUERY) { |
998 | 1023 | return new SMWDisjunction(array($curdesc,$newdesc)); |
999 | 1024 | } else { |
1000 | | - $this->m_errors[] = wfMsgForContent('smw_nodisjunctions', $newdesc->getQueryString()); |
| 1025 | + $this->m_errors[] = wfMsgForContent('smw_nodisjunctions', str_replace('[', '[', $newdesc->getQueryString())); |
1001 | 1026 | return $curdesc; |
1002 | 1027 | } |
1003 | 1028 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -38,6 +38,14 @@ |
39 | 39 | define('SMW_EQ_SOME', 1); |
40 | 40 | define('SMW_EQ_FULL', 2); |
41 | 41 | |
| 42 | +// flags to classify available query descriptions, used to enable/disable certain features |
| 43 | +define('SMW_PROPERTY_QUERY', 1); // [[some property::...]] |
| 44 | +define('SMW_CATEGORY_QUERY', 2); // [[Category:...]] |
| 45 | +define('SMW_CONCEPT_QUERY', 4); // [[Concept:...]] |
| 46 | +define('SMW_NAMESPACE_QUERY', 8); // [[User:+]] etc. |
| 47 | +define('SMW_CONJUNCTION_QUERY', 16); // any conjunctions |
| 48 | +define('SMW_DISJUNCTION_QUERY', 32); // any disjunctions (OR, ||) |
| 49 | + |
42 | 50 | // constants for identifying javascripts as used in smwfRequireHeadItem |
43 | 51 | define('SMW_HEADER_TIMELINE', 1); |
44 | 52 | define('SMW_HEADER_TOOLTIP', 2); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -93,7 +93,8 @@ |
94 | 94 | $smwgQSubcategoryDepth = 10; // Restrict level of sub-category inclusion (steps within category hierarchy) |
95 | 95 | $smwgQSubpropertyDepth = 10; // Restrict level of sub-property inclusion (steps within property hierarchy) |
96 | 96 | // (Use 0 to disable hierarchy-inferencing in queries) |
97 | | -$smwgQEqualitySupport = SMW_EQ_SOME; // Evaluate #redirects as equality between page names in simple cases |
| 97 | +$smwgQEqualitySupport = SMW_EQ_SOME; // Evaluate #redirects as equality between page names, with possible |
| 98 | + // performance-relevant restrictions depending on the storage engine |
98 | 99 | //$smwgQEqualitySupport = SMW_EQ_FULL; // Evaluate #redirects as equality between page names in all cases |
99 | 100 | //$smwgQEqualitySupport = SMW_EQ_NONE; // Never evaluate #redirects as equality between page names |
100 | 101 | $smwgQSortingSupport = true; // (De)activate sorting of results. |
— | — | @@ -101,18 +102,22 @@ |
102 | 103 | // (value NULL switches off default restrictions on searching -- this is faster) |
103 | 104 | // Example with namespaces: $smwgQDefaultNamespaces = array(NS_MAIN, NS_IMAGE); |
104 | 105 | $smwgQMaxLimit = 10000; // Max number of results ever retrieved, even when using special query pages. |
105 | | -$smwgQDisjunctionSupport = true; // Support disjunctions in queries ("||" and "OR")? |
106 | | - // (Note: things like namespace defaults and property/category hierarchies |
107 | | - // can also cause disjunctions!) |
| 106 | +// The next defines which query features should be available by default. |
| 107 | +// Examples: |
| 108 | +// only cateory intersections: $smwgQFeatures = SMW_CATEGORY_QUERY | SMW_CONJUNCTION_QUERY |
| 109 | +// only single concepts: $smwgQFeatures = SMW_CONCEPT_QUERY |
| 110 | +// The default is to support all basic features. |
| 111 | +$smwgQFeatures = SMW_PROPERTY_QUERY | SMW_CATEGORY_QUERY | SMW_CONCEPT_QUERY | |
| 112 | + SMW_NAMESPACE_QUERY | SMW_CONJUNCTION_QUERY | SMW_DISJUNCTION_QUERY; |
108 | 113 | $smwgQComparators = '<|>|!'; // List of comparator characters supported by queries, separated by '|' |
109 | 114 | // Available entries: < (smaller than), < (greater than), ! (unequal to), |
110 | 115 | // ~ (pattern with '*' as wildcard, only for Type:String) |
111 | 116 | // If unsupported comparators are used, they are treated as part of the queried value |
112 | 117 | |
113 | 118 | ### Settings about printout of (especially inline) queries: |
114 | | -$smwgQDefaultLimit = 50; // Default number of rows returned in a query. Can be increased with <ask limit="num">... |
| 119 | +$smwgQDefaultLimit = 50; // Default number of rows returned in a query. Can be increased with limit=num in #ask |
115 | 120 | $smwgQMaxInlineLimit = 500; // Max number of rows ever printed in a single inline query on a single page. |
116 | | -$smwgQPrintoutLimit = 100; // Max number of supported printouts (added columns in result table, ?-statements) |
| 121 | +$smwgQPrintoutLimit = 100; // Max number of supported printouts (added columns in result table, ?-statements) |
117 | 122 | |
118 | 123 | ### Formatting settings |
119 | 124 | $smwgQDefaultLinking = 'all'; // Default linking behaviour. Can be one of "none", "subject", "all" |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -98,6 +98,8 @@ |
99 | 99 | 'smw_badtitle' => 'Sorry, but “$1” is no valid page title.', |
100 | 100 | 'smw_badqueryatom' => 'Some part “[[…]]” of the query was not understood.', |
101 | 101 | 'smw_propvalueproblem' => 'The value of property “$1” was not understood.', |
| 102 | + 'smw_noqueryfeature' => 'Some query feature was not supported in this wiki and part of the query was dropped ($1).', |
| 103 | + 'smw_noconjunctions' => 'Conjunctions in queries are not supported in this wiki and part of the query was dropped ($1).', |
102 | 104 | 'smw_nodisjunctions' => 'Disjunctions in queries are not supported in this wiki and part of the query was dropped ($1).', |
103 | 105 | 'smw_querytoolarge' => 'The following query conditions could not be considered due to the wikis restrictions in query size or depth: $1.', |
104 | 106 | 'smw_devel_warning' => 'This feature is currently under development, and might not be fully functional. |