_getInfo($name, $value, $attribs, $options, $listsep);
$id = null;
$name = null;
$value = null;
$attribs = [];
$options = [];
$listsep = null;
$disable = null;
$escape = null;
extract($info); // name, value, attribs, options, listsep, disable
if (isset($attribs['scriptOptions'])) {
$options = $attribs['scriptOptions'];
unset($attribs['scriptOptions']);
}
$width = Qs_Array::get($attribs, 'width', Qs_SignaturePad::IMAGE_WIDTH);
$height = Qs_Array::get($attribs, 'height', Qs_SignaturePad::IMAGE_HEIGHT);
unset($attribs['width'], $attribs['height']);
$options['id'] = $id;
$options['elementWrapperId'] = $id . '-element-wrapper';
$containerAttribs = $attribs + ['id' => $options['elementWrapperId']];
$wrapperAttribs = ['class' => 'sigPad sigWrapper'];
$canvasAttribs = [
'class' => 'pad',
'width' => $width,
'height' => $height,
];
$inputAttribs = [
'type' => 'hidden',
'class' => 'output',
'id' => $id,
'name' => $name,
];
$this->_initScripts($options, $value);
$html = '
_htmlAttribs($containerAttribs) . '>';
$html .= '
Clear';
$html .= '
_htmlAttribs($wrapperAttribs) . '>';
$html .= '';
$html .= '_htmlAttribs($inputAttribs) . '>';
$html .= '
';
$html .= '
';
return $html;
}
protected function _initScripts($options, $value)
{
/** @var $doc Qs_Doc */
$doc = Zend_Registry::get('doc');
$doc->addStylesheet('css/thirdpart/signaturepad/jquery.signaturepad.css');
if ($this->_isLtIe9()) {
$doc->addScript('js/signaturepad/assets/flashcanvas.js');
}
$doc->addScript('js/signaturepad/assets/json2.js');
$doc->addScript('js/signaturepad/jquery.signaturepad.js');
$doc->addScript('js/lib/form/element/signaturePad.js');
$doc->addInitObject('lib.form.element.SignaturePad', [$options, $value]);
return $this;
}
protected function _isLtIe9()
{
$ua = $_SERVER['HTTP_USER_AGENT'];
if (false !== strpos($ua, 'MSIE')) {
$ver = [];
if (preg_match('/MSIE (\d+(?:\.\d+)?)/', $ua, $ver)) {
$ver = (float) $ver[1];
return ($ver < 9);
}
}
return false;
}
}