Exemple #1
0
    function handle(&$params)
    {
        $app = Dataface_Application::getInstance();
        header('Content-type: text/html; charset=' . $app->_conf['oe']);
        $record =& $app->getRecord();
        $query =& $app->getQuery();
        if (isset($_REQUEST['-form-id'])) {
            $formid = $_REQUEST['-form-id'];
        } else {
            $formid = 'ajax-form-' . rand();
        }
        // First let's figure out what kind of form this is
        $form_type = @$_REQUEST['-form-type'];
        $form = null;
        if (isset($_REQUEST['-fields'])) {
            $fields = explode(',', $_REQUEST['-fields']);
        } else {
            $fields = null;
        }
        switch ($form_type) {
            case 'new':
                $form = df_create_new_record_form($query['-table'], $fields);
                $form->_build();
                break;
            case 'edit':
                $form = df_create_edit_record_form($query['-table'], $fields);
                break;
            case 'new_related_record':
                $form = df_create_new_related_record_form($record, $query['-relationship'], $fields);
                break;
            case 'existing_related_record':
                $form = df_create_existing_related_record_form($record, $query['-relationship']);
                break;
            case 'composite':
                import('Dataface/CompositeForm.php');
                $form = new Dataface_CompositeForm($fields);
                $form->build();
                break;
            default:
                @(include_once 'forms/' . $form_type . '.php');
                if (!class_exists('forms_' . $form_type)) {
                    return PEAR::raiseError('Could not find form of type "' . $form_type . '".', DATAFACE_E_ERROR);
                }
                $classname = 'forms_' . $form_type;
                $form = new $classname($fields);
                break;
        }
        // We want the form to be submitted to the embedded iframe
        $form->updateAttributes(array('target' => $formid . '-target', 'accept-charset' => $app->_conf['ie']));
        $formparams = preg_grep('/^-[^\\-].*/', array_keys($query));
        foreach ($formparams as $param) {
            $form->addElement('hidden', $param);
            $form->setDefaults(array($param => $query[$param]));
        }
        $form->addElement('hidden', '-form-id');
        $form->setDefaults(array('-form-id' => $formid));
        // Now that we have our form, we can do our thing with it.
        if ($form->validate()) {
            /*
             *
             * The form was submitted and it validated ok.  We now process it (ie: save its contents).
             *
             */
            $app->clearMessages();
            $result = $form->process(array(&$form, 'save'));
            $success = true;
            $response =& Dataface_Application::getResponse();
            if (!$result) {
                trigger_error("Error occurred in save: " . xf_db_error($app->db()) . Dataface_Error::printStackTrace(), E_USER_ERROR);
                exit;
            } else {
                if (PEAR::isError($result) && !Dataface_Error::isNotice($result)) {
                    if (Dataface_Error::isDuplicateEntry($result)) {
                        return $result;
                    } else {
                        trigger_error($result->toString() . Dataface_Error::printStackTrace(), E_USER_ERROR);
                        exit;
                    }
                } else {
                    if (Dataface_Error::isNotice($result)) {
                        $app->addError($result);
                        $success = false;
                    }
                }
            }
            if ($success) {
                import('Dataface/Utilities.php');
                Dataface_Utilities::fireEvent('after_action_ajax_form');
                $msg = implode("\n", $app->getMessages());
                //$msg =@$response['--msg'];
                $msg = urlencode(Dataface_LanguageTool::translate('Record successfully saved', "Record successfully saved.<br>") . $msg);
                // We need to output the success content.
                // This could be in any of the following formats:
                //	1. HTML --- actually not yet.. let's just do JSON
                //	2. JSON
                //	3. XML --- not yet.. just JSON for now.
                $targetid = @$_REQUEST['-target-id'];
                // This should:
                // 1. Get the target element.
                // 2. Go through the element's subtree and replace
                // 		values that have been changed.  How do we know what
                // 		values have been changed.
                //
                if (method_exists($form, 'htmlValues')) {
                    if (method_exists($form, 'changedFields')) {
                        $changed_fields = $form->changedFields();
                    } else {
                        $changed_fields = null;
                    }
                    // Convert the values to JSON
                    $changed_values = $form->htmlValues($changed_fields);
                    import('Services/JSON.php');
                    $json = new Services_JSON();
                    $changed_values_json = $json->encode($changed_values);
                } else {
                    $changed_values_json = '{}';
                }
                echo <<<END
<html><body><script language="javascript"><!--
\t
\t//self.onload =  function(){
\t\t//parent.handleEditableResponse('{$targetid}', {$changed_values_json});
\t\tvar targetel = parent.document.getElementById('{$targetid}');
\t\ttargetel.handleResponse('{$targetid}', {$changed_values_json});
\t\ttargetel.onclick=parent.makeEditable;
\t\ttargetel.onmouseover=targetel.old_onmouseover;
\t\ttargetel.edit_form.parentNode.removeChild(targetel.edit_form);
\t
\t//}
\t
\t
//--></script></body></html>
END;
                exit;
            }
        }
        import('Dataface/FormTool.php');
        $formTool = new Dataface_FormTool();
        ob_start();
        if (is_array($fields) and count($fields) == 1 and strpos($fields[0], '#') !== false) {
            $singleField = $fields[0];
        } else {
            $singleField = false;
        }
        $formTool->display($form, null, $singleField);
        $out = ob_get_contents();
        ob_end_clean();
        echo <<<END
\t\t
\t\t<div id="{$formid}-wrapper">
\t\t\t<iframe id="{$formid}-target" name="{$formid}-target" style="width:0px; height:0px; border: 0px"></iframe>
\t\t\t{$out}
\t\t</div>
END;
        if ($form->isSubmitted()) {
            // The form has already been submitted so we must be displaying some
            // errors.  We need to remove this stuff from inside the iframe
            // that we are going to be inside of, and place them on the page
            // in the correct place
            echo <<<END
<script language="javascript"><!--
var targetel = parent.document.getElementById('{$formid}-wrapper');
var sourceel = document.getElementById('{$formid}-wrapper');
targetel.innerHTML = sourceel.innerHTML;
//--></script>
END;
        }
        exit;
    }
