PageRenderTime 72ms CodeModel.GetById 36ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_breezingforms/libraries/crosstec/classes/BFQuickModeMobile.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
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

  1. <?php
  2. /**
  3. * BreezingForms - A Joomla Forms Application
  4. * @version 1.8
  5. * @package BreezingForms
  6. * @copyright (C) 2008-2012 by Markus Bopp
  7. * @license Released under the terms of the GNU General Public License
  8. **/
  9. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  10. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  11. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  12. class BFQuickModeMobile{
  13. /**
  14. * @var HTML_facileFormsProcessor
  15. */
  16. private $p = null;
  17. private $dataObject = array();
  18. private $rootMdata = array();
  19. private $useErrorAlerts = false;
  20. private $useDefaultErrors = false;
  21. private $useBalloonErrors = false;
  22. private $rollover = false;
  23. private $rolloverColor = '';
  24. private $toggleFields = '';
  25. private $cancelImagePath = '';
  26. private $uploadImagePath = '';
  27. public $forceMobileUrl = '';
  28. function __construct( HTML_facileFormsProcessor $p ){
  29. $head = JFactory::getDocument()->getHeadData();
  30. $head['styleSheets'] = array();
  31. $head['style'] = array();
  32. $head['scripts'] = array();
  33. $head['script'] = array();
  34. $head['custom'] = array();
  35. JFactory::getDocument()->setHeadData( $head );
  36. // will make sure mootools loads first, important 4 jquery
  37. JHtml::_('behavior.framework');
  38. jimport('joomla.version');
  39. $version = new JVersion();
  40. if(version_compare($version->getShortVersion(), '3.0', '<')){
  41. JHTML::_('behavior.mootools');
  42. }
  43. $this->p = $p;
  44. $this->dataObject = Zend_Json::decode( base64_decode($this->p->formrow->template_code) );
  45. $this->rootMdata = $this->dataObject['properties'];
  46. $this->useErrorAlerts = $this->rootMdata['useErrorAlerts'];
  47. $this->useDefaultErrors = isset($this->rootMdata['useDefaultErrors']) ? $this->rootMdata['useDefaultErrors'] : false;
  48. $this->useBalloonErrors = isset($this->rootMdata['useBalloonErrors']) ? $this->rootMdata['useBalloonErrors'] : false;
  49. $this->rollover = $this->rootMdata['rollover'];
  50. $this->rolloverColor = $this->rootMdata['rolloverColor'];
  51. $this->toggleFields = $this->parseToggleFields( isset($this->rootMdata['toggleFields']) ? $this->rootMdata['toggleFields'] : '[]' );
  52. // loading theme
  53. $this->cancelImagePath = JURI::root(true) . '/media/breezingforms/themes/cancel.png';
  54. $this->uploadImagePath = JURI::root(true) . '/media/breezingforms/themes/upload.png';
  55. }
  56. public function fetchHead($head)
  57. {
  58. $app = JFactory::getApplication();
  59. // Get line endings
  60. $lnEnd = JFactory::getDocument()->_getLineEnd();
  61. $tab = JFactory::getDocument()->_getTab();
  62. $tagEnd = ' />';
  63. $buffer = '';
  64. // Generate stylesheet links
  65. foreach ($head['styleSheets'] as $strSrc => $strAttr)
  66. {
  67. $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '" type="' . $strAttr['mime'] . '"';
  68. if (!is_null($strAttr['media']))
  69. {
  70. $buffer .= ' media="' . $strAttr['media'] . '" ';
  71. }
  72. if ($temp = JArrayHelper::toString($strAttr['attribs']))
  73. {
  74. $buffer .= ' ' . $temp;
  75. }
  76. $buffer .= $tagEnd . $lnEnd;
  77. }
  78. // Generate stylesheet declarations
  79. foreach ($head['style'] as $type => $content)
  80. {
  81. $buffer .= $tab . '<style type="' . $type . '">' . $lnEnd;
  82. // This is for full XHTML support.
  83. if (isset($document) && $document->_mime != 'text/html')
  84. {
  85. $buffer .= $tab . $tab . $lnEnd;
  86. }
  87. $buffer .= $content . $lnEnd;
  88. // See above note
  89. if (isset($document) && $document->_mime != 'text/html')
  90. {
  91. $buffer .= $tab . $tab . $lnEnd;
  92. }
  93. $buffer .= $tab . '</style>' . $lnEnd;
  94. }
  95. // Generate script file links
  96. foreach ($head['scripts'] as $strSrc => $strAttr)
  97. {
  98. $buffer .= $tab . '<script src="' . $strSrc . '"';
  99. if (isset($strAttr['mime']) && !is_null($strAttr['mime']))
  100. {
  101. $buffer .= ' type="' . ( $strAttr['mime'] == 't' ? 'text/javascript' : $strAttr['mime'] ) . '"';
  102. }
  103. $buffer .= '></script>' . $lnEnd;
  104. }
  105. // Generate script declarations
  106. foreach ($head['script'] as $type => $content)
  107. {
  108. $buffer .= $tab . '<script type="' . $type . '">' . $lnEnd;
  109. // This is for full XHTML support.
  110. if (isset($document) && $document->_mime != 'text/html')
  111. {
  112. $buffer .= $tab . $tab . $lnEnd;
  113. }
  114. $buffer .= $content . $lnEnd;
  115. // See above note
  116. if (isset($document) && $document->_mime != 'text/html')
  117. {
  118. $buffer .= $tab . $tab . $lnEnd;
  119. }
  120. $buffer .= $tab . '</script>' . $lnEnd;
  121. }
  122. foreach ($head['custom'] as $custom)
  123. {
  124. $buffer .= $tab . $custom . $lnEnd;
  125. }
  126. return $buffer;
  127. }
  128. public function process(&$dataObject, $parent = null, $parentPage = null, $index = 0, $childrenLength = 0){
  129. if(isset($dataObject['attributes']) && isset($dataObject['properties']) ){
  130. $options = array('type' => 'normal', 'displayType' => 'breaks');
  131. if($parent != null && $parent['type'] == 'section'){
  132. $options['type'] = $parent['bfType'];
  133. $options['displayType'] = $parent['displayType'];
  134. }
  135. $class = ' class="bfBlock"';
  136. $wrapper = 'bfWrapperBlock';
  137. if($options['displayType'] == 'inline'){
  138. $class = ' class="bfInline"';
  139. $wrapper = 'bfWrapperInline';
  140. }
  141. $mdata = $dataObject['properties'];
  142. if($mdata['type'] == 'page'){
  143. $parentPage = $mdata;
  144. if($parentPage['pageNumber'] > 1){
  145. echo '</div><!-- bfPage end -->'."\n"; // closing previous pages
  146. }
  147. echo '<div id="bfPage'.$parentPage['pageNumber'].'" class="bfPage" style="display:none">'."\n"; // opening current page
  148. if(trim($mdata['pageIntro'])!=''){
  149. echo '<div class="bfPageIntro">'."\n";
  150. $regex = '/{loadposition\s+(.*?)}/i';
  151. $introtext = $mdata['pageIntro'];
  152. preg_match_all($regex, $introtext, $matches, PREG_SET_ORDER);
  153. jimport('joomla.version');
  154. $version = new JVersion();
  155. if ($matches && version_compare($version->getShortVersion(), '1.6', '>=')) {
  156. $document = JFactory::getDocument();
  157. $renderer = $document->loadRenderer('modules');
  158. $options = array('style' => 'xhtml');
  159. foreach ($matches as $match) {
  160. $matcheslist = explode(',', $match[1]);
  161. $position = trim($matcheslist[0]);
  162. $output = $renderer->render($position, $options, null);
  163. $introtext = preg_replace("|$match[0]|", addcslashes($output, '\\'), $introtext, 1);
  164. }
  165. }
  166. echo $introtext."\n";
  167. echo '</div><div style="padding-bottom: 10px;"></div>'."\n";
  168. }
  169. if(!$this->useErrorAlerts){
  170. echo '<span class="bfErrorMessage" style="color: red; display:none;"></span>'."\n";
  171. }
  172. } else if($mdata['type'] == 'section'){
  173. if(isset($dataObject['properties']['name']) && isset($mdata['off']) && $mdata['off']){
  174. echo '<script type="text/javascript"><!--'."\n".'bfDeactivateSection.push("'.$dataObject['properties']['name'].'");'."\n".'//--></script>'."\n";
  175. }
  176. if($mdata['bfType'] == 'section'){
  177. 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";
  178. if(trim($mdata['title']) != ''){
  179. echo '<h3>'.htmlentities(trim($mdata['title']), ENT_QUOTES, 'UTF-8').'</h3>'."\n";
  180. }
  181. }
  182. else if( $mdata['bfType'] == 'normal' ) {
  183. if(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != ''){
  184. echo '<div '.(isset($mdata['off']) && $mdata['off'] ? 'style="display:none" ' : '').'class="bfNoSection"'.(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != "" ? ' id="'.$dataObject['properties']['name'].'"' : '').'>'."\n";
  185. }
  186. }
  187. if(trim($mdata['description'])!=''){
  188. echo '<div>'."\n";
  189. $regex = '/{loadposition\s+(.*?)}/i';
  190. $introtext = $mdata['description'];
  191. preg_match_all($regex, $introtext, $matches, PREG_SET_ORDER);
  192. jimport('joomla.version');
  193. $version = new JVersion();
  194. if ($matches && version_compare($version->getShortVersion(), '1.6', '>=')) {
  195. $document = JFactory::getDocument();
  196. $renderer = $document->loadRenderer('modules');
  197. $options = array('style' => 'xhtml');
  198. foreach ($matches as $match) {
  199. $matcheslist = explode(',', $match[1]);
  200. $position = trim($matcheslist[0]);
  201. $output = $renderer->render($position, $options, null);
  202. $introtext = preg_replace("|$match[0]|", addcslashes($output, '\\'), $introtext, 1);
  203. }
  204. }
  205. echo $introtext."\n";
  206. echo '</div><div style="padding-bottom: 10px;"></div>'."\n";
  207. }
  208. } else if($mdata['type'] == 'element'){
  209. // if labels left
  210. if( true ) {
  211. echo '<div class="bfElemWrap" data-role="fieldcontain">';
  212. }
  213. $onclick = '';
  214. if($mdata['actionClick'] == 1){
  215. $onclick = 'onclick="'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
  216. }
  217. $onblur = '';
  218. if($mdata['actionBlur'] == 1){
  219. $onblur = 'onblur="'.$mdata['actionFunctionName'] . '(this,\'blur\');" ';
  220. }
  221. $onchange = '';
  222. if($mdata['actionChange'] == 1){
  223. $onchange = 'onchange="'.$mdata['actionFunctionName'] . '(this,\'change\');" ';
  224. }
  225. $onfocus = '';
  226. if($mdata['actionFocus'] == 1){
  227. $onfocus = 'onfocus="'.$mdata['actionFunctionName'] . '(this,\'focus\');" ';
  228. }
  229. $onselect = '';
  230. if(isset($mdata['actionSelect']) && $mdata['actionSelect'] == 1){
  231. $onselect = 'onselect="'.$mdata['actionFunctionName'] . '(this,\'select\');" ';
  232. }
  233. $legend = '';
  234. if(!$mdata['hideLabel'] && $mdata['bfType'] != 'bfPayPal' && $mdata['bfType'] != 'bfSofortueberweisung'){
  235. $maxlengthCounter = '';
  236. if($mdata['bfType'] == 'bfTextarea' && isset($mdata['maxlength']) && $mdata['maxlength'] > 0 && isset($mdata['showMaxlengthCounter']) && $mdata['showMaxlengthCounter']){
  237. $maxlengthCounter = ' <span class=***bfMaxLengthCounter*** id=***bfMaxLengthCounter'.$mdata['dbId'].'***>('.$mdata['maxlength'].' '.BFText::_('COM_BREEZINGFORMS_CHARS_LEFT').')</span>';
  238. }
  239. $for = 'for="ff_elem'.$mdata['dbId'].'"';
  240. if($mdata['bfType'] == 'bfCaptcha' || $mdata['bfType'] == 'bfReCaptcha'){
  241. $for = 'for="bfCaptchaEntry"';
  242. if(JFactory::getApplication()->isSite())
  243. {
  244. $captcha_url = JURI::root(true).'/components/com_breezingforms/images/captcha/securimage_show.php';
  245. }
  246. else
  247. {
  248. $captcha_url = JURI::root(true).'/administrator/components/com_breezingforms/images/captcha/securimage_show.php';
  249. }
  250. echo '<div align="center"><img alt="" border="0" width="230" id="ff_capimgValue" class="ff_capimg" src="'.$captcha_url.'"/></div><br/>'."\n";
  251. }
  252. //else if($mdata['bfType'] == 'bfReCaptcha'){
  253. // $for = 'for="recaptcha_response_field"';
  254. //}
  255. $req = '';
  256. if($mdata['required']){
  257. $req = '<span class="bfRequired"> *</span>'."\n";
  258. }
  259. $labelText = $req . trim($mdata['label']) . str_replace("***","\"",$maxlengthCounter);
  260. if( true && ( $mdata['bfType'] == 'bfCheckboxGroup' || $mdata['bfType'] == 'bfRadioGroup' ) ){
  261. $legend = '<legend id="bfLabel'.$mdata['dbId'].'">'.str_replace("***","\"",$labelText).'</legend>'."\n";
  262. } else if( $mdata['bfType'] == 'bfSummarize' ){
  263. $legend = $labelText;
  264. }else {
  265. echo '<label id="bfLabel'.$mdata['dbId'].'" '.$for.'>'.str_replace("***","\"",$labelText).'</label>'."\n";
  266. }
  267. }
  268. $readonly = '';
  269. if($mdata['readonly']){
  270. $readonly = 'readonly="readonly" ';
  271. }
  272. $tabIndex = '';
  273. if($mdata['tabIndex'] != -1 && is_numeric($mdata['tabIndex'])){
  274. $tabIndex = 'tabindex="'.intval($mdata['tabIndex']).'" ';
  275. }
  276. for($i = 0; $i < $this->p->rowcount; $i++) {
  277. $row = $this->p->rows[$i];
  278. if($mdata['bfName'] == $row->name){
  279. if( ( isset($mdata['value']) || isset($mdata['list']) || isset($mdata['group']))
  280. &&
  281. (
  282. $mdata['bfType'] == 'bfTextfield' ||
  283. $mdata['bfType'] == 'bfTextarea' ||
  284. $mdata['bfType'] == 'bfCheckbox' ||
  285. $mdata['bfType'] == 'bfCheckboxGroup' ||
  286. $mdata['bfType'] == 'bfSubmitButton' ||
  287. $mdata['bfType'] == 'bfHidden' ||
  288. $mdata['bfType'] == 'bfCalendar' ||
  289. $mdata['bfType'] == 'bfSelect' ||
  290. $mdata['bfType'] == 'bfRadioGroup'
  291. )
  292. ){
  293. if($mdata['bfType'] == 'bfSelect')
  294. {
  295. $mdata['list'] = $this->p->replaceCode($row->data2, "data2 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
  296. }
  297. else if($mdata['bfType'] == 'bfCheckboxGroup' || $mdata['bfType'] == 'bfRadioGroup')
  298. {
  299. $mdata['group'] = $this->p->replaceCode($row->data2, "data2 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
  300. }
  301. else
  302. {
  303. $mdata['value'] = $this->p->replaceCode($row->data1, "data1 of " . $mdata['bfName'], 'e', $mdata['dbId'], 0);
  304. }
  305. }
  306. if(isset($mdata['checked']) && $mdata['bfType'] == 'bfCheckbox'){
  307. $mdata['checked'] = $row->flag1 == 1 ? true : false;
  308. }
  309. break;
  310. }
  311. }
  312. switch($mdata['bfType']){
  313. case 'bfTextfield':
  314. $type = 'text';
  315. if($mdata['password']){
  316. $type = 'password';
  317. }
  318. $maxlength = '';
  319. if(is_numeric($mdata['maxLength'])){
  320. $maxlength = 'maxlength="'.intval($mdata['maxLength']).'" ';
  321. }
  322. 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";
  323. if($mdata['mailbackAsSender']){
  324. echo '<input type="hidden" name="mailbackSender['.$mdata['bfName'].']" value="true"/>'."\n";
  325. }
  326. break;
  327. case 'bfTextarea':
  328. $onkeyup = '';
  329. if(isset($mdata['maxlength']) && $mdata['maxlength'] > 0){
  330. $onkeyup = 'onkeyup="bfCheckMaxlength('.intval($mdata['dbId']).', '.intval($mdata['maxlength']).', '.(isset($mdata['showMaxlengthCounter']) && $mdata['showMaxlengthCounter'] ? 'true' : 'false').')" ';
  331. }
  332. 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";
  333. break;
  334. case 'bfRadioGroup':
  335. if($mdata['group'] != ''){
  336. $mdata['group'] = str_replace("\r", '', $mdata['group']);
  337. $gEx = explode("\n", $mdata['group']);
  338. $lines = count($gEx);
  339. $wrapOpen = '<div data-role="fieldcontain">'."\n".'<fieldset '.($lines <= 3 ? 'data-type="horizontal" ' : '').'data-role="controlgroup">'.$legend."\n";
  340. $wrapClose = '</fieldset>'."\n".'</div>'."\n";
  341. echo $wrapOpen;
  342. for($i = 0; $i < $lines; $i++){
  343. $idExt = $i != 0 ? '_'.$i : '';
  344. $iEx = explode(";", $gEx[$i]);
  345. $iCnt = count($iEx);
  346. if($iCnt == 3){
  347. $lblRight = '<label class="bfGroupLabel" id="bfGroupLabel'.$mdata['dbId'].$idExt.'" for="ff_elem'.$mdata['dbId'].$idExt.'">'.htmlentities(trim($iEx[1]), ENT_QUOTES, 'UTF-8').'</label>';
  348. 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";
  349. }
  350. }
  351. echo $wrapClose;
  352. }
  353. break;
  354. case 'bfCheckboxGroup':
  355. if($mdata['group'] != ''){
  356. $mdata['group'] = str_replace("\r", '', $mdata['group']);
  357. $gEx = explode("\n", $mdata['group']);
  358. $lines = count($gEx);
  359. $wrapOpen = '<div data-role="fieldcontain">'."\n".'<fieldset data-role="controlgroup">'.$legend."\n";
  360. $wrapClose = '</fieldset>'."\n".'</div>'."\n";
  361. echo $wrapOpen;
  362. for($i = 0; $i < $lines; $i++){
  363. $idExt = $i != 0 ? '_'.$i : '';
  364. $iEx = explode(";", $gEx[$i]);
  365. $iCnt = count($iEx);
  366. if($iCnt == 3){
  367. $lbl = '<label class="bfGroupLabel" id="bfGroupLabel'.$mdata['dbId'].$idExt.'" for="ff_elem'.$mdata['dbId'].$idExt.'">'.htmlentities(trim($iEx[1]), ENT_QUOTES, 'UTF-8').'</label>';
  368. 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";
  369. }
  370. }
  371. echo $wrapClose;
  372. }
  373. break;
  374. case 'bfCheckbox':
  375. 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";
  376. if($mdata['mailbackAccept']){
  377. echo '<input type="hidden" class="ff_elem" name="mailbackConnectWith['.$mdata['mailbackConnectWith'].']" value="true_'.$mdata['bfName'].'"/>'."\n";
  378. }
  379. break;
  380. case 'bfSelect':
  381. if($mdata['list'] != ''){
  382. $mdata['list'] = str_replace("\r", '', $mdata['list']);
  383. $gEx = explode("\n", $mdata['list']);
  384. $lines = count($gEx);
  385. // data-native-menu="false"
  386. 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";
  387. for($i = 0; $i < $lines; $i++){
  388. $iEx = explode(";", $gEx[$i]);
  389. $iCnt = count($iEx);
  390. if($iCnt == 3){
  391. 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";
  392. }
  393. }
  394. echo '</select>'."\n";
  395. }
  396. break;
  397. case 'bfFile':
  398. 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";
  399. if($mdata['attachToAdminMail']){
  400. echo '<input type="hidden" name="attachToAdminMail['.$mdata['bfName'].']" value="true"/>'."\n";
  401. }
  402. if($mdata['attachToUserMail']){
  403. echo '<input type="hidden" name="attachToUserMail['.$mdata['bfName'].']" value="true"/>'."\n";
  404. }
  405. // on mobiles, file uploads are forced not to be mandatory, since we cannot determin safely for all handsets if they are even allowed
  406. echo '<script type="text/javascript"><!--'."\n".'bfDeactivateField["ff_nm_'.$mdata['bfName'].'[]"]=true;'."\n".'//--></script>'."\n";
  407. break;
  408. case 'bfSubmitButton':
  409. $value = '';
  410. $type = 'submit';
  411. $src = '';
  412. if($mdata['src'] != ''){
  413. $type = 'image';
  414. $src = 'src="'.$mdata['src'].'" ';
  415. }
  416. if($mdata['value'] != ''){
  417. $value = 'value="'.htmlentities(trim($mdata['value']), ENT_QUOTES, 'UTF-8').'" ';
  418. }
  419. if($mdata['actionClick'] == 1){
  420. $onclick = 'onclick="populateSummarizers();if(document.getElementById(\'bfPaymentMethod\')){document.getElementById(\'bfPaymentMethod\').value=\'\';};'.$mdata['actionFunctionName'] . '(this,\'click\');return false;" ';
  421. } else {
  422. $onclick = 'onclick="populateSummarizers();if(document.getElementById(\'bfPaymentMethod\')){document.getElementById(\'bfPaymentMethod\').value=\'\';};return false;" ';
  423. }
  424. if($src == ''){
  425. 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";
  426. }else{
  427. 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";
  428. }
  429. break;
  430. case 'bfHidden':
  431. 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";
  432. break;
  433. case 'bfSummarize':
  434. echo '<div class="ui-grid-a">
  435. <div class="ui-block-a"><strong>'.$legend.'</strong></div>
  436. <div class="ui-block-b ff_elem bfSummarize" id="ff_elem'.$mdata['dbId'].'"></div>
  437. </div>';
  438. echo '<script type="text/javascript"><!--'."\n".'bfRegisterSummarize("ff_elem'.$mdata['dbId'].'", "'.$mdata['connectWith'].'", "'.$mdata['connectType'].'", "'.addslashes($mdata['emptyMessage']).'", '.($mdata['hideIfEmpty'] ? 'true' : 'false').')'."\n".'//--></script>';
  439. if(trim($mdata['fieldCalc']) != ''){
  440. echo '<script type="text/javascript">
  441. <!--
  442. function bfFieldCalcff_elem'.$mdata['dbId'].'(value){
  443. if(!isNaN(value)){
  444. value = Number(value);
  445. }
  446. '.$mdata['fieldCalc'].'
  447. return value;
  448. }
  449. //-->
  450. </script>';
  451. }
  452. break;
  453. // recaptcha doesn't currently play well with jquery mobile
  454. case 'bfReCaptcha':
  455. case 'bfCaptcha':
  456. echo '<input autocomplete="off" class="ff_elem" type="text" name="bfCaptchaEntry" id="bfCaptchaEntry" />'."\n";
  457. 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>';
  458. break;
  459. case 'bfCalendar':
  460. JHTML::_( 'behavior.calendar' );
  461. $exploded = explode('::',trim($mdata['value']));
  462. $left = '';
  463. $right = '';
  464. if(count($exploded) == 2){
  465. $left = trim($exploded[0]);
  466. $right = trim($exploded[1]);
  467. }else{
  468. $right = trim($exploded[0]);
  469. }
  470. 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";
  471. echo '<label for="ff_elem'.$mdata['dbId'].'_calendarButton"></label>';
  472. 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";
  473. echo '<script type="text/javascript">
  474. <!--
  475. JQuery(document).bind("pageinit", function() {
  476. Calendar.setup({
  477. inputField : "ff_elem'.$mdata['dbId'].'",
  478. ifFormat : "'.$mdata['format'].'",
  479. button : "ff_elem'.$mdata['dbId'].'_calendarButton",
  480. align : "Bl",
  481. singleClick : true
  482. });
  483. });
  484. //-->
  485. </script>'."\n";
  486. break;
  487. case 'bfPayPal':
  488. $value = '';
  489. $type = 'submit';
  490. $src = '';
  491. if($mdata['image'] != ''){
  492. $type = 'image';
  493. $src = 'src="'.$mdata['image'].'" ';
  494. }else{
  495. $value = 'value="PayPal" ';
  496. }
  497. if($mdata['actionClick'] == 1){
  498. $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'PayPal\';'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
  499. } else {
  500. $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'PayPal\';" ';
  501. }
  502. 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";
  503. break;
  504. case 'bfSofortueberweisung':
  505. $value = '';
  506. $type = 'submit';
  507. $src = '';
  508. if($mdata['image'] != ''){
  509. $type = 'image';
  510. $src = 'src="'.$mdata['image'].'" ';
  511. }else{
  512. $value = 'value="Sofortueberweisung" ';
  513. }
  514. if($mdata['actionClick'] == 1){
  515. $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'Sofortueberweisung\';'.$mdata['actionFunctionName'] . '(this,\'click\');" ';
  516. } else {
  517. $onclick = 'onclick="document.getElementById(\'bfPaymentMethod\').value=\'Sofortueberweisung\';" ';
  518. }
  519. 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";
  520. break;
  521. }
  522. if(trim($mdata['hint']) != ''){
  523. $labid = uniqid();
  524. 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>';
  525. }
  526. if(isset($mdata['bfName']) && isset($mdata['off']) && $mdata['off']){
  527. echo '<script type="text/javascript"><!--'."\n".'bfDeactivateField["ff_nm_'.$mdata['bfName'].'[]"]=true;'."\n".'//--></script>'."\n";
  528. }
  529. if($mdata['bfType'] == 'bfFile'){
  530. echo '<span id="ff_elem'.$mdata['dbId'].'_files"></span>';
  531. }
  532. // if labels left
  533. if( true ) {
  534. echo '</div>';
  535. }
  536. }
  537. }
  538. /**
  539. * Paging and wrapping of inline element containers
  540. */
  541. if(isset($dataObject['children']) && count($dataObject['children']) != 0){
  542. $childrenAmount = count($dataObject['children']);
  543. for($i = 0; $i < $childrenAmount; $i++){
  544. $this->process( $dataObject['children'][$i], $mdata, $parentPage, $i, $childrenAmount );
  545. }
  546. }
  547. if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'section' && $dataObject['properties']['bfType'] == 'section'){
  548. echo '</div></div>'."\n";
  549. } else if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'section' && $dataObject['properties']['bfType'] == 'normal' ) {
  550. if(isset($dataObject['properties']['name']) && $dataObject['properties']['name'] != ''){
  551. echo '</div>'."\n";
  552. }
  553. }
  554. else if(isset($dataObject['properties']) && $dataObject['properties']['type'] == 'page'){
  555. $isLastPage = false;
  556. if($this->rootMdata['lastPageThankYou'] && $dataObject['properties']['pageNumber'] == count($this->dataObject['children']) && count($this->dataObject['children']) > 1){
  557. $isLastPage = true;
  558. }
  559. if(!$isLastPage){
  560. $last = 0;
  561. if($this->rootMdata['lastPageThankYou']){
  562. $last = 1;
  563. }
  564. if($this->rootMdata['pagingInclude'] && $dataObject['properties']['pageNumber'] > 1){
  565. 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";
  566. }
  567. if($this->rootMdata['pagingInclude'] && $dataObject['properties']['pageNumber'] < count($this->dataObject['children']) - $last){
  568. 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";
  569. }
  570. if($this->rootMdata['cancelInclude'] && $dataObject['properties']['pageNumber'] + 1 > count($this->dataObject['children']) - $last){
  571. 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";
  572. }
  573. $callSubmit = 'ff_validate_submit(this, \'click\')';
  574. if($this->rootMdata['submitInclude'] && $dataObject['properties']['pageNumber'] + 1 > count($this->dataObject['children']) - $last){
  575. 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";
  576. }
  577. }
  578. }
  579. }
  580. public function addStyleDeclaration($declaration){
  581. echo '<style type="text/css">'."\n".$declaration."\n".'</style>'."\n";
  582. }
  583. public function addScript($script){
  584. echo '<script type="text/javascript" src="'.$script.'"/>'."\n".'</script>'."\n";
  585. }
  586. public function addStyleSheet($sheet){
  587. echo '<link rel="stylesheet" href="'.$sheet.'" type="text/css" />'."\n";
  588. }
  589. public function addScriptDeclaration($declaration){
  590. echo '<script type="text/javascript"/><!--'."\n".$declaration."\n".'//--></script>'."\n";
  591. }
  592. public function headers(){
  593. $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jq.min.js');
  594. $this->addStyleSheet( JURI::root(true) . '/media/breezingforms/themes/jq.mobile.min.css' );
  595. $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jq.mobile.min.js');
  596. $this->addStyleSheet( JURI::root(true) . '/components/com_breezingforms/libraries/jquery/tooltip.css' );
  597. $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/tooltip.js');
  598. if($this->useBalloonErrors){
  599. $this->addStyleSheet( JURI::root(true) . '/components/com_breezingforms/libraries/jquery/validationEngine.jquery.css' );
  600. $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jquery.validationEngine-en.js');
  601. $this->addScript(JURI::root(true) . '/components/com_breezingforms/libraries/jquery/jquery.validationEngine.js');
  602. }
  603. $this->addStyleDeclaration('.tooltip { margin-left: 2%; margin-top: 5px; }');
  604. $toggleCode = '';
  605. if($this->toggleFields != '[]'){
  606. $toggleCode = '
  607. var toggleFieldsArray = '.$this->toggleFields.';
  608. String.prototype.beginsWith = function(t, i) { if (i==false) { return
  609. (t == this.substring(0, t.length)); } else { return (t.toLowerCase()
  610. == this.substring(0, t.length).toLowerCase()); } }
  611. function bfDeactivateSectionFields(){
  612. for( var i = 0; i < bfDeactivateSection.length; i++ ){
  613. bfSetFieldValue(bfDeactivateSection[i], "off");
  614. JQuery("#"+bfDeactivateSection[i]+" .ff_elem").each(function(i){
  615. if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
  616. bfDeactivateField[JQuery(this).get(0).name] = true;
  617. }
  618. });
  619. }
  620. for( var i = 0; i < toggleFieldsArray.length; i++ ){
  621. if(toggleFieldsArray[i].state == "turn"){
  622. bfSetFieldValue(toggleFieldsArray[i].tName, "off");
  623. }
  624. }
  625. }
  626. function bfToggleFields(state, tCat, tName, thisBfDeactivateField){
  627. // maybe a little to harsh, but currently no other workaround
  628. // file uploads will be removed for the complete form if a rule is executed
  629. // make sure you offer file uploads at the end of your form if you have visibility rules!
  630. if(state == "on"){
  631. if(tCat == "element"){
  632. if( typeof JQuery("[name=\"ff_nm_"+tName+"[]\"]") != "undefined" && JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().attr("class").substr(0, 10) == "bfElemWrap" ){
  633. JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().css("display", "");
  634. } else if(JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "checkbox" || JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "radio"){
  635. JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().parent().css("display", "");
  636. }
  637. thisBfDeactivateField["ff_nm_"+tName+"[]"] = false;
  638. bfSetFieldValue(tName, "on");
  639. } else {
  640. JQuery("#"+tName).css("display", "");
  641. bfSetFieldValue(tName, "on");
  642. JQuery("#"+tName).find(".ff_elem").each(function(i){
  643. if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
  644. thisBfDeactivateField[JQuery(this).get(0).name] = false;
  645. }
  646. });
  647. }
  648. } else {
  649. if(tCat == "element"){
  650. if( typeof JQuery("[name=\"ff_nm_"+tName+"[]\"]") != "undefined" && JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().attr("class").substr(0, 10) == "bfElemWrap" ){
  651. JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().css("display", "none");
  652. } else if(JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "checkbox" || JQuery("[name=\"ff_nm_"+tName+"[]\"]").get(0).type == "radio"){
  653. JQuery("[name=\"ff_nm_"+tName+"[]\"]").parent().parent().css("display", "none");
  654. }
  655. thisBfDeactivateField["ff_nm_"+tName+"[]"] = true;
  656. bfSetFieldValue(tName, "off");
  657. } else {
  658. JQuery("#"+tName).css("display", "none");
  659. bfSetFieldValue(tName, "off");
  660. JQuery("#"+tName+" .ff_elem").each(function(i){
  661. if( JQuery(this).get(0).name && JQuery(this).get(0).name.beginsWith("ff_nm_", true) ){
  662. thisBfDeactivateField[JQuery(this).get(0).name] = true;
  663. }
  664. });
  665. }
  666. }
  667. }
  668. function bfSetFieldValue(name, condition){
  669. for( var i = 0; i < toggleFieldsArray.length; i++ ){
  670. if( toggleFieldsArray[i].action == "if" ) {
  671. //alert(toggleFieldsArray[i].condition);
  672. if(name == toggleFieldsArray[i].tCat && condition == toggleFieldsArray[i].statement){
  673. var element = JQuery("[name=\"ff_nm_"+toggleFieldsArray[i].condition+"[]\"]");
  674. switch(element.get(0).type){
  675. case "text":
  676. case "textarea":
  677. if(toggleFieldsArray[i].value == "!empty"){
  678. element.val("");
  679. } else {
  680. element.val(toggleFieldsArray[i].value);
  681. }
  682. break;
  683. case "select-multiple":
  684. case "select-one":
  685. if(toggleFieldsArray[i].value == "!empty"){
  686. for(var j = 0; j < element.get(0).options.length; j++){
  687. element.get(0).options[j].selected = false;
  688. }
  689. }
  690. for(var j = 0; j < element.get(0).options.length; j++){
  691. if(element.get(0).options[j].value == toggleFieldsArray[i].value){
  692. element.get(0).options[j].selected = true;
  693. }
  694. }
  695. break;
  696. case "radio":
  697. case "checkbox":
  698. var radioLength = element.size();
  699. if(toggleFieldsArray[i].value == "!empty"){
  700. for(var j = 0; j < radioLength; j++){
  701. element.get(j).checked = false;
  702. }
  703. }
  704. for(var j = 0; j < radioLength; j++){
  705. if( element.get(j).value == toggleFieldsArray[i].value ){
  706. element.get(j).checked = true;
  707. }
  708. }
  709. break;
  710. }
  711. }
  712. }
  713. }
  714. }
  715. function bfRegisterToggleFields(){
  716. var offset = 0;
  717. var last_offset = 0;
  718. var limit = 10;
  719. var limit_cnt = 0;
  720. if( arguments.length == 1 ){
  721. offset = arguments[0];
  722. }
  723. var thisToggleFieldsArray = toggleFieldsArray;
  724. var thisBfDeactivateField = bfDeactivateField;
  725. var thisBfToggleFields = bfToggleFields;
  726. for( var i = offset; limit_cnt < limit && i < toggleFieldsArray.length; i++ ){
  727. // for( var i = 0; i < toggleFieldsArray.length; i++ ){
  728. if( toggleFieldsArray[i].action == "turn" && (toggleFieldsArray[i].tCat == "element" || toggleFieldsArray[i].tCat == "section") ){
  729. var toggleField = toggleFieldsArray[i];
  730. var element = JQuery("[name=\"ff_nm_"+toggleFieldsArray[i].sName+"[]\"]");
  731. if(element.get(0)){
  732. switch(element.get(0).type){
  733. case "text":
  734. case "textarea":
  735. JQuery("[name=\"ff_nm_"+toggleField.sName+"[]\"]").unbind("blur");
  736. JQuery("[name=\"ff_nm_"+toggleField.sName+"[]\"]").blur(
  737. function(){
  738. for( var k = 0; k < thisToggleFieldsArray.length; k++ ){
  739. var regExp = "";
  740. if(thisToggleFieldsArray[k].value.beginsWith("!", true) && JQuery(this).get(0).name == "ff_nm_"+thisToggleFieldsArray[k].sName+"[]"){
  741. regExp = thisToggleFieldsArray[k].value.substring(1, thisToggleFieldsArray[k].value.length);
  742. }
  743. if(thisToggleFieldsArray[k].condition == "isnot"){
  744. if(
  745. ( ( regExp != "" && JQuery(this).val().test(regExp) <= 0 ) || JQuery(this).val() != thisToggleFieldsArray[k].value ) && JQuery(this).get(0).name == "ff_nm_"+thisToggleFieldsArray[k].sName+"[]"
  746. ){
  747. var names = thisToggleFieldsArray[k].tName.split(",");
  748. for(var n = 0; n < names.length; n++){
  749. thisBfToggleFields(thisToggleFieldsArray[k].state, thisToggleFieldsArray[k].tCat, JQuery.trim(names[n]), thisBfDeactivateField);
  750. }
  751. //break;
  752. }
  753. } else if(thisToggleFieldsArray[k].condition == "is"){
  754. if(
  755. ( ( regExp != "" && JQuery(this).val().test(

Large files files are truncated, but you can click here to view the full file