Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Validate/Barcode/Code39.php
Go to the documentation of this file.
00001 <?php
00025 require_once 'Zend/Validate/Barcode/AdapterAbstract.php';
00026 
00033 class Zend_Validate_Barcode_Code39 extends Zend_Validate_Barcode_AdapterAbstract
00034 {
00039     protected $_length = -1;
00040 
00045     protected $_characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ -.$/+%';
00046 
00051     protected $_checksum = '_code39';
00052 
00056     protected $_check = array(
00057         '0' =>  0, '1' =>  1, '2' =>  2, '3' =>  3, '4' =>  4, '5' =>  5, '6' =>  6,
00058         '7' =>  7, '8' =>  8, '9' =>  9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
00059         'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20,
00060         'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27,
00061         'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
00062         'Z' => 35, '-' => 36, '.' => 37, ' ' => 38, '$' => 39, '/' => 40, '+' => 41,
00063         '%' => 42,
00064     );
00065 
00073     public function __construct()
00074     {
00075         $this->setCheck(false);
00076     }
00077 
00084     protected function _code39($value)
00085     {
00086         $checksum = substr($value, -1, 1);
00087         $value    = str_split(substr($value, 0, -1));
00088         $count    = 0;
00089         foreach($value as $char) {
00090             $count += $this->_check[$char];
00091         }
00092 
00093         $mod = $count % 43;
00094         if ($mod == $this->_check[$checksum]) {
00095             return true;
00096         }
00097 
00098         return false;
00099     }
00100 }
 All Data Structures Namespaces Files Functions Variables Enumerations