form = $form; $this->title = $title; } protected function html_content($exclude = [], $include = []) { if (!empty($this->title)) echo '

', $this->title, '

'; foreach ($this->_subtemplates as $template) $template->html_main(); echo '
'; if (isset($this->form->content_above)) echo $this->form->content_above; $this->missing = $this->form->getMissing(); $this->data = $this->form->getData(); foreach ($this->form->getFields() as $field_id => $field) { // Either we have a blacklist if (!empty($exclude) && in_array($field_id, $exclude)) continue; // ... or a whitelist elseif (!empty($include) && !in_array($field_id, $include)) continue; // ... or neither (ha) $this->renderField($field_id, $field); } echo '
'; if (isset($this->form->content_below)) echo ' ', $this->form->content_below; echo '
'; } protected function renderField($field_id, array $field) { if (isset($field['before_html'])) echo ' ', $field['before_html']; echo '
'; if (isset($field['before'])) echo $field['before']; if ($field['type'] !== 'checkbox') if (isset($field['label'])) echo '
'; else echo '
'; switch ($field['type']) { case 'select': $this->renderSelect($field_id, $field); break; case 'radio': $this->renderRadio($field_id, $field); break; case 'checkbox': $this->renderCheckbox($field_id, $field); break; case 'textarea': $this->renderTextArea($field_id, $field); break; case 'color': $this->renderColor($field_id, $field); break; case 'numeric': $this->renderNumeric($field_id, $field); break; case 'file': $this->renderFile($field_id, $field); break; case 'captcha': $this->renderCaptcha($field_id, $field); break; case 'text': case 'password': default: $this->renderText($field_id, $field); } if (isset($field['after'])) echo ' ', $field['after']; if ($field['type'] !== 'checkbox') echo '
'; echo '
'; } private function renderCaptcha($field_id, array $field) { echo '
'; } private function renderCheckbox($field_id, array $field) { echo '
data[$field_id] ? ' checked' : '', !empty($field['disabled']) ? ' disabled' : '', ' name="', $field_id, '" id="check-', $field_id, '">
'; } private function renderColor($field_id, array $field) { echo ' '; } private function renderFile($field_id, array $field) { if (!empty($this->data[$field_id])) echo 'Currently using asset ', $this->data[$field_id], '. Upload to overwrite.
'; echo ' '; } private function renderNumeric($field_id, array $field) { echo ' '; } private function renderRadio($field_id, array $field) { foreach ($field['options'] as $value => $option) echo '
data[$field_id] == $value ? ' checked' : '', !empty($field['disabled']) ? ' disabled' : '', '>
'; } private function renderSelect($field_id, array $field) { echo ' '; } private function renderSelectOption($field_id, $label, $value, $multiple = false) { echo ' '; } private function renderSelectOptionGroup($field_id, $label, $options) { echo ' '; foreach ($options as $value => $option) $this->renderSelectOption($field_id, $option, $value); echo ' '; } private function renderText($field_id, array $field) { echo ' data[$field_id]) ? ' value="' . htmlspecialchars($this->data[$field_id]) . '"' : '', isset($field['placeholder']) ? ' placeholder="' . $field['placeholder'] . '"' : '', !empty($field['disabled']) ? ' disabled' : '', isset($field['trigger']) ? ' class="trigger-' . $field['trigger'] . '"' : '', '>'; } private function renderTextArea($field_id, array $field) { echo ' '; } }