Exemple #2
0
 /**
  * implements action handle() method.
  */
 function handle(&$params)
 {
     $action =& $params['action'];
     //print_r($params);
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $query['-skip'] = 0;
     $query['-limit'] = 9999999;
     // Let's validate some of the parameters first
     // The actions.ini file should define an email_column and email_table parameters
     // to indicate:
     //	a. the name of the column from the current table that should be used
     //	    as the "send to" email address.
     //	b. the name of the table that should store the email messages.
     if (!@$action['email_column']) {
         return PEAR::raiseError("No email column specified in actions.ini", DATAFACE_E_WARNING);
     }
     if (!@$action['email_table']) {
         return PEAR::raiseError("No email table specified in actions.ini", DATAFACE_E_WARNING);
     }
     // Make sure the table and column names are not malicious.
     $this->emailColumn = $col = $action['email_column'];
     if (strpos($col, '`') !== false) {
         return PEAR::raiseError("Invalid email column name: '{$col}'", DATAFACE_E_WARNING);
     }
     $this->emailTable = $table = $action['email_table'];
     if (strpos($table, '`') !== false) {
         return PEAR::raiseError("Invalid email table name: '{$table}'", DATAFACE_E_WARNING);
     }
     $this->joinTable = $join_table = $query['-table'] . '__' . $table;
     $this->recipientsTable = $query['-table'];
     // The name of the table that tracks which records have had email sent.
     // Next make sure that the email table(s) exist(s)
     if (!Dataface_Table::tableExists($table, false) || !Dataface_Table::tableExists($join_table, false)) {
         $this->createEmailTables($table, $join_table);
     }
     $emailTableObj =& Dataface_Table::loadTable($this->emailTable);
     $contentField =& $emailTableObj->getField('content');
     $contentField['widget']['atts']['rows'] = 20;
     $contentField['widget']['atts']['cols'] = 60;
     $contentField['widget']['label'] = 'Message body';
     $contentField['widget']['description'] = 'Please enter your message content in plain text.';
     $contentField['widget']['type'] = 'htmlarea';
     $contentField['widget']['editor'] = 'nicEdit';
     $subjectField =& $emailTableObj->getField('subject');
     $subjectField['widget']['atts']['size'] = 60;
     $fromField =& $emailTableObj->getField('from');
     $fromField['widget']['atts']['size'] = 60;
     $fromField['widget']['description'] = 'e.g. Web Lite Solutions &lt;info@weblite.ca&gt;';
     $ccField =& $emailTableObj->getField('cc');
     $ccField['widget']['atts']['size'] = 60;
     $ignoreBlacklistField =& $emailTableObj->getField('ignore_blacklist');
     $ignoreBlacklistField['widget']['type'] = 'checkbox';
     $ignoreBlacklistField['widget']['description'] = 'The black list is a list of email addresses that have opted out of receiving email.  I.e. Users on the black list do not want to receive email.  Check this box if you want to send to blacklisted addresses despite their wish to be left alone.';
     $form = df_create_new_record_form($table);
     $form->_build();
     $form->addElement('hidden', '-action');
     $form->addElement('hidden', '-table');
     $form->setDefaults(array('-action' => $query['-action'], '-table' => $query['-table']));
     $form->insertElementBefore($form->createElement('checkbox', 'send_now', '', 'Send now (leave this box unchecked if you wish these emails to be queued for later sending by the daily cron job.  Recommended to leave this box unchecked for large found sets (&gt;100 records).)'), 'submit_new_newsletters_record');
     $form->addElement('hidden', '-query_string');
     $form->setDefaults(array('-query_string' => base64_encode(serialize($query))));
     if (@$app->_conf['from_email']) {
         $form->setDefaults(array('from' => $app->_conf['from_email']));
     }
     if ($form->validate()) {
         $res = $form->process(array(&$form, 'save'), true);
         if (PEAR::isError($res)) {
             return $res;
         }
         // The form saved ok.. so we can send the emails.
         //$resultSet = $app->getResultSet();
         //$resultSet->loadSet();
         //$it =& $resultSet->iterator();
         $vals = $form->exportValues();
         $q2 = unserialize(base64_decode($vals['-query_string']));
         //print_r($q2);
         //exit;
         $qb = new Dataface_QueryBuilder($query['-table'], $q2);
         $sql = "insert ignore into `{$join_table}` (recipient_email,messageid,date_created) select `" . $col . "`, '" . addslashes($form->_record->val('id')) . "' as messageid, now() as date_created " . $qb->_from() . " " . $qb->_secure($qb->_where());
         //echo $sql;exit;
         $sres = mysql_query($sql, df_db());
         if (!$sres) {
             trigger_error(mysql_error(df_db()), E_USER_ERROR);
         }
         //while ($row = mysql_fetch_row($sres) ){
         //	$join_rec = new Dataface_Record($join_table, array('messageid'=>$form->_record->val('id'),
         //													   'recipient_email'=>$row[0],
         //													   'date_created'=>date('Y-m-d h:i:s')));
         //	$res = $join_rec->save();
         //	if ( !$res ) return PEAR::raiseError("Failed to add entry for email '".$curr->val($col)."'", DATAFACE_E_WARNING);
         //	unset($join_rec);
         //	unset($curr);
         //}
         //$it = df_get_records($query['-table'], $q2);
         //while ( $it->hasNext() ){
         //	$curr =& $it->next();
         //	$join_rec = new Dataface_Record($join_table, array('messageid'=>$form->_record->val('id'),
         //													   'recipient_email'=>$curr->val($col),
         //													   'date_created'=>date('Y-m-d h:i:s')));
         //	$res = $join_rec->save();
         //	if ( !$res ) return PEAR::raiseError("Failed to add entry for email '".$curr->val($col)."'", DATAFACE_E_WARNING);
         //	unset($join_rec);
         //	unset($curr);
         //}
         //$this->messages = array();
         // If we're set to send the email right now
         //if ( $form->exportValue('send_now') ){
         //	$this->sendMail($form->_record->val('id'));
         //}
         $this->postJob($form->_record->val('id'), $this->emailTable, $this->joinTable, $this->recipientsTable, $this->emailColumn);
         //$this->messages[] = "Email has been queued for delivery.";
         //if ( count($this->messages) > 0 ){
         //$_SESSION['--msg'] = implode("\n",$this->messages);
         //echo $_SESSION['--msg'];
         //exit;
         //}
         $q2['-action'] = 'list';
         unset($q2['-limit']);
         header('Location: ' . $app->url($q2) . '&--msg=' . urlencode("The message has been queued for delivery"));
         exit;
     }
     $addresses = array();
     //$resultSet = $app->getResultSet();
     //$resultSet->loadSet();
     //$it =& $resultSet->iterator();
     //$it = df_get_records($query['-table'], array_merge($query, array('-limit'=>30)));
     //while ( $it->hasNext() ){
     //	$curr =& $it->next();
     //	$addresses[] = $curr->val($col);
     //
     //	unset($curr);
     //}
     ob_start();
     $form->display();
     $context = array();
     $context['email_form'] = ob_get_contents();
     $profileTable =& Dataface_Table::loadTable($query['-table']);
     $context['fields'] = array_keys($profileTable->fields(false, true, true));
     //$context['blacklist'] = $this->getBlackListed($addresses);
     //$context['addresses'] = array_diff($addresses, $context['blacklist']);
     ob_end_clean();
     df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
     df_display($context, 'email_form.html');
 }
