r95788 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95787‎ | r95788 | r95789 >
Date:16:14, 30 August 2011
Author:yaron
Status:deferred
Tags:
Comment:
Page Schemas 'getXmlTextForFieldInputs' hook was replaced with two hooks, 'PageSchemasGetSchemaXML' and 'PageSchemasGetFieldXML'
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -97,7 +97,8 @@
9898 $wgHooks['PSParseFieldElements'][] = 'SFUtils::parseFieldElements' ; //Hook for creating Pages
9999 $wgHooks['PageSchemasGetPageList'][] = 'SFUtils::getPageList' ; //Hook for creating Pages
100100 $wgHooks['getHtmlTextForFieldInputs'][] = 'SFUtils::getHtmlTextForPS' ; //Hook for retuning html text to PS schema
101 -$wgHooks['getXmlTextForFieldInputs'][] = 'SFUtils::getXMLTextForPS' ; //Hook for retuning html text to PS schema
 101+$wgHooks['PageSchemasGetSchemaXML'][] = 'SFUtils::getSchemaXMLForPS';
 102+$wgHooks['PageSchemasGetFieldXML'][] = 'SFUtils::getFieldXMLForPS';
102103 $wgHooks['getFilledHtmlTextForFieldInputs'][] = 'SFUtils::getFilledHtmlTextForPS' ; //Hook for retuning html text to PS schema
103104
104105 $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -190,25 +190,31 @@
191191 return true;
192192 }
193193
194 - public static function getXMLTextForPS( $wgRequest, &$text_extensions ) {
195 - $Xmltext = "";
196 - $form_xml_text = "";
197 - $templateNum = -1;
198 - $xml_text_array = array();
199 - foreach ( $wgRequest->getValues() as $var => $val ) {
 194+ public static function getSchemaXMLForPS( $request, &$xmlArray ) {
 195+ foreach ( $request->getValues() as $var => $val ) {
200196 if ( substr( $var, 0, 13) == 'sf_form_name_' ) {
201 - $form_xml_text .= '<semanticforms_Form name="'.$val.'" >';
202 - } elseif ( substr( $var, 0, 14 ) == 'sf_input_type_') {
203 - $templateNum = substr( $var, 14, 1 );
204 - $Xmltext .= '<semanticforms_FormInput>';
205 - $Xmltext .= '<InputType>'.$val.'</InputType>';
 197+ $xml = '<semanticforms_Form name="'.$val.'" >';
206198 } elseif ( substr( $var, 0, 21 ) == 'sf_page_name_formula_') {
207 - $form_xml_text .= '<PageNameFormula>'.$val.'</PageNameFormula>';
 199+ $xml .= '<PageNameFormula>'.$val.'</PageNameFormula>';
208200 } elseif ( substr( $var, 0, 16 ) == 'sf_create_title_' ) {
209 - $form_xml_text .= '<CreateTitle>'.$val.'</CreateTitle>';
 201+ $xml .= '<CreateTitle>'.$val.'</CreateTitle>';
210202 } elseif ( substr( $var, 0, 14 ) == 'sf_edit_title_' ) {
211 - $form_xml_text .= '<EditTitle>'.$val.'</EditTitle>';
212 - $form_xml_text .= '</semanticforms_Form>';
 203+ $xml .= '<EditTitle>'.$val.'</EditTitle>';
 204+ $xml .= '</semanticforms_Form>';
 205+ }
 206+ }
 207+ $xmlArray['sf'] = $xml;
 208+ return true;
 209+ }
 210+
 211+ public static function getFieldXMLForPS( $request, &$xmlArray ) {
 212+ $xmlPerField = array();
 213+ $templateNum = -1;
 214+ foreach ( $request->getValues() as $var => $val ) {
 215+ if ( substr( $var, 0, 14 ) == 'sf_input_type_') {
 216+ $templateNum = substr( $var, 14, 1 );
 217+ $xml = '<semanticforms_FormInput>';
 218+ $xml .= '<InputType>'.$val.'</InputType>';
213219 } elseif ( substr( $var, 0, 14 ) == 'sf_key_values_' ) {
214220 if ( $val != '' ) {
215221 // replace the comma substitution character that has no chance of
@@ -222,20 +228,18 @@
223229 $param_value = explode( "=", $value );
224230 if ( $param_value[1] != null ) {
225231 //handles Parameter name="size">20</Parameter>
226 - $Xmltext .= '<Parameter name="'.$param_value[0].'">'.$param_value[1].'</Parameter>';
 232+ $xml .= '<Parameter name="'.$param_value[0].'">'.$param_value[1].'</Parameter>';
227233 } else {
228234 //handles <Parameter name="mandatory" />
229 - $Xmltext .= '<Parameter name="'.$param_value[0].'"/>';
 235+ $xml .= '<Parameter name="'.$param_value[0].'"/>';
230236 }
231237 }
232 - $Xmltext .= '</semanticforms_FormInput>';
233 - $xml_text_array[] = $Xmltext;
234 - $Xmltext = '';
 238+ $xml .= '</semanticforms_FormInput>';
 239+ $xmlPerField[] = $xml;
235240 }
236241 }
237242 }
238 - $text_extensions['sf'] = $xml_text_array;
239 - $text_extensions['sf_form'] = $form_xml_text;
 243+ $xmlArray['sf'] = $xmlPerField;
240244 return true;
241245 }
242246