function _displayForm($formname) { $form = CFChronoForm::getInstance($formname, true); if (empty($form->form_name)) { return "There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management."; } $loaded_form = JRequest::getVar('chronoform'); if (!empty($loaded_form) && trim($loaded_form) != $form->form_name) { $event = ''; } else { $event = JRequest::getVar('event'); } if (empty($event)) { $event = 'load'; } $form->process($event); ob_start(); HTML_ChronoForms::processView($form); $output = ob_get_clean(); return $output; }
function run($form, $actiondata) { $params = new JParameter($actiondata->params); //get the form name $formname = $params->get('form_name', ''); if (!empty($formname)) { $method = $params->get('action_taken', ''); //get the event to load $event = $params->get('form_event', 'load'); if (!trim($event)) { $event = 'load'; } //switch the showing method if ($method == 'load') { $MyForm = CFChronoForm::getInstance($formname); $MyForm->process($event); HTML_ChronoForms::processView($MyForm); } else { $mainframe =& JFactory::getApplication(); $form_url = "index.php?option=com_chronoforms&chronoform=" . $formname . "&event=" . $event; $mainframe->redirect($form_url); } } }
function admin_form() { require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'libraries' . DS . 'chronoform.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'chronoforms.html.php'; $formname = JRequest::getVar('chronoform', ''); $form_id = JRequest::getVar('form_id', ''); $event = JRequest::getVar('event'); if (empty($formname)) { if (empty($form_id)) { $mainframe->redirect("index.php?option=com_chronoforms", "Form doesn't exist!"); } else { $row =& JTable::getInstance('chronoforms', 'Table'); $row->load((int) $form_id); $formname = $row->name; //load some table data $database =& JFactory::getDBO(); $table_name = $_POST['table_name']; $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach ($table_fields as $table_field => $field_data) { if ($field_data->Key == 'PRI') { $primary = $table_field; } } if (empty($primary)) { JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //get record data if (isset($_POST['cb']) && !empty($_POST['cb'])) { $_POST['cf_id'] = $_POST['cb'][0]; //load all selected records data $database->setQuery("SELECT * FROM " . $table_name . " WHERE " . $primary . " IN ('" . implode("','", $_POST['cb']) . "')"); $_POST['chronoform_data'] = $rows_data = $database->loadAssocList(); } else { JError::raiseWarning(100, "Invalid record."); $mainframe->redirect("index.php?option=com_chronoforms"); } } } $form = CFChronoForm::getInstance($formname); $form->admin = true; $form->process($event); HTML_ChronoForms::processView($form); }
function admin_form() { require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'libraries' . DS . 'chronoform.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_chronoforms' . DS . 'chronoforms.html.php'; $formname = JRequest::getVar('chronoform', ''); $form_id = JRequest::getVar('form_id', ''); $event = JRequest::getVar('event'); if (empty($formname)) { if (empty($form_id)) { $mainframe->redirect("index.php?option=com_chronoforms", "Form doesn't exist!"); } else { $row =& JTable::getInstance('chronoforms', 'Table'); $row->load((int) $form_id); $formname = $row->name; //load some table data $database =& JFactory::getDBO(); $table_name = $_POST['table_name']; $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach ($table_fields as $table_field => $field_data) { if ($field_data->Key == 'PRI') { $primary = $table_field; } } if (empty($primary)) { JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //get record data if (isset($_POST['cb']) && !empty($_POST['cb'])) { $_POST['cf_id'] = $_POST['cb'][0]; //load all selected records data $database->setQuery("SELECT * FROM " . $table_name . " WHERE " . $primary . " IN ('" . implode("','", $_POST['cb']) . "')"); $_POST['chronoform_data'] = $rows_data = $database->loadAssocList(); } else { //JError::raiseWarning(100, "Invalid record."); //$mainframe->redirect("index.php?option=com_chronoforms"); } } } $form = CFChronoForm::getInstance($formname); $form->admin = true; //check if the event is the CSV export if ($event == 'cf_csv_export') { $csv_event = array('events' => array('cf_csv_export' => array('actions' => array('cfaction_csv_export_gh_9999' => array('events' => array('cfaction_csv_export_gh_9999_success' => array(), 'cfaction_csv_export_gh_9999_failed' => array())))))); $form->form_details->events_actions_map = base64_encode(serialize($csv_event)); $csv_action_data = new stdClass(); $csv_action_data->type = 'csv_export_gh'; $csv_action_data->order = 9999; $csv_action_data->enabled = 1; $csv_action_params = new JParameter(''); $csv_action_params->set('download_export', 1); $csv_action_params->set('download_nosave', 1); $csv_action_data->params = $csv_action_params->toString(); $csv_action_data->content1 = ''; $form->form_actions[] = $csv_action_data; } $form->process($event); HTML_ChronoForms::processView($form); }
function process($form, $event = '') { $form->process($event); HTML_ChronoForms::processView($form); }