コード例 #1
0
	function parseData( $input ) {
		$this->dataArray = array();

		Plotters::debug( 'plot script input: ', $this->argumentArray["scriptarguments"] );
		if ( trim( $input ) == '' ) {
			return;
		}

		// Replace escaped separators
		$sep = $this->argumentArray["datasep"];
		$input = preg_replace( "/\\\\$sep/", '§UNIQ§', $input );

		// Parse and sanitize data
		$lines = preg_split( "/\n/", $input, -1, PREG_SPLIT_NO_EMPTY );
		foreach ( $lines as $line ) {
			$values = explode( $sep, $line );
			foreach ( $values as &$value ) {
				// Fix escaped separators
				$value = preg_replace( "/§UNIQ§/", "$sep", $value );
				$value = htmlentities( $value, ENT_QUOTES );
			}
			$this->dataArray[] = $values;
			Plotters::debug( 'plot data values: ', $values );
		}
	}
コード例 #2
0
function initPlottersPF( $parser ) {
	$numargs = func_num_args();
	if ( $numargs < 2 ) {
		$input = wfMsg( "plotters-errors" ) . " " . wfMsg( "plotters-missing-arguments" );
		return str_replace( '§', '<', '§pre>§nowiki>' . $input . '§/nowiki>§/pre>' );
	}

	// fetch all user-provided arguments (skipping $parser)
	$input = "";
	$argv = array();
	$arg_list = func_get_args();
	for ( $i = 1; $i < $numargs; $i++ ) {
		$p1 = $arg_list[$i];

		$aParam = explode( '=', $p1, 2 );
		if ( count( $aParam ) < 2 ) {
			continue;
		}
		Plotters::debug( 'plot tag parameter: ', $aParam );
		if ( $aParam[0] == "data" ) {
			$input = $aParam[1];
			continue;
		}
		$sKey = trim( $aParam[0] );
		$sVal = trim( $aParam[1] );

		if ( $sKey != '' ) {
			$argv[$sKey] = $sVal;
		}
	}

	$output = initPlotters( $input, $argv, $parser );
	return array( $output, 'noparse' => true, 'isHTML' => true );
}