diff --git a/license.txt b/LICENSE.md similarity index 87% rename from license.txt rename to LICENSE.md index 9d2a1c2..f4fc1de 100644 --- a/license.txt +++ b/LICENSE.md @@ -1,19 +1,20 @@ Copyright (c) 2011 emberlabs.org +================================ Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/readme.md b/README.md similarity index 74% rename from readme.md rename to README.md index 83a632c..8d1d27d 100644 --- a/readme.md +++ b/README.md @@ -2,7 +2,7 @@ Barcode Generator for PHP ========================= Perhaps the biggest issue I encountered when creating an inventory management -system for a client was the fact that there was no unified framework for +system for a client was the fact that there was no unified framework for barcode generation in PHP that was reasonable in price, much less Open Source. I hope to fill this gaping hole in the market today with Barcode Generator for PHP. @@ -16,13 +16,12 @@ this library. Usage ----- -I have an example index.php on gist. This assumes you have the repo cloned in include/ relative to the this index file: -[index.php](https://gist.github.com/1175098) +Use the ```example.php``` to test the barcodes. Supported Codes --------------- -Some are planned, others are complete. +Some are planned, others are complete. * Code39 **DONE** * Code128 **DONE** @@ -35,5 +34,5 @@ Contribute ---------- If you have something to add (maybe a new barcode) or just a bug fix, please -send me a pull request and I will be sure to respond or even merge it. I am -always looking for help with these projects, so don't be shy. +send me a pull request and I will be sure to respond or even merge it. I am +always looking for help with these projects, so don't be shy. diff --git a/example.php b/example.php new file mode 100644 index 0000000..69e402b --- /dev/null +++ b/example.php @@ -0,0 +1,97 @@ + 'QR Code', 'obj' => new emberlabs\Barcode\QRCode()); +$bcode['dm'] = array('name' => 'DataMatrix', 'obj' => new emberlabs\Barcode\DataMatrix()); +$bcode['c39'] = array('name' => 'Code39', 'obj' => new emberlabs\Barcode\Code39()); +$bcode['c128'] = array('name' => 'Code128', 'obj' => new emberlabs\Barcode\Code128()); + +function bcode_error($m) +{ + echo "
{$m}
"; +} + +function bcode_success($bcode_name) +{ + echo "
A $bcode_name barcode was successfully created
"; +} + +function bcode_img64($b64str) +{ + echo "
"; +} + +?> + + + +Barcode Tester + + + + + + +
+ +Enter Data to encode:
+ + +
+ +
+ + +Data to be encoded:
+ + $value) + { + try + { + $bcode[$k]['obj']->setData($_POST['encode']); + $bcode[$k]['obj']->setDimensions(300, 150); + $bcode[$k]['obj']->draw(); + $b64 = $bcode[$k]['obj']->base64(); + + bcode_success($bcode[$k]['name']); + bcode_img64($b64); + } + catch (Exception $e) + { + bcode_error($e->getMessage()); + } + } +?> + + + + + \ No newline at end of file diff --git a/BarcodeBase.php b/src/BarcodeBase.php similarity index 100% rename from BarcodeBase.php rename to src/BarcodeBase.php diff --git a/Code128.php b/src/Code128.php similarity index 98% rename from Code128.php rename to src/Code128.php index 28bcd4b..a721da0 100644 --- a/Code128.php +++ b/src/Code128.php @@ -252,12 +252,13 @@ public function draw() // Calc scaling // Bars is in refrence to a single, 1-level bar $numBarsRequired = ($this->type != self::TYPE_C) ? (sizeof($charAry) * 11) + 35 : ((sizeof($charAry)/2) * 11) + 35; + $this->x = ($this->x == 0) ? $numBarsRequired : $this->x; $pxPerBar = (int) ($this->x / $numBarsRequired); $currentX = ($this->x - ($numBarsRequired * $pxPerBar)) / 2; if ($pxPerBar < 1) { - throw new LogicException("Not enough space on this barcode for this message, increase the width of the barcode"); + throw new \LogicException("Not enough space on this barcode for this message, increase the width of the barcode"); } if ($this->type == self::TYPE_C) diff --git a/Code39.php b/src/Code39.php similarity index 100% rename from Code39.php rename to src/Code39.php diff --git a/DataMatrix.php b/src/DataMatrix.php similarity index 100% rename from DataMatrix.php rename to src/DataMatrix.php diff --git a/QRCode.php b/src/QRCode.php similarity index 100% rename from QRCode.php rename to src/QRCode.php diff --git a/UPC.php b/src/UPC.php similarity index 100% rename from UPC.php rename to src/UPC.php