Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Barcode / Object / Codabar.php
blobb6e14b2cfe1a98f108f5852d0f202efa7d3221aa
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Barcode\Object;
12 /**
13 * Class for generate Codabar barcode
15 class Codabar extends AbstractObject
17 /**
18 * Coding map
19 * - 0 = space
20 * - 1 = bar
21 * @var array
23 protected $codingMap = array(
24 '0' => "101010011", '1' => "101011001", '2' => "101001011",
25 '3' => "110010101", '4' => "101101001", '5' => "110101001",
26 '6' => "100101011", '7' => "100101101", '8' => "100110101",
27 '9' => "110100101", '-' => "101001101", '$' => "101100101",
28 ':' => "1101011011", '/' => "1101101011", '.' => "1101101101",
29 '+' => "1011011011", 'A' => "1011001001", 'B' => "1010010011",
30 'C' => "1001001011", 'D' => "1010011001"
33 /**
34 * Width of the barcode (in pixels)
35 * @return int
37 protected function calculateBarcodeWidth()
39 $quietZone = $this->getQuietZone();
40 $encodedData = 0;
41 $barcodeChar = str_split($this->getText());
42 if (count($barcodeChar) > 1) {
43 foreach ($barcodeChar as $c) {
44 $encodedData += ((strlen($this->codingMap[$c]) + 1) * $this->barThinWidth) * $this->factor;
47 $encodedData -= (1 * $this->barThinWidth * $this->factor);
48 return $quietZone + $encodedData + $quietZone;
51 /**
52 * Partial check of Codabar barcode
53 * @return void
55 protected function checkSpecificParams()
58 /**
59 * Prepare array to draw barcode
60 * @return array
62 protected function prepareBarcode()
64 $text = str_split($this->getText());
65 foreach ($text as $char) {
66 $barcodeChar = str_split($this->codingMap[$char]);
67 foreach ($barcodeChar as $c) {
68 // visible, width, top, length
69 $barcodeTable[] = array($c, $this->barThinWidth, 0, 1);
71 $barcodeTable[] = array(0, $this->barThinWidth);
73 return $barcodeTable;