*/ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) die(); if(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_PLUGIN.'eshop/images/'); require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_eshop extends DokuWiki_Syntax_Plugin { function getType() { return 'substition'; } function getPType() { return 'block'; } function getSort() { return 201; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{eshop>[^}]*\}\}', $mode, 'plugin_eshop'); } function handle($match, $state, $pos, &$handler) { $match = substr($match, 8, -2); $pairs = explode('&', $match); foreach ($pairs as $pair) { list($key, $value) = explode('=', $pair, 2); $data[trim($key)] = trim($value); } $data = array_change_key_case($data, CASE_LOWER); $btcusd = $this->getConf('btcusd'); $eurusd = $this->getConf('eurusd'); if ($data['usd'] && $btcusd && !$data['btc']) { $data['btc'] = $data['usd'] / $btcusd; } else if ($data['btc'] && $btcusd && !$data['usd']) { $data['usd'] = $data['btc'] * $btcusd; } if ($data['usd'] && $eurusd) { $data['eur'] = $data['usd'] / $eurusd; } if (!$data['btc']) $data['btc'] = 0.0; if (!$data['eur']) $data['eur'] = 0.0; if (!$data['usd']) $data['usd'] = 0.0; return $data; } function render($mode, &$renderer, $data) { if ($data === false || $mode != 'xhtml') return false; global $INFO; $out = '
'; $out .= ''; $out .= sprintf('', $data['usd'], $data['usd']); $out .= sprintf('', $data['eur'], $data['eur']); $out .= sprintf('', $data['btc'], $data['btc']); $out .= ''; $out .= ''; $out .= '
Price in USD:%0.2f
Price in EUR:%0.2f
Price in BTC:%0.3f
Quantity:
'; $out .= sprintf('', end(explode(':', $INFO['id']))); $out .= sprintf('', $INFO['meta']['title']); $out .= sprintf('', $data['btc']); $out .= sprintf('', $data['btc']); $out .= '
'; $renderer->doc .= $out; return true; } } ?>