http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61884

Revision: 61884
Author:   yaron
Date:     2010-02-02 21:50:53 +0000 (Tue, 02 Feb 2010)

Log Message:
-----------
Fixed handling of apostrophes in namespace autocompletion; 
cacheFormDefinition() added

Modified Paths:
--------------
    trunk/extensions/SemanticForms/includes/SF_Utils.inc

Modified: trunk/extensions/SemanticForms/includes/SF_Utils.inc
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_Utils.inc        2010-02-02 
21:49:38 UTC (rev 61883)
+++ trunk/extensions/SemanticForms/includes/SF_Utils.inc        2010-02-02 
21:50:53 UTC (rev 61884)
@@ -245,7 +245,7 @@
                global $sfgMaxAutocompleteValues;
 
                $db = wfGetDB( DB_SLAVE );
-               $fname = "getAllPagesForCategory";
+               $fname = "SFUtils;:getAllPagesForCategory";
                $top_category = str_replace(' ', '_', $top_category);
                $categories = array($top_category);
                $checkcategories = array($top_category);
@@ -358,7 +358,7 @@
                                while ($row = $db->fetchRow($res)) {
                                        $cur_value = str_replace('_', ' ', 
$row[0]);
                                        if ($substring == null) {
-                                               $pages[] = str_replace("'", 
"\'", $cur_value);
+                                               $pages[] = $cur_value;
                                        } else {
                                                $pages[] = array('title' => 
$cur_value);
                                        }
@@ -386,4 +386,30 @@
                return $return_values;
        }
 
+       /**
+        * Parse the form definition and store the resulting HTML in the
+        * page_props table, if caching has been specified in LocalSettings.php
+        */
+       function cacheFormDefinition($parser, $text) {
+               global $sfgCacheFormDefinitions;
+               if (! $sfgCacheFormDefinitions)
+                       return true;
+
+               if ($parser->getTitle()->getNamespace() != SF_NS_FORM) return 
true;
+               // Remove <noinclude> sections and <includeonly> tags from form 
definition
+               $form_def = StringUtils::delimiterReplace('<noinclude>', 
'</noinclude>', '', $text);
+               $form_def = strtr($form_def, array('<includeonly>' => '', 
'</includeonly>' => ''));
+
+               // parse wiki-text
+               // add '<nowiki>' tags around every triple-bracketed form 
definition
+               // element, so that the wiki parser won't touch it - the parser 
will
+               // remove the '<nowiki>' tags, leaving us with what we need
+               $form_def = "__NOEDITSECTION__" . strtr($form_def, array('{{{' 
=> '<nowiki>{{{', '}}}' => '}}}</nowiki>'));
+               $dummy_title = Title::newFromText('Form definition title for 
caching purposes');
+               $form_def = $parser->parse($form_def, $dummy_title, 
$parser->mOptions)->getText();
+
+               $parser->mOutput->setProperty( 'formdefinition', $form_def );
+               return true;
+       }
+
 }



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to