public function testGivenParameterWithAliases_aliasesAreListed()
 {
     $param = new ParamDefinition('number', 'length');
     $param->addAliases('abc', 'def');
     $wikiText = $this->builder->getParameterTable(array($param));
     $expected = array('{| class="wikitable sortable"', '!validator-describe-header-parameter', '!validator-describe-header-type', '!validator-describe-header-default', '!validator-describe-header-description', '|-', '|length', '|abc, def', '|validator-type-number', "|''validator-describe-required''", '|', '|}');
     $this->stringValidator->assertThatStringContains($expected, $wikiText);
 }
 /**
  * Sets the parameter definition values contained in the provided array.
  * @see ParamDefinition::setArrayValues
  *
  * @since 1.0
  *
  * @param array $param
  */
 public function setArrayValues(array $param)
 {
     parent::setArrayValues($param);
     if (array_key_exists('tolower', $param)) {
         $this->toLower = $param['tolower'];
     }
 }
 /**
  * @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()));
 }
Esempio n. 4
0
 /**
  * Returns the value to initially display with the input.
  * 
  * @since 1.9
  * 
  * @return string
  */
 protected function getValueToUse()
 {
     $value = $this->currentValue === false ? $this->param->getDefault() : $this->currentValue;
     if ($this->param->isList() && is_array($value)) {
         $value = implode($this->param->getDelimiter(), $value);
     }
     return $value;
 }
Esempio n. 5
0
 /**
  * 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());
 }
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
0
 /**
  * @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;
 }
Esempio n. 8
0
 /**
  * @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;
 }
Esempio n. 9
0
 /**
  * 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 wikitext for a table row describing a single parameter.
     *
     * @param ParamDefinition $parameter
     * @param boolean $hasAliases
     *
     * @return string
     */
    private function getDescriptionRow(ParamDefinition $parameter, $hasAliases)
    {
        if ($hasAliases) {
            $aliases = $parameter->getAliases();
            $aliases = count($aliases) > 0 ? implode(', ', $aliases) : '-';
        }
        $description = $this->msg($parameter->getMessage());
        $type = $this->msg($parameter->getTypeMessage());
        $default = $parameter->isRequired() ? "''" . $this->msg('validator-describe-required') . "''" : $parameter->getDefault();
        if (is_array($default)) {
            $default = implode(', ', $default);
        } elseif (is_bool($default)) {
            $default = $default ? 'yes' : 'no';
        }
        if ($default === '') {
            $default = "''" . $this->msg('validator-describe-empty') . "''";
        }
        return "|{$parameter->getName()}\n" . ($hasAliases ? '|' . $aliases . "\n" : '') . <<<EOT
|{$type}
|{$default}
|{$description}
EOT;
    }
 /**
  * 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();
     }
 }
 /**
  * Get the HTML for a single parameter input
  *
  * @since 1.8
  *
  * @param ParamDefinition $definition
  * @param mixed $currentValue
  *
  * @return string
  */
 protected function showFormatOption(ParamDefinition $definition, $currentValue)
 {
     // Init
     $description = '';
     $input = new ParameterInput($definition);
     $input->setInputName('p[' . $definition->getName() . ']');
     //$input->setInputClass( 'smw-ask-input-' . str_replace( ' ', '-', $definition->getName() ) );
     if ($currentValue !== false) {
         $input->setCurrentValue($currentValue);
     }
     // Parameter description text
     if (!$this->isTooltipDisplay()) {
         $tooltipInfo = $definition->getMessage() !== null ? $this->msg($definition->getMessage())->parse() : '';
         $description = Html::rawElement('span', array('class' => 'smw-ask-parameter-description'), '<br />' . $tooltipInfo);
     }
     return Html::rawElement('td', array('overflow' => 'hidden'), $input->getHtml() . $description);
 }
 /**
  * @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));
 }
Esempio n. 15
0
    /**
     * Returns the wikitext for a table row describing a single parameter.
     *
     * @since 1.0
     *
     * @param ParamDefinition $parameter
     *
     * @return string
     */
    protected function getDescriptionRow(ParamDefinition $parameter)
    {
        $description = $this->msg($parameter->getMessage());
        $type = $parameter->getTypeMessage();
        $default = $parameter->isRequired() ? "''" . $this->msg('validator-describe-required') . "''" : $parameter->getDefault();
        if (is_array($default)) {
            $default = implode(', ', $default);
        } elseif (is_bool($default)) {
            $default = $default ? 'yes' : 'no';
        }
        if ($default === '') {
            $default = "''" . $this->msg('validator-describe-empty') . "''";
        }
        return <<<EOT
| {$parameter->getName()}
| {$type}
| {$default}
| {$description}
EOT;
    }
Esempio n. 16
0
 /**
  * Returns the parameter name aliases.
  *
  * @since 1.0
  *
  * @return array
  */
 public function getAliases()
 {
     return $this->definition->getAliases();
 }