1<?php 2/* 3 http://encode.i-nigma.com/ 4 URL: (QRCode) 5 <img src="http://encode.i-nigma.com/QRCode/img.php?d=URL%3Ahttp%3A%2F%2Fwww.ich-bin-am-wandern-gewesen.de%2F&c=WanderWiki&s=3" alt="" /> 6 <img src="http://encode.i-nigma.com/QRCode/img.php?d=URL%3Ahttp%3A%2F%2Fwww.ich-bin-am-wandern-gewesen.de%2F&c=WanderWiki&s=4" alt="" /> 7 <img src="http://encode.i-nigma.com/QRCode/img.php?d=URL%3Ahttp%3A%2F%2Fwww.ich-bin-am-wandern-gewesen.de%2F&c=WanderWiki&s=6" alt="" /> 8 Groessen: 9 s=3 : Small 10 s=4 : Medium 11 s=6 : Large 12 c := Caption 13 d := Befehl 14 URL: (DataMatrix) 15 <img src="http://encode.i-nigma.com/DMtrx/img.php?d=URL%3Ahttp%3A%2F%2Fwww.ich-bin-am-wandern-gewesen.de%2F&c=WanderWiki&s=6" alt="" /> 16 Message: 17 <img src="http://encode.i-nigma.com/DMtrx/img.php?d=Das%20Wandern%20ist%20des%20M%C3%BCllers%20Lust.&c=WanderWiki&s=6" alt="" /> 18 Personal Info: 19 Name - Phone - EMail 20 <img src="http://encode.i-nigma.com/DMtrx/img.php?d=BEGIN%3AVCARD%0AN%3ANName%2C%20VName%0ATEL%3A0241112%0AEMAIL%3Aschrott%40trash-mail.com%0AEND%3AVCARD&c=WanderWiki&s=6" alt="" /> 21 */ 22 23/** 24 * Plugin qrcode: 2D-Barcode Implementation 25 * 26 * @license GNU 27 * @author Juergen A.Lamers <jaloma.ac@googlemail.com> 28 */ 29 30if (!defined('DOKU_INC')) 31define('DOKU_INC', realpath(dirname( __FILE__ ).'/../../../').'/'); 32if (!defined('DOKU_PLUGIN')) 33define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 34require_once (DOKU_PLUGIN.'syntax.php'); 35 36/** 37 * All DokuWiki plugins to extend the parser/rendering mechanism 38 * need to inherit from this class 39 */ 40 41class syntax_plugin_qrcode_i_nigmacode extends DokuWiki_Syntax_Plugin 42{ 43 44 /** 45 * return some info 46 */ 47 function getInfo() 48 { 49 return array ( 50 'author'=>'Juergen A.Lamers', 51 'email'=>'jaloma.ac@googlemail.com', 52 'date'=>@file_get_contents(DOKU_PLUGIN . 'qrcode/VERSION'), 53 'name'=>'i-nigma -- 2D-Barcode Plugin', 54 'desc'=>'2D-Barcode Plugin using http://encode.i-nigma.com/ ~~INIGMACODE~text~~', 55 'url'=>'http://www.dokuwiki.org/plugin:qrcode', 56 ); 57 } 58 59 /** 60 * What kind of syntax are we? 61 */ 62 function getType() 63 { 64 return 'substition'; 65 } 66 67 /** 68 * What about paragraphs? (optional) 69 */ 70 function getPType() 71 { 72 return 'inline'; 73 } 74 75 /** 76 * Where to sort in? 77 */ 78 function getSort() 79 { 80 return 999; 81 } 82 83 /** 84 * Connect pattern to lexer 85 */ 86 function connectTo($mode) 87 { 88 $this->Lexer->addSpecialPattern('~~INIGMACODE.*?~~', $mode, 'plugin_qrcode_i_nigmacode'); 89 } 90 91 /** 92 * Handle the match 93 */ 94 function handle($match, $state, $pos, & $handler) 95 { 96 $paramsArr = explode('~', $match); 97 return $paramsArr; 98 } 99 100 /** 101 * Create output 102 */ 103 function render($mode, & $renderer, $data) 104 { 105 $align = ""; 106 if ($mode == 'xhtml') 107 { 108 $resultStr = ''; 109 $mode = 'QRCode'; 110 $paramsArr = $data; 111 $last = count($paramsArr); 112 for ($i = 0; $i < $last; $i++) 113 { 114 $currentParam = $paramsArr[$i]; 115 if ($i == 3 && $currentParam[0] == ' ') 116 { 117 $align = 'align="left"';//"top"; 118 $currentParam = substr($currentParam, 1); 119 } elseif ($currentParam[strlen($currentParam)-1] == ' ' && $i == ($last-3)) 120 { 121 // Habe ich schon am Anfang ein ' ' gehabt, schalte ich jetzt auf 'center' um 122 if ($align == 'align="left"') 123 { 124 $align = 'align="center"'; 125 } else 126 { 127 $align = 'align="right"';//"bottom"; 128 } 129 130 $currentParam = substr($currentParam, 1, sizeof($currentParam)-1); 131 } 132 $paramPairArr = explode('=', $currentParam); 133 switch($paramPairArr[0]) 134 { 135 case 'INIGMACODE': 136 break; 137 case '': 138 break; 139 case 'mode': 140 $mode = $paramPairArr[1]; 141 break; 142 case 'caption': 143 if ('' != $resultStr) 144 { 145 $resultStr .= '&'; 146 } 147 $resultStr .= 'c='.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8'); 148 break; 149 case 'size': 150 $size = $paramPairArr[1]; 151 /* 152 s=3 : Small S 153 s=4 : Medium M 154 s=6 : Large L 155 */ 156 if ('' != $resultStr) 157 { 158 $resultStr .= '&'; 159 } 160 switch($size) 161 { 162 case 'S': 163 $resultStr .= 's=3'; 164 break; 165 case 'M': 166 $resultStr .= 's=4'; 167 break; 168 case 'L': 169 $resultStr .= 's=6'; 170 break; 171 default: 172 $resultStr .= 's=4'; 173 break; 174 175 } 176 break; 177 case 'url': 178 /* 179 URL: 180 <img src="http://qrcode.kaywa.com/img.php?s=6&d=http%3A%2F%2Fwww.ich-bin-am-wandern-gewesen.de%2F" alt="qrcode" /> 181 */ 182 // $resultStr .= '&d=URL%3Ahttp%3A%2F%2F' . htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8'); 183 if ('' != $resultStr) 184 { 185 $resultStr .= '&'; 186 } 187 $resultStr .= 'd=URL%3Ahttp%3A%2F%2F'.$paramPairArr[1]; 188 break; 189 case 'contact': 190 /* 191 Contact 192 <img src="http://encode.i-nigma.com/DMtrx/img.php?d=BEGIN%3AVCARD%0AN%3ANName%2C%20VName%0ATEL%3A0241112%0AEMAIL%3Aschrott%40trash-mail.com%0AEND%3AVCARD&c=WanderWiki&s=6" alt="" /> 193 */ 194 $paramContactArr = explode(':', $paramPairArr[1]); 195 if ('' != $resultStr) 196 { 197 $resultStr .= '&'; 198 } 199 200 $resultStr .= 'd=BEGIN%3AVCARD%0AN%3A'. 201 htmlspecialchars($paramContactArr[0], ENT_QUOTES, 'UTF-8'). 202 '%2C%20'.htmlspecialchars($paramContactArr[1], ENT_QUOTES, 'UTF-8'). 203 '%0ATEL%3A'.htmlspecialchars($paramContactArr[2], ENT_QUOTES, 'UTF-8'). 204 '%0AEMAIL'.htmlspecialchars($paramContactArr[3], ENT_QUOTES, 'UTF-8'). 205 '%0AEND%3AVCARD' 206 ; 207 break; 208 case 'message': 209 case 'text': 210 /* 211 Text: 212 Message: 213 <img src="http://encode.i-nigma.com/DMtrx/img.php?d=Das%20Wandern%20ist%20des%20M%C3%BCllers%20Lust.&c=WanderWiki&s=6" alt="" /> 214 */ 215 if ('' != $resultStr) 216 { 217 $resultStr .= '&'; 218 } 219 $resultStr .= 'd='.htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8'); 220 break; 221 222 default: 223 // $resultStr .= ' ' . $paramPairArr[0] . '="' . $paramPairArr[1] . '"'; 224 break; 225 } 226 } 227 /* 228 Don't have barcode reader ? click here http://www.freewarepocketpc.net/ppc-tag-barcode.html 229 QRcode generated by Tec-it http://www.tec-it.com/online-demos/tbarcode/barcode-generator.aspx 230 qrcode.kaywa.com 231 <a href="http://www.freewarepocketpc.net/ppc-download-i-nigma-barcode-reader-v1-4.html">Download i-nigma barcode reader v1.40</a> 232 */ 233 234 if ($resultStr == '') 235 { 236 return false; 237 } 238 // print($resultStr.'<br>'); 239 $renderer->doc .= '<a href="http://www.i-nigma.com/personal/Default.asp">'; 240 $renderer->doc .= '<img src="http://encode.i-nigma.com/'.$mode.'/img.php?'.$resultStr.'" '.$align.' border="0"/>'; 241 $renderer->doc .= '</a>'; 242 return true; 243 } 244 return false; 245} 246} // Class 247 248 249