forked from Wavyzz/dolibarr
Fixing style errors.
This commit is contained in:
@@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Users who do not have 'composer' to manage dependencies, include this
|
* Users who do not have 'composer' to manage dependencies, include this
|
||||||
* file to provide auto-loading of the classes in this library.
|
* file to provide auto-loading of the classes in this library.
|
||||||
*/
|
*/
|
||||||
spl_autoload_register ( function ($class) {
|
spl_autoload_register( function ($class) {
|
||||||
/*
|
/*
|
||||||
* PSR-4 autoloader, based on PHP Framework Interop Group snippet (Under MIT License.)
|
* PSR-4 autoloader, based on PHP Framework Interop Group snippet (Under MIT License.)
|
||||||
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
|
* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
|
||||||
*/
|
*/
|
||||||
$prefix = "Mike42\\";
|
$prefix = "Mike42\\";
|
||||||
$base_dir = __DIR__ . "/src/Mike42/";
|
$base_dir = __DIR__ . "/src/Mike42/";
|
||||||
|
|
||||||
/* Only continue for classes in this namespace */
|
/* Only continue for classes in this namespace */
|
||||||
$len = strlen ( $prefix );
|
$len = strlen($prefix);
|
||||||
if (strncmp ( $prefix, $class, $len ) !== 0) {
|
if (strncmp($prefix, $class, $len) !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Require the file if it exists */
|
/* Require the file if it exists */
|
||||||
$relative_class = substr ( $class, $len );
|
$relative_class = substr($class, $len);
|
||||||
$file = $base_dir . str_replace ( '\\', '/', $relative_class ) . '.php';
|
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
||||||
if (file_exists ( $file )) {
|
if (file_exists($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ class CapabilityProfile
|
|||||||
*/
|
*/
|
||||||
protected $profileId;
|
protected $profileId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $vendor
|
* @var string $vendor
|
||||||
* Name of manufacturer.
|
* Name of manufacturer.
|
||||||
*/
|
*/
|
||||||
protected $vendor;
|
protected $vendor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var array $encodings
|
* @var array $encodings
|
||||||
|
|||||||
@@ -42,51 +42,51 @@ abstract class EscposImage
|
|||||||
* height of the image.
|
* height of the image.
|
||||||
*/
|
*/
|
||||||
protected $imgHeight = 0;
|
protected $imgHeight = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int $imgWidth
|
* @var int $imgWidth
|
||||||
* width of the image
|
* width of the image
|
||||||
*/
|
*/
|
||||||
protected $imgWidth = 0;
|
protected $imgWidth = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $imgData
|
* @var string $imgData
|
||||||
* Image data in rows: 1 for black, 0 for white.
|
* Image data in rows: 1 for black, 0 for white.
|
||||||
*/
|
*/
|
||||||
private $imgData = null;
|
private $imgData = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array:string $imgColumnData
|
* @var array:string $imgColumnData
|
||||||
* Cached column-format data to avoid re-computation
|
* Cached column-format data to avoid re-computation
|
||||||
*/
|
*/
|
||||||
private $imgColumnData = [];
|
private $imgColumnData = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $imgRasterData
|
* @var string $imgRasterData
|
||||||
* Cached raster format data to avoid re-computation
|
* Cached raster format data to avoid re-computation
|
||||||
*/
|
*/
|
||||||
private $imgRasterData = null;
|
private $imgRasterData = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $filename
|
* @var string $filename
|
||||||
* Filename of image on disk - null if not loaded from disk.
|
* Filename of image on disk - null if not loaded from disk.
|
||||||
*/
|
*/
|
||||||
private $filename = null;
|
private $filename = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean $allowOptimisations
|
* @var boolean $allowOptimisations
|
||||||
* True to allow faster library-specific rendering shortcuts, false to always just use
|
* True to allow faster library-specific rendering shortcuts, false to always just use
|
||||||
* image libraries to read pixels (more reproducible between systems).
|
* image libraries to read pixels (more reproducible between systems).
|
||||||
*/
|
*/
|
||||||
private $allowOptimisations = true;
|
private $allowOptimisations = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new EscposImage.
|
* Construct a new EscposImage.
|
||||||
*
|
*
|
||||||
* @param string $filename Path to image filename, or null to create an empty image.
|
* @param string $filename Path to image filename, or null to create an empty image.
|
||||||
* @param boolean $allowOptimisations True (default) to use any library-specific tricks
|
* @param boolean $allowOptimisations True (default) to use any library-specific tricks
|
||||||
* to speed up rendering, false to force the image to be read in pixel-by-pixel,
|
* to speed up rendering, false to force the image to be read in pixel-by-pixel,
|
||||||
* which is easier to unit test and more reproducible between systems, but slower.
|
* which is easier to unit test and more reproducible between systems, but slower.
|
||||||
*/
|
*/
|
||||||
public function __construct($filename = null, $allowOptimisations = true)
|
public function __construct($filename = null, $allowOptimisations = true)
|
||||||
{
|
{
|
||||||
@@ -101,15 +101,15 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
return $this -> imgHeight;
|
return $this -> imgHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int Number of bytes to represent a row of this image
|
* @return int Number of bytes to represent a row of this image
|
||||||
*/
|
*/
|
||||||
public function getHeightBytes()
|
public function getHeightBytes()
|
||||||
{
|
{
|
||||||
return (int)(($this -> imgHeight + 7) / 8);
|
return (int) (($this -> imgHeight + 7) / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int Width of the image
|
* @return int Width of the image
|
||||||
*/
|
*/
|
||||||
@@ -117,13 +117,13 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
return $this -> imgWidth;
|
return $this -> imgWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int Number of bytes to represent a row of this image
|
* @return int Number of bytes to represent a row of this image
|
||||||
*/
|
*/
|
||||||
public function getWidthBytes()
|
public function getWidthBytes()
|
||||||
{
|
{
|
||||||
return (int)(($this -> imgWidth + 7) / 8);
|
return (int) (($this -> imgWidth + 7) / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +155,7 @@ abstract class EscposImage
|
|||||||
}
|
}
|
||||||
return $this -> imgRasterData;
|
return $this -> imgRasterData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the image in column format.
|
* Output the image in column format.
|
||||||
*
|
*
|
||||||
@@ -199,7 +199,7 @@ abstract class EscposImage
|
|||||||
$this -> setImgHeight(0);
|
$this -> setImgHeight(0);
|
||||||
$this -> setImgData("");
|
$this -> setImgData("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set image data.
|
* Set image data.
|
||||||
*
|
*
|
||||||
@@ -209,7 +209,7 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
$this -> imgData = $data;
|
$this -> imgData = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set image width.
|
* Set image width.
|
||||||
*
|
*
|
||||||
@@ -219,7 +219,7 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
$this -> imgWidth = $width;
|
$this -> imgWidth = $width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set image height.
|
* Set image height.
|
||||||
*
|
*
|
||||||
@@ -229,7 +229,7 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
$this -> imgHeight = $height;
|
$this -> imgHeight = $height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* Filename to load from
|
* Filename to load from
|
||||||
@@ -242,7 +242,7 @@ abstract class EscposImage
|
|||||||
// No optimised implementation to provide
|
// No optimised implementation to provide
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* Filename to load from
|
* Filename to load from
|
||||||
@@ -257,7 +257,7 @@ abstract class EscposImage
|
|||||||
// No optimised implementation to provide
|
// No optimised implementation to provide
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get column fromat from loaded image pixels, line by line.
|
* Get column fromat from loaded image pixels, line by line.
|
||||||
*
|
*
|
||||||
@@ -279,7 +279,7 @@ abstract class EscposImage
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
$byteVal |= (int)$this -> imgData[$y * $widthPixels + $x] << (7 - $bit);
|
$byteVal |= (int) $this -> imgData[$y * $widthPixels + $x] << (7 - $bit);
|
||||||
$x++;
|
$x++;
|
||||||
$bit++;
|
$bit++;
|
||||||
if ($x >= $widthPixels) {
|
if ($x >= $widthPixels) {
|
||||||
@@ -303,7 +303,7 @@ abstract class EscposImage
|
|||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get column fromat from loaded image pixels, line by line.
|
* Get column fromat from loaded image pixels, line by line.
|
||||||
*
|
*
|
||||||
@@ -322,7 +322,7 @@ abstract class EscposImage
|
|||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output image in column format. Must be called once for each line of output.
|
* Output image in column format. Must be called once for each line of output.
|
||||||
*
|
*
|
||||||
@@ -356,7 +356,7 @@ abstract class EscposImage
|
|||||||
do {
|
do {
|
||||||
$yReal = $y + $yStart;
|
$yReal = $y + $yStart;
|
||||||
if ($yReal < $heightPixels) {
|
if ($yReal < $heightPixels) {
|
||||||
$byteVal |= (int)$this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit);
|
$byteVal |= (int) $this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit);
|
||||||
}
|
}
|
||||||
$y++;
|
$y++;
|
||||||
$bit++;
|
$bit++;
|
||||||
@@ -381,7 +381,7 @@ abstract class EscposImage
|
|||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean True if GD is loaded, false otherwise
|
* @return boolean True if GD is loaded, false otherwise
|
||||||
*/
|
*/
|
||||||
@@ -389,7 +389,7 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
return extension_loaded('gd');
|
return extension_loaded('gd');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean True if Imagick is loaded, false otherwise
|
* @return boolean True if Imagick is loaded, false otherwise
|
||||||
*/
|
*/
|
||||||
@@ -397,7 +397,7 @@ abstract class EscposImage
|
|||||||
{
|
{
|
||||||
return extension_loaded('imagick');
|
return extension_loaded('imagick');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a convinience method to load an image from file, auto-selecting
|
* This is a convinience method to load an image from file, auto-selecting
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class GdEscposImage extends EscposImage
|
|||||||
/* Set to blank image */
|
/* Set to blank image */
|
||||||
return parent::loadImageData($filename);
|
return parent::loadImageData($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
switch ($ext) {
|
switch ($ext) {
|
||||||
case "png":
|
case "png":
|
||||||
@@ -73,7 +73,7 @@ class GdEscposImage extends EscposImage
|
|||||||
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
|
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
|
||||||
$cols = imagecolorsforindex($im, imagecolorat($im, $x, $y));
|
$cols = imagecolorsforindex($im, imagecolorat($im, $x, $y));
|
||||||
// 1 for white, 0 for black, ignoring transparency
|
// 1 for white, 0 for black, ignoring transparency
|
||||||
$greyness = (int)(($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7;
|
$greyness = (int) (($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7;
|
||||||
// 1 for black, 0 for white, taking into account transparency
|
// 1 for black, 0 for white, taking into account transparency
|
||||||
$black = (1 - $greyness) >> ($cols['alpha'] >> 6);
|
$black = (1 - $greyness) >> ($cols['alpha'] >> 6);
|
||||||
$imgData[$y * $imgWidth + $x] = $black;
|
$imgData[$y * $imgWidth + $x] = $black;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ImagickEscposImage extends EscposImage
|
|||||||
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
|
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
|
||||||
$cols = $im -> getImagePixelColor($x, $y);
|
$cols = $im -> getImagePixelColor($x, $y);
|
||||||
$cols = $cols -> getcolor();
|
$cols = $cols -> getcolor();
|
||||||
$greyness = (int)(($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black
|
$greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black
|
||||||
$imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white
|
$imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ class ImagickEscposImage extends EscposImage
|
|||||||
$im = $this -> getImageFromFile($filename);
|
$im = $this -> getImageFromFile($filename);
|
||||||
$this -> setImgWidth($im -> getimagewidth());
|
$this -> setImgWidth($im -> getimagewidth());
|
||||||
$this -> setImgHeight($im -> getimageheight());
|
$this -> setImgHeight($im -> getimageheight());
|
||||||
|
|
||||||
/* Strip transparency */
|
/* Strip transparency */
|
||||||
$im = self::alphaRemove($im);
|
$im = self::alphaRemove($im);
|
||||||
$im -> setformat('pbm');
|
$im -> setformat('pbm');
|
||||||
@@ -95,7 +95,7 @@ class ImagickEscposImage extends EscposImage
|
|||||||
/* Set to blank image */
|
/* Set to blank image */
|
||||||
return parent::loadImageData($filename);
|
return parent::loadImageData($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$im = $this -> getImageFromFile($filename);
|
$im = $this -> getImageFromFile($filename);
|
||||||
$this -> readImageFromImagick($im);
|
$this -> readImageFromImagick($im);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class EscposPrintBuffer implements PrintBuffer
|
|||||||
if ($c == "\r") {
|
if ($c == "\r") {
|
||||||
/* Skip past Windows line endings (raw usage). */
|
/* Skip past Windows line endings (raw usage). */
|
||||||
continue;
|
continue;
|
||||||
} else if (self::asciiCheck($c, true)) {
|
} elseif (self::asciiCheck($c, true)) {
|
||||||
$outp[$j] = $c;
|
$outp[$j] = $c;
|
||||||
}
|
}
|
||||||
$j++;
|
$j++;
|
||||||
@@ -167,7 +167,7 @@ class EscposPrintBuffer implements PrintBuffer
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on the printer's connector, compute (or load a cached copy of) maps
|
* Based on the printer's connector, compute (or load a cached copy of) maps
|
||||||
* of UTF character to unicode characters for later use.
|
* of UTF character to unicode characters for later use.
|
||||||
@@ -219,7 +219,7 @@ class EscposPrintBuffer implements PrintBuffer
|
|||||||
$encode[$num][$utf8] = chr($char);
|
$encode[$num][$utf8] = chr($char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use generated data */
|
/* Use generated data */
|
||||||
$dataArray = ["available" => $available, "encode" => $encode, "key" => $cacheKey];
|
$dataArray = ["available" => $available, "encode" => $encode, "key" => $cacheKey];
|
||||||
$this -> available = $dataArray["available"];
|
$this -> available = $dataArray["available"];
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class ImagePrintBuffer implements PrintBuffer
|
|||||||
$draw = new \ImagickDraw();
|
$draw = new \ImagickDraw();
|
||||||
$color = new \ImagickPixel('#000000');
|
$color = new \ImagickPixel('#000000');
|
||||||
$background = new \ImagickPixel('white');
|
$background = new \ImagickPixel('white');
|
||||||
|
|
||||||
/* Create annotation */
|
/* Create annotation */
|
||||||
if ($this->font !== null) {
|
if ($this->font !== null) {
|
||||||
// Allow fallback on defaults as necessary
|
// Allow fallback on defaults as necessary
|
||||||
|
|||||||
@@ -21,20 +21,20 @@ use BadMethodCallException;
|
|||||||
*/
|
*/
|
||||||
class CupsPrintConnector implements PrintConnector
|
class CupsPrintConnector implements PrintConnector
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $buffer
|
* @var array $buffer
|
||||||
* Buffer of accumilated data.
|
* Buffer of accumilated data.
|
||||||
*/
|
*/
|
||||||
private $buffer;
|
private $buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string $printerName
|
* @var string $printerName
|
||||||
* The name of the target printer.
|
* The name of the target printer.
|
||||||
*/
|
*/
|
||||||
private $printerName;
|
private $printerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct new CUPS print connector.
|
* Construct new CUPS print connector.
|
||||||
*
|
*
|
||||||
@@ -49,7 +49,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
throw new BadMethodCallException("You do not have any printers installed on " .
|
throw new BadMethodCallException("You do not have any printers installed on " .
|
||||||
"this system via CUPS. Check 'lpr -a'.");
|
"this system via CUPS. Check 'lpr -a'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search($dest, $valid, true) === false) {
|
if (array_search($dest, $valid, true) === false) {
|
||||||
throw new BadMethodCallException("'$dest' is not a printer on this system. " .
|
throw new BadMethodCallException("'$dest' is not a printer on this system. " .
|
||||||
"Printers are: [" . implode(", ", $valid) . "]");
|
"Printers are: [" . implode(", ", $valid) . "]");
|
||||||
@@ -57,7 +57,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
$this->buffer = array ();
|
$this->buffer = array ();
|
||||||
$this->printerName = $dest;
|
$this->printerName = $dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cause a NOTICE if deconstructed before the job was printed.
|
* Cause a NOTICE if deconstructed before the job was printed.
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +67,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
trigger_error("Print connector was not finalized. Did you forget to close the printer?", E_USER_NOTICE);
|
trigger_error("Print connector was not finalized. Did you forget to close the printer?", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send job to printer.
|
* Send job to printer.
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +75,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
{
|
{
|
||||||
$data = implode($this->buffer);
|
$data = implode($this->buffer);
|
||||||
$this->buffer = null;
|
$this->buffer = null;
|
||||||
|
|
||||||
// Build command to work on data
|
// Build command to work on data
|
||||||
$tmpfname = tempnam(sys_get_temp_dir(), 'print-');
|
$tmpfname = tempnam(sys_get_temp_dir(), 'print-');
|
||||||
file_put_contents($tmpfname, $data);
|
file_put_contents($tmpfname, $data);
|
||||||
@@ -92,7 +92,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
}
|
}
|
||||||
unlink($tmpfname);
|
unlink($tmpfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a command and throw an exception if it fails, or return the output if it works.
|
* Run a command and throw an exception if it fails, or return the output if it works.
|
||||||
* (Basically exec() with good error handling)
|
* (Basically exec() with good error handling)
|
||||||
@@ -129,7 +129,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
}
|
}
|
||||||
return $outputStr;
|
return $outputStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data from the printer.
|
* Read data from the printer.
|
||||||
*
|
*
|
||||||
@@ -140,7 +140,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $data
|
* @param string $data
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +148,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
{
|
{
|
||||||
$this->buffer [] = $data;
|
$this->buffer [] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a list of CUPS printers.
|
* Load a list of CUPS printers.
|
||||||
*
|
*
|
||||||
@@ -164,7 +164,7 @@ class CupsPrintConnector implements PrintConnector
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the item before the first space in a string
|
* Get the item before the first space in a string
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ final class DummyPrintConnector implements PrintConnector
|
|||||||
{
|
{
|
||||||
$this -> buffer = [];
|
$this -> buffer = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this -> buffer !== null) {
|
if ($this -> buffer !== null) {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class FilePrintConnector implements PrintConnector
|
|||||||
$this -> fp = false;
|
$this -> fp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-PHPdoc)
|
/* (non-PHPdoc)
|
||||||
* @see PrintConnector::read()
|
* @see PrintConnector::read()
|
||||||
*/
|
*/
|
||||||
@@ -66,7 +66,7 @@ class FilePrintConnector implements PrintConnector
|
|||||||
}
|
}
|
||||||
return fread($this -> fp, $len);
|
return fread($this -> fp, $len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write data to the file
|
* Write data to the file
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ class Printer
|
|||||||
{
|
{
|
||||||
/* Set connector */
|
/* Set connector */
|
||||||
$this -> connector = $connector;
|
$this -> connector = $connector;
|
||||||
|
|
||||||
/* Set capability profile */
|
/* Set capability profile */
|
||||||
if ($profile === null) {
|
if ($profile === null) {
|
||||||
$profile = CapabilityProfile::load('default');
|
$profile = CapabilityProfile::load('default');
|
||||||
@@ -374,18 +374,18 @@ class Printer
|
|||||||
$this -> setPrintBuffer($buffer);
|
$this -> setPrintBuffer($buffer);
|
||||||
$this -> initialize();
|
$this -> initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a barcode.
|
* Print a barcode.
|
||||||
*
|
*
|
||||||
* @param string $content The information to encode.
|
* @param string $content The information to encode.
|
||||||
* @param int $type The barcode standard to output. Supported values are
|
* @param int $type The barcode standard to output. Supported values are
|
||||||
* `Printer::BARCODE_UPCA`, `Printer::BARCODE_UPCE`, `Printer::BARCODE_JAN13`,
|
* `Printer::BARCODE_UPCA`, `Printer::BARCODE_UPCE`, `Printer::BARCODE_JAN13`,
|
||||||
* `Printer::BARCODE_JAN8`, `Printer::BARCODE_CODE39`, `Printer::BARCODE_ITF`,
|
* `Printer::BARCODE_JAN8`, `Printer::BARCODE_CODE39`, `Printer::BARCODE_ITF`,
|
||||||
* `Printer::BARCODE_CODABAR`, `Printer::BARCODE_CODE93`, and `Printer::BARCODE_CODE128`.
|
* `Printer::BARCODE_CODABAR`, `Printer::BARCODE_CODE93`, and `Printer::BARCODE_CODE128`.
|
||||||
* If not specified, `Printer::BARCODE_CODE39` will be used. Note that some
|
* If not specified, `Printer::BARCODE_CODE39` will be used. Note that some
|
||||||
* barcode formats only support specific lengths or sets of characters, and that
|
* barcode formats only support specific lengths or sets of characters, and that
|
||||||
* available barcode types vary between printers.
|
* available barcode types vary between printers.
|
||||||
* @throws InvalidArgumentException Where the length or characters used in $content is invalid for the requested barcode format.
|
* @throws InvalidArgumentException Where the length or characters used in $content is invalid for the requested barcode format.
|
||||||
*/
|
*/
|
||||||
public function barcode($content, $type = Printer::BARCODE_CODE39)
|
public function barcode($content, $type = Printer::BARCODE_CODE39)
|
||||||
@@ -441,7 +441,7 @@ class Printer
|
|||||||
// More advanced function B, used in preference
|
// More advanced function B, used in preference
|
||||||
$this -> connector -> write(self::GS . "k" . chr($type) . chr(strlen($content)) . $content);
|
$this -> connector -> write(self::GS . "k" . chr($type) . chr(strlen($content)) . $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print an image, using the older "bit image" command. This creates padding on the right of the image,
|
* Print an image, using the older "bit image" command. This creates padding on the right of the image,
|
||||||
* if its width is not divisible by 8.
|
* if its width is not divisible by 8.
|
||||||
@@ -451,8 +451,8 @@ class Printer
|
|||||||
*
|
*
|
||||||
* @param EscposImage $img The image to print
|
* @param EscposImage $img The image to print
|
||||||
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
||||||
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
||||||
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
||||||
*/
|
*/
|
||||||
public function bitImage(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
public function bitImage(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
||||||
{
|
{
|
||||||
@@ -471,8 +471,8 @@ class Printer
|
|||||||
*
|
*
|
||||||
* @param EscposImage $img The image to print
|
* @param EscposImage $img The image to print
|
||||||
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
||||||
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
||||||
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
||||||
*/
|
*/
|
||||||
public function bitImageColumnFormat(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
public function bitImageColumnFormat(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
||||||
{
|
{
|
||||||
@@ -502,7 +502,7 @@ class Printer
|
|||||||
{
|
{
|
||||||
$this -> connector -> finalize();
|
$this -> connector -> finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cut the paper.
|
* Cut the paper.
|
||||||
*
|
*
|
||||||
@@ -514,7 +514,7 @@ class Printer
|
|||||||
// TODO validation on cut() inputs
|
// TODO validation on cut() inputs
|
||||||
$this -> connector -> write(self::GS . "V" . chr($mode) . chr($lines));
|
$this -> connector -> write(self::GS . "V" . chr($mode) . chr($lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print and feed line / Print and feed n lines.
|
* Print and feed line / Print and feed n lines.
|
||||||
*
|
*
|
||||||
@@ -565,7 +565,7 @@ class Printer
|
|||||||
{
|
{
|
||||||
return $this -> characterTable;
|
return $this -> characterTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PrintBuffer
|
* @return PrintBuffer
|
||||||
*/
|
*/
|
||||||
@@ -606,8 +606,8 @@ class Printer
|
|||||||
*
|
*
|
||||||
* @param EscposImage $img The image to print.
|
* @param EscposImage $img The image to print.
|
||||||
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
* @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
|
||||||
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
* (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
|
||||||
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
* `Printer::IMG_DOUBLE_WIDTH` flags.
|
||||||
*/
|
*/
|
||||||
public function graphics(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
public function graphics(EscposImage $img, $size = Printer::IMG_DEFAULT)
|
||||||
{
|
{
|
||||||
@@ -622,7 +622,7 @@ class Printer
|
|||||||
$this -> wrapperSendGraphicsData('0', 'p', $header . $rasterData);
|
$this -> wrapperSendGraphicsData('0', 'p', $header . $rasterData);
|
||||||
$this -> wrapperSendGraphicsData('0', '2');
|
$this -> wrapperSendGraphicsData('0', '2');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize printer. This resets formatting back to the defaults.
|
* Initialize printer. This resets formatting back to the defaults.
|
||||||
*/
|
*/
|
||||||
@@ -637,15 +637,15 @@ class Printer
|
|||||||
*
|
*
|
||||||
* @param string $content Text or numbers to store in the code
|
* @param string $content Text or numbers to store in the code
|
||||||
* @param int $width Width of a module (pixel) in the printed code.
|
* @param int $width Width of a module (pixel) in the printed code.
|
||||||
* Default is 3 dots.
|
* Default is 3 dots.
|
||||||
* @param int $heightMultiplier Multiplier for height of a module.
|
* @param int $heightMultiplier Multiplier for height of a module.
|
||||||
* Default is 3 times the width.
|
* Default is 3 times the width.
|
||||||
* @param int $dataColumnCount Number of data columns to use. 0 (default)
|
* @param int $dataColumnCount Number of data columns to use. 0 (default)
|
||||||
* is to auto-calculate. Smaller numbers will result in a narrower code,
|
* is to auto-calculate. Smaller numbers will result in a narrower code,
|
||||||
* making larger pixel sizes possible. Larger numbers require smaller pixel sizes.
|
* making larger pixel sizes possible. Larger numbers require smaller pixel sizes.
|
||||||
* @param float $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
|
* @param float $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
|
||||||
* @param int $options Standard code Printer::PDF417_STANDARD with
|
* @param int $options Standard code Printer::PDF417_STANDARD with
|
||||||
* start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.
|
* start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.
|
||||||
* @throws Exception If this profile indicates that PDF417 code is not supported
|
* @throws Exception If this profile indicates that PDF417 code is not supported
|
||||||
*/
|
*/
|
||||||
public function pdf417Code($content, $width = 3, $heightMultiplier = 3, $dataColumnCount = 0, $ec = 0.10, $options = Printer::PDF417_STANDARD)
|
public function pdf417Code($content, $width = 3, $heightMultiplier = 3, $dataColumnCount = 0, $ec = 0.10, $options = Printer::PDF417_STANDARD)
|
||||||
@@ -672,7 +672,7 @@ class Printer
|
|||||||
$this -> wrapperSend2dCodeData(chr(67), $cn, chr($width));
|
$this -> wrapperSend2dCodeData(chr(67), $cn, chr($width));
|
||||||
$this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier));
|
$this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier));
|
||||||
// Set error correction ratio: 1% to 400%
|
// Set error correction ratio: 1% to 400%
|
||||||
$ec_int = (int)ceil(floatval($ec) * 10);
|
$ec_int = (int) ceil(floatval($ec) * 10);
|
||||||
$this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1');
|
$this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1');
|
||||||
// Send content & print
|
// Send content & print
|
||||||
$this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0');
|
$this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0');
|
||||||
@@ -772,7 +772,7 @@ class Printer
|
|||||||
|
|
||||||
$this -> connector -> write(self::ESC . "!" . chr($mode));
|
$this -> connector -> write(self::ESC . "!" . chr($mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set barcode height.
|
* Set barcode height.
|
||||||
*
|
*
|
||||||
@@ -788,27 +788,27 @@ class Printer
|
|||||||
* Set barcode bar width.
|
* Set barcode bar width.
|
||||||
*
|
*
|
||||||
* @param int $width Bar width in dots. If not specified, 3 will be used.
|
* @param int $width Bar width in dots. If not specified, 3 will be used.
|
||||||
* Values above 6 appear to have no effect.
|
* Values above 6 appear to have no effect.
|
||||||
*/
|
*/
|
||||||
public function setBarcodeWidth($width = 3)
|
public function setBarcodeWidth($width = 3)
|
||||||
{
|
{
|
||||||
self::validateInteger($width, 1, 255, __FUNCTION__);
|
self::validateInteger($width, 1, 255, __FUNCTION__);
|
||||||
$this -> connector -> write(self::GS . "w" . chr($width));
|
$this -> connector -> write(self::GS . "w" . chr($width));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the position for the Human Readable Interpretation (HRI) of barcode characters.
|
* Set the position for the Human Readable Interpretation (HRI) of barcode characters.
|
||||||
*
|
*
|
||||||
* @param int $position. Use Printer::BARCODE_TEXT_NONE to hide the text (default),
|
* @param int $position. Use Printer::BARCODE_TEXT_NONE to hide the text (default),
|
||||||
* or any combination of Printer::BARCODE_TEXT_ABOVE and Printer::BARCODE_TEXT_BELOW
|
* or any combination of Printer::BARCODE_TEXT_ABOVE and Printer::BARCODE_TEXT_BELOW
|
||||||
* flags to display the text.
|
* flags to display the text.
|
||||||
*/
|
*/
|
||||||
public function setBarcodeTextPosition($position = Printer::BARCODE_TEXT_NONE)
|
public function setBarcodeTextPosition($position = Printer::BARCODE_TEXT_NONE)
|
||||||
{
|
{
|
||||||
self::validateInteger($position, 0, 3, __FUNCTION__, "Barcode text position");
|
self::validateInteger($position, 0, 3, __FUNCTION__, "Barcode text position");
|
||||||
$this -> connector -> write(self::GS . "H" . chr($position));
|
$this -> connector -> write(self::GS . "H" . chr($position));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn double-strike mode on/off.
|
* Turn double-strike mode on/off.
|
||||||
*
|
*
|
||||||
@@ -841,7 +841,7 @@ class Printer
|
|||||||
self::validateBoolean($on, __FUNCTION__);
|
self::validateBoolean($on, __FUNCTION__);
|
||||||
$this -> connector -> write(self::ESC . "E". ($on ? chr(1) : chr(0)));
|
$this -> connector -> write(self::ESC . "E". ($on ? chr(1) : chr(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).
|
* Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).
|
||||||
*
|
*
|
||||||
@@ -852,7 +852,7 @@ class Printer
|
|||||||
self::validateInteger($font, 0, 2, __FUNCTION__);
|
self::validateInteger($font, 0, 2, __FUNCTION__);
|
||||||
$this -> connector -> write(self::ESC . "M" . chr($font));
|
$this -> connector -> write(self::ESC . "M" . chr($font));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select justification.
|
* Select justification.
|
||||||
*
|
*
|
||||||
@@ -870,7 +870,7 @@ class Printer
|
|||||||
* Some printers will allow you to overlap lines with a smaller line feed.
|
* Some printers will allow you to overlap lines with a smaller line feed.
|
||||||
*
|
*
|
||||||
* @param int|null $height The height of each line, in dots. If not set, the printer
|
* @param int|null $height The height of each line, in dots. If not set, the printer
|
||||||
* will reset to its default line spacing.
|
* will reset to its default line spacing.
|
||||||
*/
|
*/
|
||||||
public function setLineSpacing($height = null)
|
public function setLineSpacing($height = null)
|
||||||
{
|
{
|
||||||
@@ -926,7 +926,7 @@ class Printer
|
|||||||
$this -> buffer = $buffer;
|
$this -> buffer = $buffer;
|
||||||
$this -> buffer -> setPrinter($this);
|
$this -> buffer -> setPrinter($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set black/white reverse mode on or off. In this mode, text is printed white on a black background.
|
* Set black/white reverse mode on or off. In this mode, text is printed white on a black background.
|
||||||
*
|
*
|
||||||
@@ -995,7 +995,7 @@ class Printer
|
|||||||
public function text($str = "")
|
public function text($str = "")
|
||||||
{
|
{
|
||||||
self::validateString($str, __FUNCTION__);
|
self::validateString($str, __FUNCTION__);
|
||||||
$this -> buffer -> writeText((string)$str);
|
$this -> buffer -> writeText((string) $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1010,7 +1010,7 @@ class Printer
|
|||||||
self::validateString($str, __FUNCTION__);
|
self::validateString($str, __FUNCTION__);
|
||||||
$this -> connector -> write(self::FS . "&");
|
$this -> connector -> write(self::FS . "&");
|
||||||
$str = iconv("UTF-8", "GBK//IGNORE", $str);
|
$str = iconv("UTF-8", "GBK//IGNORE", $str);
|
||||||
$this -> buffer -> writeTextRaw((string)$str);
|
$this -> buffer -> writeTextRaw((string) $str);
|
||||||
$this -> connector -> write(self::FS . ".");
|
$this -> connector -> write(self::FS . ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1025,9 +1025,9 @@ class Printer
|
|||||||
public function textRaw($str = "")
|
public function textRaw($str = "")
|
||||||
{
|
{
|
||||||
self::validateString($str, __FUNCTION__);
|
self::validateString($str, __FUNCTION__);
|
||||||
$this -> buffer -> writeTextRaw((string)$str);
|
$this -> buffer -> writeTextRaw((string) $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for GS ( k, to calculate and send correct data length.
|
* Wrapper for GS ( k, to calculate and send correct data length.
|
||||||
*
|
*
|
||||||
@@ -1045,7 +1045,7 @@ class Printer
|
|||||||
$header = $this -> intLowHigh(strlen($data) + strlen($m) + 2, 2);
|
$header = $this -> intLowHigh(strlen($data) + strlen($m) + 2, 2);
|
||||||
$this -> connector -> write(self::GS . "(k" . $header . $cn . $fn . $m . $data);
|
$this -> connector -> write(self::GS . "(k" . $header . $cn . $fn . $m . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for GS ( L, to calculate and send correct data length.
|
* Wrapper for GS ( L, to calculate and send correct data length.
|
||||||
*
|
*
|
||||||
@@ -1062,7 +1062,7 @@ class Printer
|
|||||||
$header = $this -> intLowHigh(strlen($data) + 2, 2);
|
$header = $this -> intLowHigh(strlen($data) + 2, 2);
|
||||||
$this -> connector -> write(self::GS . "(L" . $header . $m . $fn . $data);
|
$this -> connector -> write(self::GS . "(L" . $header . $m . $fn . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert widths and heights to characters. Used before sending graphics to set the size.
|
* Convert widths and heights to characters. Used before sending graphics to set the size.
|
||||||
*
|
*
|
||||||
@@ -1083,7 +1083,7 @@ class Printer
|
|||||||
}
|
}
|
||||||
return implode("", $outp);
|
return implode("", $outp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate two characters for a number: In lower and higher parts, or more parts as needed.
|
* Generate two characters for a number: In lower and higher parts, or more parts as needed.
|
||||||
*
|
*
|
||||||
@@ -1098,11 +1098,11 @@ class Printer
|
|||||||
$outp = "";
|
$outp = "";
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$outp .= chr($input % 256);
|
$outp .= chr($input % 256);
|
||||||
$input = (int)($input / 256);
|
$input = (int) ($input / 256);
|
||||||
}
|
}
|
||||||
return $outp;
|
return $outp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw an exception if the argument given is not a boolean
|
* Throw an exception if the argument given is not a boolean
|
||||||
*
|
*
|
||||||
@@ -1148,7 +1148,7 @@ class Printer
|
|||||||
{
|
{
|
||||||
self::validateIntegerMulti($test, [[$min, $max]], $source, $argument);
|
self::validateIntegerMulti($test, [[$min, $max]], $source, $argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw an exception if the argument given is not an integer within one of the specified ranges
|
* Throw an exception if the argument given is not an integer within one of the specified ranges
|
||||||
*
|
*
|
||||||
@@ -1198,7 +1198,7 @@ class Printer
|
|||||||
throw new InvalidArgumentException("$argument to $source must be a string");
|
throw new InvalidArgumentException("$argument to $source must be a string");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw an exception if the argument doesn't match the given regex.
|
* Throw an exception if the argument doesn't match the given regex.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user