Extension talk:StockQuote
Add topicAppearance
Latest comment: 17 years ago by JohanTheGhost
This doesnt work for some reason in 1.8.2, I cant figure it out.
Here's a version that I've fixed to work with 1.9.3. I've also added a "summary" option to do combined info without having to re-run the script.
<?php $wgExtensionFunctions[] = "wfStockQuote"; $wgExtensionCredits['parserhook'][] = array( 'name' => 'StockQuote', 'url' => 'http://www.mediawiki.org/wiki/Extension:StockQuote', 'author' => 'Olipro' ); function wfStockQuote() { global $wgParser; $wgParser->setHook('stock', 'StockQuote'); } function StockQuote($input, $argv, $parser) { global $wgParser; //ATTENTION; DISABLE THIS LINE IF YOU ARE ON HIGH LOAD! $wgParser->disableCache(); $info = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$input&f=sl1d1t1c1ohgv&e=csv"); $info = str_ireplace('"', '', $info); $info = explode(',', $info); if($info[1] == '0.00') { return 'ERROR'; } if (isset($argv['quote'])) { return $info[1]; } else if (isset($argv['change'])) { return $info[4]; } else if (isset($argv['high'])) { return $info[6]; } else if (isset($argv['low'])) { return $info[7]; } else if (isset($argv['open'])) { return $info[5]; } else if (isset($argv['volume'])) { return number_format($info[8]); } else if (isset($argv['summary'])) { return sprintf("%s: \$%.2f %s", $input, $info[1], $info[4]); } else { return $info[1]; } } ?>