[TASK] Formstyle
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* p01-contact - A simple contact forms manager.
|
||||
*
|
||||
@@ -87,13 +88,13 @@ class P01contactField
|
||||
}
|
||||
// value blacklisted or not in whitelist
|
||||
if ($reason = $this->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 = "<div class=\"row field {$is_single_option} {$type} {$orig} {$required}\">";
|
||||
$html = "<div class=\"col s12 input-field {$is_single_option} {$type} {$orig} {$required}\">";
|
||||
|
||||
$html .= '<div class="col-sm-12 col-md-3">';
|
||||
if ('' === $is_single_option) {
|
||||
$html .= $this->htmlLabel($id);
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="col-sm-12 col-md">';
|
||||
switch ($type) {
|
||||
case 'textarea':
|
||||
$html .= '<textarea id="'.$id.'" rows="10" ';
|
||||
$html .= 'name="'.$name.'"'.$disabled.$required.$placeholder;
|
||||
$html .= '>'.$value.'</textarea>';
|
||||
$html .= '<textarea id="' . $id . '" rows="10" ';
|
||||
$html .= 'class="materialize-textarea" ';
|
||||
$html .= 'name="' . $name . '"' . $disabled . $required . $placeholder;
|
||||
$html .= '>' . $value . '</textarea>';
|
||||
|
||||
break;
|
||||
case 'captcha':
|
||||
@@ -238,7 +234,7 @@ class P01contactField
|
||||
if (1 == $this->form->getId()) {
|
||||
$html .= '<script src="https://www.google.com/recaptcha/api.js"></script>';
|
||||
}
|
||||
$html .= '<div class="g-recaptcha" id="'.$id.'" data-sitekey="'.$key.'"></div>';
|
||||
$html .= '<div class="g-recaptcha" id="' . $id . '" data-sitekey="' . $key . '"></div>';
|
||||
$html .= "<input type=\"hidden\" id=\"{$id}\" name=\"{$name}\" value=\"trigger\">";
|
||||
|
||||
break;
|
||||
@@ -248,11 +244,11 @@ class P01contactField
|
||||
foreach ($this->value as $i => $v) {
|
||||
$selected = $this->isSelected($i) ? ' checked' : '';
|
||||
$v = !empty($v) ? $v : 'Default';
|
||||
$html .= '<label class="option col-sm-12">';
|
||||
$html .= '<p><label class="option col s12">';
|
||||
$html .= "<input id=\"{$id}_option{$i}\"";
|
||||
$html .= " type=\"{$type}\" class=\"{$type}\" name=\"{$name}\"";
|
||||
$html .= " value=\"{$i}\"{$disabled}{$required}{$selected} />{$v}";
|
||||
$html .= '</label>';
|
||||
$html .= " value=\"{$i}\"{$disabled}{$required}{$selected} /><span>{$v}</span>";
|
||||
$html .= '</label></p>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
@@ -263,20 +259,21 @@ class P01contactField
|
||||
$value = !empty($v) ? $v : 'Default';
|
||||
$selected = $this->isSelected($i) ? ' selected="selected"' : '';
|
||||
$html .= "<option id=\"{$id}_option{$i}\" value=\"{$i}\"{$selected}>";
|
||||
$html .= $value.'</option>';
|
||||
$html .= $value . '</option>';
|
||||
}
|
||||
$html .= '</select>';
|
||||
|
||||
break;
|
||||
default:
|
||||
$html .= '<input id="'.$id.'" ';
|
||||
$html .= 'name="'.$name.'" type="'.$type.'" ';
|
||||
$html .= 'value="'.$value.'"'.$disabled.$required.$placeholder.' />';
|
||||
$html .= '<input id="' . $id . '" ';
|
||||
$html .= 'name="' . $name . '" type="' . $type . '" ';
|
||||
$html .= 'value="' . $value . '"' . $disabled . $required . $placeholder . ' />';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
if ('' === $is_single_option) {
|
||||
$html .= $this->htmlLabel($id);
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
@@ -294,7 +291,7 @@ class P01contactField
|
||||
$emphasis = $this->value ? 'font-weight:bold' : 'font-style:italic';
|
||||
$html .= "\n\n\n";
|
||||
$html .= '<tr style="background-color: #eeeeee">';
|
||||
$html .= '<td style="padding: .5em .75em"><span style="'.$emphasis.'">';
|
||||
$html .= '<td style="padding: .5em .75em"><span style="' . $emphasis . '">';
|
||||
$html .= $this->title ? $this->title : ucfirst($this->form->lang($this->type));
|
||||
$html .= '</span></td>';
|
||||
$html .= "\t\t";
|
||||
@@ -302,7 +299,7 @@ class P01contactField
|
||||
// properties
|
||||
$html .= '<td style="padding:.5em 1em; text-transform:lowercase; text-align:right; font-size:.875em; color:#888888; vertical-align: middle"><em>';
|
||||
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 .= '</em></td></tr>';
|
||||
$html .= "\n\n";
|
||||
|
||||
// value
|
||||
if (!$this->value) {
|
||||
return $html.'</table>';
|
||||
return $html . '</table>';
|
||||
}
|
||||
$html .= '<tr><td colspan=2 style="padding:0">';
|
||||
$html .= '<div style="padding:.5em 1.5em;border:1px solid #ccc">';
|
||||
@@ -340,7 +337,7 @@ class P01contactField
|
||||
$html .= '<div style="color:#ccc; font-style:italic">';
|
||||
$checkmark = '☐';
|
||||
}
|
||||
$html .= '<span style="font-size:1.5em; vertical-align:middle; margin-right:.5em; font-style:normal">'.$checkmark.'</span>';
|
||||
$html .= '<span style="font-size:1.5em; vertical-align:middle; margin-right:.5em; font-style:normal">' . $checkmark . '</span>';
|
||||
$html .= empty($v) ? 'Default' : $v;
|
||||
$html .= "</div>\n";
|
||||
}
|
||||
@@ -371,17 +368,17 @@ class P01contactField
|
||||
*/
|
||||
private function htmlLabel($for)
|
||||
{
|
||||
$html .= '<label for="'.$for.'" class="doc">';
|
||||
$html .= '<label for="' . $for . '" class="doc validate">';
|
||||
if ($this->title) {
|
||||
$html .= $this->title;
|
||||
} else {
|
||||
$html .= ucfirst($this->form->lang($this->type));
|
||||
}
|
||||
if ($this->description) {
|
||||
$html .= ' <em class="description">'.$this->description.'</em>';
|
||||
$html .= ' <em class="description">' . $this->description . '</em>';
|
||||
}
|
||||
if ($this->error) {
|
||||
$html .= ' <span class="error-msg">'.$this->form->lang($this->error).'</span>';
|
||||
$html .= ' <span class="error-msg">' . $this->form->lang($this->error) . '</span>';
|
||||
}
|
||||
$html .= '</label>';
|
||||
|
||||
@@ -409,7 +406,7 @@ class P01contactField
|
||||
|
||||
function preint($arr, $return = false)
|
||||
{
|
||||
$out = '<pre class="test" style="white-space:pre-wrap;">'.print_r(@$arr, true).'</pre>';
|
||||
$out = '<pre class="test" style="white-space:pre-wrap;">' . print_r(@$arr, true) . '</pre>';
|
||||
if ($return) {
|
||||
return $out;
|
||||
}
|
||||
@@ -417,9 +414,9 @@ function preint($arr, $return = false)
|
||||
}
|
||||
function predump($arr)
|
||||
{
|
||||
echo'<pre class="test" style="white-space:pre-wrap;">';
|
||||
echo '<pre class="test" style="white-space:pre-wrap;">';
|
||||
var_dump($arr);
|
||||
echo'</pre>';
|
||||
echo '</pre>';
|
||||
}
|
||||
function unset_r($a, $i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user