/**
  * 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();
     }
 }
Esempio n. 2
0
 /**
  * @param string $format
  *
  * @return array of IParamDefinition
  */
 protected function getFormatParameters($format)
 {
     if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) {
         return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters()));
     } else {
         return array();
     }
 }
Esempio n. 3
0
 /**
  * Renders and returns the output.
  * @see ParserHook::render
  *
  * @since 1.0
  *
  * @param array $parameters
  *
  * @return string
  */
 public function render(array $parameters)
 {
     $this->language = $parameters['language'];
     $params = array();
     if (in_array($parameters['parameters'], array('all', 'base'))) {
         $params = array_merge($params, SMWQueryProcessor::getParameters());
     }
     if (in_array($parameters['parameters'], array('all', 'specific'))) {
         $params = array_merge($params, $this->getFormatParameters($parameters['format']));
     }
     return $this->getParameterTable($params);
 }
Esempio n. 4
0
 /**
  * @dataProvider instanceProvider
  *
  * @param \SMWResultPrinter $printer
  */
 public function testGetParamDefinitions(\SMWResultPrinter $printer)
 {
     $params = $printer->getParamDefinitions(\SMWQueryProcessor::getParameters());
     $params = \ParamDefinition::getCleanDefinitions($params);
     $this->assertInternalType('array', $params);
 }
	/**
	 * Display a form section showing the options for a given format,
	 * based on the getParameters() value for that format's query printer.
	 *
	 * @param string $format
	 * @param array $paramValues The current values for the parameters (name => value)
	 *
	 * @return string
	 */
	protected function showFormatOptions( $format, array $paramValues ) {
		$printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE );

		$params = SMWQueryProcessor::getParameters();

		if ( method_exists( $printer, 'getValidatorParameters' ) ) {
			$params = array_merge( $params, $printer->getValidatorParameters() );
		}

		$optionsHtml = array();

		foreach ( $params as $param ) {
			// Ignore the format parameter, as we got a special control in the GUI for it already.
			if ( $param->getName() == 'format' ) {
				continue;
			}

			$currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false;

			$optionsHtml[] =
				Html::rawElement(
					'div',
					array(
						'style' => 'width: 30%; padding: 5px; float: left;'
					),
					htmlspecialchars( $param->getName() ) . ': ' .
					$this->showFormatOption( $param, $currentValue ) .
					'<br />' .
					Html::element( 'em', array(), $param->getDescription() )
				);
		}

		for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) {
			if ( $i % 3 == 2 || $i == $n - 1 ) {
				$optionsHtml[$i] .= "<div style=\"clear: both\";></div>\n";
			}
		}

		$i = 0;
		$rowHtml = '';
		$resultHtml = '';

		while ( $option = array_shift( $optionsHtml ) ) {
			$rowHtml .= $option;
			$i++;

			$resultHtml .= Html::rawElement(
				'div',
				array(
					'style' => 'background: ' . ( $i % 6 == 0 ? 'white' : '#dddddd' ) . ';'
				),
				$rowHtml
			);

			$rowHtml = '';
		}

		return $resultHtml;
	}
Esempio n. 6
0
	public function getParameters() {		
		global $smwgQMaxInlineLimit;

		$params = array();
		$dfltParams = SMWQueryProcessor::getParameters();
		
		### adjusted basic SMW params: ###
		
		$params['limit'] = $dfltParams['limit'];
		$params['limit']->setDefault( $smwgQMaxInlineLimit );
		
		$params['link'] = $dfltParams['link'];
		$params['link']->setDefault( 'none' );
		
		$params['headers'] = $dfltParams['headers'];
		$params['headers']->setDefault( 'hide' );
		
		### new params: ###
		
		$params['titles'] = new Parameter( 'titles' );
		$params['titles']->setMessage( 'srf_paramdesc_pagetitle' );
		$params['titles']->addCriteria( new CriterionInArray( 'show', 'hide' ) );
		$params['titles']->addAliases( 'pagetitle', 'pagetitles' );
		$params['titles']->setDefault( 'show' );
		
		$params['hidegaps'] = new Parameter( 'hidegaps' );
		$params['hidegaps']->setMessage( 'srf_paramdesc_hidegaps' );
		$params['hidegaps']->addCriteria( new CriterionInArray( 'none', 'all', 'property', 'record' ) );
		$params['hidegaps']->setDefault( 'none' );
		
		# name to create 'real' array with if set (empty string '' counts as set!):
		$params['name'] = new Parameter( 'name' );
		$params['name']->setMessage( 'srf_paramdesc_arrayname' );
		$params['name']->setDefault( false, false );
		
		# separators (default values are defined in the following globals:)
		global $srfgArraySep, $srfgArrayPropSep, $srfgArrayManySep, $srfgArrayRecordSep, $srfgArrayHeaderSep;
		
		$params['sep'] = new Parameter( 'sep' );
		$params['sep']->setMessage( 'smw_paramdesc_sep' );
		$params['sep']->setDefault( $this->initializeCfgValue( $srfgArraySep, 'sep' ) );
		
		$params['propsep'] = new Parameter( 'propsep' );
		$params['propsep']->setMessage( 'srf_paramdesc_propsep' );
		$params['propsep']->setDefault( $this->initializeCfgValue( $srfgArrayPropSep, 'propsep' ) );
		
		$params['manysep'] = new Parameter( 'manysep' );
		$params['manysep']->setMessage( 'srf_paramdesc_manysep' );
		$params['manysep']->setDefault( $this->initializeCfgValue( $srfgArrayManySep, 'manysep' ) );
		
		$params['recordsep'] = new Parameter( 'recordsep' );
		$params['recordsep']->setMessage( 'srf_paramdesc_recordsep' );
		$params['recordsep']->addAliases( 'narysep', 'rcrdsep', 'recsep' );
		$params['recordsep']->setDefault( $this->initializeCfgValue( $srfgArrayRecordSep, 'recordsep' ) );
		
		$params['headersep'] = new Parameter( 'headersep' );
		$params['headersep']->setMessage( 'srf_paramdesc_headersep' );
		$params['headersep']->addAliases( 'narysep', 'rcrdsep', 'recsep' );
		$params['headersep']->setDefault( $this->initializeCfgValue( $srfgArrayHeaderSep, 'headersep' ) );
		
		return $params;
	}