1<?php
2
3/**
4 * Plugin barcode: 2D-Barcode Implementation
5 *
6 * @author Enrico Croce & Simona Burzio (staff@eiroca.net)
7 * @copyright Copyright (C) 2009-2019 eIrOcA - Enrico Croce & Simona Burzio
8 * @license GPL >=3 (http://www.gnu.org/licenses/)
9 * @version 19.02
10 * @link http://www.eiroca.net
11 */
12class QR_qrserver extends QRProvider {
13
14  // http://qrserver.com/api/documentation/create-qr-code/
15  function render(&$p) {
16    $first = true;
17    $size = $p['size'];
18    $text = $p['text'];
19    $resultStr = 'http://api.qrserver.com/v1/create-qr-code/?';
20    switch ($size) {
21      case 'S' :
22        $resultStr .= $this->addParam($first, 'size=120x120');
23        break;
24      case 'M' :
25        $resultStr .= $this->addParam($first, 'size=240x240');
26        break;
27      case 'L' :
28        $resultStr .= $this->addParam($first, 'size=350x350');
29        break;
30      case 'XL' :
31        $resultStr .= $this->addParam($first, 'size=500x500');
32        break;
33      default :
34        $resultStr .= $this->addParam($first, 'size=240x240');
35        break;
36    }
37    $resultStr .= $this->addParam($first, 'data=' . urlencode($text));
38    foreach (array (
39        'charset-source', 'charset-target', 'ecc', 'color', 'bgcolor', 'margin', 'qzone'
40    ) as $optional) {
41      if ($p[$optional]) $resultStr .= $this->addParam($first, $optional . '=' . $p[$optional]);
42    }
43    return $this->_IMG($resultStr, $p['id'], $p['class']);
44  }
45
46}
47?>