public function formSubmission($request)
 {
     $form = new Form();
     $fi = new FormInput();
     $fs = new FormSubmission();
     if (!empty($request['process_form'])) {
         $fs->submitForm($request);
     } else {
         if (!empty($request['view_form'])) {
             $form_id = $request['form_id'];
             $form = new Form($form_id);
             $form_head['form_id'] = array('type' => 'hidden', 'value' => $form_id);
             $form->insertInput($form_head);
             $form->display(null, true);
         } else {
             if (!empty($request['view_submissions'])) {
                 $fs->displaySubmissions($request['form_id']);
             } else {
                 if (!empty($request['view_submission'])) {
                     $fs->displaySubmission($request['submission_id']);
                 } else {
                     if (!empty($request['edit_form'])) {
                         echo admin_url('admin.php?page=sof_builder&id=' . $request['form_id']);
                     } else {
                         if (!empty($request['delete_form'])) {
                             $form->deleteForm($request['form_id']);
                             echo admin_url('admin.php?page=sof_info');
                         }
                     }
                 }
             }
         }
     }
 }
<?php

require_once dirname(__FILE__) . '/../classes/FormSubmission.class.php';
require_once dirname(__FILE__) . '/../classes/FormInput.class.php';
require_once dirname(__FILE__) . '/../classes/Form.class.php';
$fi = new FormInput();
$fs = new FormSubmission();
if (!empty($_REQUEST['process_form'])) {
    $fs->submitForm($_REQUEST);
} else {
    if (!empty($_REQUEST['view_form'])) {
        $form_id = $_REQUEST['form_id'];
        $form = new Form($form_id);
        $form_head['form_id'] = array('type' => 'hidden', 'value' => $form_id);
        $form->insertInput($form_head);
        $form->display(null, true);
    } else {
        if (!empty($_REQUEST['view_submissions'])) {
            $fs->displaySubmissions($_REQUEST['form_id']);
        } else {
            if (!empty($_REQUEST['view_submission'])) {
                $fs->displaySubmission($_REQUEST['submission_id']);
            }
        }
    }
}