http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61888
Revision: 61888 Author: yaron Date: 2010-02-02 22:02:14 +0000 (Tue, 02 Feb 2010) Log Message: ----------- Added support for form definition caching Modified Paths: -------------- trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc Modified: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc =================================================================== --- trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc 2010-02-02 21:56:10 UTC (rev 61887) +++ trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc 2010-02-02 22:02:14 UTC (rev 61888) @@ -124,8 +124,7 @@ return false; } - - function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false, $embedded = false) { + function formHTML($form_def, $form_id, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false, $embedded = false) { global $wgRequest, $wgUser, $wgParser; global $sfgTabIndex; // used to represent the current tab index in the form global $sfgFieldNum; // used for setting various HTML IDs @@ -219,7 +218,22 @@ $wgParser->mStripState = new StripState(); $wgParser->mOptions = new ParserOptions(); $wgParser->mOptions->initialiseFromUser($wgUser); - $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText(); + + // get the form definition from the cache, if we're using caching and it's + // there + $got_form_def_from_cache = false; + global $sfgCacheFormDefinitions; + if ($sfgCacheFormDefinitions) { + $db =& wfGetDB( DB_MASTER ); + $res = $db->select('page_props', 'pp_value', "pp_propname = 'formdefinition' AND pp_page = $form_id"); + if ($res->numRows() > 0) { + $form_def = $res->fetchObject()->pp_value; + $got_form_def_from_cache = true; + } + } + // otherwise, parse it + if (! $got_form_def_from_cache) + $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText(); $wgParser->mStripState = $old_strip_state; // turn form definition file into an array of sections, one for each @@ -1175,9 +1189,6 @@ } } else { $showFCKEditor = 0; - // for some reason, the following call was once necessary, but now - // causes problems - //$free_text = Sanitizer::safeEncodeAttribute($free_text); } // now that we have it, substitute free text into the form and page $escaped_free_text = Sanitizer::safeEncodeAttribute( $free_text ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs