00001 <?php
00002
00013 if ( !defined( 'MEDIAWIKI' ) ) {
00014 die( 'Not an entry point.' );
00015 }
00016
00017 $wgResourceModules['ext.sm.forminputs'] = array(
00018 'dependencies' => array( 'ext.maps.coord' ),
00019 'localBasePath' => dirname( __FILE__ ),
00020 'remoteBasePath' => $smgScriptPath . '/includes/forminputs',
00021 'group' => 'ext.semanticmaps',
00022 'scripts' => array(
00023 'jquery.mapforminput.js'
00024 ),
00025 'messages' => array(
00026 'semanticmaps_enteraddresshere',
00027 'semanticmaps-updatemap',
00028 'semanticmaps_lookupcoordinates',
00029 'semanticmaps-forminput-remove',
00030 'semanticmaps-forminput-add',
00031 'semanticmaps-forminput-locations'
00032 )
00033 );
00034
00035 $wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize';
00036
00037 final class SMFormInputs {
00038
00039 public static function initialize() {
00040 global $wgAutoloadClasses;
00041
00042
00043
00044 if ( !defined( 'SF_VERSION' ) ) return true;
00045
00046 $wgAutoloadClasses['SMFormInput'] = dirname( __FILE__ ) . '/SM_FormInput.php';
00047
00048 $hasFormInputs = false;
00049
00050 foreach ( MapsMappingServices::getServiceIdentifiers() as $serviceIdentifier ) {
00051 $service = MapsMappingServices::getServiceInstance( $serviceIdentifier );
00052
00053
00054 $FIClass = $service->getFeature( 'fi' );
00055
00056
00057 if ( $FIClass === false ) continue;
00058
00059
00060 $hasFormInputs = true;
00061
00062
00063 self::initFormHook( $service->getName(), $service->getName() );
00064
00065
00066 foreach ( $service->getAliases() as $alias ) {
00067 self::initFormHook( $alias, $service->getName() );
00068 }
00069 }
00070
00071
00072 if ( $hasFormInputs ) self::initFormHook( 'map' );
00073
00074 return true;
00075 }
00076
00083 private static function initFormHook( $inputName, $mainName = '' ) {
00084 global $sfgFormPrinter;
00085
00086
00087 $field_args = array();
00088
00089 if ( $mainName !== '' ) {
00090 $field_args['service_name'] = $mainName;
00091 }
00092
00093
00094
00095 $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args );
00096 }
00097
00098 }
00099
00111 function smfSelectFormInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args ) {
00112
00113 $serviceName = array_key_exists( 'service_name', $field_args ) ? $field_args['service_name'] : null;
00114
00115
00116 $service = MapsMappingServices::getValidServiceInstance( $serviceName, 'fi' );
00117
00118
00119 $formInput = $service->getFeatureInstance( 'fi' );
00120
00121
00122 return $formInput->getInputOutput( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args );
00123 }