public function __construct($db) { $this->pager = new A_Pager($db); $this->addParameter($param1 = new A_Controller_Input_Field($this->pager->parampagen)); $parampagen->addFilter(new FilterRegexp('/[^0-9]/', '')); $this->addParameter($paramrecordcount = new A_Controller_Input_Field($this->pager->paramrecordcount)); $paramrecordcount->addFilter(new FilterRegexp('/[^0-9]/', '')); $this->addParameter($paramorderby = new A_Controller_Input_Field($this->pager->paramorderby)); $paramorderby->addFilter(new FilterRegexp('/[^0-9]/', '')); }
public function render() { if ($this->addtype && $this->value == '') { $savetype = $this->type; $this->type = $this->addtype; $result = parent::render(); $this->type = $savetype; return $result; } else { return parent::render(); } }
function run($locator) { $request = $locator->get('Request'); $response = $locator->get('Response'); $response->setRenderer(new A_Template_Strreplace('templates/layout.html')); $number_rule = new A_Filter_Regexp('/[^0-9]/'); $letter_rule = new A_Filter_Regexp('/[^A-Z]/'); $param = new A_Controller_Input_Field('level'); $param->addFilter($number_rule); $this->addField($param); $param = new A_Controller_Input_Field('word'); $param->addFilter($letter_rule); $this->addField($param); $param = new A_Controller_Input_Field('guesses'); $param->addFilter($letter_rule); $this->addField($param); $param = new A_Controller_Input_Field('misses'); $param->addFilter($number_rule); $this->addField($param); $letter = new A_Controller_Input_Field('letter'); $letter->addFilter($letter_rule); $this->addField($letter); $this->processRequest($request); $game = new HangmanGame(); $locator->set('Game', $game); $game->word = $request->get('word'); $game->guesses = $request->get('guesses'); $game->misses = $request->get('misses'); $game->level = $request->get('level'); $game->guess($letter->value); $this->addState(new A_Controller_App_State('start', array(new StartView(), 'render'))); $this->addState(new A_Controller_App_State('game', array(new GameView(), 'render'))); $this->addState(new A_Controller_App_State('win', array(new WinView(), 'render'))); $this->addState(new A_Controller_App_State('lose', array(new LoseView(), 'render'))); $this->addTransition(new A_Controller_App_Transition('start', 'game', new A_Rule_Notnull('level', ''))); $this->addTransition(new A_Controller_App_Transition('start', 'lose', new A_Rule_Notnull('giveup', ''))); $this->addTransition(new A_Controller_App_Transition('game', 'lose', new LoseRule($game))); $this->addTransition(new A_Controller_App_Transition('game', 'win', new WinRule($game))); parent::run($locator); }