Exemplo n.º 1
0
 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 . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $this->attributes['multiple'] = 'multiple';
             $output .= \Form::select($this->name . '[]', $this->options, $this->values, $this->attributes);
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Exemplo n.º 2
0
 function build()
 {
     $output = "";
     if (!isset($this->style) and !isset($this->attributes['style'])) {
         $this->style = "width:290px;";
     }
     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;
 }
Exemplo n.º 3
0
 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 = '<div class="textarea_html_disabled"><pre>' . htmlspecialchars($this->value) . '</pre></div>';
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $output = Form::textarea($this->name, $this->value, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Exemplo n.º 4
0
 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 = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('packages/zofe/rapyd/assets/tinymce/tinymce.min.js');
             $output = Form::textarea($this->db_name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n          tinymce.init({\n            selector: 'textarea#" . $this->name . "',\n            plugins: [\n                 'advlist autolink link image lists charmap print preview hr anchor pagebreak',\n                 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n                 'save table contextmenu directionality emoticons template paste textcolor responsivefilemanager'\n            ],\n            toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons', \n            image_advtab: true ,\n            external_filemanager_path:'" . URL::to('/') . "/packages/filemanager/',\n            filemanager_title:'Upload',\n          });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Exemplo n.º 5
0
 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 = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             $output = Form::file($this->db_name, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Exemplo n.º 6
0
 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 . "'>&nbsp;</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;
 }
Exemplo n.º 7
0
 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 . "&nbsp;</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";
 }
Exemplo n.º 8
0
 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;
             }
             break;
         case "create":
         case "modify":
             $output = Form::checkbox($this->name, $this->checked_value, $this->checked) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Exemplo n.º 9
0
 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 . "&nbsp;</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;
 }
Exemplo n.º 10
0
 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 . "&nbsp;</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;
 }
Exemplo n.º 11
0
 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 . "&nbsp;</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');
             }
             unset($this->attributes['id']);
             //$this->attributes['class'] = "form-control";
             $from = Form::text($this->name . '[]', @$this->values[0], $this->attributes);
             $to = Form::text($this->name . '[]', @$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">&ge;</div>
                                    ' . $from . '
                                </div>
                                <div class="input-group">
                                     <div class="input-group-addon">&le;</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;
 }
Exemplo n.º 12
0
 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";
 }
Exemplo n.º 13
0
 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 . "&nbsp;</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;
 }
Exemplo n.º 14
0
 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->isodatetimeToHuman($this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->value != "") {
                 if (!$this->is_refill) {
                     $this->value = $this->isodatetimeToHuman($this->value);
                 }
             }
             Rapyd::css('datetimepicker/datetimepicker3.css');
             Rapyd::js('datetimepicker/bootstrap-datetimepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datetimepicker/locales/bootstrap-datetimepicker.' . $this->language . '.js');
             }
             $output = Form::text($this->name, $this->value, $this->attributes);
             Rapyd::script("\n                        \$('#" . $this->name . "').datetimepicker({\n                            format: '{$this->formatTodatetime()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Exemplo n.º 15
0
    public function build()
    {
        $output = "";
        Rapyd::css('packages/zofe/rapyd/assets/autocomplete/autocomplete.css');
        Rapyd::js('packages/zofe/rapyd/assets/autocomplete/typeahead.bundle.min.js');
        Rapyd::js('packages/zofe/rapyd/assets/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 {
                    $output = nl2br(htmlspecialchars($this->value));
                    if ($this->is_multiple) {
                        $output = '<div class="textarea_disabled">' . $output . '</div>';
                    }
                }
                break;
            case "create":
            case "modify":
                if (Input::get("auto_" . $this->db_name)) {
                    $autocomplete = Input::get("auto_" . $this->db_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));
                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();
                
                    \$('#div_{$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});
                    });
acp;
                    $output .= 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();
                    
                    \$('#div_{$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);
                    });
acp;
                    $output .= 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";
    }
Exemplo n.º 16
0
 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 . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->old_value) {
                 $output .= '<div class="clearfix">';
                 $output .= link_to($this->web_path . $this->value, $this->value) . "&nbsp;";
                 $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";
 }
Exemplo n.º 17
0
 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());
     }
 }
Exemplo n.º 18
0
 /**
  * Create a HTML hidden input element.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  array   $attributes
  * @return string
  */
 public function hidden($name, $value = null, $attributes = array())
 {
     $value = $this->calculateValue($name, $value);
     return Form::hidden($name, $value, $attributes);
 }
Exemplo n.º 19
0
 protected function buildForm()
 {
     $data = get_object_vars($this);
     $data['buttons'] = $this->button_container;
     $form_attr = array('url' => $this->process_url, 'class' => "", 'role' => "form", 'method' => $this->method);
     // See if we need a multipart form
     foreach ($this->fields as $field_obj) {
         if ($field_obj->type == 'file') {
             $form_attr['files'] = 'true';
             break;
         }
     }
     // Set the form open and close
     if ($this->status == 'show') {
         $data['form_begin'] = '<div class="form">';
         $data['form_end'] = '</div>';
     } else {
         $data['form_begin'] = Form::open($form_attr);
         $data['form_end'] = Form::hidden('save', 1) . Form::close();
         if ($this->method == "GET") {
             $data['form_end'] = Form::hidden('search', 1) . Form::close();
         }
     }
     if (isset($this->validator)) {
         $data['errors'] = $this->validator->messages();
     }
     $data['message'] = $this->process_status == "success" ? $this->message : '';
     $data['groups'] = $this->regroupFields($this->orderFields($this->fields));
     return View::make($this->view, $data);
 }
Exemplo n.º 20
0
    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 . "&nbsp;</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";
    }