Index: trunk/extensions/SemanticForms/includes/SF_Utils.inc |
— | — | @@ -245,7 +245,7 @@ |
246 | 246 | global $sfgMaxAutocompleteValues; |
247 | 247 | |
248 | 248 | $db = wfGetDB( DB_SLAVE ); |
249 | | - $fname = "getAllPagesForCategory"; |
| 249 | + $fname = "SFUtils;:getAllPagesForCategory"; |
250 | 250 | $top_category = str_replace(' ', '_', $top_category); |
251 | 251 | $categories = array($top_category); |
252 | 252 | $checkcategories = array($top_category); |
— | — | @@ -358,7 +358,7 @@ |
359 | 359 | while ($row = $db->fetchRow($res)) { |
360 | 360 | $cur_value = str_replace('_', ' ', $row[0]); |
361 | 361 | if ($substring == null) { |
362 | | - $pages[] = str_replace("'", "\'", $cur_value); |
| 362 | + $pages[] = $cur_value; |
363 | 363 | } else { |
364 | 364 | $pages[] = array('title' => $cur_value); |
365 | 365 | } |
— | — | @@ -386,4 +386,30 @@ |
387 | 387 | return $return_values; |
388 | 388 | } |
389 | 389 | |
| 390 | + /** |
| 391 | + * Parse the form definition and store the resulting HTML in the |
| 392 | + * page_props table, if caching has been specified in LocalSettings.php |
| 393 | + */ |
| 394 | + function cacheFormDefinition($parser, $text) { |
| 395 | + global $sfgCacheFormDefinitions; |
| 396 | + if (! $sfgCacheFormDefinitions) |
| 397 | + return true; |
| 398 | + |
| 399 | + if ($parser->getTitle()->getNamespace() != SF_NS_FORM) return true; |
| 400 | + // Remove <noinclude> sections and <includeonly> tags from form definition |
| 401 | + $form_def = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $text); |
| 402 | + $form_def = strtr($form_def, array('<includeonly>' => '', '</includeonly>' => '')); |
| 403 | + |
| 404 | + // parse wiki-text |
| 405 | + // add '<nowiki>' tags around every triple-bracketed form definition |
| 406 | + // element, so that the wiki parser won't touch it - the parser will |
| 407 | + // remove the '<nowiki>' tags, leaving us with what we need |
| 408 | + $form_def = "__NOEDITSECTION__" . strtr($form_def, array('{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>')); |
| 409 | + $dummy_title = Title::newFromText('Form definition title for caching purposes'); |
| 410 | + $form_def = $parser->parse($form_def, $dummy_title, $parser->mOptions)->getText(); |
| 411 | + |
| 412 | + $parser->mOutput->setProperty( 'formdefinition', $form_def ); |
| 413 | + return true; |
| 414 | + } |
| 415 | + |
390 | 416 | } |