protected function _row_render_function($row, HTMLTableColumn $column, HTMLTable $table)
 {
     $value = $table->get_row_id($row);
     $name = $this->_name ? $this->_name : $table->get_id();
     $html = '<input type="checkbox" ';
     $html .= 'class="checkbox column-checkbox" ';
     $html .= 'value="' . HTMLHelper::escape($value) . '" ';
     $html .= 'id="' . HTMLHelper::escape($this->_get_row_id_html($value, $table)) . '" ';
     $html .= 'name="' . HTMLHelper::escape($name . '[]') . '" ';
     $html .= 'onclick="$(this).getParent(\'tr\').toggleClass(\'checked\', $(this).attr(\'checked\'));" ';
     $html .= ' />';
     return $html;
 }
예제 #2
0
 protected static function _get_attr_html(array $params = array())
 {
     $html = "";
     foreach ($params as $key => $value) {
         $value = trim($value);
         if ($value) {
             try {
                 $html .= " {$key}=\"" . HTMLHelper::escape($value) . "\"";
             } catch (Exception $ex) {
             }
         }
     }
     return $html;
 }
 protected function _get_input_html(array $params = array())
 {
     $title = $this->_get_title();
     if ((!array_key_exists('placeholder', $params) || !$params['placeholder']) && $this->get_use_title_label() && $title) {
         $params['placeholder'] = $title;
     }
     if (array_key_exists('value', $params)) {
         $value = $params['value'];
         unset($params['value']);
     } else {
         $value = '';
     }
     $attrs_html = self::_get_attr_html($params);
     $input_html = "<{$this->_tagname}{$attrs_html}>" . \ZPHP\HTMLHelper::escape($value) . "</{$this->_tagname}>";
     return $input_html;
 }
 protected function _render_function_callback($row, HTMLTableColumn $column, HTMLTable $table)
 {
     $array = $row;
     $json = HTMLHelper::escape(JSHelper::cast_obj($array));
     $block = new HTMLLongTag('div');
     $block->add_style('white-space', 'nowrap');
     $block->add_style('text-align', 'center');
     $block->add_style('padding', '0 10px');
     $html = "";
     $count_added = 0;
     /**
      *
      * @var $tag HTMLTag
      *
      */
     foreach ($column->_actions_tags as $index => $tag) {
         if ($tag->call_filter_callback($row, $column, $table) === false) {
             continue;
         }
         $tag_html = $tag->to_string();
         $tag_html = str_replace('%7B%7B', '{{', $tag_html);
         $tag_html = str_replace('%7D%7D', '}}', $tag_html);
         if (preg_match(self::$_row_json_pattern, $tag_html, $match)) {
             $tag_html = preg_replace(self::$_row_json_pattern, $json, $tag_html);
         }
         while (preg_match(self::$_row_field_pattern, $tag_html, $match)) {
             if ($match['field'] == self::ROW_ID_FIELD) {
                 $field = $table->get_row_id($row);
             } else {
                 $field = ArrayHelper::get_value($row, $match['field']);
             }
             $tag_html = str_replace($match[0], JSHelper::cast($field), $tag_html);
         }
         if ($count_added > 0) {
             $html .= '&nbsp; &nbsp;';
         }
         $html .= $tag_html;
         $count_added++;
     }
     $block->set_content($html);
     return $block;
 }
 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;
 }
 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;
 }
예제 #8
0
 public function to_string()
 {
     $params = array_merge($this->_params, array());
     $params['width'] = $this->get_width();
     $params['height'] = $this->get_height();
     $params['type'] = 'application/x-java-applet';
     $attrs_html = self::_get_attr_html($params);
     $html = "<{$this->_tagname}{$attrs_html}>";
     $html .= '<param name="code" value=' . HTMLHelper::quote($this->get_code_class()) . ' />';
     //		$jar_url = String::put_sufix($this->get_jar_url(), '.jar', false).'?i=';
     $jar_url = $this->get_jar_url() . '?i=';
     if (!ZPHP::get_is_production()) {
         $jar_url .= uniqid();
     } else {
         $jar_url .= ZPHP::get_app_version();
     }
     $html .= '<param name="archive" value=' . HTMLHelper::quote($jar_url) . ' />';
     foreach ($this->_args->to_array() as $key => $value) {
         $html .= '<param name=' . HTMLHelper::quote($key) . ' value=' . HTMLHelper::quote($value) . ' />';
     }
     $html .= $this->get_error_string();
     $html .= "</{$this->_tagname}>";
     return $html;
 }
