Esempio n. 1
0
 /**
  * tag : INPUT
  * mode : OPEN
  *
  * @param  array $param
  * @return boolean
  */
 protected function _tag_open_INPUT($param)
 {
     if (!isset($param['name'])) {
         $param['name'] = 'champs_pdf_' . (count($this->_lstField) + 1);
     }
     if (!isset($param['value'])) {
         $param['value'] = '';
     }
     if (!isset($param['type'])) {
         $param['type'] = 'text';
     }
     $param['name'] = strtolower($param['name']);
     $param['type'] = strtolower($param['type']);
     // the type must be valid
     if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) {
         $param['type'] = 'text';
     }
     if (isset($this->_lstField[$param['name']])) {
         $this->_lstField[$param['name']]++;
     } else {
         $this->_lstField[$param['name']] = 1;
     }
     $this->parsingCss->save();
     $this->parsingCss->analyse('input', $param);
     $this->parsingCss->setPosition();
     $this->parsingCss->fontSet();
     $name = $param['name'];
     $x = $this->pdf->getX();
     $y = $this->pdf->getY();
     $f = 1.08 * $this->parsingCss->value['font-size'];
     $prop = $this->parsingCss->getFormStyle();
     switch ($param['type']) {
         case 'checkbox':
             $w = 3;
             $h = $w;
             if ($h < $f) {
                 $y += ($f - $h) * 0.5;
             }
             $checked = isset($param['checked']) && $param['checked'] == 'checked';
             $this->pdf->CheckBox($name, $w, $checked, $prop, array(), $param['value'] ? $param['value'] : 'Yes', $x, $y);
             break;
         case 'radio':
             $w = 3;
             $h = $w;
             if ($h < $f) {
                 $y += ($f - $h) * 0.5;
             }
             $checked = isset($param['checked']) && $param['checked'] == 'checked';
             $this->pdf->RadioButton($name, $w, $prop, array(), $param['value'] ? $param['value'] : 'On', $checked, $x, $y);
             break;
         case 'hidden':
             $w = 0;
             $h = 0;
             $prop['value'] = $param['value'];
             $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
             break;
         case 'text':
             $w = $this->parsingCss->value['width'];
             if (!$w) {
                 $w = 40;
             }
             $h = $f * 1.3;
             $prop['value'] = $param['value'];
             $this->pdf->TextField($name, $w, $h, $prop, array(), $x, $y);
             break;
         case 'submit':
             $w = $this->parsingCss->value['width'];
             if (!$w) {
                 $w = 40;
             }
             $h = $this->parsingCss->value['height'];
             if (!$h) {
                 $h = $f * 1.3;
             }
             $action = array('S' => 'SubmitForm', 'F' => $this->_isInForm, 'Flags' => array('ExportFormat'));
             $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
             break;
         case 'reset':
             $w = $this->parsingCss->value['width'];
             if (!$w) {
                 $w = 40;
             }
             $h = $this->parsingCss->value['height'];
             if (!$h) {
                 $h = $f * 1.3;
             }
             $action = array('S' => 'ResetForm');
             $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
             break;
         case 'button':
             $w = $this->parsingCss->value['width'];
             if (!$w) {
                 $w = 40;
             }
             $h = $this->parsingCss->value['height'];
             if (!$h) {
                 $h = $f * 1.3;
             }
             $action = isset($param['onclick']) ? $param['onclick'] : '';
             $this->pdf->Button($name, $w, $h, $param['value'], $action, $prop, array(), $x, $y);
             break;
         default:
             $w = 0;
             $h = 0;
             break;
     }
     $this->_maxX = max($this->_maxX, $x + $w);
     $this->_maxY = max($this->_maxY, $y + $h);
     $this->_maxH = max($this->_maxH, $h);
     $this->_maxE++;
     $this->pdf->setX($x + $w);
     $this->parsingCss->load();
     $this->parsingCss->fontSet();
     return true;
 }