function showForm($option, &$form, &$fields) { global $Itemid, $mainframe, $params, $hide_js, $pop, $formeConfig; $database =& JFactory::getDBO(); //Page title $mainframe->setPageTitle($form->title); $mainframe->addMetaTag('title', $form->title); //mosCommonHTML::loadCalendar(); eval($form->script_display); //if we have upload file fields, add enctype $enctype = ''; foreach ($fields as $field) { if ($field->inputtype == 'file upload') { $enctype = ' enctype="multipart/form-data"'; } } //load calendar if calendar field exists $calexists = false; foreach ($fields as $field) { if ($field->inputtype == 'calendar') { $calexists = true; } } //parse field template $formfields = ''; foreach ($fields as $field) { if ($form->fieldstyle == '') { $form->fieldstyle = _FORME_BACKEND_EDITFORMS_FIELDSTYLE_DEFAULT; } if ($field->fieldstyle == '') { $field->fieldstyle = $form->fieldstyle; } $formfields .= forme_HTML::parseFields($field); } if ($calexists) { $html = ''; $check = false; if (isset($_COOKIE['mbfcookie']['lang'])) { $check = $_COOKIE['mbfcookie']['lang']; } if (isset($_COOKIE['jfcookie']['lang'])) { $check = $_COOKIE['jfcookie']['lang']; } if (isset($_REQUEST['lang'])) { $check = JRequest::getVar('lang', false); } if ($check) { if (file_exists(JPATH_SITE . '/components/com_forme/calendar/initcal-' . $check . '.php')) { require_once JPATH_SITE . '/components/com_forme/calendar/initcal-' . $check . '.php'; } else { require_once JPATH_SITE . '/components/com_forme/calendar/initcal.php'; } } else { require_once JPATH_SITE . '/components/com_forme/calendar/initcal.php'; } echo $html; ?> <script language="javascript"> function init() { <?php foreach ($fields as $field) { if ($field->inputtype == 'calendar') { ?> function handleSelect<?php echo $field->name; ?> (type,args,obj) { var dates = args[0]; var date = dates[0]; var year = date[0], month = date[1], day = date[2]; var txtDate = document.getElementById("txt<?php echo $field->name; ?> "); txtDate.value = month + "/" + day + "/" + year; } YAHOO.example.calendar.<?php echo $field->name; ?> = new YAHOO.widget.Calendar("<?php echo $field->name; ?> ","<?php echo $field->name; ?> Container"); YAHOO.example.calendar.<?php echo $field->name; ?> .selectEvent.subscribe(handleSelect<?php echo $field->name; ?> , YAHOO.example.calendar.<?php echo $field->name; ?> , true); var txt<?php echo $field->name; ?> = document.getElementById("txt<?php echo $field->name; ?> "); if (txt<?php echo $field->name; ?> .value != "") { YAHOO.example.calendar.<?php echo $field->name; ?> .select(txt<?php echo $field->name; ?> .value); } YAHOO.example.calendar.<?php echo $field->name; ?> .render(); <?php } } ?> } YAHOO.util.Event.addListener(window, "load", init); </script> <?php } $action = JRoute::_(JURI::base() . 'index.php?option=com_forme&fid=' . $form->id . '&Itemid=' . $Itemid); //parse form template if ($form->formstyle == '') { $form->formstyle = _FORME_BACKEND_EDITFORMS_STYLE_DEFAULT; } $form->formstyle = str_replace('{formtitle}', $form->title, $form->formstyle); $form->formstyle = str_replace('{formname}', $form->name, $form->formstyle); $form->formstyle = str_replace('{enctype}', $enctype, $form->formstyle); $form->formstyle = str_replace('{action}', $action, $form->formstyle); $form->formstyle = str_replace('{formfields}', $formfields, $form->formstyle); echo $form->formstyle; }
/** * *Edit Fields Layout * **/ function editfield($option, &$row) { global $mainframe; //mosCommonHTML::loadCalendar(); $row->default_value = htmlspecialchars($row->default_value); $row->params = htmlspecialchars($row->params); //create field types list $field_types = array(); $field_types[] = JHTML::_('select.option', 'text', 'text'); $field_types[] = JHTML::_('select.option', 'password', 'password'); $field_types[] = JHTML::_('select.option', 'radio', 'radio'); $field_types[] = JHTML::_('select.option', 'checkbox', 'checkbox'); $field_types[] = JHTML::_('select.option', 'calendar', 'calendar'); $field_types[] = JHTML::_('select.option', 'textarea', 'textarea'); $field_types[] = JHTML::_('select.option', 'select', 'select'); $field_types[] = JHTML::_('select.option', 'button', 'button'); $field_types[] = JHTML::_('select.option', 'image button', 'image button'); $field_types[] = JHTML::_('select.option', 'submit button', 'submit button'); $field_types[] = JHTML::_('select.option', 'reset button', 'reset button'); $field_types[] = JHTML::_('select.option', 'file upload', 'file upload'); $field_types[] = JHTML::_('select.option', 'hidden', 'hidden'); $field_types[] = JHTML::_('select.option', 'free text', 'free text'); $field_types[] = JHTML::_('select.option', 'ticket number', 'ticket number'); $field_types[] = JHTML::_('select.option', 'captcha', 'captcha(antispam)'); $field_types = JHTML::_('select.genericlist', $field_types, 'inputtype', ' id="inputtype" size="1" class="inputbox" onchange="changeDesc();"', 'value', 'text', $row->inputtype); $field_validation = array(); $field_validation[] = JHTML::_('select.option', '', _FORME_BACKEND_EDITFIELD_VALIDATION_NONE); $field_validation[] = JHTML::_('select.option', 'email', _FORME_BACKEND_EDITFIELD_VALIDATION_EMAIL); $field_validation[] = JHTML::_('select.option', 'number', _FORME_BACKEND_EDITFIELD_VALIDATION_NUMBER); $field_validation[] = JHTML::_('select.option', 'alphanum', _FORME_BACKEND_EDITFIELD_VALIDATION_ALPHANUM); $field_validation[] = JHTML::_('select.option', 'alpha', _FORME_BACKEND_EDITFIELD_VALIDATION_ALPHA); $field_validation[] = JHTML::_('select.option', 'mandatory', _FORME_BACKEND_EDITFIELD_VALIDATION_MANDATORY); $field_validation = JHTML::_('select.genericlist', $field_validation, 'validation_rule', ' id="validation_rule" size="1" class="inputbox" onchange="outputValidation();"', 'value', 'text', $row->validation_rule); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancelfield') { submitform( pressbutton ); return; } // do field validation if (form.name.value == ""){ //BUMP needs multilanguage support alert( '<?php echo _FORME_EDITFIELD_ERROR_NAME; ?> ' ); } else { submitform( pressbutton ); } } </script> <script language="javascript"> function outputValidation(){ var validationrule = document.getElementById('validation_rule'); switch(validationrule.value){ case '': document.getElementById('validationmessage').style.display = 'none'; document.getElementById('validationmessagefield').value=''; break; <?php if ($row->validation_message != '') { ?> default: document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo $row->validation_message; ?> '; break; <?php } else { ?> case 'email': document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo sprintf(_FORME_BACKEND_EDITFIELD_VALIDATION_EMAIL_MESS, $row->title); ?> '; break; case 'number': document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo sprintf(_FORME_BACKEND_EDITFIELD_VALIDATION_NUMBER_MESS, $row->title); ?> '; break; case 'alphanum': document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo sprintf(_FORME_BACKEND_EDITFIELD_VALIDATION_ALPHANUM_MESS, $row->title); ?> '; break; case 'alpha': document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo sprintf(_FORME_BACKEND_EDITFIELD_VALIDATION_ALPHA_MESS, $row->title); ?> '; break; case 'mandatory': document.getElementById('validationmessage').style.display = 'inline'; document.getElementById('validationmessagefield').value='<?php echo sprintf(_FORME_BACKEND_EDITFIELD_VALIDATION_MANDATORY_MESS, $row->title); ?> '; break; <?php } ?> } } function changeDesc(){ var inputtype = document.getElementById('inputtype'); switch(inputtype.value){ case 'text': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_TEXT); ?> '; break; case 'password': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_PASSWORD); ?> '; break; case 'radio': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_RADIO); ?> '; break; case 'checkbox': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_CHECKBOX); ?> '; break; case 'calendar': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_CALENDAR); ?> '; break; case 'textarea': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_TEXTAREA); ?> '; break; case 'select': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_SELECT); ?> '; break; case 'button': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_BUTTON); ?> '; break; case 'submit button': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_SUBMIT_BUTTON); ?> '; break; case 'reset button': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_RESET_BUTTON); ?> '; break; case 'image button': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_IMAGE_BUTTON); ?> '; break; case 'file upload': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_FILE_UPLOAD); ?> '; break; case 'hidden': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_HIDDEN); ?> '; break; case 'free text': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_FREE_TEXT); ?> '; break; case 'ticket number': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_TICKET_NUMBER); ?> '; break; case 'captcha': document.getElementById('fieldtype').innerHTML = '<?php echo addslashes(_FORME_BACKEND_EDITFIELD_TYPE_DESC_CAPTCHA); ?> '; break; } } </script> <form action="index2.php" method="post" name="adminForm" id="adminForm"> <table class="adminlist"> <tr> <td><img src="<?php echo JURI::base() . "/components/com_forme/images/rsform.gif"; ?> " height="49" width="250" alt="RSform! Logo" align="left"></td> <td class="sectionname" align="right"><font style="color: #C24733; font-size : 18px; font-weight: bold; text-align: left;"><?php echo $row->id ? _FORME_BACKEND_EDITFORMS_EDIT_FIELD : _FORME_BACKEND_EDITFORMS_ADD_FIELD; ?> </font></td> </tr> </table> <table class="adminform"> <tr> <td valign="top"> <table cellpadding="4" cellspacing="0" border="0" class="adminform"> <tr> <th colspan="3"><?php echo _FORME_BACKEND_EDITFORMS_FIELD_HEAD . " "; ?> </th> </tr> <tr> <td valign="top" align="left" width="100%"> <table> <tr> <td><?php echo _FORME_BACKEND_EDITFORMS_FIELD_NAME . " "; ?> </td> <td><input name="name" value="<?php echo $row->name; ?> " size="55" maxlength="50"> <br><?php echo _FORME_BACKEND_EDITFORMS_FIELD_NAME_DESC . " "; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFORMS_FIELD_TITLE . " "; ?> </td> <td><input name="title" value="<?php echo $row->title; ?> " size="55" maxlength="255" id="title"><br><?php echo _FORME_BACKEND_EDITFORMS_FIELD_TITLE_DESC . " "; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFIELD_DESCRIPTION . " "; ?> </td> <td> <textarea name="description" cols="50" rows="5"><?php echo $row->description; ?> </textarea> <br><?php echo _FORME_BACKEND_EDITFIELD_DESCRIPTION_DESC . " "; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFIELD_VALIDATION . " "; ?> </td> <td><?php echo $field_validation; ?> <br><?php echo _FORME_BACKEND_EDITFIELD_VALIDATION_DESC . " "; ?> <br/> <div id="validationmessage" style="display:<?php echo $row->validation_rule == '' ? 'none' : 'inline'; ?> ;"><?php echo _FORME_BACKEND_EDITFIELD_VALIDATION_MESSAGE . " "; ?> <br/><input type="text" name="validation_message" value="<?php echo $row->validation_message; ?> " id="validationmessagefield" size="55"/></div> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFORMS_FIELD_TYPE . " "; ?> </td> <td><?php echo $field_types; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFIELD_DEFAULT . " "; ?> </td> <td><textarea name="default_value" style="width:100%;height:50px;"><?php echo $row->default_value; ?> </textarea><br><?php echo _FORME_BACKEND_EDITFIELD_DEFAULT_DESC . " "; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFIELD_PARAMS . " "; ?> </td> <td><input name="params" value="<?php echo $row->params; ?> " size="55"> <input type="hidden" name="ordering" value="<?php echo $row->ordering; ?> "/> <input type="hidden" name="published" value="<?php echo $row->published; ?> "/> <br><?php echo _FORME_BACKEND_EDITFIELD_PARAMS_DESC . " "; ?> </td> </tr> <tr> <td><?php echo _FORME_BACKEND_EDITFIELD_FIELDSTYLE . " "; ?> </td> <td> <textarea name="fieldstyle" cols="50" rows="5"><?php echo $row->fieldstyle; ?> </textarea> <br><?php echo _FORME_BACKEND_EDITFIELD_FIELDSTYLE_DESC . " "; ?> </td> </tr> </table> </td> </tr> </table> </td> <td width="40%" valign="top"> <table cellpadding="4" cellspacing="0" border="0" class="adminform"> <tr> <th><?php echo _FORME_BACKEND_EDITFIELD_PREVIEW . " "; ?> </th> </tr> <tr> <td align="center"> <table border="0" cellpadding="2" cellspacing="0"> <?php echo forme_HTML::parseFields($row); ?> </table> </td> </tr> </table> <br/><br/> <table cellpadding="4" cellspacing="0" border="0" class="adminform"> <tr> <th><?php echo _FORME_BACKEND_EDITFIELD_SUPPORT . " "; ?> </th> </tr> <tr> <td align="center"> <table border="0" cellpadding="2" cellspacing="0"> <div id="fieldtype"><?php echo _FORME_BACKEND_EDITFIELD_TYPE_DESC_TEXT . " "; ?> </div> </table> </td> </tr> </table> <br/><br/> <table cellpadding="4" cellspacing="0" border="0" class="adminform"> <tr> <th><?php echo _FORME_BACKEND_EDITFIELD_FORM_PREVIEW . " "; ?> </th> </tr> <tr> <td align="center"> <a href="<?php echo $mainframe->getSiteURL(); ?> /index.php?option=com_forme&fid=<?php echo $row->form_id; ?> " target="_blank" style="text-decoration:none;font-size:14px;text-align:center;padding-top:4px;font-weight:bold;"><?php echo _FORME_BACKEND_EDITFIELD_FORM_PREVIEW . " "; ?> </a> </td> </tr> </table> </td> </tr> </table> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="hidemainmenu" value="0"/> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="id" value="<?php echo $row->id; ?> " /> <input type="hidden" name="form_id" value="<?php echo $row->form_id; ?> " /> <input type="hidden" name="task" value="" /> </form> <script language="javascript">changeDesc();</script> <?php }