protected function _get_input_html(array $params = array()) { $attrs_html = self::_get_attr_html($params); $input_html = "<{$this->_tagname}{$attrs_html}>"; if ($this->get_default_option_enabled()) { $option_text = $this->get_default_option_text() ? $this->get_default_option_text() : \ZPHP\String::get($this->get_optional() ? 'not_specified' : 'select'); $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'>" . \ZPHP\HTMLHelper::escape($option_text) . "</option>"; $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'></option>"; } foreach ($this->_options as $option) { $option_tag = new HTMLLongTag('option', \ZPHP\HTMLHelper::escape($option['label'])); $option_tag->set_param('value', \ZPHP\HTMLHelper::escape($option['value'])); if (!is_null($this->get_value()) && $option['value'] == $this->get_value()) { $option_tag->set_param('selected', true); } $input_html .= $option_tag; } $input_html .= "</{$this->_tagname}>"; return $input_html; }
protected function _get_input_html(array $params = array()) { $title = $this->_get_title(); $attrs_html = self::_get_attr_html($params); $input_html = "<{$this->_tagname}{$attrs_html}>"; if ($this->get_default_option_enabled()) { $option_text = $this->get_default_option_text() ? $this->get_default_option_text() : \ZPHP\String::get($this->get_optional() ? 'not_specified' : 'select'); $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'>" . \ZPHP\HTMLHelper::escape($option_text) . "</option>"; $input_html .= "<option value='" . \ZPHP\HTMLHelper::escape($this->get_default_option_value()) . "'></option>"; } foreach ($this->_options as $option) { $option_tag = new HTMLLongTag('option', \ZPHP\HTMLHelper::escape($option['label'])); $option_tag->set_param('value', \ZPHP\HTMLHelper::escape($option['value'])); if (!is_null($this->get_value()) && $option['value'] == $this->get_value()) { $option_tag->set_param('selected', true); } $input_html .= $option_tag; } $input_html .= "</{$this->_tagname}>"; $js_id = \ZPHP\JSHelper::cast_str('#' . $this->_get_id()); $js_container_class = \ZPHP\JSHelper::cast_str(self::$_SELECT2_CONTAINER_CLASS); $js_searching = \ZPHP\String::get_js('searching'); $js_no_matches = \ZPHP\String::get_js('no_matches_found'); $js_placeholder = $this->_get_title(); if ((!array_key_exists('placeholder', $params) || !$params['placeholder']) && $this->get_use_title_label() && $title) { $js_placeholder = $title; } $js_placeholder = \ZPHP\JSHelper::cast_str($js_placeholder); $input_html .= "<script type='text/javascript'>\n\n\t\t\t\t//\$(document).ready(function () {\n\t\t\t\t\t\t\$({$js_id}).select2({\n\t\t\tcontainerCssClass: {$js_container_class},\n\t\t\tformatSearching: function() {\n\t\t\treturn {$js_searching};\n\t\t\t},\n\t\t\tformatNoMatches: function() {\n\t\t\treturn {$js_no_matches};\n\t\t\t},"; if ($this->get_width()) { $input_html .= "width: " . \ZPHP\JSHelper::cast_str($this->get_width()) . ","; } $input_html .= "dropdownAutoWidth: true,\n\t\t\tminimumResultsForSearch: -1,\n\t\t\tescapeMarkup: function(s) { return s; },\n\t\t\tplaceholder: {$js_placeholder}\n\t\t\t});"; /*$(<?=JSHelper::cast_str("#{$id}")?><!--).on('change', function() { --><?//=$tag_attrs['onchange']?><!-- });-->*/ // $input_html.= " }); "; $input_html .= "\n</script>"; return $input_html; }
/** * * @return HTMLTag * */ public function add_action_link_icon($title, $icon_class, $onclick = null, $field = null) { $tag = new HTMLLongTag('a'); $tag->set_content("<span class='icon {$icon_class}'> </span>"); $tag->set_param('title', $title); $tag->set_param('href', 'javascript: void(0)'); $this->_set_tag_onclick_function($tag, $onclick, $field); return $this->add_action_tag($tag); }
/** * * @return $this * */ public function add_cancel_button($text = null, array $attrs = array(), $class = '') { $button = new HTMLLongTag('button', $text ? $text : \ZPHP\String::get_html('cancel')); $button->update_params($attrs); $button->set_param('type', 'button'); $button->add_class($class); $button->add_class(self::$_DEFAULT_BUTTON_CLASS); $button->add_class(self::$_DEFAULT_BUTTON_CANCEL_CLASS); $this->_buttons[] = $button; if (!$button->get_id()) { $button->set_random_id(); } $this->_cancel_buttons[] = $button->get_id(); return $this; }
protected static function _prepare_page_html($html, $title = null, $back = null) { if ($title) { $title_html = new HTML\HTMLLongTag('div'); if ($back) { $back_link = new HTML\HTMLLongTag('a'); $back_link->content = 'Back'; $back_link->set_param('href', (string) $back); $back_link->add_style('float', 'right'); $back_link->add_style('font-weight', 'normal'); $back_link->add_style('color', '#FFF'); $back_link->add_style('text-decoration', 'underline'); $title_html->add_content($back_link); } $title_html->add_content($title); $title_html->add_style('background', '#222'); $title_html->add_style('color', '#FFF'); $title_html->add_style('padding', '10px 15px'); $title_html->add_style('font-weight', 'bold'); $title_html->add_style('border-radius', '5px'); $title_html->add_style('margin', '0 0 20px 0'); } else { $title_html = ''; } $bootstrap = '<script src="' . \URL::route(self::URL_STATIC, 'jquery.min.js') . '"></script><link rel="stylesheet" href="' . \URL::route(self::URL_STATIC, 'bootstrap.min.css') . '"><script src="' . \URL::route(self::URL_STATIC, 'bootstrap.min.js') . '"></script>'; $html = '<html><head>' . $bootstrap . '</head><body></body><style type="text/css">body {background: #F2F2F2; padding: 20px; } div#page-body {padding: 0 10px 0; clear:both;}</style>' . $title_html . '<div id="page-body">' . $html . '</div></body></html>'; return $html; }