/** * @param string $format * * @return array of IParamDefinition */ private function getFormatParameters($format) { if (!array_key_exists($format, $GLOBALS['smwgResultFormats'])) { return array(); } return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters())); }
/** * Returns an array containing the parameter info. * * @since 1.0 * * @return array */ protected function getParameterInfo() { $params = ParamDefinition::getCleanDefinitions(MapsMapper::getCommonParameters()); $this->service->addParameterInfo($params); $params['zoom']['default'] = false; $params['zoom']['manipulatedefault'] = false; return array_merge($params, $this->getParameterDefinitions()); }
/** * Returns an array with the default values of the parameters. * * @since 3.0 * * @return array */ protected function getDefaultValues() { $definitions = ParamDefinition::getCleanDefinitions($this->getInstance()->getParamDefinitions()); $defaults = array(); foreach ($definitions as $definition) { if (!$definition->isRequired()) { $defaults[$definition->getName()] = $definition->getDefault(); } } return $defaults; }
/** * @see ParamDefinition::formatValue() * * @since 2.0 * * @param mixed $value * @param IParam $param * @param IParamDefinition[] $definitions * @param IParam[] $params * * @return mixed */ protected function formatValue($value, IParam $param, array &$definitions, array $params) { // Make sure the service is valid. $value = MapsMappingServices::getValidServiceName($value, $this->feature); // Get the service object so the service specific parameters can be retrieved. $serviceObject = MapsMappingServices::getServiceInstance($value); // Add the service specific service parameters. $serviceObject->addParameterInfo($definitions); $definitions = ParamDefinition::getCleanDefinitions($definitions); return $value; }
/** * @see ParserHookTest::processingProvider * @since 3.0 * @return array */ public function processingProvider() { $definitions = ParamDefinition::getCleanDefinitions($this->getInstance()->getParamDefinitions()); $argLists = array(); $values = array('location' => '4,2'); $expected = array('location' => new LatLongValue(4, 2)); $argLists[] = array($values, $expected); $values = array('location' => '4,2', 'directional' => $definitions['directional']->getDefault() ? 'no' : 'yes', 'format' => 'dd'); $expected = array('location' => new LatLongValue(4, 2), 'directional' => !$definitions['directional']->getDefault(), 'format' => Maps_COORDS_DD); $argLists[] = array($values, $expected); $values = array('location' => '4,2', 'directional' => $definitions['directional']->getDefault() ? 'NO' : 'YES', 'format' => ' DD '); $expected = array('location' => new LatLongValue(4, 2), 'directional' => !$definitions['directional']->getDefault(), 'format' => Maps_COORDS_DD); $argLists[] = array($values, $expected); return $argLists; }
/** * Returns an array containing the parameter info. * * @since 1.0 * * @return array */ protected function getParameterInfo() { global $smgQPShowTitle, $smgQPTemplate, $smgQPHideNamespace; $params = ParamDefinition::getCleanDefinitions(MapsMapper::getCommonParameters()); $this->service->addParameterInfo($params); $params['staticlocations'] = array('type' => 'mapslocation', 'aliases' => array('locations', 'points'), 'default' => array(), 'islist' => true, 'delimiter' => ';', 'message' => 'semanticmaps-par-staticlocations'); $params['showtitle'] = array('type' => 'boolean', 'aliases' => 'show title', 'default' => $smgQPShowTitle); $params['hidenamespace'] = array('type' => 'boolean', 'aliases' => 'hide namespace', 'default' => $smgQPHideNamespace); $params['template'] = array('default' => $smgQPTemplate); $params['activeicon'] = array('type' => 'string', 'default' => ''); $params['pagelabel'] = array('type' => 'boolean', 'default' => false); // Messages: // semanticmaps-par-staticlocations, semanticmaps-par-forceshow, semanticmaps-par-showtitle, // semanticmaps-par-hidenamespace, semanticmaps-par-centre, semanticmaps-par-template, // semanticmaps-par-geocodecontrol, semanticmaps-par-activeicon semanticmaps-par-markerlabel foreach ($params as $name => &$data) { if (is_array($data) && !array_key_exists('message', $data)) { $data['message'] = 'semanticmaps-par-' . $name; } } $params = array_merge($params, MapsDisplayMap::getCommonMapParams()); return $params; }
/** * Returns the definitions of all parameters supported by the specified format. * * @since 1.8 * * @param string $format * * @return array of IParamDefinition */ public static function getFormatParameters($format) { SMWParamFormat::resolveFormatAliases($format); if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) { return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters())); } else { return array(); } }
/** * @dataProvider instanceProvider * * @param \SMWResultPrinter $printer */ public function testGetParamDefinitions(ResultPrinter $printer) { $params = $printer->getParamDefinitions(SMWQueryProcessor::getParameters()); $params = ParamDefinition::getCleanDefinitions($params); $this->assertInternalType('array', $params); }
/** * Returns the data needed to describe the parser hook. * This is mainly needed because some of the individual get methods * that return the needed data are protected, and cannot be made * public without breaking b/c in a rather bad way. * * @since 0.4.3 * * @param integer $type Item of the ParserHook::TYPE_ enum * * @return array */ public function getDescriptionData($type) { return array('names' => $this->getNames(), 'description' => $this->getDescription(), 'message' => $this->getMessage(), 'parameters' => ParamDefinition::getCleanDefinitions($this->getParameterInfo($type)), 'defaults' => $this->getDefaultParameters($type)); }
/** * Returns the wikitext for a table listing the provided parameters. * * @since 1.0 * * @param array $parameters * * @return string */ protected function getParameterTable(array $parameters) { $tableRows = array(); $parameters = ParamDefinition::getCleanDefinitions($parameters); foreach ($parameters as $parameter) { $tableRows[] = $this->getDescriptionRow($parameter); } $table = ''; if (count($tableRows) > 0) { $tableRows = array_merge(array('!' . $this->msg('validator-describe-header-parameter') . "\n" . '!' . $this->msg('validator-describe-header-type') . "\n" . '!' . $this->msg('validator-describe-header-default') . "\n" . '!' . $this->msg('validator-describe-header-description')), $tableRows); $table = implode("\n|-\n", $tableRows); $table = '{| class="wikitable sortable"' . "\n" . $table . "\n|}"; } return $table; }