r95791 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95790‎ | r95791 | r95792 >
Date:16:22, 30 August 2011
Author:yaron
Status:deferred
Tags:
Comment:
Page Schemas 'getXmlTextForFieldInputs' hook was replaced with 'PageSchemasGetFieldXML'; also cleaned up code somewhat
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -95,7 +95,7 @@
9696 $wgHooks['PageSchemasGeneratePages'][] = 'smwfGeneratePages' ; // Hook for creating Pages
9797 $wgHooks['getHtmlTextForFieldInputs'][] = 'smwfgetHtmlTextForPS' ; // Hook for retuning html text to PS schema
9898 $wgHooks['getFilledHtmlTextForFieldInputs'][] = 'smwfgetFilledHtmlTextForPS' ; //Hook for retuning html text to PS schema
99 - $wgHooks['getXmlTextForFieldInputs'][] = 'smwfgetXMLTextForPS' ; // Hook for retuning html text to PS schema
 99+ $wgHooks['PageSchemasGetFieldXML'][] = 'smwfGetFieldXMLForPS';
100100 $wgHooks['PSParseFieldElements'][] = 'smwfParseFieldElements' ; // Hook for creating Pages
101101 $wgHooks['PageSchemasGetPageList'][] = 'smwfGetPageList' ; //Hook for creating Pages
102102 /* End: Hooks related to Pageschemas extension */
@@ -641,18 +641,16 @@
642642 return true;
643643 }
644644
645 -function smwfgetXMLTextForPS( $wgRequest, &$text_extensions ){
646 -
647 - $Xmltext = "";
 645+function smwfGetFieldXMLForPS( $request, &$xmlArray ) {
648646 $templateNum = -1;
649 - $xml_text_array = array();
650 - foreach ( $wgRequest->getValues() as $var => $val ) {
651 - if(substr($var,0,18) == 'smw_property_name_'){
 647+ $xmlPerField = array();
 648+ foreach ( $request->getValues() as $var => $val ) {
 649+ if ( substr( $var, 0, 18 ) == 'smw_property_name_' ) {
652650 $templateNum = substr($var,18,1);
653 - $Xmltext .= '<semanticmediawiki_Property name="'.$val.'" >';
654 - }else if(substr($var,0,18) == 'smw_property_type_'){
655 - $Xmltext .= '<Type>'.$val.'</Type>';
656 - }else if(substr($var,0,11) == 'smw_values_'){
 651+ $xml = '<semanticmediawiki_Property name="'.$val.'" >';
 652+ } elseif ( substr( $var, 0, 18 ) == 'smw_property_type_'){
 653+ $xml .= '<Type>'.$val.'</Type>';
 654+ } elseif ( substr( $var, 0, 11 ) == 'smw_values_') {
657655 if ( $val != '' ) {
658656 // replace the comma substitution character that has no chance of
659657 // being included in the values list - namely, the ASCII beep
@@ -662,17 +660,17 @@
663661 foreach ( $allowed_values_array as $i => $value ) {
664662 // replace beep back with comma, trim
665663 $value = str_replace( "\a", $listSeparator, trim( $value ) );
666 - $Xmltext .= '<AllowedValue>'.$value.'</AllowedValue>';
 664+ $xml .= '<AllowedValue>'.$value.'</AllowedValue>';
667665 }
668666 }
669 - $Xmltext .= '</semanticmediawiki_Property>';
670 - $xml_text_array[] = $Xmltext;
671 - $Xmltext = '';
 667+ $xml .= '</semanticmediawiki_Property>';
 668+ $xmlPerField[] = $xml;
672669 }
673670 }
674 - $text_extensions['smw'] = $xml_text_array;
 671+ $xmlArray['smw'] = $xmlPerField;
675672 return true;
676673 }
 674+
677675 function smwfgetFilledHtmlTextForPS( $pageSchemaObj, &$text_extensions ){
678676 global $smwgContLang;
679677 $datatype_labels = $smwgContLang->getDatatypeLabels();