public function ajaxFunctions($params = array(), $ajaxObj) { require_once t3lib_extMgm::extPath('mailformplus_admin') . 'classes/class.tx_mailformplusadmin.php'; $scope = htmlspecialchars(t3lib_div::_GP("scope")); $query = htmlspecialchars(t3lib_div::_GP("query")); $action = htmlspecialchars(t3lib_div::_GP("action")); $pid = htmlspecialchars(t3lib_div::_GP("pid")); $firstrun = htmlspecialchars(t3lib_div::_GP("firstrun")); $user = $GLOBALS["BE_USER"]->user["uid"]; $lang = 'se'; //$GLOBALS['LANG']; $sid = htmlspecialchars(t3lib_div::_GP("sid")); $myAjaxObj = new tx_mailformplusadmin(); $content = $myAjaxObj->ajaxFunctions($action, $scope, $query, $lang, $user, $pid, $firstrun); if ($action === 'getFormStructure' or $action === 'printDetail' or $action === 'printList' or $action === 'printColumns' or $action === 'exportChoice' or $action === 'deleteRow' or $action === 'updateRow' or $action === 'saveColumns' or $action === 'updateRow') { echo $content; } else { return $content; } }
function showFormhandler($pluginId, $to_email, $subject, $content_email) { /*$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_formhandler_pi1.']; print_r($conf); $conf["debug"] = 1; $conf["templateFile"] = "typo3conf/ext/mailformplus_admin/templates/template.html"; $conf["langFile"] = "typo3conf/ext/mailformplus_admin/templates/lang.xml"; //$conf["name"] = "myform"; $conf["formValuesPrefix"] = "formhandler"; $conf["finishers"][1]["class"] = "Tx_Formhandler_Finisher_Mail"; $conf["finishers"][2]["class"] = "Tx_Formhandler_Finisher_SubmittedOK"; $conf["returns"] = 1; // Get plugin instance $cObj = t3lib_div::makeInstance('tslib_cObj'); $cObj->start(array(), ''); $objType = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_formhandler_pi1']; $content = $cObj->cObjGetSingle($objType, $conf);*/ // Formhandler einbinden require_once t3lib_extMgm::extPath("formhandler") . "pi1/class.tx_formhandler_pi1.php"; // Neue Instanz erzeugen $formhandler = new tx_formhandler_pi1(); // Dem Formhandler ein cObj geben $formhandler->cObj = t3lib_div::makeInstance('tslib_cObj'); // Die TypoScript Konfiguration abrufen // Dabei zu beachten: die Punkte am Ende der Keys $config = $GLOBALS["TSFE"]->tmpl->setup['plugin.']['tx_mailformplusadmin_pi2.']['formhandler.']; $config["templateFile"] = "typo3conf/ext/mailformplus_admin/templates/step-1.html"; $config['finishers']['1']['config']['admin']['to_email'] = $to_email; #$config["masterTemplateFile"] = "typo3conf/ext/mailformplus_admin/templates/mastertemplate.html"; /* '' * Rendern des Forumlars */ $content = $formhandler->main("Formular", $config); unset($config, $formhandler); // Die gerenderte Form an das Template übergeben //$this->view->assign("form",$form); require_once t3lib_extMgm::extPath('mailformplus_admin') . 'classes/class.tx_mailformplusadmin.php'; $ajaxObj = new tx_mailformplusadmin(); $formStructure = $ajaxObj->getFormStructure($pluginId . ':tt_content'); $formStructure = str_replace('{"fields"', '{"html"', $formStructure); $formStructure = str_replace('"label"', '"caption"', $formStructure); $formStructure = str_replace('"field_type"', '"type"', $formStructure); //$formStructure = str_replace('[','',$formStructure); //$formStructure = str_replace(']','',$formStructure); $json = json_decode($formStructure, true); //echo 'sucker'; foreach ($json['html'] as $key => $value) { $json['html'][$key]['name'] = 'formhandler[' . $value['caption'] . ']'; $json['html'][$key]['value'] = 'test'; //REmove later! $json['html'][$key]['id'] = $value['caption']; } $key++; $json['html'][$key]['type'] = 'p'; $json['html'][$key]['html'] = '<img class="formhandler-ajax-submit" src="../typo3conf/ext/formhandler/Resources/Images/ajax-loader.gif"/>'; $key++; $json['html'][$key]['type'] = 'hidden'; $json['html'][$key]['name'] = 'to_email'; $json['html'][$key]['value'] = $to_email; $key++; $json['html'][$key]['type'] = 'hidden'; $json['html'][$key]['name'] = 'subject'; $json['html'][$key]['value'] = $subject; $key++; $json['html'][$key]['type'] = 'hidden'; $json['html'][$key]['name'] = 'pluginId'; $json['html'][$key]['value'] = $pluginId; $formStructure = json_encode($json); $formStructure = ltrim($formStructure, '{'); $formStructure = rtrim($formStructure, '}'); //{"fields":[{"label":"fffff","field_type":"text","required":true,"field_options":{"size":"small"},"cid":"c2"},{"label":"eeeee","field_type":"text","required":true,"field_options":{"size":"small"},"cid":"c6"},{"label":"qqqqq","field_type":"text","required":true,"field_options":{"size":"small"},"cid":"c10"},{"label":"wwww","field_type":"text","required":true,"field_options":{"size":"small"},"cid":"c11"}],"formtitle":"qqq","formdescription":"qqq","user":"******"} $content .= ' <style type="text/css"> .loading_ajax-submit { display:none; } .ui-dform-text { display:block; } </style> <script type="text/javascript"> function attachValidationEvents() { } jQuery(document).ready(function () { // Generate a form jQuery("#Formular").dform({ "action" : "' . $_SERVER["REQUEST_URI"] . '", "method" : "post", "enctype" : "multipart/form-data",' . $formStructure . ', "id" : "newForm" }); jQuery("#newForm").append(jQuery("#receive-copy").parent().parent()); jQuery("#newForm").append(jQuery("#fomhandler_submit").parent().parent()); }); </script>'; return $content; }
<?php require_once t3lib_extMgm::extPath('mailformplus_admin') . 'classes/class.tx_mailformplusadmin.php'; $ajaxObj = new tx_mailformplusadmin(); $id = $_GET['id']; $formStructure = $ajaxObj->getFormStructure(intval($id)); $template_form1 = '<!-- ###TEMPLATE_FORM1### begin --> <div id="form_body" > <form class="form-horizontal" name="Formular" id="Formular" method="post" action="###REL_URL###" enctype="multipart/form-data"> <input type="hidden" name="id" id="id" value="###PID###" /> <input type="hidden" name="submitted" value="1" /> <input type="hidden" name="L" value="###value_L###" /> <label>* = ###LLL:mandatory###</label> <img class="formhandler-ajax-submit" src="../typo3conf/ext/formhandler/Resources/Images/ajax-loader.gif"/> <div class="control-group"> <label class="control-label" for="first_name">###LLL:first_name### ###required_first_name###</label> <div class="controls"> <input class="formhandler_input" type="text" placeholder="###LLL:first_name###" name="formhandler[first_name]" id="first_name" value="###value_first_name###" tabindex="1"/> ###error_first_name### </div> </div> <div class="control-group"> <label class="control-label" for="last_name">###LLL:last_name### ###required_last_name###</label> <div class="controls"> <input class="formhandler_input" type="text" placeholder="###LLL:last_name###" name="formhandler[last_name]" id="last_name" value="###value_last_name###" tabindex="2"/> ###error_last_name### </div> </div>
function saveFormStructure($action, $scope, $query, $lang, $user, $pid, $firstrun) { $ajaxObj = new tx_mailformplusadmin(); $content = $ajaxObj->ajaxFunctions($action, $scope, $query, $lang, $user, $pid, $firstrun); echo $content; }