From f5f43b2173fe8e7f3d5edf9213eb30c26ba185b1 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 20 May 2020 17:34:25 +0200 Subject: [PATCH] [TASK] Formstyle --- plugins/PicoContact/src/P01contact_Field.php | 73 ++++++++++---------- plugins/PicoContact/src/P01contact_Form.php | 32 +++++---- plugins/PicoContact/style.css | 2 + 3 files changed, 56 insertions(+), 51 deletions(-) diff --git a/plugins/PicoContact/src/P01contact_Field.php b/plugins/PicoContact/src/P01contact_Field.php index 2f08bbe..06b7690 100644 --- a/plugins/PicoContact/src/P01contact_Field.php +++ b/plugins/PicoContact/src/P01contact_Field.php @@ -1,4 +1,5 @@ isBlacklisted()) { - $this->error = 'field_'.$reason; + $this->error = 'field_' . $reason; return false; } // not empty but not valid if (!empty($this->value) && !$this->isValid()) { - $this->error = 'field_'.$this->type; + $this->error = 'field_' . $this->type; return false; } @@ -145,7 +146,7 @@ class P01contactField 'secret' => $this->form->config('recaptcha_secret_key'), 'response' => $answer, ]; - $url = 'https://www.google.com/recaptcha/api/siteverify?'.http_build_query($params); + $url = 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($params); if (function_exists('curl_version')) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); @@ -204,30 +205,25 @@ class P01contactField */ public function html() { - $id = 'p01-contact'.$this->form->getId().'_field'.$this->id; - $name = 'p01-contact_fields['.$this->id.']'; + $id = 'p01-contact' . $this->form->getId() . '_field' . $this->id; + $name = 'p01-contact_fields[' . $this->id . ']'; $type = $this->getGeneralType(); $orig = $type != $this->type ? $this->type : ''; $value = $this->value; $disabled = $this->locked ? ' disabled="disabled"' : ''; $required = $this->required ? ' required ' : ''; - $placeholder = $this->placeholder ? ' placeholder="'.$this->placeholder.'"' : ''; + $placeholder = $this->placeholder ? ' placeholder="' . $this->placeholder . '"' : ''; $is_single_option = is_array($this->value) && 1 == count($this->value) ? 'inline' : ''; - $html = "
"; + $html = "
"; - $html .= '
'; - if ('' === $is_single_option) { - $html .= $this->htmlLabel($id); - } - $html .= '
'; - $html .= '
'; switch ($type) { case 'textarea': - $html .= ''; break; case 'captcha': @@ -238,7 +234,7 @@ class P01contactField if (1 == $this->form->getId()) { $html .= ''; } - $html .= '
'; + $html .= '
'; $html .= ""; break; @@ -248,11 +244,11 @@ class P01contactField foreach ($this->value as $i => $v) { $selected = $this->isSelected($i) ? ' checked' : ''; $v = !empty($v) ? $v : 'Default'; - $html .= '
'; @@ -263,20 +259,21 @@ class P01contactField $value = !empty($v) ? $v : 'Default'; $selected = $this->isSelected($i) ? ' selected="selected"' : ''; $html .= "'; + $html .= $value . ''; } $html .= ''; break; default: - $html .= ''; + $html .= ''; break; } - - $html .= '
'; + if ('' === $is_single_option) { + $html .= $this->htmlLabel($id); + } $html .= '
'; return $html; @@ -294,7 +291,7 @@ class P01contactField $emphasis = $this->value ? 'font-weight:bold' : 'font-style:italic'; $html .= "\n\n\n"; $html .= ''; - $html .= ''; + $html .= ''; $html .= $this->title ? $this->title : ucfirst($this->form->lang($this->type)); $html .= ''; $html .= "\t\t"; @@ -302,7 +299,7 @@ class P01contactField // properties $html .= ''; if (!$this->value) { - $html .= $this->form->lang('empty').' '; + $html .= $this->form->lang('empty') . ' '; } if ($this->title) { $properties[] = $this->type; @@ -316,15 +313,15 @@ class P01contactField } } if (count($properties)) { - $html .= '('.implode(', ', $properties).') '; + $html .= '(' . implode(', ', $properties) . ') '; } - $html .= '#'.$this->id; + $html .= '#' . $this->id; $html .= ''; $html .= "\n\n"; // value if (!$this->value) { - return $html.''; + return $html . ''; } $html .= ''; $html .= '
'; @@ -340,7 +337,7 @@ class P01contactField $html .= '
'; $checkmark = '☐'; } - $html .= ''.$checkmark.''; + $html .= '' . $checkmark . ''; $html .= empty($v) ? 'Default' : $v; $html .= "
\n"; } @@ -371,17 +368,17 @@ class P01contactField */ private function htmlLabel($for) { - $html .= '