public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": Rapyd::js('tinymce/tinymce.min.js'); Rapyd::js('tinymce/tinymce_editor.js'); $output = Form::textarea($this->name, $this->value, $this->attributes); Rapyd::script("function elFinderBrowser (field_name, url, type, win) {" . "tinymce.activeEditor.windowManager.open({" . "file: '" . route('elfinder.tinymce4') . "'," . "title: 'elFinder 2.0'," . "width: 900," . "height: 450," . "resizable: 'yes'" . "}, {" . "setUrl: function (url) {" . "win.document.getElementById(field_name).value = url;" . "}" . "});" . "return false;" . "}"); Rapyd::script("tinymce.init({selector: '#" . $this->name . "', file_browser_callback : elFinderBrowser, plugins: 'image', convert_urls: false});"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->description; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": foreach ($this->options as $val => $label) { $this->checked = (!is_null($this->value) and $this->value == $val); $output .= Form::radio($this->name, $val, $this->checked) . ' ' . $label . $this->separator; } $output .= $this->extra_output; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; $this->attributes["class"] = "form-control"; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = "<img border=\"0\" src=\"//maps.googleapis.com/maps/api/staticmap?center={$this->value['lat']},{$this->value['lon']}&zoom={$this->zoom}&size=500x500\">"; } $output = "<div class='help-block'>" . $output . "</div>"; break; case "create": case "modify": $output = Form::hidden($this->lat, $this->value['lat'], ['id' => $this->lat]); $output .= Form::hidden($this->lon, $this->value['lon'], ['id' => $this->lon]); $output .= '<div id="map_' . $this->name . '" style="width:500px; height:500px"></div>'; $output .= '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>'; \Rapyd::script("\n \n function initialize()\n {\n var latitude = document.getElementById('{$this->lat}');\n var longitude = document.getElementById('{$this->lon}');\n var zoom = {$this->zoom};\n \n var LatLng = new google.maps.LatLng(latitude.value, longitude.value);\n \n var mapOptions = {\n zoom: zoom,\n center: LatLng,\n panControl: false,\n zoomControl: false,\n scaleControl: true,\n mapTypeId: google.maps.MapTypeId.ROADMAP\n }\n \n var map = new google.maps.Map(document.getElementById('map_{$this->name}'),mapOptions);\n \n var marker = new google.maps.Marker({\n position: LatLng,\n map: map,\n title: 'Drag Me!',\n draggable: true\n });\n \n google.maps.event.addListener(marker, 'dragend', function (event) {\n latitude.value = event.latLng.lat();\n longitude.value = event.latLng.lng();\n });\n \n }\n initialize();\n "); break; case "hidden": $output = ''; //Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; unset($this->attributes['type'], $this->attributes['size']); if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->description; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::select($this->name, $this->options, $this->value, $this->attributes) . $this->extra_output; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "show": $output = $this->value; $output = "<div class='help-block' style='background-color:" . $output . "'> </div>"; break; case "create": case "modify": Rapyd::css('colorpicker/css/bootstrap-colorpicker.min.css'); Rapyd::js('colorpicker/js/bootstrap-colorpicker.min.js'); $output = Form::text($this->name, $this->value, $this->attributes); $output .= Rapyd::script("\n \$('#" . $this->name . "').colorpicker({\n format: 'hex'\n });"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = "********"; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::password($this->name, $this->attributes); break; case "hidden": $output = ""; break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": Rapyd::js('redactor/jquery.browser.min.js'); Rapyd::js('redactor/redactor.min.js'); Rapyd::css('redactor/css/redactor.css'); $output = Form::textarea($this->name, $this->value, $this->attributes); Rapyd::script("\$('#" . $this->name . "').redactor();"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->checked ? $this->checked_output : $this->unchecked_output; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": //dd($this->checked); $output = Form::checkbox($this->name, $this->checked_value, $this->checked, $this->attributes) . $this->extra_output; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::text($this->name, $this->value, array_merge(array('class' => 'col-xs-12'), $this->attributes)); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "show": if (!isset($this->value)) { $value = $this->layout['null_label']; } else { $value = str_replace($this->serialization_sep, ' ', $this->value); } $output = $value; $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": Rapyd::css('datepicker/datepicker3.css'); Rapyd::js('datepicker/bootstrap-datepicker.js'); if ($this->language != "en") { Rapyd::js('datepicker/locales/bootstrap-datepicker.' . $this->language . '.js'); } unset($this->attributes['id']); //$this->attributes['class'] = "form-control"; $from = Form::text($this->name . '[from]', @$this->values[0], $this->attributes); $to = Form::text($this->name . '[to]', @$this->values[1], $this->attributes); $output = ' <div id="range_' . $this->name . '_container"> <div class="input-daterange"> <div class="input-group"> <div class="input-group-addon">≥</div> ' . $from . ' </div> <div class="input-group"> <div class="input-group-addon">≤</div> ' . $to . ' </div> </div> </div>'; Rapyd::pop_script(); Rapyd::script("\n \$('#range_{$this->name}_container .input-daterange').datepicker({\n format: '{$this->formatToDate()}',\n language: '{$this->language}',\n todayBtn: 'linked',\n autoclose: true\n });"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": break; case "create": case "modify": case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->value; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $lower = Form::number($this->name . '[]', @$this->values[0], $this->attributes); $upper = Form::number($this->name . '[]', @$this->values[1], $this->attributes); $output = ' <div id="range_' . $this->name . '_container"> <div class="input-group"> <div class="input-group-addon">≥</div> ' . $lower . ' </div> <div class="input-group"> <div class="input-group-addon">≤</div> ' . $upper . ' </div> </div>'; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (!isset($this->style)) { $this->style = "margin:0 2px 0 0; vertical-align: middle"; } unset($this->attributes['id']); if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->description; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": //dd($this->options, $this->values); foreach ($this->options as $val => $label) { $this->checked = in_array($val, $this->values); //echo ((int)$this->checked)."<br />"; $output .= sprintf($this->format, Form::checkbox($this->name . '[]', $val, $this->checked) . $label) . $this->separator; } $output .= $this->extra_output; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) return; switch ($this->status) { case "disabled": case "show": if ($this->type =='hidden' || $this->value == "") { $output = ""; } elseif ( (!isset($this->value)) ) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>".$output." </div>"; break; case "create": case "modify": Rapyd::js('tinymce/tinymce.min.js'); $output = Form::textarea($this->name, $this->value, $this->attributes); Rapyd::script("tinymce.init({selector: '#".$this->name."'});"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default:; } $this->output = "\n".$output."\n". $this->extra_output."\n"; }
public function prepareForm() { $form_attr = array('url' => $this->process_url, 'class' => "form-horizontal", 'role' => "form", 'method' => $this->method); $form_attr = array_merge($form_attr, $this->attributes); // See if we need a multipart form foreach ($this->fields as $field_obj) { if (in_array($field_obj->type, array('file', 'image'))) { $form_attr['files'] = 'true'; break; } } // Set the form open and close if ($this->status == 'show') { $this->open = '<div class="form">'; $this->close = '</div>'; } else { $this->open = Form::open($form_attr); $this->close = Form::hidden('save', 1) . Form::close(); if ($this->method == "GET") { $this->close = Form::hidden('search', 1) . Form::close(); } } if (isset($this->validator)) { $this->errors = $this->validator->messages(); $this->error .= implode('<br />', $this->errors->all()); } }
public function build() { $output = ""; Rapyd::css('autocomplete/autocomplete.css'); Rapyd::js('autocomplete/typeahead.bundle.min.js'); Rapyd::js('template/handlebars.js'); unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } elseif ($this->value == "") { $output = ""; } else { if ($this->relation != null) { $name = $this->rel_field; $value = @$this->relation->get()->first()->{$name}; } else { $value = $this->value; } $output = nl2br(htmlspecialchars($value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if (Input::get("auto_" . $this->name)) { $autocomplete = Input::get("auto_" . $this->name); } elseif ($this->relation != null) { $name = $this->rel_field; $autocomplete = @$this->relation->get()->first()->{$name}; } elseif (count($this->local_options)) { $autocomplete = $this->description; } else { $autocomplete = $this->value; } $output = Form::text("auto_" . $this->name, $autocomplete, array_merge($this->attributes, array('id' => "auto_" . $this->name))) . "\n"; $output .= Form::hidden($this->name, $this->value, array('id' => $this->name)); $output = '<span id="th_' . $this->name . '">' . $output . '</span>'; if ($this->remote) { $script = <<<acp var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('auto_{$this->name}'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: '{$this->remote}?q=%QUERY' }); blod_{$this->name}.initialize(); \$('#th_{$this->name} .typeahead').typeahead(null, { name: '{$this->name}', displayKey: '{$this->record_label}', highlight: true, minLength: {$this->min_chars}, source: blod_{$this->name}.ttAdapter(), templates: { suggestion: Handlebars.compile('{{{$this->record_label}}}') } }).on("typeahead:selected typeahead:autocompleted", function (e,data) { \$('#{$this->name}').val(data.{$this->record_id}); }).on("typeahead:closed", function (e,data) { if (\$(this).val() == '') { \$('#{$this->name}').val(''); } }); acp; Rapyd::script($script); } elseif (count($this->options)) { $options = json_encode($this->local_options); //options $script = <<<acp var {$this->name}_options = {$options}; var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, local: {$this->name}_options }); blod_{$this->name}.initialize(); \$('#th_{$this->name} .typeahead').typeahead({ hint: true, highlight: true, minLength: {$this->min_chars} }, { name: '{$this->name}', displayKey: 'value', source: blod_{$this->name}.ttAdapter() }).on("typeahead:selected typeahead:autocompleted", function (e,data) { \$('#{$this->name}').val(data.key); }).on("typeahead:closed", function (e,data) { if (\$(this).val() == '') { \$('#{$this->name}').val(''); } }); acp; Rapyd::script($script); } break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function options($name, $options = []) { $options = empty($options) ? [1 => 'Active', '' => 'Disable'] : $options; return Form::select($name, $options, $this->{$name}, ['class' => 'form-control']); }
/** * return a form with a nested action button * @param $url * @param $method * @param $name * @param string $position * @param array $attributes * @return $this */ public function formButton($url, $method, $name, $position = "BL", $attributes = array()) { $attributes = array_merge(array("class" => "btn btn-default"), $attributes); $this->button_container[$position][] = Form::open(array('url' => $url, 'method' => $method)) . Form::submit($name, $attributes) . Form::close(); return $this; }
/** * @param string $name * @param string $position * @param array $options * * @return $this */ public function submit($name, $position = "BL", $options = array()) { $options = array_merge(array("class" => "btn btn-primary"), $options); $this->button_container[$position][] = Form::submit($name, $options); return $this; }
public function build() { $this->path = $this->parseString($this->path); $this->web_path = $this->parseString($this->web_path); $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if ($this->old_value) { $output .= '<div class="clearfix">'; $output .= link_to($this->web_path . $this->value, $this->value) . " "; $output .= Form::checkbox($this->name . '_remove', 1, (bool) Input::get($this->name . '_remove')) . " " . trans('rapyd::rapyd.delete') . " <br/>\n"; $output .= '</div>'; } $output .= Form::file($this->name, $this->attributes); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; unset($this->attributes['type']); if (parent::build() === false) return; switch ($this->status) { case "show": if (!isset($this->value)) { $value = $this->layout['null_label']; } else { $value = $this->isoDateToHuman($this->value); } $output = $value; $output = "<div class='help-block'>".$output." </div>"; break; case "create": case "modify": if ($this->value != "") { if (!$this->is_refill) { $this->value = $this->isoDateToHuman($this->value); } } Rapyd::css('datepicker/datepicker3.css'); Rapyd::js('datepicker/bootstrap-datepicker.js'); if ($this->language != "en") { Rapyd::js('datepicker/locales/bootstrap-datepicker.'.$this->language.'.js'); } $output = Form::text($this->name, $this->value, $this->attributes); Rapyd::script(" $('#".$this->name."').datepicker({ format: '{$this->formatToDate()}', language: '{$this->language}', todayBtn: 'linked', autoclose: true });"); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default:; } $this->output = $output; }
public function build() { $output = ""; //typeahead Rapyd::css('autocomplete/autocomplete.css'); Rapyd::js('autocomplete/typeahead.bundle.min.js'); Rapyd::js('template/handlebars.js'); //tagsinput Rapyd::css('autocomplete/bootstrap-tagsinput.css'); Rapyd::js('autocomplete/bootstrap-tagsinput.min.js'); unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->description; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::text($this->name, '', array_merge($this->attributes, array('id' => "" . $this->name))) . "\n"; if ($this->remote) { $script = <<<acp \$('#{$this->name}').tagsinput({ itemValue: '{$this->record_id}', itemText: '{$this->record_label}' }); {$this->fill_tags} var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('{$this->name}'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: '{$this->remote}?q=%QUERY' }); blod_{$this->name}.initialize(); \$('#{$this->name}').tagsinput('input').typeahead(null, { name: '{$this->name}', displayKey: '{$this->record_label}', highlight: true, minLength: {$this->min_chars}, source: blod_{$this->name}.ttAdapter() }).bind('typeahead:selected', \$.proxy(function (obj, data) { this.tagsinput('add', data); this.tagsinput('input').typeahead('val', ''); }, \$('#{$this->name}'))); acp; Rapyd::script($script); } elseif (count($this->options)) { $options = json_encode($this->local_options); //options $script = <<<acp var {$this->name}_options = {$options}; \$('#{$this->name}').tagsinput({ itemValue: 'key', itemText: 'value' }); {$this->fill_tags} var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, local: {$this->name}_options }); blod_{$this->name}.initialize(); \$('#{$this->name}').tagsinput('input').typeahead({ hint: true, highlight: true, minLength: {$this->min_chars} }, { name: '{$this->name}', displayKey: 'value', source: blod_{$this->name}.ttAdapter() }).bind('typeahead:selected', \$.proxy(function (obj, data) { this.tagsinput('add', data); this.tagsinput('input').typeahead('val', ''); }, \$('#{$this->name}'))); acp; Rapyd::script($script); } break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }