r61884 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61883‎ | r61884 | r61885 >
Date:21:50, 2 February 2010
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Fixed handling of apostrophes in namespace autocompletion; cacheFormDefinition() added
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.inc
@@ -245,7 +245,7 @@
246246 global $sfgMaxAutocompleteValues;
247247
248248 $db = wfGetDB( DB_SLAVE );
249 - $fname = "getAllPagesForCategory";
 249+ $fname = "SFUtils;:getAllPagesForCategory";
250250 $top_category = str_replace(' ', '_', $top_category);
251251 $categories = array($top_category);
252252 $checkcategories = array($top_category);
@@ -358,7 +358,7 @@
359359 while ($row = $db->fetchRow($res)) {
360360 $cur_value = str_replace('_', ' ', $row[0]);
361361 if ($substring == null) {
362 - $pages[] = str_replace("'", "\'", $cur_value);
 362+ $pages[] = $cur_value;
363363 } else {
364364 $pages[] = array('title' => $cur_value);
365365 }
@@ -386,4 +386,30 @@
387387 return $return_values;
388388 }
389389
 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+
390416 }

Comments

#Comment by Nikerabbit (talk | contribs)   06:53, 3 February 2010

+ $fname = "SFUtils;:getAllPagesForCategory";

Typo in ;? __METHOD__ should work too.

#Comment by Nikerabbit (talk | contribs)   07:08, 3 February 2010

+ $fname = "SFUtils;:getAllPagesForCategory";

Typo in ;? __METHOD__ should work too.

Status & tagging log