Exemple #3
0
 function handle($params)
 {
     if (!defined('DISABLE_reCAPTCHA')) {
         define('DISABLE_reCAPTCHA', 1);
     }
     import('Dataface/QuickForm.php');
     Dataface_QuickForm::$TRACK_SUBMIT = false;
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     $errors = null;
     try {
         if (!@$_POST['-table']) {
             throw new Exception("No table specified");
         }
         $table = $_POST['-table'];
         $rec = new Dataface_Record($table, array());
         $tableObj = $rec->_table;
         $fields = array();
         if (!$rec->checkPermission('new')) {
             throw new Exception("Failed to insert record.  Permission denied");
         }
         foreach ($_POST as $k => $v) {
             if ($k[0] == '-') {
                 continue;
             }
             $fields[] = $k;
             $rec->setValue($k, $v);
             if (!$rec->checkPermission('new', array('field' => $k))) {
                 throw new Exception(sprintf("Failed to insert record because you do not have permission to insert data into the %s column", $k));
             }
         }
         $form = df_create_new_record_form($table, $fields);
         $form->_flagSubmitted = true;
         $res = $form->validate();
         if (!$res) {
             $errors = $form->_errors;
             throw new Exception('Validation error', REST_INSERT_VALIDATION_ERROR);
         }
         $res = $rec->save(null, true);
         if (PEAR::isError($res)) {
             throw new Exception("Failed to insert record due to a server error: " . $res->getMessage(), 500);
         }
         $out = array();
         $vals = $rec->strvals();
         foreach ($vals as $k => $v) {
             if ($rec->checkPermission('view')) {
                 $out[$k] = $v;
             }
         }
         $this->out(array('code' => 200, 'message' => 'Record successfully inserted', 'record' => $out));
         exit;
     } catch (Exception $ex) {
         $this->out(array('code' => $ex->getCode(), 'message' => $ex->getMessage(), 'errors' => $errors));
         exit;
     }
 }
