Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -121,6 +121,11 @@ |
122 | 122 | public function addPrintRequest(SMWPrintRequest $printrequest) { |
123 | 123 | return $this->m_printreqs[$printrequest->getHash()] = $printrequest; |
124 | 124 | } |
| 125 | + |
| 126 | + /** |
| 127 | + * Return a string expressing this query. |
| 128 | + */ |
| 129 | + abstract public function getQueryString(); |
125 | 130 | } |
126 | 131 | |
127 | 132 | /** |
— | — | @@ -131,6 +136,9 @@ |
132 | 137 | * SMWValueDescription objects. |
133 | 138 | */ |
134 | 139 | class SMWThingDescription extends SMWDescription { |
| 140 | + public function getQueryString() { |
| 141 | + return '+'; |
| 142 | + } |
135 | 143 | } |
136 | 144 | |
137 | 145 | /** |
— | — | @@ -147,6 +155,14 @@ |
148 | 156 | public function getCategory() { |
149 | 157 | return $this->m_title; |
150 | 158 | } |
| 159 | + |
| 160 | + public function getQueryString() { |
| 161 | + if ($this->m_title !== NULL) { |
| 162 | + return '[[' . $this->m_title->getPrefixedText() . ']]'; |
| 163 | + } else { |
| 164 | + return ''; |
| 165 | + } |
| 166 | + } |
151 | 167 | } |
152 | 168 | |
153 | 169 | /** |
— | — | @@ -166,6 +182,15 @@ |
167 | 183 | public function getIndividual() { |
168 | 184 | return $this->m_title; |
169 | 185 | } |
| 186 | + |
| 187 | + public function getQueryString() { |
| 188 | + if ($this->m_title !== NULL) { |
| 189 | + return '[[:' . $this->m_title->getPrefixedText() . ']]'; |
| 190 | + } else { |
| 191 | + return ''; |
| 192 | + } |
| 193 | + } |
| 194 | + |
170 | 195 | } |
171 | 196 | |
172 | 197 | /** |
— | — | @@ -195,6 +220,30 @@ |
196 | 221 | public function getComparator() { |
197 | 222 | return $this->m_comparator; |
198 | 223 | } |
| 224 | + |
| 225 | + public function getQueryString() { |
| 226 | + if ($this->m_datavalue !== NULL) { |
| 227 | + switch ($m_comparator) { |
| 228 | + case SMW_CMP_EQ: |
| 229 | + $comparator = ''; |
| 230 | + break; |
| 231 | + case SMW_CMP_LEQ: |
| 232 | + $comparator = '<'; |
| 233 | + break; |
| 234 | + case SMW_CMP_GEQ: |
| 235 | + $comparator = '>'; |
| 236 | + break; |
| 237 | + case SMW_CMP_NEQ: |
| 238 | + $comparator = '!'; // not supported yet? |
| 239 | + break; |
| 240 | + case SMW_CMP_ANY: default: |
| 241 | + return '+'; |
| 242 | + } |
| 243 | + return $comparator . $datavalue->getShortWikiText(); // TODO: this fails if tooltips are used |
| 244 | + } else { |
| 245 | + return '+'; |
| 246 | + } |
| 247 | + } |
199 | 248 | } |
200 | 249 | |
201 | 250 | /** |
— | — | @@ -217,6 +266,14 @@ |
218 | 267 | public function addDescription(SMWDescription $description) { |
219 | 268 | $this->m_descriptions[] = $description; |
220 | 269 | } |
| 270 | + |
| 271 | + public function getQueryString() { |
| 272 | + $result = ''; |
| 273 | + foreach ($this->m_descriptions as $desc) { |
| 274 | + $result .= $desc->getQueryString() . ' '; |
| 275 | + } |
| 276 | + return $result; |
| 277 | + } |
221 | 278 | } |
222 | 279 | |
223 | 280 | /** |
— | — | @@ -239,6 +296,20 @@ |
240 | 297 | public function addDescription(SMWDescription $description) { |
241 | 298 | $this->m_descriptions[] = $description; |
242 | 299 | } |
| 300 | + |
| 301 | + public function getQueryString() { |
| 302 | + $result = ''; |
| 303 | + // TODO: this is not quite correct ... (many disjunctions have || abbreviations) |
| 304 | + foreach ($this->m_descriptions as $desc) { |
| 305 | + if ($first) { |
| 306 | + $first = false; |
| 307 | + } else { |
| 308 | + $result .= ' OR '; |
| 309 | + } |
| 310 | + $result .= $desc->getQueryString(); |
| 311 | + } |
| 312 | + return $result; |
| 313 | + } |
243 | 314 | } |
244 | 315 | |
245 | 316 | /** |
— | — | @@ -265,6 +336,10 @@ |
266 | 337 | public function getDescription() { |
267 | 338 | return $this->m_description; |
268 | 339 | } |
| 340 | + |
| 341 | + public function getQueryString() { |
| 342 | + return '[[' . $this->m_relation->getText() . '::' . $this->m_description->getQueryString() . ']]'; |
| 343 | + } |
269 | 344 | } |
270 | 345 | |
271 | 346 | /** |
— | — | @@ -291,6 +366,10 @@ |
292 | 367 | public function getDescription() { |
293 | 368 | return $this->m_description; |
294 | 369 | } |
| 370 | + |
| 371 | + public function getQueryString() { |
| 372 | + return '[[' . $this->m_attribute->getText() . '::' . $this->m_description->getQueryString() . ']]'; |
| 373 | + } |
295 | 374 | } |
296 | 375 | |
297 | 376 | |