/administrator/components/com_breezingforms/libraries/crosstec/classes/BFQuickModeMobile.php
PHP | 1423 lines | 1257 code | 125 blank | 41 comment | 132 complexity | 3da243cb44609d935fa8a403aeeff236 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT, LGPL-3.0, LGPL-2.0, JSON
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * BreezingForms - A Joomla Forms Application
- * @version 1.8
- * @package BreezingForms
- * @copyright (C) 2008-2012 by Markus Bopp
- * @license Released under the terms of the GNU General Public License
- **/
- defined('_JEXEC') or die('Direct Access to this location is not allowed.');
- 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');
- class BFQuickModeMobile{
-
- /**
- * @var HTML_facileFormsProcessor
- */
- private $p = null;
-
- private $dataObject = array();
-
- private $rootMdata = array();
-
- private $useErrorAlerts = false;
- private $useDefaultErrors = false;
- private $useBalloonErrors = false;
-
- private $rollover = false;
-
- private $rolloverColor = '';
-
- private $toggleFields = '';
-
- private $cancelImagePath = '';
-
- private $uploadImagePath = '';
-
- public $forceMobileUrl = '';
-
- function __construct( HTML_facileFormsProcessor $p ){
- $head = JFactory::getDocument()->getHeadData();
- $head['styleSheets'] = array();
- $head['style'] = array();
- $head['scripts'] = array();
- $head['script'] = array();
- $head['custom'] = array();
- JFactory::getDocument()->setHeadData( $head );
- // will make sure mootools loads first, important 4 jquery
- JHtml::_('behavior.framework');
- jimport('joomla.version');
- $version = new JVersion();
- if(version_compare($version->getShortVersion(), '3.0', '<')){
- JHTML::_('behavior.mootools');
- }
-
- $this->p = $p;
- $this->dataObject = Zend_Json::decode( base64_decode($this->p->formrow->template_code) );
- $this->rootMdata = $this->dataObject['properties'];
- $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'] : '[]' );
- // loading theme
- $this->cancelImagePath = JURI::root(true) . '/media/breezingforms/themes/cancel.png';
- $this->uploadImagePath = JURI::root(true) . '/media/breezingforms/themes/upload.png';
-
- }
-
- public function fetchHead($head)
- {
- $app = JFactory::getApplication();
-
- // Get line endings
- $lnEnd = JFactory::getDocument()->_getLineEnd();
- $tab = JFactory::getDocument()->_getTab();
- $tagEnd = ' />';
- $buffer = '';
- // Generate stylesheet links
- foreach ($head['styleSheets'] as $strSrc => $strAttr)
- {
- $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '" type="' . $strAttr['mime'] . '"';
- if (!is_null($strAttr['media']))
- {
- $buffer .= ' media="' . $strAttr['media'] . '" ';
- }
- if ($temp = JArrayHelper::toString($strAttr['attribs']))
- {
- $buffer .= ' ' . $temp;
- }
- $buffer .= $tagEnd . $lnEnd;
- }
- // Generate stylesheet declarations
- foreach ($head['style'] as $type => $content)
- {
- $buffer .= $tab . '<style type="' . $type . '">' . $lnEnd;
- // This is for full XHTML support.
- if (isset($document) && $document->_mime != 'text/html')
- {
- $buffer .= $tab . $tab . $lnEnd;
- }
- $buffer .= $content . $lnEnd;
- // See above note
- if (isset($document) && $document->_mime != 'text/html')
- {
- $buffer .= $tab . $tab . $lnEnd;
- }
- $buffer .= $tab . '</style>' . $lnEnd;
- }
- // Generate script file links
- foreach ($head['scripts'] as $strSrc => $strAttr)
- {
- $buffer .= $tab . '<script src="' . $strSrc . '"';
- if (isset($strAttr['mime']) && !is_null($strAttr['mime']))
- {
- $buffer .= ' type="' . ( $strAttr['mime'] == 't' ? 'text/javascript' : $strAttr['mime'] ) . '"';
- }
- $buffer .= '></script>' . $lnEnd;
- }
- // Generate script declarations
- foreach ($head['script'] as $type => $content)
- {
- $buffer .= $tab . '<script type="' . $type . '">' . $lnEnd;
- // This is for full XHTML support.
- if (isset($document) && $document->_mime != 'text/html')
- {
- $buffer .= $tab . $tab . $lnEnd;
- }
- $buffer .= $content . $lnEnd;
- // See above note
- if (isset($document) && $document->_mime != 'text/html')
- {
- $buffer .= $tab . $tab . $lnEnd;
- }
- $buffer .= $tab . '</script>' . $lnEnd;
- }
- foreach ($head['custom'] as $custom)
- {
- $buffer .= $tab . $custom . $lnEnd;
- }
- return $buffer;
- }
-
- public function process(&$dataObject, $parent = null, $parentPage = null, $index = 0, $childrenLength = 0){
- if(isset($dataObject['attributes']) && isset($dataObject['properties']) ){
-
- $options = array('type' => 'normal', 'displayType' => 'breaks');
- if($parent != null && $parent['type'] == 'section'){
- $options['type'] = $parent['bfType'];
- $options['displayType'] = $parent['displayType'];
- }
-
- $class = ' class="bfBlock"';
- $wrapper = 'bfWrapperBlock';
- if($options['displayType'] == 'inline'){
- $class = ' class="bfInline"';
- $wrapper = 'bfWrapperInline';
- }
-
- $mdata = $dataObject['properties'];
-
- if($mdata['type'] == 'page'){
-
- $parentPage = $mdata;
- if($parentPage['pageNumber'] > 1){
- echo '</div><!-- bfPage end -->'."\n"; // closing previous pages
- }
-
- echo '<div id="bfPage'.$parentPage['pageNumber'].'" class="bfPage" style="display:none">'."\n"; // opening current page
-
- if(trim($mdata['pageIntro'])!=''){
-
- echo '<div class="bfPageIntro">'."\n";
-
- $regex = '/{loadposition\s+(.*?)}/i';
- $introtext = $mdata['pageIntro'];
-
- preg_match_all($regex, $introtext, $matches, PREG_SET_ORDER);
-
- jimport('joomla.version');
- $version = new JVersion();
-
- if ($matches && version_compare($version->getShortVersion(), '1.6', '>=')) {
-
- $document = JFactory::getDocument();
- $renderer = $document->loadRenderer('modules');
- $options = array('style' => 'xhtml');
-
- foreach ($matches as $match) {
-
- $matcheslist = explode(',', $match[1]);
- $position = trim($matcheslist[0]);
- $output = $renderer->render($position, $options, null);
- $introtext = preg_replace("|$match[0]|", addcslashes($output, '\\'), $introtext, 1);
- }
- }
-
- echo $introtext."\n";
-
- echo '</div><div style="padding-bottom: 10px;"></div>'."\n";
- }
-
- if(!$this->useErrorAlerts){
- echo '<span class="bfErrorMessage" style="color: red; display:none;"></span>'."\n";
- }
-
- } else if($mdata['type'] == 'section'){
- if(isset($dataObject['properties']['name']) && isset($mdata['off']) && $mdata['off']){
- echo '<script type="text/javascript"><!--'."\n".'bfDeactivateSection.push("'.$dataObject['properties']['name'].'");'."\n".'//--></script>'."\n";
- }
-
- if($mdata['bfType'] == 'section'){
- echo '<div data-theme="b" data-role="collapsible-set"'.(isset($mdata['off']) && $mdata['off'] ? ' style="display:none" ' : '').(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != "" ? ' id="'.$dataObject['properties']['name'].'"' : '').'><div data-role="collapsible" data-collapsed="false">'."\n";
- if(trim($mdata['title']) != ''){
- echo '<h3>'.htmlentities(trim($mdata['title']), ENT_QUOTES, 'UTF-8').'</h3>'."\n";
- }
- }
- else if( $mdata['bfType'] == 'normal' ) {
- if(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != ''){
- echo '<div '.(isset($mdata['off']) && $mdata['off'] ? 'style="display:none" ' : '').'class="bfNoSection"'.(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != "" ? ' id="'.$dataObject['properties']['name'].'"' : '').'>'."\n";
- }
- }
-
- if(trim($mdata['description'])!=''){
- echo '<div>'."\n";
-
- $regex = '/{loadposition\s+(.*?)}/i';
- $introtext = $mdata['description'];
-
- preg_match_all($regex, $introtext, $matches, PREG_SET_ORDER);
-
- jimport('joomla.version');
- $version = new JVersion();
-
- if ($matches && version_compare($version->getShortVersion(), '1.6', '>=')) {
-
- $document = JFactory::getDocument();
- $renderer = $document->loadRenderer('modules');
- $options = array('style' => 'xhtml');
-
- foreach ($matches as $match) {
-
- $matcheslist = explode(',', $match[1]);
- $position = trim($matcheslist[0]);
- $output = $renderer->render($position, $options, null);
- $introtext = preg_replace("|$match[0]|", addcslashes($output, '\\'), $introtext, 1);
- }
- }
-
- echo $introtext."\n";
- echo '</div><div style="padding-bottom: 10px;"></div>'."\n";
- }
-
- } else if($mdata['type'] == 'element'){
-
- // if labels left
- if( true ) {
- echo '<div class="bfElemWrap" data-role="fieldcontain">';
- }
-
- $onclick = '';
- if($mdata['actionClick'] == 1){
- $onclick = 'onclick="'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
- }
-
- $onblur = '';
- if($mdata['actionBlur'] == 1){
- $onblur = 'onblur="'.$mdata['actionFunctionName'] . '(this,\'blur\');" ';
- }
-
- $onchange = '';
- if($mdata['actionChange'] == 1){
- $onchange = 'onchange="'.$mdata['actionFunctionName'] . '(this,\'change\');" ';
- }
-
- $onfocus = '';
- if($mdata['actionFocus'] == 1){
- $onfocus = 'onfocus="'.$mdata['actionFunctionName'] . '(this,\'focus\');" ';
- }
-
- $onselect = '';
- if(isset($mdata['actionSelect']) && $mdata['actionSelect'] == 1){
- $onselect = 'onselect="'.$mdata['actionFunctionName'] . '(this,\'select\');" ';
- }
-
- $legend = '';
-
- if(!$mdata['hideLabel'] && $mdata['bfType'] != 'bfPayPal' && $mdata['bfType'] != 'bfSofortueberweisung'){
-
- $maxlengthCounter = '';
- if($mdata['bfType'] == 'bfTextarea' && isset($mdata['maxlength']) && $mdata['maxlength'] > 0 && isset($mdata['showMaxlengthCounter']) && $mdata['showMaxlengthCounter']){
- $maxlengthCounter = ' <span class=***bfMaxLengthCounter*** id=***bfMaxLengthCounter'.$mdata['dbId'].'***>('.$mdata['maxlength'].' '.BFText::_('COM_BREEZINGFORMS_CHARS_LEFT').')</span>';
- }
- $for = 'for="ff_elem'.$mdata['dbId'].'"';
- if($mdata['bfType'] == 'bfCaptcha' || $mdata['bfType'] == 'bfReCaptcha'){
- $for = 'for="bfCaptchaEntry"';
- if(JFactory::getApplication()->isSite())
- {
- $captcha_url = JURI::root(true).'/components/com_breezingforms/images/captcha/securimage_show.php';
- }
- else
- {
- $captcha_url = JURI::root(true).'/administrator/components/com_breezingforms/images/captcha/securimage_show.php';
- }
- echo '<div align="center"><img alt="" border="0" width="230" id="ff_capimgValue" class="ff_capimg" src="'.$captcha_url.'"/></div><br/>'."\n";
- }
- //else if($mdata['bfType'] == 'bfReCaptcha'){
- // $for = 'for="recaptcha_response_field"';
- //}
- $req = '';
- if($mdata['required']){
- $req = '<span class="bfRequired"> *</span>'."\n";
- }
-
- $labelText = $req . trim($mdata['label']) . str_replace("***","\"",$maxlengthCounter);
-
- if( true && ( $mdata['bfType'] == 'bfCheckboxGroup' || $mdata['bfType'] == 'bfRadioGroup' ) ){
- $legend = '<legend id="bfLabel'.$mdata['dbId'].'">'.str_replace("***","\"",$labelText).'</legend>'."\n";
- } else if( $mdata['bfType'] == 'bfSummarize' ){
- $legend = $labelText;
- }else {
- echo '<label id="bfLabel'.$mdata['dbId'].'" '.$for.'>'.str_replace("***","\"",$labelText).'</label>'."\n";
- }
- }
-
- $readonly = '';
- if($mdata['readonly']){
- $readonly = 'readonly="readonly" ';
- }
-
- $tabIndex = '';
- if($mdata['tabIndex'] != -1 && is_numeric($mdata['tabIndex'])){
- $tabIndex = 'tabindex="'.intval($mdata['tabIndex']).'" ';
- }
-
- for($i = 0; $i < $this->p->rowcount; $i++) {
- $row = $this->p->rows[$i];
- if($mdata['bfName'] == $row->name){
- if( ( isset($mdata['value']) || isset($mdata['list']) || isset($mdata['group']))
- &&
- (
- $mdata['bfType'] == 'bfTextfield' ||
- $mdata['bfType'] == 'bfTextarea' ||
- $mdata['bfType'] == 'bfCheckbox' ||
- $mdata['bfType'] == 'bfCheckboxGroup' ||
- $mdata['bfType'] == 'bfSubmitButton' ||
- $mdata['bfType'] == 'bfHidden' ||
- $mdata['bfType'] == 'bfCalendar' ||
- $mdata['bfType'] == 'bfSelect' ||
- $mdata['bfType'] == 'bfRadioGroup'
- )
- ){
- if($mdata['bfType'] == 'bfSelect')
- {
- $mdata['list'] = $this->p->replaceCode($row->data2, "data2 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
- }
- else if($mdata['bfType'] == 'bfCheckboxGroup' || $mdata['bfType'] == 'bfRadioGroup')
- {
- $mdata['group'] = $this->p->replaceCode($row->data2, "data2 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
- }
- else
- {
- $mdata['value'] = $this->p->replaceCode($row->data1, "data1 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
- }
- }
- if(isset($mdata['checked']) && $mdata['bfType'] == 'bfCheckbox'){
- $mdata['checked'] = $row->flag1 == 1 ? true : false;
- }
- break;
- }
- }
-
- switch($mdata['bfType']){
-
- case 'bfTextfield':
- $type = 'text';
-
- if($mdata['password']){
- $type = 'password';
- }
- $maxlength = '';
- if(is_numeric($mdata['maxLength'])){
- $maxlength = 'maxlength="'.intval($mdata['maxLength']).'" ';
- }
-
- echo '<input class="ff_elem" '.$tabIndex.$maxlength.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="'.$type.'" name="ff_nm_'.$mdata['bfName'].'[]" value="'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'" id="ff_elem'.$mdata['dbId'].'"/>'."\n";
- if($mdata['mailbackAsSender']){
- echo '<input type="hidden" name="mailbackSender['.$mdata['bfName'].']" value="true"/>'."\n";
- }
- break;
-
- case 'bfTextarea':
-
- $onkeyup = '';
- if(isset($mdata['maxlength']) && $mdata['maxlength'] > 0){
- $onkeyup = 'onkeyup="bfCheckMaxlength('.intval($mdata['dbId']).', '.intval($mdata['maxlength']).', '.(isset($mdata['showMaxlengthCounter']) && $mdata['showMaxlengthCounter'] ? 'true' : 'false').')" ';
- }
- echo '<textarea cols="20" rows="5" class="ff_elem" '.$onkeyup.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'">'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'</textarea>'."\n";
- break;
-
- case 'bfRadioGroup':
-
- if($mdata['group'] != ''){
-
- $mdata['group'] = str_replace("\r", '', $mdata['group']);
- $gEx = explode("\n", $mdata['group']);
- $lines = count($gEx);
-
- $wrapOpen = '<div data-role="fieldcontain">'."\n".'<fieldset '.($lines <= 3 ? 'data-type="horizontal" ' : '').'data-role="controlgroup">'.$legend."\n";
- $wrapClose = '</fieldset>'."\n".'</div>'."\n";
-
- echo $wrapOpen;
- for($i = 0; $i < $lines; $i++){
- $idExt = $i != 0 ? '_'.$i : '';
- $iEx = explode(";", $gEx[$i]);
- $iCnt = count($iEx);
- if($iCnt == 3){
- $lblRight = '<label class="bfGroupLabel" id="bfGroupLabel'.$mdata['dbId'].$idExt.'" for="ff_elem'.$mdata['dbId'].$idExt.'">'.htmlentities(trim($iEx[1]), ENT_QUOTES, 'UTF-8').'</label>';
- echo '<input '.($iEx[0] == 1 ? 'checked="checked" ' : '').' class="ff_elem" '.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="radio" name="ff_nm_'.$mdata['bfName'].'[]" value="'.htmlentities(trim($iEx[2]), ENT_QUOTES, 'UTF-8').'" id="ff_elem'.$mdata['dbId'].$idExt.'"/>'.$lblRight."\n";
- }
- }
- echo $wrapClose;
- }
-
- break;
-
- case 'bfCheckboxGroup':
-
- if($mdata['group'] != ''){
-
- $mdata['group'] = str_replace("\r", '', $mdata['group']);
- $gEx = explode("\n", $mdata['group']);
- $lines = count($gEx);
-
- $wrapOpen = '<div data-role="fieldcontain">'."\n".'<fieldset data-role="controlgroup">'.$legend."\n";
- $wrapClose = '</fieldset>'."\n".'</div>'."\n";
-
- echo $wrapOpen;
- for($i = 0; $i < $lines; $i++){
- $idExt = $i != 0 ? '_'.$i : '';
- $iEx = explode(";", $gEx[$i]);
- $iCnt = count($iEx);
- if($iCnt == 3){
- $lbl = '<label class="bfGroupLabel" id="bfGroupLabel'.$mdata['dbId'].$idExt.'" for="ff_elem'.$mdata['dbId'].$idExt.'">'.htmlentities(trim($iEx[1]), ENT_QUOTES, 'UTF-8').'</label>';
- echo '<input '.($iEx[0] == 1 ? 'checked="checked" ' : '').' class="ff_elem" '.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="checkbox" name="ff_nm_'.$mdata['bfName'].'[]" value="'.htmlentities(trim($iEx[2]), ENT_QUOTES, 'UTF-8').'" id="ff_elem'.$mdata['dbId'].$idExt.'"/>'.$lbl."\n";
- }
- }
- echo $wrapClose;
-
- }
-
- break;
-
- case 'bfCheckbox':
-
- echo '<input class="ff_elem" '.($mdata['checked'] ? 'checked="checked" ' : '').$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="checkbox" name="ff_nm_'.$mdata['bfName'].'[]" value="'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'" id="ff_elem'.$mdata['dbId'].'"/>'."\n";
- if($mdata['mailbackAccept']){
- echo '<input type="hidden" class="ff_elem" name="mailbackConnectWith['.$mdata['mailbackConnectWith'].']" value="true_'.$mdata['bfName'].'"/>'."\n";
- }
- break;
-
- case 'bfSelect':
-
- if($mdata['list'] != ''){
-
- $mdata['list'] = str_replace("\r", '', $mdata['list']);
- $gEx = explode("\n", $mdata['list']);
- $lines = count($gEx);
- // data-native-menu="false"
- echo '<select class="ff_elem" '.($mdata['multiple'] ? 'multiple="multiple" data-native-menu="false" ' : '').$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'">'."\n";
- for($i = 0; $i < $lines; $i++){
- $iEx = explode(";", $gEx[$i]);
- $iCnt = count($iEx);
- if($iCnt == 3){
- echo '<option '.($iEx[0] == 1 ? 'selected="selected" ' : '').'value="'.htmlentities(trim($iEx[2]), ENT_QUOTES, 'UTF-8').'">'.htmlentities(trim($iEx[1]), ENT_QUOTES, 'UTF-8').'</option>'."\n";
- }
- }
- echo '</select>'."\n";
- }
-
- break;
-
- case 'bfFile':
- echo '<input class="ff_elem" '.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="file" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'"/>'."\n";
- if($mdata['attachToAdminMail']){
- echo '<input type="hidden" name="attachToAdminMail['.$mdata['bfName'].']" value="true"/>'."\n";
- }
- if($mdata['attachToUserMail']){
- echo '<input type="hidden" name="attachToUserMail['.$mdata['bfName'].']" value="true"/>'."\n";
- }
-
- // on mobiles, file uploads are forced not to be mandatory, since we cannot determin safely for all handsets if they are even allowed
- echo '<script type="text/javascript"><!--'."\n".'bfDeactivateField["ff_nm_'.$mdata['bfName'].'[]"]=true;'."\n".'//--></script>'."\n";
-
- break;
-
- case 'bfSubmitButton':
-
- $value = '';
- $type = 'submit';
- $src = '';
-
- if($mdata['src'] != ''){
- $type = 'image';
- $src = 'src="'.$mdata['src'].'" ';
- }
- if($mdata['value'] != ''){
- $value = 'value="'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'" ';
- }
- if($mdata['actionClick'] == 1){
- $onclick = 'onclick="populateSummarizers();if(document.getElementById(\'bfPaymentMethod\')){document.getElementById(\'bfPaymentMethod\').value=\'\';};'.$mdata['actionFunctionName'] . '(this,\'click\');return false;" ';
- } else {
- $onclick = 'onclick="populateSummarizers();if(document.getElementById(\'bfPaymentMethod\')){document.getElementById(\'bfPaymentMethod\').value=\'\';};return false;" ';
- }
- if($src == ''){
- echo '<button data-theme="e" class="ff_elem" '.$value.$src.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="'.$type.'" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'"><span>'.$mdata['value'].'</span></button>'."\n";
- }else{
- echo '<input class="ff_elem" '.$value.$src.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="'.$type.'" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'" value="'.$mdata['value'].'"/>'."\n";
- }
- break;
-
- case 'bfHidden':
-
- echo '<input class="ff_elem" type="hidden" name="ff_nm_'.$mdata['bfName'].'[]" value="'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'" id="ff_elem'.$mdata['dbId'].'"/>'."\n";
- break;
-
- case 'bfSummarize':
-
- echo '<div class="ui-grid-a">
- <div class="ui-block-a"><strong>'.$legend.'</strong></div>
- <div class="ui-block-b ff_elem bfSummarize" id="ff_elem'.$mdata['dbId'].'"></div>
- </div>';
- echo '<script type="text/javascript"><!--'."\n".'bfRegisterSummarize("ff_elem'.$mdata['dbId'].'", "'.$mdata['connectWith'].'", "'.$mdata['connectType'].'", "'.addslashes($mdata['emptyMessage']).'", '.($mdata['hideIfEmpty'] ? 'true' : 'false').')'."\n".'//--></script>';
- if(trim($mdata['fieldCalc']) != ''){
- echo '<script type="text/javascript">
- <!--
- function bfFieldCalcff_elem'.$mdata['dbId'].'(value){
- if(!isNaN(value)){
- value = Number(value);
- }
- '.$mdata['fieldCalc'].'
- return value;
- }
- //-->
- </script>';
- }
- break;
-
- // recaptcha doesn't currently play well with jquery mobile
- case 'bfReCaptcha':
- case 'bfCaptcha':
- echo '<input autocomplete="off" class="ff_elem" type="text" name="bfCaptchaEntry" id="bfCaptchaEntry" />'."\n";
- echo '<button data-role="button" data-icon="refresh" data-inline="true" data-iconpos="notext" data-theme="e" id="bfCaptchaReload" onclick="document.getElementById(\'bfCaptchaEntry\').value=\'\';document.getElementById(\'bfCaptchaEntry\').focus();document.getElementById(\'ff_capimgValue\').src = \''.$captcha_url.'?bfMathRandom=\' + Math.random(); return false"><span>Reload Captcha</span></button>';
-
- break;
-
- case 'bfCalendar':
-
- JHTML::_( 'behavior.calendar' );
-
- $exploded = explode('::',trim($mdata['value']));
-
- $left = '';
- $right = '';
- if(count($exploded) == 2){
- $left = trim($exploded[0]);
- $right = trim($exploded[1]);
- }else{
- $right = trim($exploded[0]);
- }
-
-
- echo '<input autocomplete="off" class="ff_elem" type="text" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'" value="'.htmlentities($left, ENT_QUOTES, 'UTF-8').'"/>'."\n";
- echo '<label for="ff_elem'.$mdata['dbId'].'_calendarButton"></label>';
- echo '<button data-theme="e" id="ff_elem'.$mdata['dbId'].'_calendarButton" type="submit" class="bfCalendar" value="'.htmlentities($right, ENT_QUOTES, 'UTF-8').'"><span>'.htmlentities($right, ENT_QUOTES, 'UTF-8').'</span></button>'."\n";
-
-
- echo '<script type="text/javascript">
- <!--
- JQuery(document).bind("pageinit", function() {
- Calendar.setup({
- inputField : "ff_elem'.$mdata['dbId'].'",
- ifFormat : "'.$mdata['format'].'",
- button : "ff_elem'.$mdata['dbId'].'_calendarButton",
- align : "Bl",
- singleClick : true
- });
- });
- //-->
- </script>'."\n";
-
- break;
-
- case 'bfPayPal':
-
- $value = '';
- $type = 'submit';
- $src = '';
- if($mdata['image'] != ''){
- $type = 'image';
- $src = 'src="'.$mdata['image'].'" ';
- }else{
- $value = 'value="PayPal" ';
- }
- if($mdata['actionClick'] == 1){
- $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'PayPal\';'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
- } else {
- $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'PayPal\';" ';
- }
- echo '<div align="center"><input data-role="none" class="ff_elem" '.$value.$src.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="'.$type.'" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'"/></div>'."\n";
- break;
-
- case 'bfSofortueberweisung':
-
- $value = '';
- $type = 'submit';
- $src = '';
- if($mdata['image'] != ''){
- $type = 'image';
- $src = 'src="'.$mdata['image'].'" ';
- }else{
- $value = 'value="Sofortueberweisung" ';
- }
- if($mdata['actionClick'] == 1){
- $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'Sofortueberweisung\';'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
- } else {
- $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'Sofortueberweisung\';" ';
- }
- echo '<div align="center"><input data-role="none" class="ff_elem" '.$value.$src.$tabIndex.$onclick.$onblur.$onchange.$onfocus.$onselect.$readonly.'type="'.$type.'" name="ff_nm_'.$mdata['bfName'].'[]" id="ff_elem'.$mdata['dbId'].'"/></div>'."\n";
- break;
- }
-
- if(trim($mdata['hint']) != ''){
- $labid = uniqid();
- echo '<div><button data-theme="e" onclick="JQuery(\'.tooltip\').hide(\'fast\');JQuery(\'#'.$labid.'_tip\').show(\'fast\');" data-role="button" data-icon="info" data-inline="true" data-iconpos="notext" id="'.$labid.'">'.trim($mdata['hint']).'</button><span id="'.$labid.'_tip" class="tooltip">'.trim($mdata['hint']).'</span></div>';
- }
-
- if(isset($mdata['bfName']) && isset($mdata['off']) && $mdata['off']){
- echo '<script type="text/javascript"><!--'."\n".'bfDeactivateField["ff_nm_'.$mdata['bfName'].'[]"]=true;'."\n".'//--></script>'."\n";
- }
-
- if($mdata['bfType'] == 'bfFile'){
- echo '<span id="ff_elem'.$mdata['dbId'].'_files"></span>';
- }
-
- // if labels left
- if( true ) {
- echo '</div>';
- }
- }
- }
- /**
- * Paging and wrapping of inline element containers
- */
- if(isset($dataObject['children']) && count($dataObject['children']) != 0){
- $childrenAmount = count($dataObject['children']);
- for($i = 0; $i < $childrenAmount; $i++){
- $this->process( $dataObject['children'][$i], $mdata, $parentPage, $i, $childrenAmount );
- }
- }
-
- if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'section' && $dataObject['properties']['bfType'] == 'section'){
-
- echo '</div></div>'."\n";
-
- } else if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'section' && $dataObject['properties']['bfType'] == 'normal' ) {
- if(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != ''){
- echo '</div>'."\n";
- }
- }
- else if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'page'){
- $isLastPage = false;
- if($this->rootMdata['lastPageThankYou'] && $dataObject['properties']['pageNumber'] == count($this->dataObject['children']) && count($this->dataObject['children']) > 1){
- $isLastPage = true;
- }
-
- if(!$isLastPage){
-
- $last = 0;
- if($this->rootMdata['lastPageThankYou']){
- $last = 1;
- }
-
- if($this->rootMdata['pagingInclude'] && $dataObject['properties']['pageNumber'] > 1){
- echo '<button data-theme="e" class="bfPrevButton" type="submit" onclick="if(ff_currentpage > 1){ff_switchpage(ff_currentpage-1);self.scrollTo(0,0);}populateSummarizers();" value="'.htmlentities(trim($this->rootMdata['pagingPrevLabel']), ENT_QUOTES, 'UTF-8').'"><span>'.htmlentities(trim($this->rootMdata['pagingPrevLabel']), ENT_QUOTES, 'UTF-8').'</span></button>'."\n";
- }
-
- if($this->rootMdata['pagingInclude'] && $dataObject['properties']['pageNumber'] < count($this->dataObject['children']) - $last){
- echo '<button data-theme="e" class="bfNextButton" type="submit" onclick="ff_validate_nextpage(this, \'click\');populateSummarizers();" value="'.htmlentities(trim($this->rootMdata['pagingNextLabel']), ENT_QUOTES, 'UTF-8').'"><span>'.htmlentities(trim($this->rootMdata['pagingNextLabel']), ENT_QUOTES, 'UTF-8').'</span></button>'."\n";
- }
-
- if($this->rootMdata['cancelInclude'] && $dataObject['properties']['pageNumber'] + 1 > count($this->dataObject['children']) - $last){
- echo '<button data-theme="e" class="bfCancelButton" type="submit" onclick="ff_resetForm(this, \'click\');" value="'.htmlentities(trim($this->rootMdata['cancelLabel']), ENT_QUOTES, 'UTF-8').'"><span>'.htmlentities(trim($this->rootMdata['cancelLabel']), ENT_QUOTES, 'UTF-8').'</span></button>'."\n";
- }
-
- $callSubmit = 'ff_validate_submit(this, \'click\')';
- if($this->rootMdata['submitInclude'] && $dataObject['properties']['pageNumber'] + 1 > count($this->dataObject['children']) - $last){
- echo '<button data-theme="b" id="bfSubmitButton" class="bfSubmitButton" type="submit" onclick="if(document.getElementById(\'bfPaymentMethod\')){document.getElementById(\'bfPaymentMethod\').value=\'\';};'.$callSubmit.';" value="'.htmlentities(trim($this->rootMdata['submitLabel']), ENT_QUOTES, 'UTF-8').'"><span>'.htmlentities(trim($this->rootMdata['submitLabel']), ENT_QUOTES, 'UTF-8').'</span></button>'."\n";
- }
-
- }
- }
- }
-
- public function addStyleDeclaration($declaration){
- echo '<style type="text/css">'."\n".$declaration."\n".'</style>'."\n";
- }
-
- public function addScript($script){
- echo '<script type="text/javascript" src="'.$script.'"/>'."\n".'</script>'."\n";
- }
-
- public function addStyleSheet($sheet){
- echo '<link rel="stylesheet" href="'.$sheet.'" type="text/css" />'."\n";
- }
-
- public function addScriptDeclaration($declaration){
- echo '<script type="text/javascript"/><!--'."\n".$declaration."\n".'//--></script>'."\n";
- }
-
- public function headers(){
-
- $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jq.min.js');
-
- $this->addStyleSheet( JURI::root(true) . '/media/breezingforms/themes/jq.mobile.min.css' );
- $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jq.mobile.min.js');
-
- $this->addStyleSheet( JURI::root(true) . '/components/com_breezingforms/libraries/jquery/tooltip.css' );
- $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/tooltip.js');
- if($this->useBalloonErrors){
- $this->addStyleSheet( JURI::root(true) . '/components/com_breezingforms/libraries/jquery/validationEngine.jquery.css' );
- $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jquery.validationEngine-en.js');
- $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jquery.validationEngine.js');
- }
- $this->addStyleDeclaration('.tooltip { margin-left: 2%; margin-top: 5px; }');
-
- $toggleCode = '';
- if($this->toggleFields != '[]'){
- $toggleCode = '
- var toggleFieldsArray = '.$this->toggleFields.';
- String.prototype.beginsWith = function(t, i) { if (i==false) { return
- (t == this.substring(0, t.length)); } else { return (t.toLowerCase()
- == this.substring(0, t.length).toLowerCase()); } }
- function bfDeactivateSectionFields(){
- for( var i = 0; i < bfDeactivateSection.length; i++ ){
- bfSetFieldValue(bfDeactivateSection[i], "off");
- JQuery("#"+bfDeactivateSection[i]+" .ff_elem").each(function(i){
- if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
- bfDeactivateField[JQuery(this).get(0).name] = true;
- }
- });
- }
- for( var i = 0; i < toggleFieldsArray.length; i++ ){
- if(toggleFieldsArray[i].state == "turn"){
- bfSetFieldValue(toggleFieldsArray[i].tName, "off");
- }
- }
- }
- function bfToggleFields(state, tCat, tName, thisBfDeactivateField){
- // maybe a little to harsh, but currently no other workaround
- // file uploads will be removed for the complete form if a rule is executed
- // make sure you offer file uploads at the end of your form if you have visibility rules!
- if(state == "on"){
- if(tCat == "element"){
- if( typeof JQuery("[name=\"ff_nm_"+tName+"[]\"]") != "undefined" && JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().attr("class").substr(0, 10) == "bfElemWrap" ){
- JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().css("display", "");
- } else if(JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "checkbox" || JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "radio"){
- JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().parent().css("display", "");
- }
- thisBfDeactivateField["ff_nm_"+tName+"[]"] = false;
- bfSetFieldValue(tName, "on");
- } else {
- JQuery("#"+tName).css("display", "");
- bfSetFieldValue(tName, "on");
- JQuery("#"+tName).find(".ff_elem").each(function(i){
- if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
- thisBfDeactivateField[JQuery(this).get(0).name] = false;
- }
- });
- }
- } else {
- if(tCat == "element"){
- if( typeof JQuery("[name=\"ff_nm_"+tName+"[]\"]") != "undefined" && JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().attr("class").substr(0, 10) == "bfElemWrap" ){
- JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().css("display", "none");
- } else if(JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "checkbox" || JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "radio"){
- JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().parent().css("display", "none");
- }
- thisBfDeactivateField["ff_nm_"+tName+"[]"] = true;
- bfSetFieldValue(tName, "off");
- } else {
- JQuery("#"+tName).css("display", "none");
- bfSetFieldValue(tName, "off");
- JQuery("#"+tName+" .ff_elem").each(function(i){
- if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
- thisBfDeactivateField[JQuery(this).get(0).name] = true;
- }
- });
- }
- }
- }
- function bfSetFieldValue(name, condition){
- for( var i = 0; i < toggleFieldsArray.length; i++ ){
- if( toggleFieldsArray[i].action == "if" ) {
- //alert(toggleFieldsArray[i].condition);
- if(name == toggleFieldsArray[i].tCat && condition == toggleFieldsArray[i].statement){
-
- var element = JQuery("[name=\"ff_nm_"+toggleFieldsArray[i].condition+"[]\"]");
-
- switch(element.get(0).type){
- case "text":
- case "textarea":
- if(toggleFieldsArray[i].value == "!empty"){
- element.val("");
- } else {
- element.val(toggleFieldsArray[i].value);
- }
- break;
- case "select-multiple":
- case "select-one":
- if(toggleFieldsArray[i].value == "!empty"){
- for(var j = 0; j < element.get(0).options.length; j++){
- element.get(0).options[j].selected = false;
- }
- }
- for(var j = 0; j < element.get(0).options.length; j++){
- if(element.get(0).options[j].value == toggleFieldsArray[i].value){
- element.get(0).options[j].selected = true;
- }
- }
- break;
- case "radio":
- case "checkbox":
- var radioLength = element.size();
- if(toggleFieldsArray[i].value == "!empty"){
- for(var j = 0; j < radioLength; j++){
- element.get(j).checked = false;
- }
- }
- for(var j = 0; j < radioLength; j++){
- if( element.get(j).value == toggleFieldsArray[i].value ){
- element.get(j).checked = true;
- }
- }
- break;
- }
- }
- }
- }
- }
- function bfRegisterToggleFields(){
-
- var offset = 0;
- var last_offset = 0;
- var limit = 10;
- var limit_cnt = 0;
-
- if( arguments.length == 1 ){
- offset = arguments[0];
- }
- var thisToggleFieldsArray = toggleFieldsArray;
- var thisBfDeactivateField = bfDeactivateField;
- var thisBfToggleFields = bfToggleFields;
-
- for( var i = offset; limit_cnt < limit && i < toggleFieldsArray.length; i++ ){
- // for( var i = 0; i < toggleFieldsArray.length; i++ ){
- if( toggleFieldsArray[i].action == "turn" && (toggleFieldsArray[i].tCat == "element" || toggleFieldsArray[i].tCat == "section") ){
- var toggleField = toggleFieldsArray[i];
- var element = JQuery("[name=\"ff_nm_"+toggleFieldsArray[i].sName+"[]\"]");
- if(element.get(0)){
- switch(element.get(0).type){
- case "text":
- case "textarea":
- JQuery("[name=\"ff_nm_"+toggleField.sName+"[]\"]").unbind("blur");
- JQuery("[name=\"ff_nm_"+toggleField.sName+"[]\"]").blur(
- function(){
- for( var k = 0; k < thisToggleFieldsArray.length; k++ ){
- var regExp = "";
- if(thisToggleFieldsArray[k].value.beginsWith("!", true) && JQuery(this).get(0).name == "ff_nm_"+thisToggleFieldsArray[k].sName+"[]"){
- regExp = thisToggleFieldsArray[k].value.substring(1, thisToggleFieldsArray[k].value.length);
- }
- if(thisToggleFieldsArray[k].condition == "isnot"){
- if(
- ( ( regExp != "" && JQuery(this).val().test(regExp) <= 0 ) || JQuery(this).val() != thisToggleFieldsArray[k].value ) && JQuery(this).get(0).name == "ff_nm_"+thisToggleFieldsArray[k].sName+"[]"
- ){
- var names = thisToggleFieldsArray[k].tName.split(",");
- for(var n = 0; n < names.length; n++){
- thisBfToggleFields(thisToggleFieldsArray[k].state, thisToggleFieldsArray[k].tCat, JQuery.trim(names[n]), thisBfDeactivateField);
- }
- //break;
- }
- } else if(thisToggleFieldsArray[k].condition == "is"){
- if(
- ( ( regExp != "" && JQuery(this).val().test(…
Large files files are truncated, but you can click here to view the full file