protected function getResultText($res, $outputmode) { global $wgParser; $dataArray = array(); while ( $row = $res->getNext() ) { $values = array(); foreach ($row as $i => $field) { while ( ($object = $field->getNextObject()) !== false ) { if ($object->getTypeID() == '_dat') { $values[] = SRFCalendar::formatDateStr($object); } elseif ($object->getTypeID() == '_wpg') { // use shorter "LongText" for wikipage $values[] = $object->getLongText($outputmode, null); } else { $values[] = $object->getShortText($outputmode, null); } } } $dataArray[] = $values; } $pParser = new PlottersParser(); $pParser->setData( $dataArray ); $pParser->parseArguments( $this->params ); $pPlotter = new Plotters( $pParser, $wgParser ); $pPlotter->checkForErrors(); if ( $pPlotter->hasErrors() ) { $results = $pPlotter->getErrors(); } else { $results = $pPlotter->toHTML(); } if (is_null($wgParser->getTitle())) return $results; else return array($results, 'noparse' => 'true', 'isHTML' => 'true'); }
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 ); } }
/** * Hook callback that injects messages and things into the <head> tag * Does nothing if $parserOutput->mPlotterTag is not set */ function PlottersParserOutput( $outputPage, $parserOutput ) { if ( !empty( $parserOutput->mPlottersTag ) ) { // Output required javascript $genericname = "generic"; $plotkitname = "plotkit"; if ( $parserOutput->mplotter["$genericname"] ) { Plotters::setPlottersHeaders( $outputPage, 'generic' ); } elseif ( $parserOutput->mplotter["$plotkitname"] ) { Plotters::setPlottersHeaders( $outputPage, 'plotkit' ); } // Output user defined javascript $plotters = wfLoadPlotters(); if ( !$plotters ) return true; $done = array(); foreach ( $plotters as $pname => $code ) { $tname = strtolower( "$pname" ); if ( $parserOutput->mplotter["$tname"] ) { wfApplyPlotterCode( $code, $outputPage, $done ); } } } return true; }