예제 #9
0
    protected static function _get_exception_html(Exception $ex)
    {
        $message = $ex->getMessage();
        $id_type = 0;
        $type_name = array_key_exists($id_type, self::$_error_types_names) ? self::$_error_types_names[$id_type] : null;
        $trace = self::_get_trace_array($ex->getTraceAsString());
        $file_lines = file($ex->getFile());
        $error_line = $ex->getLine();
        foreach ($file_lines as $index => $line) {
            $file_lines[$index] = rtrim($line);
        }
        $file_lines_count = count($file_lines);
        if ($file_lines_count > self::FILE_OUT_PADDING * 2 + 1) {
            $start_line = $ex->getLine() - self::FILE_OUT_PADDING;
            $end_line = $ex->getLine() + self::FILE_OUT_PADDING;
            if ($start_line < 0) {
                $start_line = 0;
            } else {
                if ($end_line >= $file_lines_count) {
                    $start_line = $file_lines_count - $end_line;
                }
            }
            if ($start_line < 1) {
                $start_line = 1;
            }
            $new_file_lines = array();
            for ($i = 0; $i <= self::FILE_OUT_PADDING * 2 + 1; $i++) {
                $new_file_lines[$i + $start_line] = $file_lines[$start_line + $i - 1];
            }
            $file_lines = $new_file_lines;
        }
        $trace_odd_item_background = '#DDD';
        $trace_even_item_background = '#EEE';
        $trace_item_style = "list-style-type: none; font-size: 10pt; padding: 7px 10px;";
        $trace_item_file_style = "font-weight: bold; ";
        $trace_item_function_style = "";
        $line_number_style = "display: inline-block; width: 50px; color: #888;";
        $selected_line_number_style = "color: #EEE;";
        $line_style = "font-family: mono;font-size: 10pt; font-weight: bold;";
        $stack_trace_file_style = "font-weight: bold;";
        $stack_trace_line_style = "";
        $stack_trace_line_number_style = "font-weight: bold; color: #555; padding-right: 10px; padding-left: 5px;";
        $stack_trace_line_index_style = "display: inline-block; width: 30px; color: #555; ";
        $current_line_style = "background: #FF7070 !important; font-weight: bold; color: #FFF !important;";
        $header_row_style = "padding: 3px 0;";
        $link_style = "color: #FFF; text-decoration: underline; ";
        $box_style = "box-shadow: 2px 2px 1px 1px rgba(0,0,0,0.5); border: solid 1px #111; border-radius: 5px; margin-bottom: 40px !important; ";
        $red_box_style = "box-shadow: 2px 2px 1px 1px rgba(0,0,0,0.5); border: solid 1px #EEE; border-radius: 5px; margin-bottom: 40px !important; ";
        $list_style = "border-radius: 5px;";
        $first_list_item_style = "border-radius: 5px 5px 0 0;";
        $last_list_item_style = "border-radius: 0 0 5px 5px;";
        $list_item_style = "border-radius: 0;";
        $html = '<div style="padding: 20px; background: #F2F2F2;">

			<div style="background: #F00; padding: 10px 15px; border: solid 1px #A88; font-size: 12pt; ' . $red_box_style . '">

				<div style="text-transform: uppercase; font-weight: bold; padding-right: 5px; color: #FFF; text-decoration: underline; padding-bottom: 8px;">
					Error
				</div>

				<div style="' . $header_row_style . '">
					<span style="color: #FFF; font-weight: bold; padding-right: 5px;">
						Site:
					</span>
					<span style="color: #FFF">
						' . env('APP_NAME', '') . '
						<span style="padding-left: 10px;">[ <a target="_blank" style="' . $link_style . '" href="' . \ZPHP\ZPHP::get_app_url() . '">' . \ZPHP\ZPHP::get_app_url() . '</a> ]</span>
					</span>
				</div>

				<div style="' . $header_row_style . '">
					<span style="color: #FFF; font-weight: bold; padding-right: 5px;">
						Request URL:
					</span>
					<span style="color: #FFF">
						' . $_SERVER['REQUEST_URI'] . '
					</span>
				</div>

				<div style="' . $header_row_style . '">
					<span style="color: #FFF; font-weight: bold; ">
						Message:
					</span>
					<span style="color: #FFF">
						' . $message . '
					</span>
				</div></div>';
        if ($type_name) {
            $html .= '<div style="' . $header_row_style . '">
						<span style="color: #FFF; font-weight: bold; ">
							Error Type:
						</span>
						<span style="color: #FFF">
							' . $type_name . '
						</span>
					</div>';
        }
        if (!empty($trace)) {
            $html .= '<div style="margin: 20px 0 0;' . $box_style . ';max-height:300px;overflow-y:auto;">
						<ul style="list-style-type: none; width: 100%; list-style-position: inside;margin:0;padding:0;' . $list_style . '">
							
							<li style="margin-left: 0; padding: 10px 10px; background: ' . $trace_odd_item_background . ';background: #F00;">
								<span style="color: #DDD; ' . $trace_item_file_style . '">
				Stack Trace
			</span>
							</li>

			';
            foreach ($trace as $index => $line) {
                $html .= '<li style="margin-left: 0;background: ' . ($index % 2 == 0 ? $trace_even_item_background : $trace_odd_item_background) . ' !important;' . $trace_item_style . ($index == count($trace) - 1 ? $last_list_item_style : $list_item_style) . '">
								<span style="' . $stack_trace_line_index_style . '">
									#' . ($index + 1) . '
								</span>
					<span style="' . $stack_trace_file_style . '">' . $line['file'] . ' </span><span style="' . $stack_trace_line_number_style . '">[' . $line['line'] . '] </span>
								<span style="' . $stack_trace_line_style . '">
									' . $line['code'] . '
								</span>
				</li>';
            }
            $html .= '</ul></div>';
        }
        $html .= '
	<div style="margin: 20px 0 0;' . $box_style . '">
		<ul style="list-style-type: none; width: 100%; list-style-position: inside;margin:0;padding:0;border: solid 1px #555;' . $list_style . '">
			<li style="margin-left: 0; padding: 10px 10px; background: ' . $trace_odd_item_background . ';background: #F00;">
				<span style="color: #DDD; ' . $trace_item_file_style . '">
					' . $ex->getFile() . '
				</span>

				<span style="color: #FFF; padding-left: 5px; font-weight: bold;">
					[' . $ex->getLine() . ']
				</span>
			</li>

			';
        $index = 0;
        foreach ((array) $file_lines as $line_number => $lines) {
            if ($line_number == 0) {
                continue;
            }
            $lines = HTMLHelper::escape($lines);
            $html .= '<li style="margin-left: 0;' . ($index == 0 ? ' padding-top: 10px !important; ' : '') . 'background: ' . ($index % 2 == 0 ? $trace_even_item_background : $trace_odd_item_background) . ' !important;' . $trace_item_style . ($line_number == $error_line ? $current_line_style : '') . ($index == count($file_lines) - 1 ? $last_list_item_style : $list_item_style) . '">
					<span style="' . $line_number_style . ($line_number == $error_line ? $selected_line_number_style : '') . '">
						# ' . $line_number . '
					</span>

					<span style="' . $line_style . '">
						<!--<pre style="display: inline; border: 0; background: transparent;">' . $lines . '</pre>-->
						' . str_replace("\t", '&nbsp;&nbsp;&nbsp;', $lines) . '
					</span>
				</li>';
            $index++;
        }
        $html .= '</ul></div>';
        foreach (self::$_debug_vars as $debug_var) {
            $var = isset($GLOBALS[$debug_var]) ? $GLOBALS[$debug_var] : array();
            $html .= '<div style="' . $box_style . '">

			<div style="margin: 0px; border: solid 1px #333; background: #777; font-weight: bold; padding: 10px; color: #FFF;">
				' . $debug_var . '
			</div>

			' . VariableHelper::var_export_html($var, true) . '

			</div>';
        }
        return $html;
    }
