2016-09-06 15:32:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HelperForm{
|
|
|
|
|
|
|
|
public $_forms = array();
|
|
|
|
public $_debug = false;
|
|
|
|
|
|
|
|
public $_html;
|
|
|
|
public $_object;
|
|
|
|
public $_css;
|
|
|
|
public $_script; // inc js
|
|
|
|
public $_js; // user js
|
|
|
|
public $_messages;
|
|
|
|
|
|
|
|
public $_selectCheck;
|
|
|
|
public $_dateTime;
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
$this->_html = '';
|
|
|
|
$this->_object = NULL;
|
|
|
|
$this->_css = '';
|
|
|
|
$this->_script = '';
|
|
|
|
$this->_js = '';
|
|
|
|
$this->_messages = '';
|
|
|
|
$this->_selectCheck = false;
|
|
|
|
$this->_dateTime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderForm($display = true, $action = NULL, $method = 'POST', $enctype = 'multipart/form-data'){
|
2016-10-21 15:54:52 +02:00
|
|
|
|
2016-09-06 15:32:52 +02:00
|
|
|
$this->generateForms();
|
|
|
|
|
|
|
|
$this->_script .= '<script type="text/javascript" src="'.__PS_BASE_URI__.'adm/helpers/includes/jquery-ui-1.8.20.custom.min.js"></script>';
|
|
|
|
if ($this->_selectCheck)
|
|
|
|
$this->includeSelectCheck();
|
|
|
|
if ($this->_dateTime)
|
|
|
|
$this->includeDateTime();
|
|
|
|
$this->addFilters();
|
2016-10-21 15:54:52 +02:00
|
|
|
$form =
|
2016-09-06 15:32:52 +02:00
|
|
|
'<style type="text/css">
|
|
|
|
@import url("'.__PS_BASE_URI__.'adm/helpers/includes/jquery-ui-1.8.20.custom.css");
|
|
|
|
label.radio_label { float: none; }
|
|
|
|
label.checkbox_label { float: none; }
|
|
|
|
.margin-form.checkbox { padding-top: 3px; }
|
|
|
|
' . $this->_css . '
|
|
|
|
</style>' .
|
|
|
|
$this->_script .
|
|
|
|
($this->_messages ? implode("\n", $this->_messages) : '') .
|
|
|
|
$this->_html .
|
|
|
|
$this->_js; // display user js after render form
|
2016-10-21 15:54:52 +02:00
|
|
|
|
2016-09-06 15:32:52 +02:00
|
|
|
if ($display)
|
|
|
|
echo $form;
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generateForms($action = NULL, $method = 'POST', $enctype = 'multipart/form-data'){
|
|
|
|
if (!$this->_forms || empty($this->_forms))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!$method)
|
|
|
|
$method = 'POST';
|
|
|
|
if (!$enctype)
|
|
|
|
$enctype = 'multipart/form-data';
|
|
|
|
|
|
|
|
foreach ($this->_forms as $form) {
|
|
|
|
$action = isset($form['action']) ? $form['action'] : $action;
|
|
|
|
$method = isset($form['method']) ? $form['method'] : $method;
|
|
|
|
$enctype = isset($form['enctype']) ? $form['enctype'] : $enctype;
|
|
|
|
$css = isset($form['style']) ? $form['style'] : '';
|
|
|
|
|
|
|
|
// OPEN FORM
|
|
|
|
$this->_html .= '<form action="'.$action.'" method="'.$method.'" enctype="'.$enctype.'">';
|
|
|
|
$id = (isset($form['id']) && $form['id']) ? $form['id'] : false;
|
|
|
|
$img = (isset($form['img']) && $form['img']) ? $form['img'] : false;
|
|
|
|
$css = (isset($form['css']) && $form['css']) ? $form['css'] : false;
|
|
|
|
|
|
|
|
if (!isset($form['fieldsets'])){
|
|
|
|
$form['fieldsets'] = array(
|
|
|
|
array(
|
|
|
|
'legend' => $form['legend'],
|
|
|
|
'id' => $id,
|
|
|
|
'img' => $img,
|
|
|
|
'css' => $css,
|
|
|
|
'inputs' => $form['inputs'],
|
|
|
|
'actions' => $form['actions']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($form['fieldsets'] as $fieldset) {
|
|
|
|
|
|
|
|
$id = (isset($fieldset['id']) && $fieldset['id']) ? $fieldset['id'] : false;
|
|
|
|
$img = (isset($fieldset['img']) && $fieldset['img']) ? $fieldset['img'] : false;
|
|
|
|
$css = (isset($fieldset['css']) && $fieldset['css']) ? $fieldset['css'] : false;
|
|
|
|
|
|
|
|
// OPEN FIELDSET
|
|
|
|
$this->openFieldset($fieldset['legend'], $id, $img, $css);
|
|
|
|
|
|
|
|
foreach ($fieldset['inputs'] as $input)
|
|
|
|
$this->addInput($input);
|
|
|
|
|
|
|
|
if (isset($fieldset['actions']) && $fieldset['actions']){
|
|
|
|
$this->_html .= '<div class="margin-form">';
|
|
|
|
foreach ($fieldset['actions'] as $action)
|
|
|
|
$this->addAction($action);
|
|
|
|
$this->_html .= '</div>';
|
|
|
|
}
|
|
|
|
$this->closeFieldset();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->_html .= '</form>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addJs($js){
|
|
|
|
$this->_js .= $js;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addCss($css){
|
|
|
|
$this->_css .= $css;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addInput($input){
|
|
|
|
if (!isset($input['type']))
|
|
|
|
return false;
|
|
|
|
$html = (isset($input['html']) && $input['html']) ? $input['html'] : NULL;
|
|
|
|
switch ($input['type']) {
|
|
|
|
case 'text':
|
|
|
|
$this->inputText($input);
|
|
|
|
break;
|
|
|
|
case 'select':
|
|
|
|
$this->inputSelect($input);
|
|
|
|
break;
|
2016-10-21 15:54:52 +02:00
|
|
|
case 'select-styled':
|
|
|
|
$this->inputSelectStyled($input);
|
|
|
|
break;
|
2016-09-06 15:32:52 +02:00
|
|
|
case 'bool':
|
|
|
|
case 'radio':
|
|
|
|
$this->inputBool($input);
|
|
|
|
break;
|
|
|
|
case 'checkbox':
|
|
|
|
$this->inputCheckbox($input);
|
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
$this->inputDate($input);
|
|
|
|
break;
|
|
|
|
case 'textarea':
|
|
|
|
$this->inputRte($input);
|
|
|
|
break;
|
|
|
|
case 'checkList':
|
|
|
|
case 'selectCheck':
|
|
|
|
$this->selectCheck($input);
|
|
|
|
break;
|
|
|
|
case 'file':
|
|
|
|
$this->inputFile($input);
|
|
|
|
break;
|
|
|
|
case 'hidden':
|
|
|
|
$this->inputHidden($input);
|
|
|
|
break;
|
|
|
|
case 'html':
|
|
|
|
$this->_html .= $input['value'];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addAction($action){
|
|
|
|
if (!isset($action['type']) || !isset($action['name']))
|
|
|
|
return false;
|
|
|
|
$css = (isset($action['css']) && $action['css']) ? $action['css'] : NULL;
|
|
|
|
switch ($action['type']) {
|
|
|
|
case 'button':
|
|
|
|
$this->inputButton($action);
|
|
|
|
break;
|
|
|
|
case 'submit':
|
|
|
|
$this->inputSubmit($action);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function includeSelectCheck(){
|
|
|
|
$this->_css .= '
|
|
|
|
a.multiSelect {
|
|
|
|
background: #FFF url('.__PS_BASE_URI__.'adm/helpers/includes/dropdown.gif) right -1px no-repeat;
|
|
|
|
border: 1px solid #e0d0b1;
|
|
|
|
padding-right: 20px;
|
|
|
|
position: relative;
|
|
|
|
cursor: default;
|
|
|
|
text-decoration: none;
|
|
|
|
color: black;
|
|
|
|
display: -moz-inline-stack;
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: top;
|
|
|
|
margin-top: 2px;
|
|
|
|
}
|
|
|
|
a.multiSelect:link, a.multiSelect:visited, a.multiSelect:hover, a.multiSelect:active {
|
|
|
|
color: black;
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
a.multiSelect span {
|
|
|
|
margin: 1px 0px 1px 3px;
|
|
|
|
overflow: hidden;
|
|
|
|
display: -moz-inline-stack;
|
|
|
|
display: inline-block;
|
|
|
|
white-space: nowrap;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
a.multiSelect.hover {
|
|
|
|
background-image: url('.__PS_BASE_URI__.'adm/helpers/includes/dropdown_hover.gif);
|
|
|
|
}
|
|
|
|
a.multiSelect.active, a.multiSelect.focus {
|
|
|
|
border: inset 1px #000000;
|
|
|
|
}
|
|
|
|
a.multiSelect.active {
|
|
|
|
background-image: url('.__PS_BASE_URI__.'adm/helpers/includes/dropdown_active.gif);
|
|
|
|
}
|
|
|
|
.multiSelectOptions {
|
|
|
|
margin-top: -1px;
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
border: solid 1px #b2b2b2;
|
|
|
|
background: #ffffff;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label {
|
|
|
|
padding: 0px 2px;
|
|
|
|
display: block;
|
|
|
|
white-space: nowrap;
|
|
|
|
float: none;
|
|
|
|
text-align: left;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label.optGroup {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.multiSelectOptions .optGroupContainer label {
|
|
|
|
padding-left: 10px;
|
|
|
|
font-size: 12px;
|
|
|
|
color: #333333;
|
|
|
|
padding: 2px 0px;
|
|
|
|
}
|
|
|
|
.multiSelectOptions.optGroupHasCheckboxes .optGroupContainer label {
|
|
|
|
padding-left: 18px;
|
|
|
|
}
|
|
|
|
.multiSelectOptions input {
|
|
|
|
vertical-align: middle;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label.checked {
|
|
|
|
background-color: #dce5f8;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label.optGroup {
|
|
|
|
color: #000000;
|
|
|
|
font-size: 12px;
|
|
|
|
margin-bottom: 2px;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label.selectAll {
|
|
|
|
border-bottom: dotted 1px #cccccc;
|
|
|
|
font-size: 12px;
|
|
|
|
color: #333333;
|
|
|
|
padding-top: 2px;
|
|
|
|
margin: 0px 0px 6px;
|
|
|
|
}
|
|
|
|
.multiSelectOptions label.hover {
|
|
|
|
background-color: #3399ff;
|
|
|
|
color: #ffffff;
|
|
|
|
}';
|
|
|
|
$this->_script .= '
|
|
|
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'adm/helpers/includes/jquery.multiSelect.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(".multiSelectCheck").each(function(){
|
|
|
|
var text = $(this).data("text");
|
|
|
|
$(this).multiSelect({
|
|
|
|
selectAllText: text,
|
|
|
|
noneSelected: " ",
|
|
|
|
oneOrMoreSelected: "*"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function includeDateTime(){
|
|
|
|
$this->_css .= '
|
|
|
|
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
|
|
|
|
.ui-timepicker-div dl { text-align: left; }
|
|
|
|
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
|
|
|
|
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
|
|
|
|
.ui-timepicker-div td { font-size: 90%; }
|
|
|
|
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }';
|
|
|
|
$this->_script .= '
|
|
|
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'adm/helpers/includes/jquery-ui-timepicker-addon.js"></script>';
|
|
|
|
$this->_js .= '
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(".date div input").datetimepicker({
|
|
|
|
showSecond: true,
|
|
|
|
timeFormat: "hh:mm:ss",
|
|
|
|
dateFormat: "yy-mm-dd",
|
|
|
|
addSliderAccess: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addFilters(){
|
|
|
|
$this->_script .= '
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {';
|
|
|
|
// SELECT CHECK FILTERS
|
|
|
|
$this->_script .= '
|
|
|
|
$(".selectCheck_filter").bind("keyup", function() {
|
|
|
|
var val = $(this).val().toLowerCase();
|
|
|
|
if(val == "") {
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck input[name=\"" + $(this).data("id") + "[]\"]").parent().show();
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck label.selectAll").show();
|
|
|
|
} else {
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck input[name=\"" + $(this).data("id") + "[]\"]").parent().hide();
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck label.selectAll").hide();
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck input[name=\"" + $(this).data("id") + "[]\"][value=\""+$(this).val()+"\"]").parent().show();
|
|
|
|
|
|
|
|
$("#" + $(this).data("id") + "_selectCheck input[name=\"" + $(this).data("id") + "[]\"]").parent().filter(function(index) {
|
|
|
|
return $(this).text().toLowerCase().indexOf(val) !== -1;
|
|
|
|
}).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
';
|
|
|
|
// @todo SELECT FILTERS
|
|
|
|
$this->_script .= '
|
|
|
|
$(".select_filter").bind("keyup", function() {
|
|
|
|
var val = $(this).val().toLowerCase();
|
|
|
|
if(val == "") {
|
|
|
|
$("#" + $(this).data("id") + " option").show().addClass("shown");
|
|
|
|
$("#filter_count_" + $(this).data("id")).text("");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$("#" + $(this).data("id") + " option").hide().removeClass("shown");
|
|
|
|
$("#" + $(this).data("id") + " option[value=\""+$(this).val()+"\"]").show().attr("selected", true).addClass("shown");
|
|
|
|
$("#" + $(this).data("id") + " option").filter(function(index) {
|
|
|
|
return $(this).text().toLowerCase().indexOf(val) !== -1;
|
|
|
|
}).show().attr("selected", true).addClass("shown");
|
|
|
|
$("#filter_count_" + $(this).data("id")).text("(" + $("#" + $(this).data("id") + " option.shown").length + ")");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
';
|
|
|
|
$this->_script .= '
|
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function openFieldset($legend, $id = NULL, $img_src='../img/admin/edit.gif', $css = false){
|
|
|
|
$this->_html .= '<fieldset' . ($id ? ' id="' . $id . '"' : '') .' class="space"' . ($css ? ' style="' . $css . '"' : '') .'>
|
|
|
|
<legend><img src="'.$img_src.'" alt="" title="" /> '.$legend.'</legend>
|
|
|
|
<div class="fieldset_content">';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function closeFieldset($legend, $img_src='../img/admin/edit.gif'){
|
|
|
|
$this->_html .= '</div></fieldset>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputText($p = array()){
|
|
|
|
|
|
|
|
if (isset($p['lang']) && $p['lang'] === true)
|
|
|
|
return $this->inputTextL($p);
|
|
|
|
$default_value = (isset($p['default']) ? $p['default'] : '');
|
|
|
|
$disabled = ((isset($p['disabled']) && $p['disabled']) ? 'disabled="disabled"' : '');
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form text' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<input type="text" ' . $disabled . ' name="'.$p['name'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'" value="'.($this->_object ? $this->_object->{$p['name']} : $default_value ).'"'.(isset($p['css']) ? 'style="'.$p['css'].'"' : '').'/>
|
|
|
|
' . ((isset($p['required']) && $p['required']) ? '<sup> *</sup>' : '') . '
|
|
|
|
' . ((isset($p['hint']) && $p['hint']) ? '<p class="hint">'.$p['hint'].'</p>' : '') . '
|
2016-12-08 11:54:04 +01:00
|
|
|
' . ((isset($p['help']) && $p['help']) ? '<p class="help">'.$p['help'].'</p>' : '') . '
|
2016-09-06 15:32:52 +02:00
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputTextL($p = array()){
|
|
|
|
$default_value = (isset($p['default']) ? $p['default'] : '');
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form translatable rte' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">';
|
|
|
|
foreach ($this->_languages AS $language){
|
|
|
|
$default_lang = (is_array($p['default'])) ? $p['default'][(int)$language['id_lang']] : $default_value;
|
|
|
|
$this->_html .= '
|
|
|
|
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
|
|
<input type="text" name="'.$p['name'].'_'.$language['id_lang'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'_'.$language['id_lang'].'" value="'.($this->_object ? $this->_object->{$p['name']}[(int)$language['id_lang']] : $default_lang).'"' . (isset($p['css']) ? 'style="'.$p['css'].'"' : '') . '>
|
|
|
|
' . ((isset($p['required']) && $p['required']) ? '<sup> *</sup>' : '') . '
|
|
|
|
' . ((isset($p['hint']) && $p['hint']) ? '<p class="hint">'.$p['hint'].'</p>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
$this->_html .= '
|
|
|
|
<p class="clear"></p>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputFile($p = array()){
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<input type="file" name="'.$p['name'].'" id="'.$p['name'].'" value="" />
|
|
|
|
' . ((isset($p['required']) && $p['required']) ? '<sup> *</sup>' : '') . '
|
|
|
|
' . ((isset($p['hint']) && $p['hint']) ? '<p class="small">'.$p['hint'].'</p>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<p class="clear"></p>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputSelect($p = array()){
|
|
|
|
$disabled = ((isset($p['disabled']) && $p['disabled']) ? 'disabled="disabled"' : '');
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<select ' . $disabled . ' id="'.$p['name'].'" name="'.$p['name'].'">';
|
|
|
|
foreach($p['options'] as $opt) {
|
|
|
|
$selected = '';
|
|
|
|
if (
|
|
|
|
(isset($opt['selected']) && $opt['selected']) ||
|
|
|
|
(isset($this->_object) && $this->_object->{$p['name']} == $opt['value'])
|
|
|
|
)
|
|
|
|
$selected = ' selected="selected"';
|
|
|
|
$this->_html .= '<option id="' . $p['name'] . '_' . $opt['value'] . '" value="' . $opt['value'] . '"'. $selected .'>'.$opt['label'].'</option>';
|
|
|
|
}
|
|
|
|
$this->_html .= '
|
|
|
|
</select>
|
|
|
|
' . ((isset($p['filter']) && $p['filter']) ? '<div class="clear"></div><br/><input data-id="' . $p['name'] . '" class="select_filter" id="filter_' . $p['name'] . '" type="text" ' . ((isset($p['filter_text']) && $p['filter_text']) ? 'placeholder="' . $p['filter_text'] . '"' : '') . 'autocomplete="off" value="" /> <span class="filter_count" id="filter_count_' . $p['name'] . '"></span>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-10-21 15:54:52 +02:00
|
|
|
public function inputSelectStyled($p = array()){
|
|
|
|
$disabled = ((isset($p['disabled']) && $p['disabled']) ? 'disabled="disabled"' : '');
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
2016-10-21 16:16:12 +02:00
|
|
|
<div class="styled-select'.(isset($p['class-select']) && $p['class-select'] ? ' ' . $p['class-select'] : '').'">
|
2016-10-21 15:54:52 +02:00
|
|
|
<select ' . $disabled . ' id="'.$p['name'].'" name="'.$p['name'].'">';
|
|
|
|
foreach($p['options'] as $opt) {
|
|
|
|
$selected = '';
|
|
|
|
if (
|
|
|
|
(isset($opt['selected']) && $opt['selected']) ||
|
|
|
|
(isset($this->_object) && $this->_object->{$p['name']} == $opt['value'])
|
|
|
|
)
|
|
|
|
$selected = ' selected="selected"';
|
|
|
|
$this->_html .= '<option id="' . $p['name'] . '_' . $opt['value'] . '" value="' . $opt['value'] . '"'. $selected .'>'.$opt['label'].'</option>';
|
|
|
|
}
|
|
|
|
$this->_html .= '
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
' . ((isset($p['filter']) && $p['filter']) ? '<div class="clear"></div><br/><input data-id="' . $p['name'] . '" class="select_filter" id="filter_' . $p['name'] . '" type="text" ' . ((isset($p['filter_text']) && $p['filter_text']) ? 'placeholder="' . $p['filter_text'] . '"' : '') . 'autocomplete="off" value="" /> <span class="filter_count" id="filter_count_' . $p['name'] . '"></span>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-06 15:32:52 +02:00
|
|
|
public function inputBool($p = array()){
|
|
|
|
$checked = ((isset($p['default']) && $p['default']) ? $p['default'] : false);
|
|
|
|
if ($this->_object)
|
|
|
|
$checked = $this->_object->{$p['name']};
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form bool' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<div id="'.$p['name'].'" style="float: left;">
|
|
|
|
<input type="radio" name="'.$p['name'].'" value="1" id="'.$p['name'].'_on"'.($checked ? ' checked="checked"' : '').'/>' . (isset($p['label_on']) && $p['label_on'] ? ' <label class="radio_label" for="'.$p['name'].'_on">'.$p['label_on'].'</label>' : '') . '
|
|
|
|
<input type="radio" name="'.$p['name'].'" value="0" id="'.$p['name'].'_off"'.($checked ? '' : ' checked="checked"').'/>' . (isset($p['label_off']) && $p['label_off'] ? ' <label class="radio_label" for="'.$p['name'].'_off">'.$p['label_off'].'</label>' : '') . '
|
|
|
|
</div>
|
|
|
|
<div class="clear"></div>
|
|
|
|
' . ((isset($p['hint']) && $p['hint']) ? '<p class="small">'.$p['hint'].'</p>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<div class="clear"></div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputCheckbox($p = array()){
|
|
|
|
$checked = ((isset($p['checked']) && $p['checked']) ? $p['checked'] : false);
|
|
|
|
if ($this->_object)
|
|
|
|
$checked = $this->_object->{$p['name']};
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form checkbox' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<input type="checkbox" id="'.$p['name'].'" name="'.$p['name'].'" value="1" id="'.$p['name'].'"'.($checked ? ' checked="checked"' : '').'/>
|
|
|
|
' . (isset($p['text']) && $p['text'] ? '<label class="checkbox_label" for="'.$p['name'].'">'.$p['text'].'</label>' : '') . '
|
|
|
|
<div class="clear"></div>
|
|
|
|
' . ((isset($p['hint']) && $p['hint']) ? '<p class="small">'.$p['hint'].'</p>' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<div class="clear"></div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputDate($p = array()){
|
|
|
|
$this->_dateTime = true;
|
|
|
|
$default = ((isset($p['default']) && $p['default']) ? $p['default'] : '');
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form date' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<div id="'.$p['name'].'" style="float: left;">
|
|
|
|
<input class="datetimepicker" name="'.$p['name'].'" type="text" value="'.($this->_object ? $this->_object->{$p['name']} : $default).'" style="width: 150px;" />
|
|
|
|
' . ((isset($p['required']) && $p['required']) ? '<sup> *</sup>' : '') . '
|
|
|
|
</div>
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<div class="clear"></div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputRte($p = array()){
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form translatable rte' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">';
|
|
|
|
foreach ($this->_languages AS $language){
|
|
|
|
$default_lang = (is_array($p['default'])) ? $p['default'][(int)$language['id_lang']] : '';
|
|
|
|
$this->_html .= '
|
|
|
|
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
|
|
<textarea name="'.$p['name'].'_'.$language['id_lang'].'" rows="4" cols="75">'.($this->_object ? $this->_object->{$p['name']}[(int)$language['id_lang']] : $default_lang).'</textarea>
|
|
|
|
' . ((isset($p['required']) && $p['required']) ? '<sup> *</sup>' : '') . '
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
$this->_html .= '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<p class="clear"></p>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function selectCheck($p = array()){
|
|
|
|
$this->_selectCheck = true;
|
|
|
|
$size = ((isset($p['size']) && $p['size']) ? (int) $p['size'] : 5);
|
|
|
|
$this->_html .= '<label' . (isset($p['class']) && $p['class'] ? ' class="' . $p['class'] . '"' : '') . '>'.$p['label'].'</label>
|
|
|
|
<div class="margin-form' . (isset($p['class']) && $p['class'] ? ' ' . $p['class'] : '') . '">
|
|
|
|
<div id="'.$p['name'].'_selectCheck" style="float: left;">
|
|
|
|
<select data-text="' . $p['select_all_text'] . '" id="'.$p['name'].'" class="multiSelectCheck" name="'.$p['name'].'[]" multiple="multiple" size="'.$size.'">
|
|
|
|
<option value=""></option>
|
|
|
|
<optgroup label="'.$p['group_label'].'">';
|
|
|
|
|
|
|
|
foreach($p['options'] as $opt) {
|
|
|
|
$selected = '';
|
|
|
|
if (isset($opt['selected']) && $opt['selected'])
|
|
|
|
$selected = ' selected="selected"';
|
|
|
|
$this->_html .= '<option' .
|
|
|
|
((isset($opt['class']) && $opt['class']) ? ' class="' . $opt['class'] . '"' : '') .
|
|
|
|
' value="' . $opt['value'] . '"'. $selected . '>' . $opt['label'] .
|
|
|
|
'</option>';
|
|
|
|
}
|
|
|
|
$this->_html .= '
|
|
|
|
</optgroup>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
' . ((isset($p['filter']) && $p['filter']) ? '<div class="clear"></div><br/><input data-id="' . $p['name'] . '" class="selectCheck_filter" id="filter_' . $p['name'] . '" type="text" ' . ((isset($p['filter_text']) && $p['filter_text']) ? 'placeholder="' . $p['filter_text'] . '"' : '') . 'autocomplete="off" value="" />' : '') . '
|
|
|
|
' . ((isset($p['html']) && $p['html']) ? $p['html'] : '') . '
|
|
|
|
<div class="clear"></div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function inputButton($p = array()){
|
|
|
|
$css = isset($p['css']) && $p['css'] ? $p['css'] : false;
|
|
|
|
$this->_html .= '
|
|
|
|
<a '.($css ? 'style="'.$css.'"' : '').' href="'.$p['action'].'" class="button" name="'.$p['name'].'">'.$p['label'].'</a>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
public function inputSubmit($p = array()){
|
|
|
|
$css = isset($p['css']) && $p['css'] ? $p['css'] : false;
|
|
|
|
$this->_html .= '
|
|
|
|
<input '.($css ? 'style="'.$css.'"' : '').' type="submit" class="button" name="'.$p['name'].'" value="'.$p['label'].'" />
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inputHidden($p = array()){
|
|
|
|
$id = ((isset($p['id']) && $p['id']) ? $p['id'] : $p['name']);
|
|
|
|
$this->_html .= '
|
|
|
|
<input type="hidden" id="'.$id.'" name="'.$p['name'].'" value="'.$p['value'].'" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function displayError($message){
|
|
|
|
$this->_messages[] = '<div class="error">' . $message . '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function displayMessage($message){
|
|
|
|
return $this->_messages[] = '<div class="message">' . $message . '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function displayConf($message){
|
|
|
|
return $this->_messages[] = '<div class="conf">' . $message . '</div>';
|
|
|
|
}
|
|
|
|
}
|