Qual: Clean code for barcode

This commit is contained in:
Laurent Destailleur 2011-11-27 22:55:49 +01:00
parent 0e4d70d664
commit 9d1a008768
25 changed files with 43 additions and 297 deletions

View File

@ -328,10 +328,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/.svn $BUILDROOT/$PROJECT/*/.svn $BUILDROOT/$PROJECT/*/*/.svn $BUILDROOT/$PROJECT/*/*/*/.svn $BUILDROOT/$PROJECT/*/*/*/*/.svn`;
$ret=`rm -f $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`;
$ret=`rm -f $BUILDROOT/$PROJECT/.gitignore $BUILDROOT/$PROJECT/*/.gitignore $BUILDROOT/$PROJECT/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.gitignore`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/barcode/php-barcode/fonts/AerialMono*.ttf`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/barcode/php-barcode/fonts/Tymes*.ttf`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/barcode/php-barcode/fonts/Veranda*.ttf`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/barcode/php-barcode/genbarcode`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/fckeditor`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/flot/LICENSE.txt`;
@ -438,7 +434,8 @@ if ($nboftargetok) {
next;
}
if ($target =~ /RPM/) { # Linux only
if ($target =~ /RPM/) # Linux only
{
$NEWDESTI=$DESTI;
$subdir="package_rpm_generic";
if ($target =~ /FEDO/i) { $subdir="package_rpm_redhat-fedora"; }
@ -477,65 +474,6 @@ if ($nboftargetok) {
print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ2\n";
$cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'";
$ret=`$cmd`;
# print "Fix filefunc.inc.php, install/inc.php, support/inc.php\n";
# $cmd="cat \"$BUILDROOT/$PROJECT/htdocs/filefunc.inc.php\" |
# sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$FILENAMETGZ2/htdocs/filefunc.inc.php\"";
# $ret=`$cmd`;
# $cmd="cat \"$BUILDROOT/$PROJECT/htdocs/install/inc.php\" |
# sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$FILENAMETGZ2/htdocs/install/inc.php\"";
# $ret=`$cmd`;
# $cmd="cat \"$BUILDROOT/$PROJECT/htdocs/support/inc.php\" |
# sed -e 's/conffile = \"\\\.\\\.\\\/conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffile = \"conf\\\/conf.php\"/conffile = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' |
# sed -e 's/conffiletoshow = \"htdocs\\\/conf\\\/conf.php\"/conffiletoshow = \"\\\/etc\\\/dolibarr\\\/conf.php\"/g' > \"$BUILDROOT/$FILENAMETGZ2/htdocs/support/inc.php\"";
# $ret=`$cmd`;
#print "Remove other files\n";
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/ChangeLog`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/COPYING`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/INSTALL`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/README`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/README-FR`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/README`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/README-FR`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/aps`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/deb`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/dmg`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/pad/README`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/tgz/README`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/deb/README`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/doap`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/exe`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/live`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/patch`;
#$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/rpm/conf.php`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/zip`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/perl`;
# We remove embedded libraries or fonts
#if ($target !~ /GENE/i)
#{
# $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/artichow/font`,
# $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/fonts`,
#}
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`;
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/gnu-lgpl.txt`;
# Conf files
#print "Copy config files into $BUILDROOT/$FILENAMETGZ2/etc/$PROJECT\n";
#$ret=`mkdir -p "$BUILDROOT/$FILENAMETGZ2/etc/$PROJECT"`;
#$ret=`cp "$SOURCE/build/rpm/httpd-dolibarr.conf" "$BUILDROOT/$FILENAMETGZ2/etc/$PROJECT/apache.conf"`;
#$ret=`cp "$SOURCE/build/rpm/file_contexts.dolibarr" "$BUILDROOT/$FILENAMETGZ2/etc/$PROJECT/file_contexts.dolibarr"`;
#$ret=`cp "$SOURCE/build/rpm/conf.php" "$BUILDROOT/$FILENAMETGZ2/etc/$PROJECT/conf.php"`;
#$installfile="install.forced.php.generic";
#if ($target =~ /FEDO/i) { $installfile="install.forced.php.fedora"; }
#if ($target =~ /MAND/i) { $installfile="install.forced.php.mandriva"; }
#if ($target =~ /OPEN/i) { $installfile="install.forced.php.opensuse"; }
#$ret=`cp "$SOURCE/build/rpm/$installfile" "$BUILDROOT/$FILENAMETGZ2/etc/$PROJECT/install.forced.php"`;
# Set owners
print "Set owners on files/dir\n";
@ -545,18 +483,6 @@ if ($nboftargetok) {
$ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`;
$cmd="find $BUILDROOT/$FILENAMETGZ2 -type f -exec chmod 644 {} \\; ";
$ret=`$cmd`;
#$cmd="find $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build -name '*.php' -type f -exec chmod 755 {} \\; ";
#$ret=`$cmd`;
#$cmd="find $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build -name '*.pl' -type f -exec chmod 755 {} \\; ";
#$ret=`$cmd`;
#$cmd="find $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/dev -name '*.php' -type f -exec chmod 755 {} \\; ";
#$ret=`$cmd`;
#$ret=`chmod -R 644 $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/dev/translation/langAutoParser.class.php`;
#$ret=`chmod -R 644 $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/dev/skeletons/skeleton_page.php`;
#$ret=`chmod -R 644 $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/dev/skeletons/modMyModule.class.php`;
#$ret=`chmod -R 644 $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/dev/skeletons/skeleton_class.class.php`;
#$cmd="find $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/scripts -name '*.php' -type f -exec chmod 755 {} \\; ";
#$ret=`$cmd`;
# Build tgz
print "Compress $FILENAMETGZ2 into $FILENAMETGZ2.tgz...\n";
@ -727,7 +653,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/zip`;
# We remove embedded libraries or fonts
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/artichow/font`,
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/fonts`,
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fonts`,
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/geoip`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/nusoap`;

View File

@ -176,6 +176,11 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
{
global $bar_color, $bg_color, $text_color;
global $font_loc;
//var_dump($text);
//var_dump($bars);
//var_dump($font_loc);
/* set defaults */
if ($scale<1) $scale=2;
$total_y=(int)($total_y);
@ -204,25 +209,9 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
/* allocate the image */
$total_x=( $xpos )+$space['right']+$space['right'];
$xpos=$space['left'];
if (!function_exists("imagecreate")){
if (!function_exists("imagecreate"))
{
print "You don't have the gd2 extension enabled<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "Short HOWTO<BR>\n";
print "<BR>\n";
print "Debian: # apt-get install php4-gd2<BR>\n";
print "<BR>\n";
print "SuSE: ask YaST<BR>\n";
print "<BR>\n";
print "OpenBSD: # pkg_add /path/php4-gd-4.X.X.tgz (read output, you have to enable it)<BR>\n";
print "<BR>\n";
print "Windows: Download the PHP zip package from <A href=\"http://www.php.net/downloads.php\">php.net</A>, NOT the windows-installer, unzip the php_gd2.dll to C:\PHP (this is the default install dir) and uncomment 'extension=php_gd2.dll' in C:\WINNT\php.ini (or where ever your os is installed)<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "The author of php-barcode will give not support on this topic!<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<A HREF=\"http://www.ashberg.de/bar/\">Folke Ashberg's OpenSource PHP-Barcode</A><BR>\n";
return "";
}
$im=imagecreate($total_x, $total_y);
@ -233,7 +222,6 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
$height=round($total_y-($scale*10));
$height2=round($total_y-$space['bottom']);
/* paint the bars */
$width=true;
for ($i=0;$i<strlen($bars);$i++){
@ -310,20 +298,29 @@ function barcode_encode_genbarcode($code,$encoding)
$code=preg_replace("/[\\\|]/", "_", $code);
$cmd=$genbarcode_loc." \""
.str_replace("\"", "\\\"",$code)."\" \""
.str_replace("\"", "\\\"",strtoupper($encoding))."\"";
.str_replace("\"", "\\\"",strtoupper($encoding))."\" 2>&1";
//print "'$cmd'<BR>\n";
$fp=popen($cmd, "r");
if ($fp){
if ($fp)
{
$bars=fgets($fp, 1024);
$text=fgets($fp, 1024);
$encoding=fgets($fp, 1024);
pclose($fp);
} else return false;
}
else
{
dol_syslog("phpbarcode::barcode_encode_genbarcode failed to run popen ".$cmd, LOG_ERR);
return false;
}
//var_dump($bars);
$ret=array(
"encoding" => trim($encoding),
"bars" => trim($bars),
"text" => trim($text)
);
//var_dump($ret);
if (!$ret['encoding']) return false;
if (!$ret['bars']) return false;
if (!$ret['text']) return false;
@ -358,6 +355,7 @@ function barcode_encode_genbarcode($code,$encoding)
function barcode_encode($code,$encoding)
{
global $genbarcode_loc;
if (
((preg_match("/^ean$/i", $encoding)
&& ( strlen($code)==12 || strlen($code)==13)))
@ -369,24 +367,29 @@ function barcode_encode($code,$encoding)
|| (( !isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding) ))
&& (preg_match("/^[0-9]{12,13}$/", $code)))
){
)
{
/* use built-in EAN-Encoder */
dol_syslog("phpbarcode.php::barcode_encode Use barcode_encode_ean");
$bars=barcode_encode_ean($code, $encoding);
} else if (file_exists($genbarcode_loc)){
}
else if (file_exists($genbarcode_loc))
{
/* use genbarcode */
dol_syslog("phpbarcode.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
$bars=barcode_encode_genbarcode($code, $encoding);
} else {
print "php-barcode needs an external programm for encodings other then EAN/ISBN<BR>\n";
}
else
{
print "barcode_encode needs an external programm for encodings other then EAN/ISBN<BR>\n";
print "<UL>\n";
print "<LI>download gnu-barcode from <A href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
print "<LI>compile and install them\n";
print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
print "<LI>compile and install them\n";
print "<LI>specify path the genbarcode in php-barcode.php\n";
print "<LI>specify path the genbarcode in barcode module setup\n";
print "</UL>\n";
print "<BR>\n";
print "<A HREF=\"http://www.ashberg.de/bar/\">Folke Ashberg's OpenSource PHP-Barcode</A><BR>\n";
return false;
}
return $bars;
@ -402,17 +405,17 @@ function barcode_encode($code,$encoding)
* array[bars] : the bars
* array[text] : text-positioning info
*/
function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png" )
function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png")
{
// DOLCHANGE LDR Add log
dol_syslog("php-barcode.php:barcode_print $code $encoding $scale $mode");
dol_syslog("phpbarcode.php::barcode_print $code $encoding $scale $mode");
$bars=barcode_encode($code,$encoding);
if (!$bars)
{
// DOLCHANGE LDR Return error message instead of array
$error='Bad Value '.$code.' for encoding '.$encoding;
dol_syslog('php-barcode.php:barcode_print '.$error, LOG_ERR);
dol_syslog('phpbarcode.php::barcode_print '.$error, LOG_ERR);
return $error;
}
if (!$mode) $mode="png";

View File

@ -120,7 +120,7 @@ class modPhpbarcode extends ModeleBarCode
$_GET["scale"]=$scale;
$_GET["mode"]=$mode;
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/php-barcode.php');
require_once(DOL_DOCUMENT_ROOT.'/core/lib/phpbarcode.php');
dol_syslog("modPhpbarcode::buildBarCode $code,$encoding,$scale,$mode");
if ($code) $result=barcode_print($code,$encoding,$scale,$mode);

View File

@ -68,7 +68,7 @@ class modBarcode extends DolibarrModules
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
$this->const = array(
//0=>array('GENBARCODE_LOCATION','chaine',DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/genbarcode/genbarcode','Path to genbarcode command line tool',0)
//0=>array('GENBARCODE_LOCATION','chaine',DOL_DOCUMENT_ROOT.'/includes/barcode/genbarcode/genbarcode','Path to genbarcode command line tool',0)
);
// Boxes

View File

@ -193,8 +193,8 @@ if (! defined('ARTICHOW_PATH')) { define('ARTICHOW_PATH', (!isset(
// Other required path
if (! defined('ARTICHOW_FONT')) { define('ARTICHOW_FONT', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?DOL_DOCUMENT_ROOT.'/includes/artichow/font':dirname($dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
if (! defined('ARTICHOW_FONT_NAMES')) { define('ARTICHOW_FONT_NAMES', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?'Tuffy,TuffyBold,TuffyBoldItalic,TuffyItalic':'DejaVuSans,DejaVuSans-Bold,DejaVuSans-BoldOblique,DejaVuSans-Oblique'); }
if (! defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF))?DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/fonts/Aerial.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF)?'':$dolibarr_font_DOL_DEFAULT_TTF)); }
if (! defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/fonts/AerialBd.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?'':$dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
if (! defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF))?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF)?'':$dolibarr_font_DOL_DEFAULT_TTF)); }
if (! defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?'':$dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
// Old path to root deprecated (no more used).
//if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); }

View File

@ -1,162 +0,0 @@
PHP-Barcode 0.3pl1
PHP-Barcode generates
- Barcode-Images using libgd (png, jpg,gif),
- HTML-Images (using 1x1 pixel and html-table)
- silly Text-Barcodes
PHP-Barcode encodes using
- a built-in EAN-13/ISBN Encoder
- genbarcode (by Folke Ashberg), a command line
barcode-encoder which uses GNU-Barcode
genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
I25, 128RAW, CBR, MSI, PLS
genbarcode is available at www.ashberg.de/bar
(C) 2001,2002,2003,2004 by Folke Ashberg <folke@ashberg.de>
The newest version can be found at http://www.ashberg.de/bar
INSTALLATION:
WHAT YOU NEED TO BE ABLE TO USE PHP-BARCODE
You need php>4 on your system.
You need the gd2-extension to be able to render images.
You need a TrueTypeFont if you want to see the CODE below the bars.
You need genbarcode (from www.ashberg.de/bar) in you want to use
another encoding than EAN-12/EAN-12/ISBN
Copy the following files into your html/php-directory
- php-barcode.php - main library
- encode_bars.php - built-in encoders
optional:
- barcode.php - Sample-File
- white.png - for HTML-Images
- black.png - for HTML-Images
FONT-Installation
UNIX:
A TrueTypeFont isn't included in this distribution!
Copy one into the html/php-directory and change in php-barcode.php
$font_loc (change the arialbd.tff to your font name).
arialbd.ttf from Windows looks great.
WINDOWS:
If you use Windows the font should be located automatically.
OPTIONAL - genbarcode:
If you want to generate not only EAN-12/EAN-13/ISBN-Codes you have to install
genbarcode, a small unix-commandline tool which uses GNU-Barcode.
genbarcode is available http://www.ashberg.de/bar , read genbarcodes
README for installation.
If you have installed genbarcode not to /usr/bin set the $genbarcode_loc
in php-barcode.php .
TESTING
If everything works fine you should see an image if you call
http://localhost/path/barcode.php
Or call http://localhost/path/barcode.php?code=<CODE>&encoding=<ENCODING>&mode=<png|jpg|gif|html|text>&size=<1,2,3,...>
If you need more then the sample barcode.php can do, you need to build your own.
FUNCTIONS - API-Reference
--------------------------------------------------------------------------
function barcode_encode(code, encoding)
encodes $code with $encoding using genbarcode OR built-in encoder
if you don't have genbarcode only EAN-13/ISBN is possible
You can use the following encodings (when you have genbarcode):
ANY choose best-fit (default)
EAN 8 or 13 EAN-Code
UPC 12-digit EAN
ISBN isbn numbers (still EAN-13)
39 code 39
128 code 128 (a,b,c: autoselection)
128C code 128 (compact form for digits)
128B code 128, full printable ascii
I25 interleaved 2 of 5 (only digits)
128RAW Raw code 128 (by Leonid A. Broukhis)
CBR Codabar (by Leonid A. Broukhis)
MSI MSI (by Leonid A. Broukhis)
PLS Plessey (by Leonid A. Broukhis)
return:
array[encoding] : the encoding which has been used
array[bars] : the bars
array[text] : text-positioning info
--------------------------------------------------------------------------
function barcode_outimage(text, bars [, scale [, mode [, total_y [, space ]]]] )
Outputs an image using libgd
text : the text-line (<position>:<font-size>:<character> ...)
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...)
scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
5400x300 pixels when
using EAN-13!!!))
mode : png,gif,jpg, depending on libgd ! (default='png')
total_y: the total height of the image ( default: scale * 60 )
space : space
default:
$space[top] = 2 * $scale;
$space[bottom]= 2 * $scale;
$space[left] = 2 * $scale;
$space[right] = 2 * $scale;
--------------------------------------------------------------------------
function barcode_outhtml(text, bars [, scale [, total_y [, space ]]] )
returns(!) HTML-Code for barcode-image using html-code (using a table and with black.png and white.png)
text : the text-line (<position>:<font-size>:<character> ...)
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...)
scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
5400x300 pixels when
using EAN-13!!!))
total_y: the total height of the image ( default: scale * 60 )
space : space
default:
$space[top] = 2 * $scale;
$space[bottom]= 2 * $scale;
$space[left] = 2 * $scale;
$space[right] = 2 * $scale;
--------------------------------------------------------------------------
function barcode_outtext(code, bars)
Returns (!) a barcode as plain-text
ATTENTION: this is very silly!
text : the text-line (<position>:<font-size>:<character> ...)
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...)
--------------------------------------------------------------------------
For more function see php-barcode.php
Also see barcode.php or just use them :)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

View File

@ -41,22 +41,3 @@ with
//var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth);
window.location.href=pRef
* Replace hard coded string with i18n["String"];
PHP-BARCODE:
------------
If files are replaced by new version, following changes must be done:
* Restore changes done into php-barcode.php marked with DOL_CHANGE LDR
* Add lines into barcode_outimage function:
// DOLCHANGE LDR
global $filebarcode;
// Begin DOLCHANGE LDR
} else if (! empty($filebarcode))
{
imagepng($im,$filebarcode);
// End DOLCHANGE LDR

View File

@ -103,7 +103,7 @@ PriceRemoved=Prix supprimé
BarCode=Code-barres
BarcodeType=Type de code-barres
BarcodeValue=Valeur du code-barres
GenbarcodeLocation=Outil de génération de code-barres en ligne de commande (utilisé par le moteur phpbarcode pour certains types de codes-barres)
GenbarcodeLocation=Outil de génération de code-barres en ligne de commande (utilisé par le moteur interne pour certains types de codes-barres)
SetDefaultBarcodeType=Définissez le type de code-barres
NoteNotVisibleOnBill=Note (non visible sur les factures, propals...)
CreateCopy=Créer copie

View File

@ -16,7 +16,6 @@
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
<directory suffix=".php">../../htdocs/includes/adodbtime/</directory>
<directory suffix=".php">../../htdocs/includes/artichow/</directory>
<directory suffix=".php">../../htdocs/includes/barcode/php-barcode/</directory>
<directory suffix=".php">../../htdocs/includes/ckeditor/</directory>
<directory suffix=".php">../../htdocs/includes/fpdfi/</directory>
<directory suffix=".php">../../htdocs/includes/geoip/</directory>
@ -52,7 +51,6 @@
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
<directory suffix=".php">../../htdocs/includes/adodbtime/</directory>
<directory suffix=".php">../../htdocs/includes/artichow/</directory>
<directory suffix=".php">../../htdocs/includes/barcode/php-barcode/</directory>
<directory suffix=".php">../../htdocs/includes/ckeditor/</directory>
<directory suffix=".php">../../htdocs/includes/fpdfi/</directory>
<directory suffix=".php">../../htdocs/includes/geoip/</directory>