<label class="booktext"> Did <?php echo $student->first_name; ?> find this activity fun or boring? </label> <?php echo Form::select('experience', FormList::experience(), null, array('id' => 'experience', 'class' => 'form-control')); ?> </div> <div class="form-group"> <label class="booktext"> Was this activity appropiate for <?php echo $student->first_name; ?> ? </label> <?php echo Form::select('appropriate', FormList::confirm(), null, array('id' => 'appropriate', 'class' => 'form-control')); ?> </div> <div class="form-group"> <label class="booktext"> How would you rate this activity overall on a scale of 0 (bad) to 5 (good)? </label> <input id="rating" name="rating" type="number" class="rating" min=0 max=5 step=1 data-size="md"/> </div> <div class="col-lg-2 col-lg-offset-5"> <br> </div> <?php echo Form::submit('Rate', ['class' => 'btn btn-info']); ?>
public function Load($ff, $addendum, $signal) { if (!isfile($ff, 'forms/')) { return; } $file = file_get_contents('forms/' . $ff); $data = new HDataStream($file); $data = $data->toArray(); $settings = array(); $settings['insert'] = array(); $settings['hidden'] = array(); $settings['text'] = array(); $settings['multiline'] = array(); $settings['slider'] = array(); $settings['date'] = array(); $settings['select'] = array(); $settings['radio'] = array(); $settings['submit'] = array(); $settings['list'] = array(); $settings['name'] = 'form'; $settings['action'] = 'ajax.post.php'; if (!is_null($addendum) && is_array($addendum)) { foreach ($addendum as $add => $val) { $settings[$add] = $val; } } if (isset($settings['dbid'])) { $this->dbid = $settings['dbid']; } $t = count($data); $o = 0; for ($i = 0; $i < $t; $i++) { $setting = $data[$i + 1]; if (matches($data[$i], "text")) { $settings['text'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "hidden")) { $settings['hidden'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "multiline") || matches($data[$i], "textarea")) { $settings['multiline'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "slider")) { $settings['slider'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "date")) { $settings['date'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "select")) { $settings['select'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "list")) { $settings['list'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "radio")) { $settings['radio'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "insert")) { $settings['insert'][$o++] = HDataStream::asKV($setting); } else { if (matches($data[$i], "submit")) { $settings['submit'][$o++] = HDataStream::asKV($setting); } else { $settings[$data[$i]] = $setting; } } } } } } } } } } $i++; } $this->form = new FormHelper($settings['name'], $settings['action'], $this->dbid, $signal); for ($i = 0; $i < $o; $i++) { if (isset($settings['radio'][$i])) { $e = $settings['radio'][$i]; $e['html'] = HDataStream::asKV($e['html']); $e['options'] = HDataStream::asKV($e['options']); $element = new FormRadio($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['select'][$i])) { $e = $settings['select'][$i]; $e['html'] = HDataStream::asKV($e['html']); $e['options'] = HDataStream::asKV($e['options']); $element = new FormSelect($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['list'][$i])) { $e = $settings['list'][$i]; $e['html'] = HDataStream::asKV($e['html']); $e['options'] = HDataStream::asKV($e['options']); $element = new FormList($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['slider'][$i])) { $e = $settings['slider'][$i]; $e['html'] = HDataStream::asKV($e['html']); $element = new FormSlider($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['multiline'][$i])) { $e = $settings['multiline'][$i]; $e['html'] = HDataStream::asKV($e['html']); $element = new FormMultiline($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['text'][$i])) { $e = $settings['text'][$i]; $e['html'] = HDataStream::asKV($e['html']); $element = new FormText($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } else { if (isset($settings['insert'][$i])) { $e = $settings['insert'][$i]; $this->form->Add(new FormInsert($e)); } else { if (isset($settings['hidden'][$i])) { $e = $settings['insert'][$i]; $this->form->Add(new FormHidden($e)); } else { if (isset($settings['submit'][$i])) { $e = $settings['submit'][$i]; $e['html'] = HDataStream::asKV($e['html']); $element = new FormSubmit($e, TRUE); if (!is_null($this->data) && isset($e['data']) && isset($this->data[$e['data']])) { $element->Set($this->data[$e['data']]); } $element->_Init($element->settings); $this->form->Add($element); } } } } } } } } } } }
# Klein is used as the router. $klein = new \Klein\Klein(); # Create a config file parser $parser = new Parser(); $stringifier = new Stringifier(); // header('X-Frame-Options: DENY'); # Display simple error messages. # Based on code from the Klein documentation. $klein->onHttpError(function ($code, $router) use($stringifier) { $res = $router->response(); $message = h()->h1->style('text-align:center;font-size:72px;')->c($res->status()->getCode())->end->h2->style('text-align:center')->c($res->status()->getMessage())->end; $stringifier->writeResponse(new PageWrapper($message), $res); }); # The main list of forms $klein->respond('GET', '/', function ($req, $res) use($parser, $stringifier) { $formlist = new FormList($parser->getFormInfo()); $stringifier->writeResponse(new PageWrapper($formlist->makeFormList()), $res); }); # A view $klein->respond('GET', '/view', function ($req, $res) use($parser, $stringifier) { $page = $parser->parseJade($_GET['form']); $view = $page->getView($_GET['view']); $render = $view->makeView($view->query($req->paramsGet()->get('page', 1))); $stringifier->writeResponse(new PageWrapper($render), $res); }); # A form itself $klein->respond('GET', '/forms/[:formID]', function ($req, $res) use($parser, $stringifier) { $config = Config::get(); # This code caches the HTML associated with a form if "cache-forms" is enabled $cache = $config['cache-forms'] ? new Cache() : new FakeCache(); $cache->setPrefixSize(0);