Protection on using non embended code format with windows (it hangs)

This commit is contained in:
Laurent Destailleur 2009-05-04 00:12:55 +00:00
parent ed33882ca3
commit 42a32481a2

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -19,23 +19,23 @@
*/ */
/** /**
\file htdocs/includes/modules/barcode/phpbarcode.modules.php * \file htdocs/includes/modules/barcode/phpbarcode.modules.php
\ingroup facture * \ingroup facture
\brief Fichier contenant la classe du modèle de generation code barre phpbarcode * \brief Fichier contenant la classe du modèle de generation code barre phpbarcode
\version $Id$ * \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/barcode/modules_barcode.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/barcode/modules_barcode.php");
/** \class modPhpbarcode /** \class modPhpbarcode
\brief Classe du modèle de numérotation de generation code barre phpbarcode * \brief Classe du modèle de numérotation de generation code barre phpbarcode
*/ */
class modPhpbarcode extends ModeleBarCode class modPhpbarcode extends ModeleBarCode
{ {
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error=''; var $error='';
/** \brief Return if a module can be used or not /** \brief Return if a module can be used or not
* \return boolean true if module can be used * \return boolean true if module can be used
*/ */
@ -44,6 +44,7 @@ class modPhpbarcode extends ModeleBarCode
return true; return true;
} }
/** \brief Renvoi la description du modele de numérotation /** \brief Renvoi la description du modele de numérotation
* \return string Texte descripif * \return string Texte descripif
*/ */
@ -65,19 +66,22 @@ class modPhpbarcode extends ModeleBarCode
return true; return true;
} }
/** /**
\brief Return true if encodinf is supported * \brief Return true if encodinf is supported
\return int >0 if supported, 0 if not * \return int >0 if supported, 0 if not
*/ */
function encodingIsSupported($encoding) function encodingIsSupported($encoding)
{ {
$supported=0; $supported=0;
if ($encoding == 'EAN8') $supported=1;
if ($encoding == 'EAN13') $supported=1; if ($encoding == 'EAN13') $supported=1;
if ($encoding == 'UPC') $supported=1;
if ($encoding == 'ISBN') $supported=1; if ($encoding == 'ISBN') $supported=1;
if ($encoding == 'C39') $supported=1; // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not
if ($encoding == 'C128') $supported=1; // activated on Windows)
if ($encoding == 'EAN8' && empty($_SERVER["WINDIR"])) $supported=1;
if ($encoding == 'UPC' && empty($_SERVER["WINDIR"])) $supported=1;
if ($encoding == 'C39' && empty($_SERVER["WINDIR"])) $supported=1;
if ($encoding == 'C128' && empty($_SERVER["WINDIR"])) $supported=1;
return $supported; return $supported;
} }
@ -106,6 +110,7 @@ class modPhpbarcode extends ModeleBarCode
$_GET["mode"]=$mode; $_GET["mode"]=$mode;
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/php-barcode.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/php-barcode.php');
dol_syslog("modPhpbarcode::buildBarCode $code,$encoding,$scale,$mode");
if ($code) barcode_print($code,$encoding,$scale,$mode); if ($code) barcode_print($code,$encoding,$scale,$mode);
return 1; return 1;