/** * Returns an array containing the parameter info. * @see ParserHook::getParameterInfo * * @since 0.7 * * @return array */ protected function getParameterInfo($type) { global $egMapsDistanceUnit, $egMapsDistanceDecimals; $params = array(); $params['distance'] = new Parameter('distance'); $params['distance']->addCriteria(new CriterionIsDistance()); $params['distance']->setMessage('maps-distance-par-distance'); $params['unit'] = new Parameter('unit', Parameter::TYPE_STRING, $egMapsDistanceUnit, array(), array(new CriterionInArray(MapsDistanceParser::getUnits()))); $params['unit']->setMessage('maps-distance-par-unit'); $params['decimals'] = new Parameter('decimals', Parameter::TYPE_INTEGER, $egMapsDistanceDecimals); $params['decimals']->setMessage('maps-distance-par-decimals'); return $params; }
/** * Returns an array containing the parameter info. * @see ParserHook::getParameterInfo * * @since 0.7 * * @return array */ protected function getParameterInfo($type) { global $egMapsDistanceUnit, $egMapsDistanceDecimals; $params = array(); $params['distance'] = array('type' => 'distance'); $params['unit'] = array('default' => $egMapsDistanceUnit, 'values' => MapsDistanceParser::getUnits()); $params['decimals'] = array('type' => 'integer', 'default' => $egMapsDistanceDecimals); // Give grep a chance to find the usages: // maps-distance-par-distance, maps-distance-par-unit, maps-distance-par-decimals foreach ($params as $name => &$param) { $param['message'] = 'maps-distance-par-' . $name; } return $params; }
/** * Returns an array containing the parameter info. * @see ParserHook::getParameterInfo * * @since 0.7 * * @return array */ protected function getParameterInfo($type) { global $egMapsDistanceUnit, $egMapsDistanceDecimals, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; $params = array(); $params['mappingservice'] = array('default' => '', 'values' => MapsMappingServices::getAllServiceValues(), 'tolower' => true); $params['geoservice'] = array('default' => $egMapsDefaultGeoService, 'aliases' => 'service', 'values' => $egMapsAvailableGeoServices, 'tolower' => true); $params['unit'] = array('default' => $egMapsDistanceUnit, 'values' => MapsDistanceParser::getUnits()); $params['decimals'] = array('type' => 'integer', 'default' => $egMapsDistanceDecimals); $params['location1'] = array('type' => 'mapslocation', 'aliases' => 'from', 'dependencies' => array('mappingservice', 'geoservice')); $params['location2'] = array('type' => 'mapslocation', 'aliases' => 'to', 'dependencies' => array('mappingservice', 'geoservice')); // Give grep a chance to find the usages: // maps-geodistance-par-mappingservice, maps-geodistance-par-geoservice, // maps-geodistance-par-unit, maps-geodistance-par-decimals, // maps-geodistance-par-location1, maps-geodistance-par-location2 foreach ($params as $name => &$param) { $param['message'] = 'maps-geodistance-par-' . $name; } return $params; }
/** * Returns an array containing the parameter info. * @see ParserHook::getParameterInfo * * @since 0.7 * * @return array */ protected function getParameterInfo($type) { global $egMapsDistanceUnit, $egMapsDistanceDecimals, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; $params = array(); $params['location1'] = new Parameter('location1', Parameter::TYPE_STRING, null, array('from'), array(new CriterionIsLocation())); $params['location1']->addDependencies('mappingservice', 'geoservice'); $params['location1']->setMessage('maps-geodistance-par-location1'); $params['location2'] = new Parameter('location2', Parameter::TYPE_STRING, null, array('to'), array(new CriterionIsLocation())); $params['location2']->addDependencies('mappingservice', 'geoservice'); $params['location2']->setMessage('maps-geodistance-par-location2'); $params['unit'] = new Parameter('unit', Parameter::TYPE_STRING, $egMapsDistanceUnit, array(), array(new CriterionInArray(MapsDistanceParser::getUnits()))); $params['unit']->addManipulations(new ParamManipulationFunctions('strtolower')); $params['unit']->setMessage('maps-geodistance-par-unit'); $params['decimals'] = new Parameter('decimals', Parameter::TYPE_INTEGER, $egMapsDistanceDecimals); $params['decimals']->setMessage('maps-geodistance-par-decimals'); $params['mappingservice'] = new Parameter('mappingservice', Parameter::TYPE_STRING, '', array(), array(new CriterionInArray(MapsMappingServices::getAllServiceValues()))); $params['mappingservice']->addManipulations(new ParamManipulationFunctions('strtolower')); $params['mappingservice']->setMessage('maps-geodistance-par-mappingservice'); $params['geoservice'] = new Parameter('geoservice', Parameter::TYPE_STRING, $egMapsDefaultGeoService, array('service'), array(new CriterionInArray($egMapsAvailableGeoServices))); $params['geoservice']->addManipulations(new ParamManipulationFunctions('strtolower')); $params['geoservice']->setMessage('maps-geodistance-par-geoservice'); return $params; }
/** * Tests MapsDistanceParser::getUnits() */ public function testGetUnits() { $this->assertEquals(array_keys($GLOBALS['egMapsDistanceUnits']), MapsDistanceParser::getUnits()); }