Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -151,8 +151,9 @@ |
152 | 152 | * produced by the #ask parser function. The parsing results in a querystring, |
153 | 153 | * an array of additional parameters, and an array of additional SMWPrintRequest |
154 | 154 | * objects, which are filled into call-by-ref parameters. |
| 155 | + * $showmode is true if the input should be treated as if given by #show |
155 | 156 | */ |
156 | | - static public function processFunctionParams($rawparams, &$querystring, &$params, &$printouts) { |
| 157 | + static public function processFunctionParams($rawparams, &$querystring, &$params, &$printouts, $showmode=false) { |
157 | 158 | global $wgContLang; |
158 | 159 | $querystring = ''; |
159 | 160 | $printouts = array(); |
— | — | @@ -176,7 +177,7 @@ |
177 | 178 | $title = NULL; |
178 | 179 | $printmode = SMWPrintRequest::PRINT_CATS; |
179 | 180 | if (count($parts) == 1) { // no label found, use category label |
180 | | - $parts[] = $wgContLang->getNSText(NS_CATEGORY); |
| 181 | + $parts[] = $showmode?'':$wgContLang->getNSText(NS_CATEGORY); |
181 | 182 | } |
182 | 183 | } else { // print property or check category |
183 | 184 | $title = Title::newFromText(trim($propparts[0]), SMW_NS_PROPERTY); // trim needed for \n |
— | — | @@ -189,7 +190,7 @@ |
190 | 191 | $printmode = SMWPrintRequest::PRINT_CCAT; |
191 | 192 | } //else? |
192 | 193 | if (count($parts) == 1) { // no label found, use property/category name |
193 | | - $parts[] = $title->getText(); |
| 194 | + $parts[] = $showmode?'':$title->getText(); |
194 | 195 | } |
195 | 196 | } |
196 | 197 | if (count($propparts) == 1) { // no outputformat found, leave empty |
— | — | @@ -206,6 +207,7 @@ |
207 | 208 | } |
208 | 209 | } |
209 | 210 | $querystring = str_replace(array('<','>'), array('<','>'), $querystring); |
| 211 | + if ($showmode) $querystring = "[[:$querystring]]"; |
210 | 212 | } |
211 | 213 | |
212 | 214 | /** |
— | — | @@ -219,8 +221,8 @@ |
220 | 222 | * obtain actual parameters, printout requests, and the query string for |
221 | 223 | * further processing. |
222 | 224 | */ |
223 | | - static public function getResultFromFunctionParams($rawparams, $outputmode, $inline = true) { |
224 | | - SMWQueryProcessor::processFunctionParams($rawparams,$querystring,$params,$printouts); |
| 225 | + static public function getResultFromFunctionParams($rawparams, $outputmode, $inline = true, $showmode = false) { |
| 226 | + SMWQueryProcessor::processFunctionParams($rawparams,$querystring,$params,$printouts,$showmode); |
225 | 227 | return SMWQueryProcessor::getResultFromQueryString($querystring,$params,$printouts, SMW_OUTPUT_WIKI, $inline); |
226 | 228 | } |
227 | 229 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -237,6 +237,8 @@ |
238 | 238 | function smwfRegisterInlineQueries( &$parser, &$text, &$stripstate ) { |
239 | 239 | $parser->setHook( 'ask', 'smwfProcessInlineQuery' ); |
240 | 240 | $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' ); |
| 241 | + $parser->setFunctionHook( 'show', 'smwfProcessShowParserFunction' ); |
| 242 | + $parser->setFunctionHook( 'info', 'smwfProcessInfoParserFunction' ); |
241 | 243 | return true; // always return true, in order not to stop MW's hook processing! |
242 | 244 | } |
243 | 245 | |
— | — | @@ -268,6 +270,31 @@ |
269 | 271 | } |
270 | 272 | } |
271 | 273 | |
| 274 | +/** |
| 275 | + * The {{#show }} parser function processing part. |
| 276 | + */ |
| 277 | +function smwfProcessShowParserFunction(&$parser) { |
| 278 | + global $smwgQEnabled, $smwgIQRunningNumber; |
| 279 | + if ($smwgQEnabled) { |
| 280 | + $smwgIQRunningNumber++; |
| 281 | + $params = func_get_args(); |
| 282 | + array_shift( $params ); // we already know the $parser ... |
| 283 | + return SMWQueryProcessor::getResultFromFunctionParams($params,SMW_OUTPUT_WIKI,true,true); |
| 284 | + } else { |
| 285 | + return smwfEncodeMessages(array(wfMsgForContent('smw_iq_disabled'))); |
| 286 | + } |
| 287 | +} |
| 288 | + |
| 289 | +/** |
| 290 | + * The {{#info }} parser function processing part. |
| 291 | + */ |
| 292 | +function smwfProcessInfoParserFunction(&$parser) { |
| 293 | + $params = func_get_args(); |
| 294 | + array_shift( $params ); // we already know the $parser ... |
| 295 | + $content = array_shift( $params ); // use only first parameter, ignore rest (may get meaning later) |
| 296 | + return smwfEncodeMessages(array($content), 'info'); |
| 297 | +} |
| 298 | + |
272 | 299 | /**********************************************/ |
273 | 300 | /***** Header modifications *****/ |
274 | 301 | /**********************************************/ |
— | — | @@ -409,21 +436,14 @@ |
410 | 437 | * Set up (possibly localised) names for SMW's parser functions. |
411 | 438 | */ |
412 | 439 | function smwfAddMagicWords(&$magicWords, $langCode) { |
413 | | - $magicWords['ask'] = array( 0, 'ask' ); |
| 440 | + $magicWords['ask'] = array( 0, 'ask' ); |
| 441 | + $magicWords['show'] = array( 0, 'show' ); |
| 442 | + $magicWords['info'] = array( 0, 'info' ); |
414 | 443 | $magicWords['SMW_NOFACTBOX'] = array( 0, '__NOFACTBOX__' ); |
415 | 444 | $magicWords['SMW_SHOWFACTBOX'] = array( 0, '__SHOWFACTBOX__' ); |
416 | 445 | return true; |
417 | 446 | } |
418 | 447 | |
419 | | -// function smwfAddMagicWords(&$magicWords) { |
420 | | -// $magicWords[] = 'MAG_NOTITLE'; |
421 | | -// return true; |
422 | | -// } |
423 | | -// |
424 | | -// function smwfAddMagicWordIds(&$magicWords) { |
425 | | -// $magicWords[] = MAG_NOTITLE; |
426 | | -// } |
427 | | - |
428 | 448 | /** |
429 | 449 | * Initialise a global language object for content language. This |
430 | 450 | * must happen early on, even before user language is known, to |