예제 #10
0
 /**
  *
  * @return $this
  *
  */
 public function open_col($class = '')
 {
     $this->close_col();
     if (!$this->_row_open) {
         $this->open_row();
     }
     $this->_col_open = true;
     $this->_content .= "<div class='" . \ZPHP\HTMLHelper::escape(trim('col form-col ' . $class)) . "'>\n";
     return $this;
 }
 protected function _get_container_html($input_html, $label_html)
 {
     return "<" . self::$_INPUT_CONTAINER_TAGNAME . " class='" . \ZPHP\HTMLHelper::escape(self::$_INPUT_CONTAINER_CLASS) . "'>{$input_html}</" . self::$_INPUT_CONTAINER_TAGNAME . ">" . $label_html;
 }
예제 #12
0
    public function to_string()
    {
        $prepared_rows = array();
        $prepared_columns = array();
        $array_rows = array();
        $has_checkbox_column = false;
        foreach ($this->_rows as $row) {
            $prepared_row = array();
            foreach ($this->_columns as $column) {
                $prepared_row[] = $column->call_row_render_function($row, $this);
            }
            $prepared_rows[] = $prepared_row;
            $array_rows[$this->get_row_id($row)] = $row;
        }
        foreach ($this->_columns as $column) {
            $prepared_column = array();
            $prepared_column['title'] = $column->call_header_render_function($this);
            $prepared_column['orderable'] = $column->get_orderable();
            $prepared_column['class'] = trim($column->get_class());
            $prepared_columns[] = $prepared_column;
            if (ClassHelper::is_instance_of($column, 'ZPHP\\HTML\\HTMLTableColumnCheckbox')) {
                $has_checkbox_column = true;
            }
        }
        $html = '';
        if (empty($this->_rows)) {
            $html = '<div class="panel panel-default datatable-empty">
				<div class="panel-body">
					' . $this->_empty_html . '
				</div>
			</div>';
        } else {
            $attrs_html = self::_get_attr_html($this->_params);
            $html = '

				<div id="' . HTMLHelper::escape('div_container_' . $this->id) . '" class="datatable-container">
					<table' . $attrs_html . '>
						<thead><tr>';
            foreach ($this->_columns as $column) {
                $html .= $column;
            }
            $data_table_params = array();
            $data_table_params['data'] = $prepared_rows;
            $data_table_params['columns'] = $prepared_columns;
            $data_table_params['paging'] = $this->_paging;
            $data_table_params['info'] = $this->_show_info;
            $data_table_params['ordering'] = $this->_ordering;
            $data_table_params['language'] = array();
            $data_table_params['language']['search'] = \ZPHP\String::get('datatables_search');
            $data_table_params['language']['lengthMenu'] = \ZPHP\String::get('datatables_length_menu');
            $data_table_params['language']['zeroRecords'] = \ZPHP\String::get('datatables_zero_records');
            $data_table_params['language']['info'] = \ZPHP\String::get('datatables_info');
            $data_table_params['language']['infoEmpty'] = \ZPHP\String::get('datatables_info_empty');
            $data_table_params['language']['infoFiltered'] = \ZPHP\String::get('datatables_info_filtered');
            $data_table_params['language']['loadingRecords'] = \ZPHP\String::get('datatables_loading_records');
            $data_table_params['language']['paginate'] = array();
            $data_table_params['language']['paginate']['first'] = \ZPHP\String::get('datatables_first');
            $data_table_params['language']['paginate']['last'] = \ZPHP\String::get('datatables_last');
            $data_table_params['language']['paginate']['last'] = \ZPHP\String::get('datatables_last');
            $data_table_params['language']['paginate']['next'] = \ZPHP\String::get('datatables_next');
            $data_table_params['language']['paginate']['previous'] = \ZPHP\String::get('datatables_previous');
            $html .= '

				</tr></thead>
						<tbody></tbody>
					</table>
				</div>
				<script type="text/javascript">
					(function() {
						var table = $(' . JSHelper::cast_str('#' . $this->id) . ');
						var dataTable = table.dataTable(' . JSHelper::cast_obj($data_table_params) . ');

						table.data("rowsData", ' . JSHelper::cast_obj($array_rows) . ');
						table.data("dataTable", dataTable);

						table.data("getRowData", function(id) {
							return table.data("rowsData")[id];
						});

						';
            foreach ($this->_columns as $column) {
                $html .= $column->call_load_render_function($this);
            }
            if ($has_checkbox_column) {
                $html .= 'table.data("getCheckedRows", function(field) {
							var checkedInputs = table.find("tbody tr input.checkbox:checked");
							var rowsData = [];
							checkedInputs.each(function(index, item)
							{
								var id = $(this).val();
								var rowData = table.data("getRowData")(id);

								if(field)
								{
									rowData = rowData[field];
								}

								rowsData.push(rowData);
							});

							return rowsData;
						});';
            }
            $html .= '	})();';
            $html .= "\n\t\t\t\$(document).ready(function() {\n\t\t\t\tvar table = \$(" . JSHelper::cast_str('#' . $this->id) . ");\n\t\t\t\ttable.parent().css({'min-height': table.height()});\n\n\t\t\t\tvar selects = \$('.dataTables_length select');\n\n\t\t\t\tselects.each(function() {\n\n\t\t\t\t\tif(\$(this).children().length == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t\$(this).parents('.dataTables_length').css({'visibility': 'hidden'});\n\t\t\t\t\t}\n\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t";
            $html .= "</script>";
        }
        return $html;
    }