Exemple #4
0
 function handle(&$params)
 {
     $this->params =& $params['action'];
     unset($params);
     $params =& $this->params;
     Dataface_PermissionsTool::getInstance()->setDelegate(new dataface_actions_register_permissions_delegate());
     $app =& Dataface_Application::getInstance();
     $auth =& Dataface_AuthenticationTool::getInstance();
     import('Dataface/Ontology.php');
     Dataface_Ontology::registerType('Person', 'Dataface/Ontology/Person.php', 'Dataface_Ontology_Person');
     $this->ontology =& Dataface_Ontology::newOntology('Person', $app->_conf['_auth']['users_table']);
     $atts =& $this->ontology->getAttributes();
     $query =& $app->getQuery();
     if (!is_array(@$app->_conf['_auth'])) {
         return PEAR::raiseError("Cannot register when authentication is not enabled.", DATAFACE_E_ERROR);
     }
     if (isset($app->_conf['_auth']['email_column'])) {
         $atts['email'] =& $this->ontology->table->getField($app->_conf['_auth']['email_column']);
         $this->fieldnames['email'] = $app->_conf['_auth']['email_column'];
     }
     if ($auth->isLoggedIn()) {
         return Dataface_Error::permissionDenied("Sorry you cannot register once you are logged in.  If you want to register, you must first log out.");
     }
     if (!@$app->_conf['_auth']['allow_register']) {
         return PEAR::raiseError("Sorry, registration is not allowed.  Please contact the administrator for an account.", DATAFACE_E_ERROR);
     }
     $pt =& Dataface_PermissionsTool::getInstance();
     // Create a new record form on the users table
     $this->form =& df_create_new_record_form($app->_conf['_auth']['users_table']);
     // add the -action element so that the form will direct us back here.
     $this->form->addElement('hidden', '-action');
     $this->form->setDefaults(array('-action' => $query['-action']));
     // Check to make sure that there isn't another user with the same
     // username already.
     $validationResults = $this->validateRegistrationForm($_POST);
     if (count($_POST) > 0 and PEAR::isError($validationResults)) {
         $app->addMessage($validationResults->getMessage());
         $this->form->_errors[$app->_conf['_auth']['username_column']] = $validationResults->getMessage();
     }
     if (!PEAR::isError($validationResults) and $this->form->validate()) {
         // The form input seems OK.  Let's process the form
         // Since we will be using our own form processing for this action,
         // we need to manually push the field inputs into the Dataface_Record
         // object.
         $this->form->push();
         // Now we obtain the Dataface_Record object that is to be added.
         $rec =& $this->form->_record;
         $delegate =& $rec->_table->getDelegate();
         // Give the delegate classes an opportunity to have some fun
         if (isset($delegate) and method_exists($delegate, 'beforeRegister')) {
             $res = $delegate->beforeRegister($rec);
             if (PEAR::isError($res)) {
                 return $res;
             }
         }
         $appdel =& $app->getDelegate();
         if (isset($appdel) and method_exists($appdel, 'beforeRegister')) {
             $res = $appdel->beforeRegister($rec);
             if (PEAR::isError($res)) {
                 return $res;
             }
         }
         // This is where we actually do the processing.  This passes control
         // to the processRegistrationForm method in this class.
         $res = $this->form->process(array(&$this, 'processRegistrationForm'), true);
         // If there was an error in processing mark the error, and show the
         // form again.  Otherwise we just redirect to the next page and
         // let the user know that he was successful.
         if (PEAR::isError($res)) {
             $app->addError($res);
         } else {
             // Let the delegate classes perform their victory lap..
             if (isset($delegate) and method_exists($delegate, 'afterRegister')) {
                 $res = $delegate->afterRegister($rec);
                 if (PEAR::isError($res)) {
                     return $res;
                 }
             }
             if (isset($appdel) and method_exists($appdel, 'afterRegister')) {
                 $res = $appdel->afterRegister($rec);
                 if (PEAR::isError($res)) {
                     return $res;
                 }
             }
             // We accept --redirect markers to specify which page to redirect
             // to after we're done.  This will usually be the page that the
             // user was on before they went to the login page.
             if (isset($_SESSION['--redirect'])) {
                 $url = $_SESSION['--redirect'];
             } else {
                 if (isset($_SESSION['-redirect'])) {
                     $url = $_SESSION['-redirect'];
                 } else {
                     if (isset($_REQUEST['--redirect'])) {
                         $url = $_REQUEST['--redirect'];
                     } else {
                         if (isset($_REQUEST['-redirect'])) {
                             $url = $_REQUEST['-redirect'];
                         } else {
                             $url = $app->url('-action=' . $app->_conf['default_action']);
                         }
                     }
                 }
             }
             if (@$params['email_validation']) {
                 $individual = $this->ontology->newIndividual($this->form->_record);
                 $msg = df_translate('actions.register.MESSAGE_THANKYOU_PLEASE_VALIDATE', 'Thank you. An email has been sent to ' . $individual->strval('email') . ' with instructions on how to complete the registration process.', array('email' => $individual->strval('email')));
             } else {
                 // To save the user from having to log in after he has just filled
                 // in the registration form, we will just log him in right here.
                 $_SESSION['UserName'] = $this->form->exportValue($app->_conf['_auth']['username_column']);
                 $msg = df_translate('actions.register.MESSAGE_REGISTRATION_SUCCESSFUL', "Registration successful.  You are now logged in.");
             }
             // Now we actually forward to the success page along with a success message
             if (strpos($url, '?') === false) {
                 $url .= '?';
             }
             $app->redirect($url . '&--msg=' . urlencode($msg));
         }
     }
     // We want to display the form, but not yet so we will use an output buffer
     // to store the form HTML in a variable and pass it to our template.
     ob_start();
     $this->form->display();
     $out = ob_get_contents();
     ob_end_clean();
     $context = array('registration_form' => $out);
     // We don't want to keep the registration page in history, because we want to
     // be able to redirect the user back to where he came from before registering.
     $app->prefs['no_history'] = true;
     df_display($context, 'Dataface_Registration.html');
 }
