public function getTemplateCode($form) { $this->db->setQuery("Select template_code From #__facileforms_forms Where id = " . $this->db->Quote($form) . ""); $objList = $this->db->loadObjectList(); $objListCount = count($objList); if ($objListCount == 1) { return bf_b64dec($objList[0]->template_code); } return ''; }
function __construct(HTML_facileFormsProcessor $p) { // will make sure mootools loads first, important 4 jquery jimport('joomla.version'); $version = new JVersion(); if (version_compare($version->getShortVersion(), '2.5', '>=')) { $this->language_tag = JFactory::getLanguage()->getTag() != JFactory::getLanguage()->getDefault() ? JFactory::getLanguage()->getTag() : 'zz-ZZ'; } JFactory::getDocument()->addScriptDeclaration('<!--'); $this->p = $p; $this->dataObject = Zend_Json::decode(bf_b64dec($this->p->formrow->template_code)); $this->rootMdata = $this->dataObject['properties']; /* translatables */ if (isset($this->rootMdata['title_translation' . $this->language_tag]) && $this->rootMdata['title_translation' . $this->language_tag] != '') { $this->rootMdata['title'] = $this->rootMdata['title_translation' . $this->language_tag]; JFactory::getDocument()->setTitle($this->rootMdata['title']); } /* translatables end */ $this->fading = $this->rootMdata['fadeIn']; $this->useErrorAlerts = $this->rootMdata['useErrorAlerts']; $this->useDefaultErrors = isset($this->rootMdata['useDefaultErrors']) ? $this->rootMdata['useDefaultErrors'] : false; $this->useBalloonErrors = isset($this->rootMdata['useBalloonErrors']) ? $this->rootMdata['useBalloonErrors'] : false; $this->rollover = $this->rootMdata['rollover']; $this->rolloverColor = $this->rootMdata['rolloverColor']; $this->toggleFields = $this->parseToggleFields(isset($this->rootMdata['toggleFields']) ? $this->rootMdata['toggleFields'] : '[]'); mt_srand(); $this->flashUploadTicket = md5(strtotime('now') . mt_rand(0, mt_getrandmax())); $this->cancelImagePath = JURI::root(true) . '/media/breezingforms/themes/cancel.png'; $this->uploadImagePath = JURI::root(true) . '/media/breezingforms/themes/upload.png'; if (@file_exists(JPATH_SITE . '/media/breezingforms/themes/' . $this->rootMdata['theme'] . '/img/cancel.png')) { $this->cancelImagePath = JURI::root(true) . '/media/breezingforms/themes/' . $this->rootMdata['theme'] . '/img/cancel.png'; } if (@file_exists(JPATH_SITE . '/media/breezingforms/themes/' . $this->rootMdata['theme'] . '/img/upload.png')) { $this->uploadImagePath = JURI::root(true) . '/media/breezingforms/themes/' . $this->rootMdata['theme'] . '/img/upload.png'; } }
$pages = $easyMode->getNumFormPages($form); if ($nameTitle == null) { $formName = 'EasyForm_' . mt_rand(0, mt_getrandmax()); $formTitle = $formName; } else { $formName = $nameTitle->name; $formTitle = $nameTitle->title; } switch ($task) { case 'save': //print_r(Zend_Json::decode(bf_b64dec(JRequest::getVar('areas', '')))); //exit; $templateCode = JRequest::getVar('templateCode', ''); $areas = JRequest::getVar('areas', ''); $pages = JRequest::getVar('pages', 1); $formId = $easyMode->save($form, $formName, $formTitle, array(), bf_b64dec($templateCode), Zend_Json::decode(bf_b64dec($areas)), $pages); // CONTENTBUILDER jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); if (JFile::exists(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php')) { require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php'; $cbForm = contentbuilder::getForm('com_breezingforms', $formId); $db = JFactory::getDBO(); $db->setQuery("Select id From #__contentbuilder_forms Where `type` = 'com_breezingforms' And `reference_id` = " . intval($formId)); jimport('joomla.version'); $version = new JVersion(); if (version_compare($version->getShortVersion(), '3.0', '>=')) { $cbForms = $db->loadColumn(); } else { $cbForms = $db->loadResultArray(); }
function emitForm() { global $database; $database = JFactory::getDBO(); // sanity check if ($this->hasErrors()) { return; } if (!array_key_exists('emitted', $this->params[1])) { // save new row $row = new facileFormsForms($database); $database->setQuery("select max(ordering)+1 from #__facileforms_forms"); $row->ordering = $database->loadResult(); $row->published = $this->getInt(1, 'published', 1); $row->runmode = $this->getInt(1, 'runmode'); $row->package = $this->getText(1, 'package'); $row->name = $this->getText(1, 'name', BFText::_('COM_BREEZINGFORMS_INSTALLER_UNKNOWN')); $row->title = $this->getText(1, 'title', BFText::_('COM_BREEZINGFORMS_INSTALLER_UNKNOWN')); $row->description = $this->getText(1, 'description'); $row->template_code = ''; $row->template_code_processed = ''; $row->template_areas = ''; if ($this->getText(1, 'template_code') != '') { $row->template_code = bf_b64dec($this->getText(1, 'template_code')); $row->template_code_processed = bf_b64dec($this->getText(1, 'template_code_processed')); $row->template_areas = $this->getText(1, 'template_areas'); } $row->class1 = $this->getText(1, 'class1'); $row->class2 = $this->getText(1, 'class2'); $row->width = $this->getInt(1, 'width'); $row->widthmode = $this->getInt(1, 'widthmode'); $row->height = $this->getInt(1, 'height'); $row->heightmode = $this->getInt(1, 'heightmode'); $row->pages = $this->getInt(1, 'pages', 1); $row->emailntf = $this->getInt(1, 'emailntf', 1); $row->emaillog = $this->getInt(1, 'emaillog', 1); $row->emailxml = $this->getInt(1, 'emailxml'); $row->emailadr = $this->getText(1, 'emailadr'); $row->dblog = $this->getInt(1, 'dblog', 1); $row->prevmode = $this->getInt(1, 'prevmode', 2); $row->prevwidth = $this->getInt(1, 'prevwidth', ''); $this->getScriptPiece(1, $row, '#__facileforms_scripts', 'script1', $this->xscripts); if ($this->hasErrors()) { return; } $this->getScriptPiece(1, $row, '#__facileforms_scripts', 'script2', $this->xscripts); if ($this->hasErrors()) { return; } $this->getScriptPiece(1, $row, '#__facileforms_pieces', 'piece1', $this->xpieces); if ($this->hasErrors()) { return; } $this->getScriptPiece(1, $row, '#__facileforms_pieces', 'piece2', $this->xpieces); if ($this->hasErrors()) { return; } $this->getScriptPiece(1, $row, '#__facileforms_pieces', 'piece3', $this->xpieces); if ($this->hasErrors()) { return; } $this->getScriptPiece(1, $row, '#__facileforms_pieces', 'piece4', $this->xpieces); if ($this->hasErrors()) { return; } if (!$row->store()) { $this->setError($row->getError(), true); return; } // if // final tasks $this->forms[] = $row->id; $this->params[1]['form_id'] = $row->id; $this->params[1]['elem_ord'] = 0; $this->params[1]['emitted'] = true; } // if }
} else { // as last resort, we use the // joomla api that uses FTP if possible // and if the folder is not writable // and hope the file is not exceeding the // php memory limit $final = ''; if (@JFile::exists($finaltargetFile)) { $final = @JFile::read($finaltargetFile); } $newbuf = $final . $chunky; @JFile::write($finaltargetFile, $newbuf); } require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php'; require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php'; $dataObject = Zend_Json::decode(bf_b64dec($objectList[0]->template_code)); bfProcess($dataObject, $finaltargetFile); @JFile::delete($targetFile); } else { echo 'Could not upload file ' . addslashes($_FILES['Filedata']['name']) . '!'; } } else { echo 'Invalid file storage path for file ' . addslashes($_FILES['Filedata']['name']) . '! Please check the upload folder path and its permissions!'; } } else { echo 'Form id and element do not match!'; } } exit; } }
static function copy($option, $pkg, $ids) { global $database; JArrayHelper::toInteger($ids); require_once JPATH_SITE . '/administrator/components/com_breezingforms/admin/quickmode.class.php'; require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php'; require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php'; $database = JFactory::getDBO(); $total = count($ids); $row = new facileFormsForms($database); $elem = new facileFormsElements($database); if (count($ids)) { foreach ($ids as $id) { $row->load(intval($id)); $row->id = NULL; $row->ordering = 999999; $row->title = 'Copy of ' . $row->title; $row->name = 'copy_' . $row->name; $row->store(); $row->reorder(''); $database->setQuery("select id from #__facileforms_elements where form={$id}"); $eids = $database->loadObjectList(); for ($i = 0; $i < count($eids); $i++) { $eid = $eids[$i]; $elem->load(intval($eid->id)); $elem->id = NULL; $elem->form = $row->id; $elem->store(); } // for // resetting easy and quickmode database ids JFactory::getDBO()->setQuery("Select template_areas, template_code_processed, template_code From #__facileforms_forms Where id = " . intval($row->{$id})); $row_ = JFactory::getDBO()->loadObject(); if (trim($row_->template_code) != '') { $areas = Zend_Json::decode($row_->template_areas); $i = 0; foreach ($areas as $area) { $j = 0; foreach ($area['elements'] as $element) { $areas[$i]['elements'][$j]['dbId'] = 0; $j++; } $i++; } $template_areas = Zend_Json::encode($areas); $template_code = $row_->template_code; if ($row_->template_code_processed == 'QuickMode') { $dataObject = Zend_Json::decode(bf_b64dec($row_->template_code)); resetQuickModeDbId($dataObject); $template_code = bf_b64enc(Zend_Json::encode($dataObject)); } JFactory::getDBO()->setQuery("Update #__facileforms_forms Set template_code = " . JFactory::getDBO()->Quote($template_code) . ", template_areas = " . JFactory::getDBO()->Quote($template_areas) . " Where id = " . intval($id)); JFactory::getDBO()->query(); if ($row_ && $row_->template_code_processed == 'QuickMode') { $quickMode = new QuickMode(); $quickMode->save($id, Zend_Json::decode(bf_b64dec($template_code))); } } // reset end } } // foreach $msg = $total . ' ' . BFText::_('COM_BREEZINGFORMS_FORMS_SUCOPIED'); JFactory::getApplication()->redirect("index.php?option={$option}&act=manageforms&pkg={$pkg}&mosmsg={$msg}"); }
$form = JRequest::getInt('form', 0); $chunkIdx = JRequest::getInt('chunkIdx', 0); $rndAdd = JRequest::getVar('rndAdd', 0); $_dest = JPATH_SITE . '/media/breezingforms/ajax_cache/ajaxsave_' . $chunkIdx . '_' . $rndAdd . '.txt'; $_chunk = JRequest::getVar('chunk', ''); @JFile::write($_dest, $_chunk); @ob_end_clean(); if ($chunkIdx == $chunksLength - 1) { $contents = ''; for ($i = 0; $i < $chunksLength; $i++) { $contents .= @JFile::read(JPATH_SITE . '/media/breezingforms/ajax_cache/ajaxsave_' . $i . '_' . $rndAdd . '.txt'); @JFile::delete(JPATH_SITE . '/media/breezingforms/ajax_cache/ajaxsave_' . $i . '_' . $rndAdd . '.txt'); } $formId = 0; @ob_end_clean(); $formId = $quickMode->save($form, Zend_Json::decode(bf_b64dec($contents))); ob_start(); // CONTENTBUILDER jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); if (JFile::exists(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php')) { require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php'; $cbForm = contentbuilder::getForm('com_breezingforms', $formId); $db = JFactory::getDBO(); $db->setQuery("Select id From #__contentbuilder_forms Where `type` = 'com_breezingforms' And `reference_id` = " . intval($formId)); jimport('joomla.version'); $version = new JVersion(); if (version_compare($version->getShortVersion(), '3.0', '>=')) { $cbForms = $db->loadColumn(); } else { $cbForms = $db->loadResultArray();
/** * Sets the opening SVG element handler function for the XML parser. (*** TO BE COMPLETED ***) * @param $parser (resource) The first parameter, parser, is a reference to the XML parser calling the handler. * @param $name (string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters. * @param $attribs (array) The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on. * @param $ctm (array) tranformation matrix for clipping mode (starting transformation matrix). * @author Nicola Asuni * @since 5.0.000 (2010-05-02) * @protected */ protected function startSVGElementHandler($parser, $name, $attribs, $ctm = array()) { // check if we are in clip mode if ($this->svgclipmode) { $this->svgclippaths[$this->svgclipid][] = array('name' => $name, 'attribs' => $attribs, 'tm' => $this->svgcliptm[$this->svgclipid]); return; } if ($this->svgdefsmode and !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) { if (isset($attribs['id'])) { $attribs['child_elements'] = array(); $this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs); return; } if (end($this->svgdefs) !== FALSE) { $last_svgdefs_id = key($this->svgdefs); if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) { $attribs['id'] = 'DF_' . (count($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements']) + 1); $this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$attribs['id']] = array('name' => $name, 'attribs' => $attribs); return; } } return; } $clipping = false; if ($parser == 'clip-path') { // set clipping mode $clipping = true; } // get styling properties $prev_svgstyle = $this->svgstyles[max(0, count($this->svgstyles) - 1)]; // previous style $svgstyle = $this->svgstyles[0]; // set default style if ($clipping and !isset($attribs['fill']) and (!isset($attribs['style']) or !preg_match('/[;\\"\\s]{1}fill[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval))) { // default fill attribute for clipping $attribs['fill'] = 'none'; } if (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style']) and $attribs['style'][0] != ';') { // fix style for regular expression $attribs['style'] = ';' . $attribs['style']; } foreach ($prev_svgstyle as $key => $val) { if (in_array($key, TCPDF_IMAGES::$svginheritprop)) { // inherit previous value $svgstyle[$key] = $val; } if (isset($attribs[$key]) and !TCPDF_STATIC::empty_string($attribs[$key])) { // specific attribute settings if ($attribs[$key] == 'inherit') { $svgstyle[$key] = $val; } else { $svgstyle[$key] = $attribs[$key]; } } elseif (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style'])) { // CSS style syntax $attrval = array(); if (preg_match('/[;\\"\\s]{1}' . $key . '[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval) and isset($attrval[1])) { if ($attrval[1] == 'inherit') { $svgstyle[$key] = $val; } else { $svgstyle[$key] = $attrval[1]; } } } } // transformation matrix if (!empty($ctm)) { $tm = $ctm; } else { $tm = array(1, 0, 0, 1, 0, 0); } if (isset($attribs['transform']) and !empty($attribs['transform'])) { $tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, TCPDF_STATIC::getSVGTransformMatrix($attribs['transform'])); } $svgstyle['transfmatrix'] = $tm; $invisible = false; if ($svgstyle['visibility'] == 'hidden' or $svgstyle['visibility'] == 'collapse' or $svgstyle['display'] == 'none') { // the current graphics element is invisible (nothing is painted) $invisible = true; } // process tag switch ($name) { case 'defs': $this->svgdefsmode = true; break; // clipPath // clipPath case 'clipPath': if ($invisible) { break; } $this->svgclipmode = true; if (!isset($attribs['id'])) { $attribs['id'] = 'CP_' . (count($this->svgcliptm) + 1); } $this->svgclipid = $attribs['id']; $this->svgclippaths[$this->svgclipid] = array(); $this->svgcliptm[$this->svgclipid] = $tm; break; case 'svg': // start of SVG object break; case 'g': // group together related graphics elements array_push($this->svgstyles, $svgstyle); $this->StartTransform(); $x = isset($attribs['x']) ? $attribs['x'] : 0; $y = isset($attribs['y']) ? $attribs['y'] : 0; $w = isset($attribs['width']) ? $attribs['width'] : 1; $h = isset($attribs['height']) ? $attribs['height'] : 1; $tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, array($w, 0, 0, $h, $x, $y)); $this->SVGTransform($tm); $this->setSVGStyles($svgstyle, $prev_svgstyle); break; case 'linearGradient': if ($this->pdfa_mode) { break; } if (!isset($attribs['id'])) { $attribs['id'] = 'GR_' . (count($this->svggradients) + 1); } $this->svggradientid = $attribs['id']; $this->svggradients[$this->svggradientid] = array(); $this->svggradients[$this->svggradientid]['type'] = 2; $this->svggradients[$this->svggradientid]['stops'] = array(); if (isset($attribs['gradientUnits'])) { $this->svggradients[$this->svggradientid]['gradientUnits'] = $attribs['gradientUnits']; } else { $this->svggradients[$this->svggradientid]['gradientUnits'] = 'objectBoundingBox'; } //$attribs['spreadMethod'] if (!isset($attribs['x1']) and !isset($attribs['y1']) and !isset($attribs['x2']) and !isset($attribs['y2']) or (isset($attribs['x1']) and substr($attribs['x1'], -1) == '%' or isset($attribs['y1']) and substr($attribs['y1'], -1) == '%' or isset($attribs['x2']) and substr($attribs['x2'], -1) == '%' or isset($attribs['y2']) and substr($attribs['y2'], -1) == '%')) { $this->svggradients[$this->svggradientid]['mode'] = 'percentage'; } else { $this->svggradients[$this->svggradientid]['mode'] = 'measure'; } $x1 = isset($attribs['x1']) ? $attribs['x1'] : '0'; $y1 = isset($attribs['y1']) ? $attribs['y1'] : '0'; $x2 = isset($attribs['x2']) ? $attribs['x2'] : '100'; $y2 = isset($attribs['y2']) ? $attribs['y2'] : '0'; if (isset($attribs['gradientTransform'])) { $this->svggradients[$this->svggradientid]['gradientTransform'] = TCPDF_STATIC::getSVGTransformMatrix($attribs['gradientTransform']); } $this->svggradients[$this->svggradientid]['coords'] = array($x1, $y1, $x2, $y2); if (isset($attribs['xlink:href']) and !empty($attribs['xlink:href'])) { // gradient is defined on another place $this->svggradients[$this->svggradientid]['xref'] = substr($attribs['xlink:href'], 1); } break; case 'radialGradient': if ($this->pdfa_mode) { break; } if (!isset($attribs['id'])) { $attribs['id'] = 'GR_' . (count($this->svggradients) + 1); } $this->svggradientid = $attribs['id']; $this->svggradients[$this->svggradientid] = array(); $this->svggradients[$this->svggradientid]['type'] = 3; $this->svggradients[$this->svggradientid]['stops'] = array(); if (isset($attribs['gradientUnits'])) { $this->svggradients[$this->svggradientid]['gradientUnits'] = $attribs['gradientUnits']; } else { $this->svggradients[$this->svggradientid]['gradientUnits'] = 'objectBoundingBox'; } //$attribs['spreadMethod'] if (!isset($attribs['cx']) and !isset($attribs['cy']) or (isset($attribs['cx']) and substr($attribs['cx'], -1) == '%' or isset($attribs['cy']) and substr($attribs['cy'], -1) == '%')) { $this->svggradients[$this->svggradientid]['mode'] = 'percentage'; } else { $this->svggradients[$this->svggradientid]['mode'] = 'measure'; } $cx = isset($attribs['cx']) ? $attribs['cx'] : 0.5; $cy = isset($attribs['cy']) ? $attribs['cy'] : 0.5; $fx = isset($attribs['fx']) ? $attribs['fx'] : $cx; $fy = isset($attribs['fy']) ? $attribs['fy'] : $cy; $r = isset($attribs['r']) ? $attribs['r'] : 0.5; if (isset($attribs['gradientTransform'])) { $this->svggradients[$this->svggradientid]['gradientTransform'] = TCPDF_STATIC::getSVGTransformMatrix($attribs['gradientTransform']); } $this->svggradients[$this->svggradientid]['coords'] = array($cx, $cy, $fx, $fy, $r); if (isset($attribs['xlink:href']) and !empty($attribs['xlink:href'])) { // gradient is defined on another place $this->svggradients[$this->svggradientid]['xref'] = substr($attribs['xlink:href'], 1); } break; case 'stop': // gradient stops if (substr($attribs['offset'], -1) == '%') { $offset = floatval(substr($attribs['offset'], -1)) / 100; } else { $offset = floatval($attribs['offset']); if ($offset > 1) { $offset /= 100; } } $stop_color = isset($svgstyle['stop-color']) ? TCPDF_COLORS::convertHTMLColorToDec($svgstyle['stop-color'], $this->spot_colors) : 'black'; $opacity = isset($svgstyle['stop-opacity']) ? $svgstyle['stop-opacity'] : 1; $this->svggradients[$this->svggradientid]['stops'][] = array('offset' => $offset, 'color' => $stop_color, 'opacity' => $opacity); break; // paths // paths case 'path': if ($invisible) { break; } if (isset($attribs['d'])) { $d = trim($attribs['d']); if (!empty($d)) { $x = isset($attribs['x']) ? $attribs['x'] : 0; $y = isset($attribs['y']) ? $attribs['y'] : 0; $w = isset($attribs['width']) ? $attribs['width'] : 1; $h = isset($attribs['height']) ? $attribs['height'] : 1; $tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, array($w, 0, 0, $h, $x, $y)); if ($clipping) { $this->SVGTransform($tm); $this->SVGPath($d, 'CNZ'); } else { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'SVGPath', array($d, 'CNZ')); if (!empty($obstyle)) { $this->SVGPath($d, $obstyle); } $this->StopTransform(); } } } break; // shapes // shapes case 'rect': if ($invisible) { break; } $x = isset($attribs['x']) ? $this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false) : 0; $y = isset($attribs['y']) ? $this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false) : 0; $w = isset($attribs['width']) ? $this->getHTMLUnitToUnits($attribs['width'], 0, $this->svgunit, false) : 0; $h = isset($attribs['height']) ? $this->getHTMLUnitToUnits($attribs['height'], 0, $this->svgunit, false) : 0; $rx = isset($attribs['rx']) ? $this->getHTMLUnitToUnits($attribs['rx'], 0, $this->svgunit, false) : 0; $ry = isset($attribs['ry']) ? $this->getHTMLUnitToUnits($attribs['ry'], 0, $this->svgunit, false) : $rx; if ($clipping) { $this->SVGTransform($tm); $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry, '1111', 'CNZ', array(), array()); } else { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'RoundedRectXY', array($x, $y, $w, $h, $rx, $ry, '1111', 'CNZ')); if (!empty($obstyle)) { $this->RoundedRectXY($x, $y, $w, $h, $rx, $ry, '1111', $obstyle, array(), array()); } $this->StopTransform(); } break; case 'circle': if ($invisible) { break; } $r = isset($attribs['r']) ? $this->getHTMLUnitToUnits($attribs['r'], 0, $this->svgunit, false) : 0; $cx = isset($attribs['cx']) ? $this->getHTMLUnitToUnits($attribs['cx'], 0, $this->svgunit, false) : (isset($attribs['x']) ? $this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false) : 0); $cy = isset($attribs['cy']) ? $this->getHTMLUnitToUnits($attribs['cy'], 0, $this->svgunit, false) : (isset($attribs['y']) ? $this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false) : 0); $x = $cx - $r; $y = $cy - $r; $w = 2 * $r; $h = $w; if ($clipping) { $this->SVGTransform($tm); $this->Circle($cx, $cy, $r, 0, 360, 'CNZ', array(), array(), 8); } else { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'Circle', array($cx, $cy, $r, 0, 360, 'CNZ')); if (!empty($obstyle)) { $this->Circle($cx, $cy, $r, 0, 360, $obstyle, array(), array(), 8); } $this->StopTransform(); } break; case 'ellipse': if ($invisible) { break; } $rx = isset($attribs['rx']) ? $this->getHTMLUnitToUnits($attribs['rx'], 0, $this->svgunit, false) : 0; $ry = isset($attribs['ry']) ? $this->getHTMLUnitToUnits($attribs['ry'], 0, $this->svgunit, false) : 0; $cx = isset($attribs['cx']) ? $this->getHTMLUnitToUnits($attribs['cx'], 0, $this->svgunit, false) : (isset($attribs['x']) ? $this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false) : 0); $cy = isset($attribs['cy']) ? $this->getHTMLUnitToUnits($attribs['cy'], 0, $this->svgunit, false) : (isset($attribs['y']) ? $this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false) : 0); $x = $cx - $rx; $y = $cy - $ry; $w = 2 * $rx; $h = 2 * $ry; if ($clipping) { $this->SVGTransform($tm); $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, 'CNZ', array(), array(), 8); } else { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'Ellipse', array($cx, $cy, $rx, $ry, 0, 0, 360, 'CNZ')); if (!empty($obstyle)) { $this->Ellipse($cx, $cy, $rx, $ry, 0, 0, 360, $obstyle, array(), array(), 8); } $this->StopTransform(); } break; case 'line': if ($invisible) { break; } $x1 = isset($attribs['x1']) ? $this->getHTMLUnitToUnits($attribs['x1'], 0, $this->svgunit, false) : 0; $y1 = isset($attribs['y1']) ? $this->getHTMLUnitToUnits($attribs['y1'], 0, $this->svgunit, false) : 0; $x2 = isset($attribs['x2']) ? $this->getHTMLUnitToUnits($attribs['x2'], 0, $this->svgunit, false) : 0; $y2 = isset($attribs['y2']) ? $this->getHTMLUnitToUnits($attribs['y2'], 0, $this->svgunit, false) : 0; $x = $x1; $y = $y1; $w = abs($x2 - $x1); $h = abs($y2 - $y1); if (!$clipping) { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'Line', array($x1, $y1, $x2, $y2)); $this->Line($x1, $y1, $x2, $y2); $this->StopTransform(); } break; case 'polyline': case 'polygon': if ($invisible) { break; } $points = isset($attribs['points']) ? $attribs['points'] : '0 0'; $points = trim($points); // note that point may use a complex syntax not covered here $points = preg_split('/[\\,\\s]+/si', $points); if (count($points) < 4) { break; } $p = array(); $xmin = 2147483647; $xmax = 0; $ymin = 2147483647; $ymax = 0; foreach ($points as $key => $val) { $p[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit, false); if ($key % 2 == 0) { // X coordinate $xmin = min($xmin, $p[$key]); $xmax = max($xmax, $p[$key]); } else { // Y coordinate $ymin = min($ymin, $p[$key]); $ymax = max($ymax, $p[$key]); } } $x = $xmin; $y = $ymin; $w = $xmax - $xmin; $h = $ymax - $ymin; if ($name == 'polyline') { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'PolyLine', array($p, 'CNZ')); if (!empty($obstyle)) { $this->PolyLine($p, $obstyle, array(), array()); } $this->StopTransform(); } else { // polygon if ($clipping) { $this->SVGTransform($tm); $this->Polygon($p, 'CNZ', array(), array(), true); } else { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h, 'Polygon', array($p, 'CNZ')); if (!empty($obstyle)) { $this->Polygon($p, $obstyle, array(), array(), true); } $this->StopTransform(); } } break; // image // image case 'image': if ($invisible) { break; } if (!isset($attribs['xlink:href']) or empty($attribs['xlink:href'])) { break; } $x = isset($attribs['x']) ? $this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false) : 0; $y = isset($attribs['y']) ? $this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false) : 0; $w = isset($attribs['width']) ? $this->getHTMLUnitToUnits($attribs['width'], 0, $this->svgunit, false) : 0; $h = isset($attribs['height']) ? $this->getHTMLUnitToUnits($attribs['height'], 0, $this->svgunit, false) : 0; $img = $attribs['xlink:href']; if (!$clipping) { $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h); $base = 'base'; $sixty_four = '64'; if (preg_match('/^data:image\\/[^;]+;' . $base . $sixty_four . ',/', $img, $m) > 0) { // embedded image encoded as b64 $img = '@' . bf_b64dec(substr($img, strlen($m[0]))); } else { // fix image path if (!TCPDF_STATIC::empty_string($this->svgdir) and ($img[0] == '.' or basename($img) == $img)) { // replace relative path with full server path $img = $this->svgdir . '/' . $img; } if ($img[0] == '/' and !empty($_SERVER['DOCUMENT_ROOT']) and $_SERVER['DOCUMENT_ROOT'] != '/') { $findroot = strpos($img, $_SERVER['DOCUMENT_ROOT']); if ($findroot === false or $findroot > 1) { if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') { $img = substr($_SERVER['DOCUMENT_ROOT'], 0, -1) . $img; } else { $img = $_SERVER['DOCUMENT_ROOT'] . $img; } } } $img = urldecode($img); $testscrtype = @parse_url($img); if (!isset($testscrtype['query']) or empty($testscrtype['query'])) { // convert URL to server path $img = str_replace(K_PATH_URL, K_PATH_MAIN, $img); } } // get image type $imgtype = TCPDF_IMAGES::getImageFileType($img); if ($imgtype == 'eps' or $imgtype == 'ai') { $this->ImageEps($img, $x, $y, $w, $h); } elseif ($imgtype == 'svg') { $this->ImageSVG($img, $x, $y, $w, $h); } else { $this->Image($img, $x, $y, $w, $h); } $this->StopTransform(); } break; // text // text case 'text': case 'tspan': // only basic support - advanced features must be implemented $this->svgtextmode['invisible'] = $invisible; if ($invisible) { break; } array_push($this->svgstyles, $svgstyle); if (isset($attribs['x'])) { $x = $this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false); } elseif ($name == 'tspan') { $x = $this->x; } else { $x = 0; } if (isset($attribs['dx'])) { $x += $this->getHTMLUnitToUnits($attribs['dx'], 0, $this->svgunit, false); } if (isset($attribs['y'])) { $y = $this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false); } elseif ($name == 'tspan') { $y = $this->y; } else { $y = 0; } if (isset($attribs['dy'])) { $y += $this->getHTMLUnitToUnits($attribs['dy'], 0, $this->svgunit, false); } $svgstyle['text-color'] = $svgstyle['fill']; $this->svgtext = ''; if (isset($svgstyle['text-anchor'])) { $this->svgtextmode['text-anchor'] = $svgstyle['text-anchor']; } else { $this->svgtextmode['text-anchor'] = 'start'; } if (isset($svgstyle['direction'])) { if ($svgstyle['direction'] == 'rtl') { $this->svgtextmode['rtl'] = true; } else { $this->svgtextmode['rtl'] = false; } } else { $this->svgtextmode['rtl'] = false; } if (isset($svgstyle['stroke']) and $svgstyle['stroke'] != 'none' and isset($svgstyle['stroke-width']) and $svgstyle['stroke-width'] > 0) { $this->svgtextmode['stroke'] = $this->getHTMLUnitToUnits($svgstyle['stroke-width'], 0, $this->svgunit, false); } else { $this->svgtextmode['stroke'] = false; } $this->StartTransform(); $this->SVGTransform($tm); $obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, 1, 1); $this->x = $x; $this->y = $y; break; // use // use case 'use': if (isset($attribs['xlink:href']) and !empty($attribs['xlink:href'])) { $svgdefid = substr($attribs['xlink:href'], 1); if (isset($this->svgdefs[$svgdefid])) { $use = $this->svgdefs[$svgdefid]; if (isset($attribs['xlink:href'])) { unset($attribs['xlink:href']); } if (isset($attribs['id'])) { unset($attribs['id']); } if (isset($use['attribs']['x']) and isset($attribs['x'])) { $attribs['x'] += $use['attribs']['x']; } if (isset($use['attribs']['y']) and isset($attribs['y'])) { $attribs['y'] += $use['attribs']['y']; } if (empty($attribs['style'])) { $attribs['style'] = ''; } if (!empty($use['attribs']['style'])) { // merge styles $attribs['style'] = str_replace(';;', ';', ';' . $use['attribs']['style'] . $attribs['style']); } $attribs = array_merge($use['attribs'], $attribs); $this->startSVGElementHandler('use-tag', $use['name'], $attribs); return; } } break; default: break; } // end of switch // process child elements if (!empty($attribs['child_elements'])) { $child_elements = $attribs['child_elements']; unset($attribs['child_elements']); foreach ($child_elements as $child_element) { if (empty($child_element['attribs']['closing_tag'])) { $this->startSVGElementHandler('child-tag', $child_element['name'], $child_element['attribs']); } else { if (isset($child_element['attribs']['content'])) { $this->svgtext = $child_element['attribs']['content']; } $this->endSVGElementHandler('child-tag', $child_element['name']); } } } }