Permalink
Browse files

Fix documentation. Image_Barcode2::draw - static method. Deleted inco…

…rrect constructor from Code39.php
  • Loading branch information...
1 parent 349ad19 commit 234d928297d2cd4f43a82f59d118062aa4f0e645 @Gemorroj committed Dec 11, 2011
View
@@ -85,7 +85,7 @@ class Image_Barcode2
* @author Marcelo Subtil Marcal <msmarcal@php.net>
* @since Image_Barcode2 0.3
*/
- public function draw($text, $type = Image_Barcode2::BARCODE_INT25, $imgtype = Image_Barcode2::IMAGE_PNG, $bSendToBrowser = true, $height = 60, $width = 1)
+ public static function draw($text, $type = Image_Barcode2::BARCODE_INT25, $imgtype = Image_Barcode2::IMAGE_PNG, $bSendToBrowser = true, $height = 60, $width = 1)
{
//Make sure no bad files are included
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $type)) {
View
@@ -120,46 +120,20 @@ class Image_Barcode2_Code39
' ' => '011000100'
);
- /**
- * Constructor
- *
- * @param string $text A text that should be in the image barcode
- * @param int $wThin Width of the thin lines on the barcode
- * @param int $wThick Width of the thick lines on the barcode
- *
- * @author Ryan Briones <ryanbriones@webxdesign.org>
- *
- */
- public function __construct( $text = '', $wThin = 0, $wThick = 0 )
- {
- // Check $text for invalid characters
- if ( $this->_checkInvalid( $text ) ) {
- return false;
- }
-
- $this->text = $text;
- if ( $wThin > 0 ) {
- $this->_barthinwidth = $wThin;
- }
- if ( $wThick > 0 ) {
- $this->_barthickwidth = $wThick;
- }
-
- return true;
- }
/**
* Make an image resource using the GD image library
*
+ * @param string $text A text that should be in the image barcode
* @return resource The Barcode Image (TM)
*
* @author Ryan Briones <ryanbriones@webxdesign.org>
*
*/
- private function _plot()
+ private function _plot($text)
{
// add start and stop * characters
- $final_text = '*' . $this->text . '*';
+ $final_text = '*' . $text . '*';
$barcode = '';
foreach ( str_split( $final_text ) as $character ) {
@@ -198,9 +172,9 @@ private function _plot()
imagestring(
$img,
$this->_font_size,
- ( $barcode_len - $font_width * strlen( $this->text ) )/2,
+ ( $barcode_len - $font_width * strlen( $text ) ) / 2,
$this->_barcodeheight - $font_height,
- $this->text,
+ $text,
$black
);
@@ -212,7 +186,7 @@ private function _plot()
/**
* Send image to the browser; for Image_Barcode2 compaitbility
*
- * @param string $text
+ * @param string $text A text that should be in the image barcode
* @return gd_image GD image object
*
* @author Ryan Briones <ryanbriones@webxdesign.org>
@@ -227,8 +201,7 @@ public function draw($text)
return 'Invalid text';
}
- $this->text = $text;
- return $this->_plot();
+ return $this->_plot($text);
}
@@ -138,7 +138,7 @@ public function draw($text)
// the image with a nice, white background, ready for printing
// our black bars and the text.
- $img = imagecreate($barcodewidth, $barcodelongheight + imagefontheight($this->_font)+1);
+ $img = imagecreate($barcodewidth, $barcodelongheight + imagefontheight($this->_font) + 1);
$black = imagecolorallocate($img, 0, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $white);
View
@@ -155,7 +155,7 @@ public function draw($text)
+ imagefontwidth($this->_font)+1
;
- $barcodelongheight = (int) (imagefontheight($this->_font)/2) + $this->_barcodeheight;
+ $barcodelongheight = (int) (imagefontheight($this->_font) / 2) + $this->_barcodeheight;
// Create the image
$img = imagecreate(
@@ -243,4 +243,5 @@ public function draw($text)
} // function create
} // class
+
?>
View
@@ -212,4 +212,5 @@ public function draw($text)
} // function create
} // class
+
?>
View
@@ -152,7 +152,7 @@ public function draw($text)
$barcodelongheight = (int) (imagefontheight($this->_font) / 2) + $this->_barcodeheight;
// Create the image
- $img = imagecreate($barcodewidth, $barcodelongheight + imagefontheight($this->_font)+1);
+ $img = imagecreate($barcodewidth, $barcodelongheight + imagefontheight($this->_font) + 1);
// Alocate the black and white colors
$black = imagecolorallocate($img, 0, 0, 0);
@@ -194,8 +194,8 @@ public function draw($text)
// Draw left $text contents
for ($idx = 1; $idx < 6; $idx ++) {
- $value=substr($text,$idx,1);
- imagestring ($img, $this->_font, $xpos+1, $this->_barcodeheight, $value, $black);
+ $value=substr($text, $idx, 1);
+ imagestring ($img, $this->_font, $xpos + 1, $this->_barcodeheight, $value, $black);
foreach ($this->_number_set[$value]['L'] as $bar) {
if ($bar) {
@@ -223,7 +223,7 @@ public function draw($text)
// Draw right $text contents
for ($idx = 6; $idx < 11; $idx ++) {
- $value = substr($text,$idx,1);
+ $value = substr($text, $idx, 1);
imagestring ($img, $this->_font, $xpos + 1, $this->_barcodeheight, $value, $black);
foreach ($this->_number_set[$value]['R'] as $bar) {
if ($bar) {
View
2 README
@@ -1,4 +1,4 @@
-This package is http://pear.php.net/package/Image_Barcode and has been migrated from http://svn.php.net/repository/pear/packages/Image_Barcode
+This package is http://pear.php.net/package/Image_Barcode2 and has been migrated from http://svn.php.net/repository/pear/packages/Image_Barcode
Please report all new issues via the PEAR bug tracker.
View
@@ -1,7 +1,7 @@
-= Image_Barcode - a package to render barcodes =
+= Image_Barcode2 - a package to render barcodes =
------------------------------------------------
-With PEAR::Image_Barcode class you can create a barcode representation of a
+With PEAR::Image_Barcode2 class you can create a barcode representation of a
given string.
This class uses GD function because this the generated graphic can be any of
@@ -11,9 +11,9 @@ GD supported supported image types.
= Installation =
----------------
-You can install Image_Barcode issuing the following command (as root):
+You can install Image_Barcode2 issuing the following command (as root):
- # pear install Image_Barcode
+ # pear install Image_Barcode2
If you don't have the 'pear' command, please consult PEAR::The PHP Extension and
Application Repository homepage at http://pear.php.net
@@ -24,11 +24,11 @@ Application Repository homepage at http://pear.php.net
Just load the class in your script:
- require_once('Image/Barcode.php');
+ require_once('Image/Barcode2.php');
-Call the Image_Barcode::draw() as the follow:
+Call the Image_Barcode2::draw() as the follow:
- Image_Barcode::draw('1234', 'int25', 'png');
+ Image_Barcode2::draw('1234', 'int25', 'png');
Where:
@@ -41,7 +41,7 @@ Where:
-----------------
You can get the latest code at the PEAR site:
- http://pear.php.net/package/Image_Barcode/
+ http://pear.php.net/package/Image_Barcode2/
= Contributing =
@@ -88,4 +88,4 @@ Written by Marcelo Subtil Marcal <msmarcal@php.net>
= Reporting Bugs =
------------------
-Report bugs at: http://pear.php.net/bugs/report.php?package=Image_Barcode
+Report bugs at: http://pear.php.net/bugs/report.php?package=Image_Barcode2
@@ -1,11 +1,11 @@
<?php
-require_once("Image/Barcode.php");
+require_once("Image/Barcode2.php");
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '15101967';
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'int25';
$imgtype = isset($_REQUEST['imgtype']) ? $_REQUEST['imgtype'] : 'png';
-Image_Barcode::draw($num, $type, $imgtype);
+Image_Barcode2::draw($num, $type, $imgtype);
?>

0 comments on commit 234d928

Please sign in to comment.