Tel:
Text:
SMS:
Groessen:
s=5 : S
s=6 : M
s=8 : L
s=12 : XL
*/
/**
* Plugin qrcode: 2D-Barcode Implementation
*
* @license GNU
* @author Juergen A.Lamers
*/
if (!defined('DOKU_INC'))
define('DOKU_INC', realpath(dirname( __FILE__ ).'/../../../').'/');
if (!defined('DOKU_PLUGIN'))
define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
require_once (DOKU_PLUGIN.'syntax.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_qrcode_qrcode extends DokuWiki_Syntax_Plugin
{
/**
* return some info
*/
function getInfo()
{
return array (
'author'=>'Juergen A.Lamers',
'email'=>'jaloma.ac@googlemail.com',
'date'=>@file_get_contents(DOKU_PLUGIN . 'qrcode/VERSION'),
'name'=>'qrcode -- 2D-Barcode Plugin',
'desc'=>'2D-Barcode Plugin using http://qrcode.kaywa.com/ ~~QRCODE~text~~',
'url'=>'http://wiki.splitbrain.org/plugin:qrcode',
);
}
/**
* What kind of syntax are we?
*/
function getType()
{
return 'substition';
}
/**
* What about paragraphs? (optional)
*/
function getPType()
{
return 'inline';
}
/**
* Where to sort in?
*/
function getSort()
{
return 999;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode)
{
$this->Lexer->addSpecialPattern('~~QRCODE.*?~~', $mode, 'plugin_qrcode_qrcode');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, & $handler)
{
global $conf;
$resultStr = '';
$paramsArr = explode('~', $match);
$align = "";//"middle";
$last = count($paramsArr);
for ($i = 0; $i < $last; $i++)
{
$currentParam = $paramsArr[$i];
if ($i == 3 && $currentParam[0] == ' ')
{
$align = 'align="left"';//"top";
$currentParam = substr($currentParam, 1);
} elseif ($currentParam[strlen($currentParam)-1] == ' ' && $i == ($last-3))
{
// Habe ich schon am Anfang ein ' ' gehabt, schalte ich jetzt auf 'center' um
if ($align == 'align="left"')
{
$align = 'align="center"';
} else
{
$align = 'align="right"';//"bottom";
}
$currentParam = substr($currentParam, 1, sizeof($currentParam)-1);
}
$paramPairArr = explode('=', $currentParam);
switch($paramPairArr[0])
{
case 'QRCODE':
break;
case '':
break;
case 'size':
$size = $paramPairArr[1];
/*
s=5 : S
s=6 : M
s=8 : L
s=12 : XL
*/
switch($size)
{
case 'S':
$resultStr .= '&s=5';
break;
case 'M':
$resultStr .= '&s=6';
break;
case 'L':
$resultStr .= '&s=8';
break;
case 'XL':
$resultStr .= '&s=12';
break;
default:
$resultStr .= '&s=15';
break;
}
case 'url':
/*
URL:
*/
$resultStr .= '&d=http%3A%2F%2F'.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8');
break;
case 'tel':
/*
Tel:
*/
$resultStr .= '&d=TEL'.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8');
break;
case 'text':
/*
Text:
*/
$resultStr .= '&d='.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8');
break;
case 'sms':
/*
SMS:
*/
$resultStr .= '&d=SMSTO'.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8');
break;
default:
// $resultStr .= ' ' . $paramPairArr[0] . '="' . $paramPairArr[1] . '"';
break;
}
}
/*
Don't have barcode reader ? click here http://www.freewarepocketpc.net/ppc-tag-barcode.html
QRcode generated by Tec-it http://www.tec-it.com/online-demos/tbarcode/barcode-generator.aspx
qrcode.kaywa.com
Download i-nigma barcode reader v1.40
*/
return '';
}
/**
* Create output
*/
function render($mode, & $renderer, $data)
{
if ($mode == 'xhtml')
{
$renderer->doc .= $data;
if ($this->getConf('qrcodeshowfooter'))
{
$txt = 'Dont have barcode reader ? click here http://www.freewarepocketpc.net/ppc-tag-barcode.html
QRcode generated by Tec-it http://www.tec-it.com/online-demos/tbarcode/barcode-generator.aspx
qrcode.kaywa.com
Download i-nigma barcode reader v1.40
';
$renderer->doc .= $txt;
}
return true;
}
return false;
}
} // Class
//Setup VIM: ex: et ts=4 enc=utf-8 :