function onSubmit() { if (!empty($this->data)) { $this->save(); } $this->redirect(parent::getSuccessRedirect()); }
function toHtml() { $this->_initTemplate(); $formcontroller = new FormController(); for ($i = 0; $i < count($this->_arr_form); $i++) { $formcontroller->form =& $this->_arr_form[$i]; $arr_form = $formcontroller->toTemplate(); $name = $this->_arr_form[$i]->getAttribute('name'); $this->smarty->assign($name, $arr_form); } $controller = new ComponentController($this->_container); $arr_component = $controller->toTemplate(); $this->smarty->assign("component", $arr_component); foreach ($this->_arr_output as $key => $value) { $this->smarty->assign($key, $value); } $this->smarty->display($this->template); }
for ($i = 0; $i < count($arr_field); $i++) { $arr_checkbox[$arr_field[$i]['name']] = ''; } $checkbox2 =& $form->addElement('checkbox'); $checkbox2->setAttribute('id', 'is_list'); $checkbox2->setAttribute('checkboxes', $arr_checkbox); $checkbox2->return_type = 'array'; $button1 =& $form->addElement('reset'); $button1->setAttribute('id', 'resetbutton'); $button1->setAttribute('value', 'Reset'); $button2 =& $form->addElement('submit'); $button2->setAttribute('id', 'submitbutton'); $button2->setAttribute('value', 'Submit'); $button3 =& $form->addElement('backbutton'); $form_op =& $form->addElement('hidden'); $form_op->setAttribute('id', 'op'); $form_op->setAttribute('value', 'gen_generate'); $hidden2 =& $form->addElement('hidden'); $hidden2->setAttribute('id', 'table_name'); $hidden2->setAttribute('value', $arr_table[$current_table]['name']); $formcontroller = new FormController($form); $arr_form = $formcontroller->toTemplate(); $smarty->assign("data", $arr_field); $smarty->assign("form", $arr_form); $smarty->assign('table_name', $arr_table[$current_table]['name']); $smarty->assign('INPUT_TITLE', INPUT_TITLE); $smarty->assign('TABLE', TABLE); $smarty->assign('FIELD', FIELD); $smarty->assign('maincontent', 'gen_input.html'); $smarty->display($view); //print_r($arr_field);
public function initialize() { parent::initialize(); }
<?php $scriptpath = substr($_SERVER['SCRIPT_FILENAME'], 0, -4); $paths = explode(DIRECTORY_SEPARATOR, $scriptpath); $myName = end($paths); require $scriptpath . '/fbapp/php/config.inc.php'; if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { $ctl = new FormController(); $ctl->Dispatch(); } else { if (!isset($_GET['action'])) { $myPage->ReportStats('NotifyFormView'); } } ob_start(); $myPage->Show(); ob_end_flush();
var_dump($form->getData()); } else { //print_r(getFormErrorMessages($form)); } $formView = $form->createView(); $form2 = clone $form; $formView2 = $form2->createView(); $form3 = clone $form; $formView3 = $form3->createView(); // ------------------------------------------------------------------ // initiate smarty & set basic stuff to get it going $smarty = new Smarty(); $smarty->setTemplateDir(__DIR__ . '/../views/'); $smarty->setCompileDir('/tmp/test-standalone-forms-templates_c/'); // initiate our 'controller' (which is just a temp class which will hold our helper function) $formController = new FormController(); $formController->setSymfonyVendorDir(__DIR__ . '/../vendor/symfony'); // register the form plugins with smarty, passing in the form helper which it talks to $plugins = new SmartyFormPlugins($formController->getFormHelper()); $plugins->registerFormPluginsWithSmarty($smarty); // give smarty some variables to play with to demonstrate everything works $smarty->assign(['form' => $formView, 'form2' => $formView2, 'form3' => $formView3, 'isValid' => $form->isValid(), 'isSubmitted' => $form->isSubmitted()]); // show the form as it should be. $smarty->display('test.tpl'); echo "<hr />\n\n\n"; // alternatively, we can also generate the form using raw PHP instead too; $formView = $form->createView(); $form_helper = $formController->getFormHelper(); echo 'Start: ' . $form_helper->start($formView) . "\n"; echo 'Fields: ' . $form_helper->rest($formView) . "\n"; echo 'End: ' . $form_helper->end($formView) . "<br />\n";
<?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once $_SERVER['DOCUMENT_ROOT'] . '/comment_mail_test/db/init_db.php'; global $link; include $_SERVER['DOCUMENT_ROOT'] . 'comment_mail_test/controller/form_controller.php'; $controll = new FormController(); if (isset($_POST['email']) && isset($_POST['email']) != "") { /*echo '<script type="text/javascript"> $(document).ready(function(){ $("#modal_alert").modal("show"); jQuery(".close").css("display", "none"); jQuery(".modal-message").css("display", "none"); jQuery(".modal-footer").css("display", "none"); }); </script>';*/ $controll->set_data(); $controll->get_view(); $controll->send_email(); } else { $controll->get_last_comments(); }
public function getComponents() { return parent::getComponents(); }
reason_include_once('classes/page_types.php'); reason_include_once('minisite_templates/page_types.php'); reason_include_once('classes/session_php.php'); include_once DISCO_INC . 'controller.php'; if (!carl_is_php5()) { echo '<p>Sorry this requires php 5 for now</p>'; die; } // Require that whomever is using the form have access. reason_require_authentication('', 'session'); // Include all of the forms. reason_include_once('scripts/developer_tools/page_type_wizard/SelectForm.php'); reason_include_once('scripts/developer_tools/page_type_wizard/EditForm.php'); reason_include_once('scripts/developer_tools/page_type_wizard/FormatForm.php'); //Initialize the controller and set a few options. $controller = new FormController(); $controller->set_session_class('Session_PHP'); $controller->set_session_name('REASON_SESSION'); $controller->set_data_context('page_type_wizard'); $controller->show_back_button = true; $controller->clear_form_data_on_finish = false; $controller->allow_arbitrary_start = false; // Set up the progression of forms. $forms = array('SelectForm' => array('start_step' => true, 'next_steps' => array('EditForm' => array('label' => 'Select this page type')), 'step_decision' => array('type' => 'user')), 'EditForm' => array('next_steps' => array('FormatForm' => array('label' => 'Next')), 'step_decision' => array('type' => 'user')), 'FormatForm' => array('final_step' => array('label' => 'export'))); // Add, init, and run the forms. $controller->add_forms($forms); $controller->init(); //$controller->set_request( $_REQUEST ); $controller->run(); ?> </body>
echo '<body>' . "\n"; if (isset($_GET['report'])) { $link = carl_make_link(array('report' => '')); $cache = new ReasonObjectCache($_GET['report']); $report =& $cache->fetch(); if (isset($report['report'])) { echo '<h2>Full Report</h2>'; echo $report['report']; } else { echo '<p>Nothing to Report</p>'; } $link = carl_make_link(array('report' => '')); echo '<p><a href="' . $link . '">Do another Wordpress Import</a></p>'; } else { // Initialize the controller and set a few options. $controller = new FormController(); $controller->set_session_class('Session_PHP'); $controller->set_session_name('REASON_SESSION'); $controller->set_data_context('wordpress_import'); $controller->show_back_button = false; $controller->clear_form_data_on_finish = true; $controller->allow_arbitrary_start = false; $controller->reason_user_id = $reason_user_id; // Set up the progression of forms. $forms = array('SetupForm' => array('start_step' => true, 'next_steps' => array('ConfirmForm' => array('label' => 'Continue')), 'step_decision' => array('type' => 'user')), 'ConfirmForm' => array('final_step' => 'true', 'final_button_text' => 'Confirm')); $controller->add_forms($forms); $controller->init(); $controller->run(); } echo '</body>'; echo '</html>';
/** * 推送栏目页的某个分页 * * @param int $id 栏目id * @param int $page 总页码 */ public function categoryPush($id, $page, $publicdata, $last_html_precent, $html_precent) { $paths = []; $result = $publicdata['result']; $result['navs'] = $this->publicnavs($id); $result['index_navs'] = $result['navs']; foreach ((array) $result['navs'] as $nav) { if ($nav['current'] == 1) { $pagenavs = $nav['childmenu']; break; } else { $pagenavs = []; } } $classify = Classify::find($id); $customerinfo = CustomerInfo::where("cus_id", $this->cus_id)->first(); $result['title'] = $customerinfo->title != "" ? $customerinfo->title . '-' . $classify->name : $classify->name; $result['keywords'] = $classify->meta_keywords != "" ? $classify->meta_keywords : $customerinfo->keywords; $result['description'] = $classify->meta_description != "" ? $classify->meta_description : $customerinfo->description; $result['list']['name'] = $classify->name; $result['list']['en_name'] = $classify->en_name; $result['list']['description'] = $classify->meta_description; $result['list']['icon'] = '<i class="iconfont">' . $classify->icon . '</i>'; $result['list']['image'] = $classify->img ? $this->source_dir . 's/category/' . $classify->img : ''; $result['list']['type'] = $classify->type; if ($this->showtype == 'preview') { $result['list']['link'] = $this->domain . '/category/' . $id; } else { $result['list']['link'] = $this->domain . '/category/' . $id . '.html'; } $result['pagenavs'] = $pagenavs; $result['posnavs'] = $this->getPosNavs($id); if ($classify->type == 1) { //文字列表 $viewname = 'list-text'; } elseif ($classify->type == 2) { //图片列表 $viewname = 'list-image'; } elseif ($classify->type == 3) { //图文列表 $viewname = 'list-imagetext'; } elseif ($classify->type == 4) { //内容单页 $viewname = 'list-page'; } elseif ($classify->type == 5) { //留言板 $viewname = 'list-page'; } elseif ($classify->type == 9) { //万用表单 //===获取数据=== $viewname = 'list-page'; $form_id = $classify->form_id; $formC = new FormController(); $formCdata = $formC->getFormdataForPrint($form_id); } else { //跳转404 } if (in_array($classify->type, array(1, 2, 3, 4, 5, 9))) { $sub = str_replace('-', '_', $viewname); $data = $this->pagedata($viewname, $publicdata['pagedata']); $index = $this->detailList($data); $result = array_add($result, $sub, $index); $data_index = $this->pagedata($viewname); if ($classify->type == 4) { if ($this->showtype == 'preview') { $result['list']['content'] = Page::where('id', $classify->page_id)->pluck('content'); } else { $result['list']['content'] = preg_replace('/\\/customers\\/' . $this->customer . '/i', '', Page::where('id', $classify->page_id)->pluck('content')); } } elseif ($classify->type == 5) { $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); if ($customer_info->lang == 'en') { $result['list']['content'] = '<form action="http://swap.5067.org/message/' . $this->cus_id . '" method="post" name="messageboard" onsubmit="return CheckPost();" class="elegant-aero"> <h1>' . $classify->name . ' <span>' . $classify->en_name . '</span> </h1> <label> <span>Name :</span> <input id="name" type="text" name="name" placeholder="Name" /> </label> <label> <span>Email :</span> <input id="email" type="email" name="email" placeholder="Email Address" /> </label> <label> <span>Tel :</span> <input id="telephone" type="tel" name="telephone" placeholder="Telephone" /> </label> <label> <label> <span>Content :</span> <textarea id="content" name="content" placeholder="You mind ...."></textarea> </label> <label> <span> </span> <input type="submit" class="button" name="submit" value="Submit" /> </label> </form>'; } else { $result['list']['content'] = '<form action="http://swap.5067.org/message/' . $this->cus_id . '" method="post" name="messageboard" onsubmit="return CheckPost();" class="elegant-aero"> <h1>' . $classify->name . ' <span>' . $classify->en_name . '</span> </h1> <label> <span>姓名 :</span> <input id="name" type="text" name="name" placeholder="Name" /> </label> <label> <span>Email :</span> <input id="email" type="email" name="email" placeholder="Email Address" /> </label> <label> <span>联系电话 :</span> <input id="telephone" type="tel" name="telephone" placeholder="Telephone" /> </label> <label> <span>内容 :</span> <textarea id="content" name="content" placeholder="You mind ...."></textarea> </label> <label> <span> </span> <input type="submit" class="button" name="submit" value="提交" /> </label> </form>'; } } elseif ($classify->type == 9) { //===显示前端=== $result['list']['content'] = $formC->showFormHtmlForPrint($formCdata); } $json_keys = $this->getJsonKey($viewname . '.html'); if (count($json_keys)) { foreach ($json_keys as $key) { $result[$key] = $this->detailList($this->pagedata($key)); } } if ($classify->type == 5) { $result['footscript'] .= '<STYLE TYPE="text/css"> <!-- .elegant-aero { margin-left:auto; margin-right:auto; width: 90%; max-width: 500px; /*background: #D2E9FF;*/ padding: 20px 20px 20px 20px; font: 12px Arial, Helvetica, sans-serif; /*color: #666;*/ } .input[placeholder]{color:#5c5c5c;} .elegant-aero h1 { font: 24px "Trebuchet MS", Arial, Helvetica, sans-serif; padding: 10px 10px 10px 20px; display: block; /*background: #C0E1FF;*/ border-bottom: 1px solid #B8DDFF; margin: -20px -20px 15px; } .elegant-aero h1>span { display: block; font-size: 11px; } .elegant-aero label>span { float: left; margin-top: 10px; /*color: #5E5E5E;*/ } .elegant-aero label { display: block; margin: 0px 0px 5px; } .elegant-aero label>span { float: left; width: 25%; text-align: right; padding-right: 10px; margin-top: 10px; font-weight: bold; } .elegant-aero input[type="text"], .elegant-aero input[type="tel"], .elegant-aero input[type="email"], .elegant-aero textarea, .elegant-aero select { color: #888; width: 65%; padding: 0px 0px 0px 5px; border: 1px solid #C5E2FF; background: #FBFBFB; outline: 0; -webkit-box-shadow:inset 0px 1px 6px #ECF3F5; box-shadow: inset 0px 1px 6px #ECF3F5; font: 200 12px/25px Arial, Helvetica, sans-serif; height: 30px; line-height:15px; margin: 2px 4px 16px 0px; } .elegant-aero textarea{ height:100px; padding: 5px 0px 0px 5px; width: 65%; } .elegant-aero select { background: #fbfbfb url(\'down-arrow.png\') no-repeat right; background: #fbfbfb url(\'down-arrow.png\') no-repeat right; appearance:none; -webkit-appearance:none; -moz-appearance: none; text-indent: 0.01px; text-overflow: \'\'; width: 70%; } .elegant-aero .button{ padding: 10px 30px 10px 30px; background: #ACB5B7; border: none; color: #FFF; box-shadow: 1px 1px 1px #4C6E91; -webkit-box-shadow: 1px 1px 1px #4C6E91; -moz-box-shadow: 1px 1px 1px #4C6E91; text-shadow: 1px 1px 1px #5079A3; } .elegant-aero .button:hover{ background: #C5CFD2; color: #6B6262; }--> </STYLE> <SCRIPT language=javascript> function CheckPost() { if (messageboard.name.value=="") { alert("请填写您的姓名"); messageboard.name.focus(); return false; } if (messageboard.content.value=="") { alert("必须要填写留言内容"); messageboard.content.focus(); return false; } if (messageboard.telephone.value!="") { if(isNaN(messageboard.telephone.value)){ alert("电话号码请填写数字"); messageboard.telephone.focus(); return false; } if(!(/^1[3|4|5|7|8]\\d{9}$/.test(messageboard.telephone.value))){ alert("手机号码有误"); messageboard.telephone.focus(); return false; } } } </SCRIPT>'; } if ($classify->type == 9) { //===加载css\js=== $result['footscript'] .= $formC->assignFormCSSandJSForPrint(); } $the_result = $result; $index_list = $this->pageList($id, 1); $the_result['page_links'] = $index_list['page_links']; //===显示类型不是'list-page'=== if ($classify->type != 5 && $classify->type != 4 && $classify->type != 9) { $the_result['list']['data'] = $index_list['data']; $the_result['list']['total'] = $index_list['page_links']['total']; } //===页面名字.html=== // if ($classify->view_name) { // $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/v/' . $classify->view_name . '.html') : public_path('customers/' . $this->customer . '/mobile/category/v/' . $classify->view_name . '.html'); // } else { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $id . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $id . '.html'); // } $content = $publicdata['repleace'][$viewname . '.html']; $content = preg_replace($publicdata['pattern'], $publicdata['repleace'], $content); $output = $this->pushdisplay($the_result, $content); if (!count($result['footer_navs'])) { $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>Home<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); } file_put_contents($path, $output); $paths[] = $path; $nowpercent = $last_html_precent + $html_precent; if (floor($nowpercent) !== floor($last_html_precent)) { echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>'; ob_flush(); flush(); PushQueue::where('pushtime', '<', time() - 60)->delete(); PushQueue::where('cus_id', $this->cus_id)->update(['pushtime' => time()]); } $last_html_precent += $html_precent; //===显示类型不是'list-page'=== if ($classify->type != 5 && $classify->type != 4 && $classify->type != 9) { for ($i = 1; $i <= $page; $i++) { $the_result = $result; $index_list = $this->pageList($id, $i); $the_result['page_links'] = $index_list['page_links']; $the_result['list']['data'] = $index_list['data']; $the_result['list']['total'] = $index_list['page_links']['total']; //===页面名字.html=== if ($classify->view_name) { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $classify->view_name . '_' . $i . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $classify->view_name . '_' . $i . '.html'); } else { $path = $this->type == 'pc' ? public_path('customers/' . $this->customer . '/category/' . $id . '_' . $i . '.html') : public_path('customers/' . $this->customer . '/mobile/category/' . $id . '_' . $i . '.html'); } //===end=== $output = $this->pushdisplay($the_result, $content); if (!count($result['footer_navs'])) { $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>Home<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); } file_put_contents($path, $output); $paths[] = $path; $nowpercent = $last_html_precent + $html_precent; if (floor($nowpercent) !== floor($last_html_precent)) { echo '<div class="prompt">' . floor($nowpercent) . '%</div><script type="text/javascript">refresh(' . floor($nowpercent) . ');</script>'; ob_flush(); flush(); PushQueue::where('pushtime', '<', time() - 60)->delete(); PushQueue::where('cus_id', $this->cus_id)->update(['pushtime' => time()]); } $last_html_precent += $html_precent; } } return $paths; //return View::make('templates.'.$this->themename.'.'.$viewname,$result); } }
<?php header("Content-Type:application/json"); include '../controller/FormController.php'; $form = new FormController(); if ($_POST['action'] == "save") { $form->save($_POST['forms']); } else { if ($_POST['action'] == "getRef") { $form->getRef($_POST); } else { if ($_POST['action'] == "getForm") { $form->getForm($_POST); } else { if ($_POST['action'] == "getTopic") { $form->getTopic($_POST); } } } }
public function Show() { if (isset($_GET['action'])) { $content = $_GET['action']; } elseif (isset($_GET['merchant_return_link']) && $_GET['merchant_return_link']) { // PayPal sends it's own query string when the return after payment link is clicked, // set our 'checkedout' state if found $content = 'checkedout'; } else { $content = ''; } if (Config::GetInstance()->UsePayments() || empty($content)) { // session is needed for payments and most submits that have '?action' set Config::GetInstance()->InitSession(); // clear any old sessions when showing a fresh form to clear payment stuff if (empty($content)) { Config::GetInstance()->ClearSession(); } } // check what content to show switch ($content) { case 'confirmation': case 'checkout': $this->_PageFromSession(); break; case 'cancel': $this->SetErrors(array(array('field' => 'Form', 'err' => _T('Payment transaction cancelled.')))); // fall through // fall through case 'back': // show the original page after canceling a payment transaction $this->RestorePostFromSession(); $this->HandleErrors(); echo $this->source; $this->_UpdateCartState('cancelled'); break; case 'checkedout': $this->_UpdateCartState('checked-out'); $this->RestorePostFromSession(); $ctl = new FormController(); $ctl->checkedout = true; $ctl->ShowUserConfirmation(); break; case 'submitpayment': // sent by Javascript when user pushed on a 'Pay' button $this->RestorePostFromSession(false); // don't clear session, it is needed upon 'checkedout' // ensure the merger has access to cart details $payment = new CheckoutController(); MessagePostMerger::GetInstance()->cart = $payment->getCartInstance(); // send the emails $this->SendEmails(); // prepare feedback if (count($this->errors) == 0) { echo 'ok'; } else { echo json_encode($this->errors); } break; default: if ($this->source === false) { $this->ReadSource(); } if ($this->source !== false) { echo $this->source; } else { trigger_error('Read the template BEFORE trying to send it to a user.', E_USER_WARNING); } break; } }
function run() { $nametag = $this->admin_page->user_id; $face = $this->admin_page->authenticated_user_id; if (empty($_REQUEST['site_id'])) { echo "Please select a site to get started."; return; } if (!empty($_REQUEST['newsletterIsFinished'])) { echo "<h1>Newsletter sent!</h1>"; echo "<h2>Process complete.<h2>"; echo '<p><a href="' . $this->admin_page->make_link(array('newsletterIsFinished' => '')) . '">Send another newsletter</a></p>' . "\n"; return; } $controller = new FormController(); $controller->set_session_class('Session_PHP'); $controller->set_session_name('REASON_SESSION'); $controller->set_data_context('newsletter_maker_' . $this->admin_page->site_id); $controller->show_back_button = true; $controller->clear_form_data_on_finish = true; $controller->allow_arbitrary_start = false; $controller->authenticated_user_id = $face; $controller->user_id = $face; if ($nametag != $face) { if (reason_user_has_privs($face, 'pose_as_other_user')) { $controller->user_id = $nametag; } } // Set up the progression of forms. $forms = array('SelectIncludes' => array('start_step' => true, 'next_steps' => array('SelectItems' => array('label' => 'Continue')), 'step_decision' => array('type' => 'user')), 'SelectItems' => array('next_steps' => array('SelectTemplate' => array('label' => 'Continue')), 'step_decision' => array('type' => 'user')), 'SelectTemplate' => array('next_steps' => array('EditNewsletter' => array('label' => 'Continue')), 'step_decision' => array('type' => 'user')), 'EditNewsletter' => array('next_steps' => array('ComposeEmail' => array('label' => 'Continue')), 'step_decision' => array('type' => 'user')), 'ComposeEmail' => array('final_step' => true)); // Add, init, and run the forms. $controller->add_forms($forms); $controller->init(); $controller->preserve_query_string = true; $controller->run(); }