From b4b2c09f457efee567e2c2f84474cb2b2f88cc9b Mon Sep 17 00:00:00 2001 From: iCodr8 Date: Fri, 31 Jan 2014 19:01:27 +0100 Subject: [PATCH 1/5] added example.php to the repository and optimized the file structure --- license.txt => LICENSE.md | 19 ++--- example.php | 97 ++++++++++++++++++++++++++ readme.md | 11 ++- BarcodeBase.php => src/BarcodeBase.php | 0 Code128.php => src/Code128.php | 0 Code39.php => src/Code39.php | 0 DataMatrix.php => src/DataMatrix.php | 0 QRCode.php => src/QRCode.php | 0 UPC.php => src/UPC.php | 0 9 files changed, 112 insertions(+), 15 deletions(-) rename license.txt => LICENSE.md (87%) create mode 100644 example.php rename BarcodeBase.php => src/BarcodeBase.php (100%) rename Code128.php => src/Code128.php (100%) rename Code39.php => src/Code39.php (100%) rename DataMatrix.php => src/DataMatrix.php (100%) rename QRCode.php => src/QRCode.php (100%) rename UPC.php => src/UPC.php (100%) 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/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/readme.md b/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/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 100% rename from Code128.php rename to src/Code128.php 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 From 2899975efde2b4a61caf909874e081bddc9ffade Mon Sep 17 00:00:00 2001 From: iCodr8 Date: Fri, 31 Jan 2014 19:02:26 +0100 Subject: [PATCH 2/5] write readme.md uppercase --- readme.md | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 readme.md diff --git a/readme.md b/readme.md deleted file mode 100644 index 8d1d27d..0000000 --- a/readme.md +++ /dev/null @@ -1,38 +0,0 @@ -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 -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. - -License -------- - -In order to facilitate a wide range of usage, the [MIT License](http://www.opensource.org/licenses/MIT) was adopted for -this library. - -Usage ------ - -Use the ```example.php``` to test the barcodes. - -Supported Codes ---------------- - -Some are planned, others are complete. - -* Code39 **DONE** -* Code128 **DONE** -* QRCode *In Progress* -* DataMatrix *Not Started* -* UPC *Not Started* -* PDF417 *Discontinued* - -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. From f209de1417677a034951b6df37404ef547396643 Mon Sep 17 00:00:00 2001 From: iCodr8 Date: Fri, 31 Jan 2014 19:02:35 +0100 Subject: [PATCH 3/5] write read me uppercase --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d1d27d --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +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 +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. + +License +------- + +In order to facilitate a wide range of usage, the [MIT License](http://www.opensource.org/licenses/MIT) was adopted for +this library. + +Usage +----- + +Use the ```example.php``` to test the barcodes. + +Supported Codes +--------------- + +Some are planned, others are complete. + +* Code39 **DONE** +* Code128 **DONE** +* QRCode *In Progress* +* DataMatrix *Not Started* +* UPC *Not Started* +* PDF417 *Discontinued* + +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. From 36a57c763b4b996681e4d43df14a37e355388c59 Mon Sep 17 00:00:00 2001 From: iCodr8 Date: Fri, 31 Jan 2014 20:06:56 +0100 Subject: [PATCH 4/5] fixed barcode128 exception bug --- src/Code128.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Code128.php b/src/Code128.php index 28bcd4b..60a4a64 100644 --- a/src/Code128.php +++ b/src/Code128.php @@ -257,7 +257,7 @@ public function draw() 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) From 5841f9c5ca21fbdb7904bd08bafe5e79a565a891 Mon Sep 17 00:00:00 2001 From: iCodr8 Date: Fri, 31 Jan 2014 20:49:08 +0100 Subject: [PATCH 5/5] added autowith fix --- src/Code128.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Code128.php b/src/Code128.php index 60a4a64..a721da0 100644 --- a/src/Code128.php +++ b/src/Code128.php @@ -252,6 +252,7 @@ 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;