Exemple #5
0
 function _build()
 {
     if ($this->_built) {
         return;
     }
     $app =& Dataface_Application::getInstance();
     $mainQuery = $app->getQuery();
     /*
      * Add necessary flag fields so that the controller will find its way back here
      * on submit.
      */
     $this->addElement('hidden', '-table');
     $this->addElement('hidden', '--step');
     $this->addElement('hidden', '-relationship');
     $this->addElement('hidden', '-query');
     $this->addElement('hidden', '-action');
     $this->setDefaults(array('-table' => $this->_table->tablename, '--step' => $this->_step, '-action' => 'import', '-query' => $_SERVER['QUERY_STRING']));
     if ($this->_relationship !== null) {
         $this->setDefaults(array('-relationship' => $this->_relationship->getName()));
     }
     /*
      * Add keys of the current record as hidden fields so that we know we are importing
      * into the correct record.
      */
     $factory = new HTML_QuickForm('factory');
     $keyEls = array();
     $keyDefaults = array();
     foreach (array_keys($this->_table->keys()) as $key) {
         $keyEls[] = $factory->addElement('hidden', $key);
     }
     $this->addGroup($keyEls, '__keys__');
     $keyvals = array();
     if (is_object($this->_record)) {
         foreach (array_keys($this->_table->keys()) as $key) {
             $keyvals[$key] = $this->_record->getValueAsString($key);
         }
     }
     $this->setDefaults(array('__keys__' => $keyvals));
     /*
      * Now add the fields of the form.
      */
     if (intval($this->_step) === 1) {
         /*
          * Import filters define what formats can be imported into the table.
          */
         if ($this->_relationship === null) {
             $filters =& $this->_table->getImportFilters();
             $currentTableName = $this->_table->tablename;
             $currentTable =& $this->_table;
             $df_factory = df_create_new_record_form($currentTableName);
             $fields = $this->_table->fields(false, true);
         } else {
             $domainTablename = $this->_relationship->getDomainTable();
             if (PEAR::isError($domainTable)) {
                 $destTables =& $this->_relationship->getDestinationTables();
                 $domainTablename = $destTables[0];
             }
             $domainTable =& Dataface_Table::loadTable($domainTablename);
             $currentTable =& $domainTable;
             $currentTablename = $domainTable->tablename;
             $filters =& $domainTable->getImportFilters();
             //$df_factory = df_create_new_related_record_form($currentTablename, $this->_relationship->getName());
             $df_factory = df_create_new_record_form($domainTable->tablename);
             //$df_factory->_build();
             $fields = $domainTable->fields(false, true);
         }
         $options = array(0 => df_translate('scripts.GLOBAL.FORMS.OPTION_PLEASE_SELECT', 'Please select ...'));
         foreach (array_keys($filters) as $key) {
             $options[$key] = $filters[$key]->label;
             $this->_filterNames[] = $key;
         }
         $this->addElement('select', 'filter', df_translate('scripts.Dataface.ImportForm._build.LABEL_IMPORT_FILE_FORMAT', 'Import File Format:'), $options, array('onchange' => 'updateFilterDescription(this.options[this.options.selectedIndex].value)'));
         $this->addElement('textarea', 'content', df_translate('scripts.Dataface.ImportForm._build.LABEL_PASTE_IMPORT_DATA', 'Paste Import Data'), array('cols' => 60, 'rows' => 10));
         $this->addElement('file', 'upload', df_translate('scripts.Dataface.ImportForm._build.LABEL_UPLOAD_IMPORT_DATA', 'Upload Import Data'));
         $defaultValsEl =& $this->addElement('optionalelement', '__default_values__', 'Default Values');
         require_once 'dataface-public-api.php';
         foreach (array_keys($fields) as $field) {
             if ($fields[$field]['widget']['type'] == 'hidden') {
                 $fields[$field]['widget']['type'] = 'text';
             }
             $tempEl = $df_factory->_buildWidget($fields[$field]);
             if (!$tempEl->getLabel() || $tempEl->_type == 'hidden') {
             } else {
                 $defaultValsEl->addField($tempEl);
             }
             unset($tempEl);
         }
         $this->addElement('submit', 'submit', 'Submit');
         $this->addRule('filter', 'required', df_translate('scripts.Dataface.ImportForm._build.MESSAGE_IMPORT_FILE_FORMAT_REQUIRED', 'Import File Format is a required field'), null, 'client');
     } else {
         /*
          * We are in step 2 where we are verifying the data only.
          */
         //$this->addElement('submit', 'back', 'Data is incorrect. Go back');
         $this->addElement('submit', 'continue', df_translate('scripts.Dataface.ImportForm._build.MESSAGE_PROCEED_WITH_IMPORT', 'Looks good.  Proceed with import'));
         $this->addElement('hidden', '--importTablename');
         $this->setDefaults(array('--importTablename' => $_REQUEST['--importTablename']));
     }
     // Set the return page
     $returnPage = @$_SERVER['HTTP_REFERER'];
     if (isset($mainQuery['-redirect'])) {
         $returnPage = $mainQuery['-redirect'];
     } else {
         if (isset($mainQuery['--redirect'])) {
             $returnPage = $mainQuery['--redirect'];
         }
     }
     //print_r($mainQuery);exit;
     if (!$returnPage) {
         if (isset($this->_relationship)) {
             $returnPage = $app->url('-action=related_records_list&-relationship=' . $this->_relationship->getName());
         } else {
             $returnPage = $app->url('-action=list');
         }
     }
     $this->addElement('hidden', '--redirect');
     $this->setDefaults(array('--redirect' => $returnPage));
     $this->_built = true;
 }