r89265 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89264‎ | r89265 | r89266 >
Date:15:31, 1 June 2011
Author:yaron
Status:deferred
Tags:
Comment:
Simplfied registerInputType() - property-type labels no longer needed, for any version of SMW
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -62,43 +62,19 @@
6363 * Must be derived from SFFormInput.
6464 */
6565 public function registerInputType( $inputTypeClass ) {
66 - global $smwgContLang;
67 -
6866 $inputTypeName = call_user_func( array( $inputTypeClass, 'getName' ) );
6967 $this->mInputTypeClasses[$inputTypeName] = $inputTypeClass;
7068 $this->setInputTypeHook( $inputTypeName, array( $inputTypeClass, 'getHTML' ), array() );
7169
7270 $defaultProperties = call_user_func( array( $inputTypeClass, 'getDefaultPropTypes' ) );
73 - foreach ( $defaultProperties as $propertyTypeID => $additionalValues ) {
74 - if ( $smwgContLang != null ) {
75 - if ( class_exists( 'SMWDIProperty' ) ) {
76 - // For SMW 1.6+, we use the ID of each
77 - // property, instead of its label.
78 - $propertyType = $propertyTypeID;
79 - } else {
80 - $datatypeLabels = $smwgContLang->getDatatypeLabels();
81 - $datatypeLabels['enumeration'] = 'enumeration';
82 - $propertyType = $datatypeLabels[$propertyTypeID];
83 - }
84 - $this->setSemanticTypeHook( $propertyType, false, array( $inputTypeClass, 'getHTML' ), $additionalValues );
85 - }
86 - $this->mDefaultInputForPropType[$propertyTypeID] = $inputTypeName;
 71+ foreach ( $defaultProperties as $propertyType => $additionalValues ) {
 72+ $this->setSemanticTypeHook( $propertyType, false, array( $inputTypeClass, 'getHTML' ), $additionalValues );
 73+ $this->mDefaultInputForPropType[$propertyType] = $inputTypeName;
8774 }
8875 $defaultPropertyLists = call_user_func( array( $inputTypeClass, 'getDefaultPropTypeLists' ) );
89 - foreach ( $defaultPropertyLists as $propertyTypeID => $additionalValues ) {
90 - if ( $smwgContLang != null ) {
91 - if ( class_exists( 'SMWDIProperty' ) ) {
92 - // For SMW 1.6+, we use the ID of each
93 - // property, instead of its label.
94 - $propertyType = $propertyTypeID;
95 - } else {
96 - $datatypeLabels = $smwgContLang->getDatatypeLabels();
97 - $datatypeLabels['enumeration'] = 'enumeration';
98 - $propertyType = $datatypeLabels[$propertyTypeID];
99 - }
100 - $this->setSemanticTypeHook( $propertyType, true, array( $inputTypeClass, 'getHTML' ), $additionalValues );
101 - }
102 - $this->mDefaultInputForPropTypeList[$propertyTypeID] = $inputTypeName;
 76+ foreach ( $defaultPropertyLists as $propertyType => $additionalValues ) {
 77+ $this->setSemanticTypeHook( $propertyType, true, array( $inputTypeClass, 'getHTML' ), $additionalValues );
 78+ $this->mDefaultInputForPropTypeList[$propertyType] = $inputTypeName;
10379 }
10480
10581 $otherProperties = call_user_func( array( $inputTypeClass, 'getOtherPropTypesHandled' ) );