protected function _get_input_html(array $params = array()) { $attrs_html = self::_get_attr_html_exclude($params, array('onclick', 'onchange', 'value')); $checkbox_attrs_html = self::_get_attr_html_only($params, array('onclick', 'onchange')); $input_html = "<{$this->_tagname}{$attrs_html}>"; if (!empty($this->_options)) { $list_html = array(); foreach ($this->_options as $option) { $option_tag = new HTMLInputCheckboxControl($this->get_name() . '[]', $option['label'], in_array($option['value'], $this->_selected_values), $option['value']); $option_tag->update_params($checkbox_attrs_html); $option_tag->set_id($this->get_name() . '_' . $option['value']); $list_html[] = $option_tag->to_string(); } $need_count = ceil(count($list_html) / $this->_columns) * $this->_columns; while (count($list_html) < $need_count) { $list_html[] = self::$_DEFAULT_FILL_CELL_HTML; } $col_md = floor(12 / $this->_columns); $table = array(); $row = array(); foreach ($list_html as $cell) { $row[] = $cell; if (count($row) == $this->_columns) { $table[] = $row; $row = array(); } } if ($this->_sort_type == self::SORT_ROWS) { $count_cols = count($table[0]); $count_rows = count($table); $list_index = 0; for ($index_col = 0; $index_col < $count_cols; $index_col++) { for ($index_row = 0; $index_row < $count_rows; $index_row++) { $table[$index_row][$index_col] = $list_html[$list_index]; $list_index++; } } } foreach ($table as $row) { $input_html .= "<div class='row'>"; foreach ($row as $cell) { $input_html .= "<div class='col-md-{$col_md}'>{$cell}</div>"; } $input_html .= "</div>"; } } $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); $html = "<{$this->_tagname}{$attrs_html} />"; if ($this->get_value()) { $delete_checkbox = new HTMLInputCheckboxControl($this->get_name() . '_delete', \ZPHP\String::get('delete')); $delete_checkbox->onclick = '$(' . JSHelper::cast_str('#' . $this->get_name() . '_image') . ').toggleClass("todelete", $(this).attr("checked"))'; $delete_checkbox->onclick = '$(this).parents(".input-image-container").find("img").toggleClass("todelete", $(this).attr("checked"))'; $html .= '<br />'; $html .= '<div class="input-image-container"> '; $html .= '<img src="' . HTMLHelper::escape($this->get_value()) . '" alt="Image" id="' . HTMLHelper::escape($this->get_name() . '_image') . '" class="' . HTMLHelper::escape(self::$_IMAGE_CLASS) . '" />'; $html .= $delete_checkbox->to_string(); $html .= '</div>'; $html .= '<br />'; } else { $delete_checkbox = new HTMLInputHiddenControl($this->get_name() . '_delete', ''); $html .= '<div class="input-image-container"> '; $html .= $delete_checkbox->to_string(); $html .= '</div>'; } return $html; }