当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::setParameters方法代码示例

本文整理汇总了PHP中Validator::setParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::setParameters方法的具体用法?PHP Validator::setParameters怎么用?PHP Validator::setParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::setParameters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateAndRender

	/**
	 * Takes care of validation and rendering, and returns the output.
	 *
	 * @since 0.4
	 *
	 * @param array $arguments
	 * @param integer $type Item of the ParserHook::TYPE_ enum
	 *
	 * @return string
	 */
	public function validateAndRender( array $arguments, $type ) {
		$names = $this->getNames();
		$this->validator = new Validator( $names[0] );

		if ( $type === self::TYPE_FUNCTION ) {
			$this->validator->setFunctionParams( $arguments, $this->getParameterInfo( $type ), $this->getDefaultParameters( $type ) );
		}
		else {
			$this->validator->setParameters( $arguments, $this->getParameterInfo( $type ) );
		}

		$this->validator->validateParameters();

		$fatalError = $this->validator->hasFatalError();

		if ( $fatalError === false ) {
			$output = $this->render( $this->validator->getParameterValues() );
			$output = $this->renderErrors( $output );
		}
		else {
			$output = $this->renderFatalError( $fatalError );
		}

		return $output;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:ParserHook.php

示例2: getValidatorForParams

 /**
  * Takes an array of unprocessed parameters,
  * and sets them on a new Validator object,
  * which is returned and ready to process the parameters.
  *
  * @since 1.8
  *
  * @param array $params
  * @param array $printRequests
  * @param boolean $unknownInvalid
  *
  * @return Validator
  */
 public static function getValidatorForParams(array $params, array $printRequests = array(), $unknownInvalid = true)
 {
     $paramDefinitions = self::getParameters();
     $paramDefinitions['format']->setPrintRequests($printRequests);
     $validator = new Validator('SMW query', $unknownInvalid);
     $validator->setParameters($params, $paramDefinitions, false);
     return $validator;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:SMW_QueryProcessor.php

示例3: getProcessedParams

 /**
  * Takes an array of unprocessed parameters,
  * processes them using Validator, and returns them.
  * 
  * Both input and output arrays are
  * param name (string) => param value (mixed)
  * 
  * @since 1.6.2
  * 
  * @param array $params
  * @param array $printRequests
  * @param boolean $unknownInvalid
  * 
  * @return array
  */
 public static function getProcessedParams(array $params, array $printRequests = null, $unknownInvalid = true)
 {
     $paramDefinitions = self::getParameters();
     $formatManipulation = new SMWParamFormat();
     if (!is_null($printRequests)) {
         $formatManipulation->setPrintRequests($printRequests);
     }
     $paramDefinitions['format']->addManipulations($formatManipulation);
     $validator = new Validator('SMW query', $unknownInvalid);
     $validator->setParameters($params, $paramDefinitions, false);
     $validator->validateParameters();
     return $validator->getParameterValues();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:SMW_QueryProcessor.php

示例4: setParams

 /**
  * Sets the parameters for the query.
  *
  * The structure of $params is defined partly by #ask and also by the
  * Result Printer used. When validation is enabled, $params are checked
  * for conformance, and error messages, if any, are returned.
  *
  * Although it is not mandatory for any params to be set while calling
  * this method, this method must be called so that default parameters
  * are used.
  *
  * @global int $smwgQMaxInlineLimit
  * @global array $smwgResultFormats
  * @param array $params
  * @param boolean $enableValidation
  * @return array of strings
  */
 public function setParams(array $params = array(), $enableValidation = false)
 {
     global $smwgQMaxInlineLimit, $smwgResultFormats;
     $errors = array();
     // checking for missing parameters and adding them
     if (!array_key_exists('format', $params) || !array_key_exists($params['format'], $smwgResultFormats)) {
         $params['format'] = $this->defaultResultPrinter;
     }
     if (!array_key_exists('limit', $params)) {
         $params['limit'] = 20;
     }
     $params['limit'] = min($params['limit'], $smwgQMaxInlineLimit);
     if (!array_key_exists('offset', $params)) {
         $params['offset'] = 0;
     }
     if ($enableValidation) {
         // validating the format
         if (!array_key_exists($params['format'], $smwgResultFormats)) {
             $errors[] = wfMsg('smw_qui_invalidformat', $params['format']);
             $this->errorsOccured = true;
         } else {
             // validating parameters for result printer
             $printer = SMWQueryProcessor::getResultPrinter($params['format']);
             $para_meters = $printer->getParameters();
             if (is_array($para_meters)) {
                 $validator = new Validator();
                 $validator->setParameters($params, $para_meters);
                 $validator->validateParameters();
                 if ($validator->hasFatalError()) {
                     array_merge($errors, $validator->getErrorMessages());
                     $this->errorsOccured = true;
                 }
             }
         }
     }
     $this->parameters = $params;
     $this->errors = array_merge($errors, $this->errors);
     return $errors;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:SMW_QueryUIHelper.php

示例5: validate

 /**
  * Validates the layer.
  * 
  * @since 0.7.1
  */
 protected function validate()
 {
     $validator = new Validator();
     $validator->setParameters($this->properties, $this->getParameterDefinitions(array()));
     $validator->validateParameters();
     if ($validator->hasFatalError() !== false) {
         $this->errors = $validator->getErrors();
     }
     $this->properties = $validator->getParameterValues();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:Maps_Layer.php

示例6: validate

 /**
  * Validates the layer.
  * 
  * @since 0.7.1
  */
 protected function validate()
 {
     if ($this->hasValidated) {
         return;
     }
     $this->hasValidated = true;
     $validator = new Validator();
     $validator->setParameters($this->properties, $this->getParameterDefinitions());
     $validator->validateParameters();
     if ($validator->hasErrors() !== false) {
         $this->errors = $validator->getErrors();
     }
     $params = $validator->getParameterValues();
     $this->properties = $params;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:20,代码来源:Maps_Layer.php

示例7: getInputOutput

 /**
  * 
  * 
  * @since 1.0
  * 
  * @param string $coordinates
  * @param string $input_name
  * @param boolean $is_mandatory
  * @param boolean $is_disabled
  * @param array $field_args
  * 
  * @return string
  */
 public function getInputOutput($coordinates, $input_name, $is_mandatory, $is_disabled, array $params)
 {
     $parameters = array();
     foreach ($params as $key => $value) {
         if (!is_array($value) && !is_object($value) && !is_null($value)) {
             $parameters[$key] = $value;
         }
     }
     if (!is_null($coordinates)) {
         $parameters['locations'] = $coordinates;
     }
     $validator = new Validator(wfMessage('maps_' . $this->service->getName())->text(), false);
     $validator->setParameters($parameters, $this->getParameterInfo());
     $validator->validateParameters();
     $fatalError = $validator->hasFatalError();
     if ($fatalError === false) {
         global $wgParser;
         $params = $validator->getParameterValues();
         // We can only take care of the zoom defaulting here,
         // as not all locations are available in whats passed to Validator.
         if ($params['zoom'] === false && count($params['locations']) <= 1) {
             $params['zoom'] = $this->service->getDefaultZoom();
         }
         $mapName = $this->service->getMapId();
         $params['inputname'] = $input_name;
         $output = $this->getInputHTML($params, $wgParser, $mapName);
         $this->service->addResourceModules($this->getResourceModules());
         $configVars = Skin::makeVariablesScript($this->service->getConfigVariables());
         // MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook.
         if (version_compare($GLOBALS['wgVersion'], '1.18', '<')) {
             $GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables();
         }
         if (true) {
             // TODO
             global $wgOut;
             $this->service->addDependencies($wgOut);
             $wgOut->addScript($configVars);
         } else {
             $this->service->addDependencies($wgParser);
         }
         return $output;
     } else {
         return '<span class="errorbox">' . htmlspecialchars(wfMessage('validator-fatal-error', $fatalError->getMessage())->text()) . '</span>';
     }
 }
开发者ID:nischayn22,项目名称:mediawiki-extensions-SemanticMaps,代码行数:58,代码来源:SM_FormInput.php


注:本文中的Validator::setParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。