function indexAction() { $controller = new HTML_QuickForm2_Controller('plugin_maker'); $controller->addPage(new Am_Form_Controller_Page_PluginMaker_Mysql(new Am_Form('mysql'))); $controller->addPage(new Am_Form_Controller_Page_PluginMaker_Plugin(new Am_Form('plugin'))); $controller->addPage(new Am_Form_Controller_Page_PluginMaker_Tables(new Am_Form('tables'))); $controller->addPage(new Am_Form_Controller_Page_PluginMaker_Columns(new Am_Form('columns'))); $controller->addPage(new Am_Form_Controller_Page_PluginMaker_Display(new Am_Form('display'))); $controller->addHandler('next', new HTML_QuickForm2_Controller_Action_Next()); $controller->addHandler('back', new HTML_QuickForm2_Controller_Action_Back()); $controller->addHandler('jump', new HTML_QuickForm2_Controller_Action_Jump()); ob_start(); $controller->run(); $this->view->content = ob_get_clean(); $this->view->title = "Integration Plugin Maker"; $this->view->display('admin/layout.phtml'); }
public function testActionHandlerPrecedence() { $controller = new HTML_QuickForm2_Controller('precedence'); $mockPage = $this->getMock('HTML_QuickForm2_Controller_Page', array('populateForm'), array(new HTML_QuickForm2('precedencePage'))); $controller->addPage($mockPage); try { $mockPage->handle('foo'); $this->fail('Expected HTML_QuickForm2_NotFoundException was not thrown'); } catch (HTML_QuickForm2_NotFoundException $e) { } $mockFoo1 = $this->getMock('HTML_QuickForm2_Controller_Action', array('perform')); $mockFoo1->expects($this->once())->method('perform')->will($this->returnValue('foo common')); $controller->addHandler('foo', $mockFoo1); $this->assertEquals('foo common', $mockPage->handle('foo')); $mockFoo2 = $this->getMock('HTML_QuickForm2_Controller_Action', array('perform')); $mockFoo2->expects($this->once())->method('perform')->will($this->returnValue('foo specific')); $mockPage->addHandler('foo', $mockFoo2); $this->assertEquals('foo specific', $mockPage->handle('foo')); }
$renderer->setTemplateForId('nameGrp', '<div class="row"><p class="label"><qf:required><span class="required">*</span></qf:required><qf:label><label>{label}</label></qf:label></p>{content}</div>'); echo $form->render($renderer); ?> </body> </html> <?php } } class WizardProcess implements HTML_QuickForm2_Controller_Action { public function perform(HTML_QuickForm2_Controller_Page $page, $name) { echo "Submit successful!<br>\n<pre>\n"; var_dump($page->getController()->getValue()); echo "\n</pre>\n"; } } $wizard = new HTML_QuickForm2_Controller('Wizard'); $wizard->addPage(new PageFirst(new HTML_QuickForm2('page1'))); $wizard->addPage(new PageSecond(new HTML_QuickForm2('page2'))); $wizard->addPage(new PageThird(new HTML_QuickForm2('page3'))); // We actually add these handlers here for the sake of example // They can be automatically loaded and added by the controller $wizard->addHandler('next', new HTML_QuickForm2_Controller_Action_Next()); $wizard->addHandler('back', new HTML_QuickForm2_Controller_Action_Back()); $wizard->addHandler('jump', new HTML_QuickForm2_Controller_Action_Jump()); // This is the action we should always define ourselves $wizard->addHandler('process', new WizardProcess()); // We redefine 'display' handler to use the proper stylesheets $wizard->addHandler('display', new WizardDisplay()); $wizard->run();
</html> <?php } } class TabbedProcess implements HTML_QuickForm2_Controller_Action { public function perform(HTML_QuickForm2_Controller_Page $page, $name) { echo "Submit successful!<br>\n<pre>\n"; var_dump($page->getController()->getValue()); echo "\n</pre>\n"; } } $tabbed = new HTML_QuickForm2_Controller('Tabbed', false); $tabbed->addPage(new PageFoo(new HTML_QuickForm2('foo'))); $tabbed->addPage(new PageBar(new HTML_QuickForm2('bar'))); $tabbed->addPage(new PageBaz(new HTML_QuickForm2('baz'))); // These actions manage going directly to the pages with the same name $tabbed->addHandler('foo', new HTML_QuickForm2_Controller_Action_Direct()); $tabbed->addHandler('bar', new HTML_QuickForm2_Controller_Action_Direct()); $tabbed->addHandler('baz', new HTML_QuickForm2_Controller_Action_Direct()); // We actually add these handlers here for the sake of example // They can be automatically loaded and added by the controller $tabbed->addHandler('submit', new HTML_QuickForm2_Controller_Action_Submit()); $tabbed->addHandler('jump', new HTML_QuickForm2_Controller_Action_Jump()); // This is the action we should always define ourselves $tabbed->addHandler('process', new TabbedProcess()); // We redefine 'display' handler to use the proper stylesheets $tabbed->addHandler('display', new TabbedDisplay()); $tabbed->addDatasource(new HTML_QuickForm2_DataSource_Array(array('iradYesNoMaybe' => 'M', 'favLetter' => array('A' => true, 'Z' => true), 'favDate' => array('d' => 1, 'M' => 1, 'Y' => 2001), 'textOpinion' => 'Yes, it rocks!'))); $tabbed->run();
public function testHttpXForwardedHost() { $_SERVER['HTTP_X_FORWARDED_HOST'] = 'example.org, example.com'; $_SERVER['HTTP_HOST'] = 'localhost'; $controller = new HTML_QuickForm2_Controller('forwarded'); $mockPage = $this->getMock('HTML_QuickForm2_Controller_Page', array('populateForm'), array(new HTML_QuickForm2('forwarded'))); $controller->addPage($mockPage); $controller->addHandler('jump', $this->mockJump); $mockPage->getForm()->setAttribute('action', '/foo'); $this->assertStringStartsWith('http://localhost/foo?', $mockPage->handle('jump')); $trustingJump = $this->getMock('HTML_QuickForm2_Controller_Action_Jump', array('doRedirect'), array(true)); $trustingJump->expects($this->atLeastOnce())->method('doRedirect')->will($this->returnArgument(0)); $controller->addHandler('jump', $trustingJump); $this->assertStringStartsWith('http://example.com/foo?', $mockPage->handle('jump')); }