diff options
Diffstat (limited to 'srcs/phpmyadmin/templates/table/search')
10 files changed, 620 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/templates/table/search/column_comparison_operators.twig b/srcs/phpmyadmin/templates/table/search/column_comparison_operators.twig new file mode 100644 index 0000000..b72e530 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/column_comparison_operators.twig @@ -0,0 +1,3 @@ +<select id="ColumnOperator{{ search_index }}" name="criteriaColumnOperators[{{ search_index }}]"> + {{ type_operators|raw }} +</select> diff --git a/srcs/phpmyadmin/templates/table/search/fields_table.twig b/srcs/phpmyadmin/templates/table/search/fields_table.twig new file mode 100644 index 0000000..8b74939 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/fields_table.twig @@ -0,0 +1,33 @@ +<table class="data"{{ search_type == 'zoom' ? ' id="tableFieldsId"' }}> + <thead> + <tr> + {% if geom_column_flag %} + <th>{% trans 'Function' %}</th> + {% endif %} + <th>{% trans 'Column' %}</th> + <th>{% trans 'Type' %}</th> + <th>{% trans 'Collation' %}</th> + <th>{% trans 'Operator' %}</th> + <th>{% trans 'Value' %}</th> + </tr> + </thead> + <tbody> + {% if search_type == 'zoom' %} + {% include 'table/search/rows_zoom.twig' with { + 'self': self, + 'column_names': column_names, + 'keys': keys, + 'criteria_column_names': criteria_column_names, + 'criteria_column_types': criteria_column_types + } only %} + {% else %} + {% include 'table/search/rows_normal.twig' with { + 'self': self, + 'geom_column_flag': geom_column_flag, + 'column_names': column_names, + 'column_types': column_types, + 'column_collations': column_collations + } only %} + {% endif %} + </tbody> +</table> diff --git a/srcs/phpmyadmin/templates/table/search/form_tag.twig b/srcs/phpmyadmin/templates/table/search/form_tag.twig new file mode 100644 index 0000000..1017abd --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/form_tag.twig @@ -0,0 +1,4 @@ +<form method="post" action="{{ script_name }}" name="insertForm" id="{{ form_id }}" class="ajax lock-page"> + {{ get_hidden_inputs(db, table) }} + <input type="hidden" name="goto" value="{{ goto }}"> + <input type="hidden" name="back" value="{{ script_name }}"> diff --git a/srcs/phpmyadmin/templates/table/search/geom_func.twig b/srcs/phpmyadmin/templates/table/search/geom_func.twig new file mode 100644 index 0000000..f7a7415 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/geom_func.twig @@ -0,0 +1,19 @@ +{# Displays 'Function' column if it is present #} +<td> + {% set geom_types = get_gis_datatypes() %} + {% if column_types[column_index] in geom_types %} + <select class="geom_func" name="geom_func[{{ column_index }}]"> + {# get the relevant list of GIS functions #} + {% set funcs = get_gis_functions(column_types[column_index], true, true) %} + + {% for func_name, func in funcs %} + {% set name = func['display'] is defined ? func['display'] : func_name %} + <option value="{{ name }}"> + {{ name }} + </option> + {% endfor %} + </select> + {% else %} + + {% endif %} +</td> diff --git a/srcs/phpmyadmin/templates/table/search/input_box.twig b/srcs/phpmyadmin/templates/table/search/input_box.twig new file mode 100644 index 0000000..5c30535 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/input_box.twig @@ -0,0 +1,97 @@ +{# Get inputbox based on different column types (Foreign key, geometrical, enum) #} +{% if foreigners and search_column_in_foreigners(foreigners, column_name) %} + {% if foreign_data['disp_row'] is iterable %} + <select name="criteriaValues[{{ column_index }}]" + id="{{ column_id }}{{ column_index }}"> + {{ foreign_dropdown( + foreign_data['disp_row'], + foreign_data['foreign_field'], + foreign_data['foreign_display'], + '', + foreign_max_limit + ) }} + </select> + {% elseif foreign_data['foreign_link'] == true %} + <input type="text" + id="{{ column_id }}{{ column_index }}" + name="criteriaValues[{{ column_index }}]" + id="field_{{ column_name_hash }}[{{ column_index }}]" + class="textfield" + {% if criteria_values[column_index] is defined %} + value="{{ criteria_values[column_index] }}" + {% endif %}> + <a class="ajax browse_foreign" href="browse_foreigners.php" data-post=" + {{- get_common({'db': db, 'table': table}, '') -}} + &field={{ column_name|url_encode }}&fieldkey= + {{- column_index }}&fromsearch=1"> + {{ titles['Browse']|replace({"'": "\\'"})|raw }} + </a> + {% endif %} +{% elseif column_type in get_gis_datatypes() %} + <input type="text" + name="criteriaValues[{{ column_index }}]" + size="40" + class="textfield" + id="field_{{ column_index }}"> + {% if in_fbs %} + {% set edit_url = 'gis_data_editor.php' ~ get_common() %} + {% set edit_str = get_icon('b_edit', 'Edit/Insert'|trans) %} + <span class="open_search_gis_editor"> + {{ link_or_button(edit_url, edit_str, [], '_blank') }} + </span> + {% endif %} +{% elseif column_type starts with 'enum' + or (column_type starts with 'set' and in_zoom_search_edit) %} + {% set in_zoom_search_edit = false %} + {% set value = column_type|e|slice(5, -1)|replace({''': ''})|split(', ') %} + {% set cnt_value = value|length %} + {# + Enum in edit mode --> dropdown + Enum in search mode --> multiselect + Set in edit mode --> multiselect + Set in search mode --> input (skipped here, so the 'else' section would handle it) + #} + {% if (column_type starts with 'enum' and not in_zoom_search_edit) + or (column_type starts with 'set' and in_zoom_search_edit) %} + <select name="criteriaValues[{{ column_index }}]" + id="{{ column_id }}{{ column_index }}"> + {% else %} + <select name="criteriaValues[{{ column_index }}]" + id="{{ column_id }}{{ column_index }}" + multiple="multiple" + size="{{ min(3, cnt_value) }}"> + {% endif %} + {# Add select options #} + <option value=""></option> + {% for i in 0..cnt_value - 1 %} + {% if criteria_values[column_index] is defined + and criteria_values[column_index] is iterable + and value[i] in criteria_values[column_index] %} + <option value="{{ value[i]|raw }}" selected> + {{ value[i]|raw }} + </option> + {% else %} + <option value="{{ value[i]|raw }}"> + {{ value[i]|raw }} + </option> + {% endif %} + {% endfor %} + </select> +{% else %} + {% set the_class = 'textfield' %} + {% if column_type == 'date' %} + {% set the_class = the_class ~ ' datefield' %} + {% elseif column_type == 'datetime' or column_type starts with 'timestamp' %} + {% set the_class = the_class ~ ' datetimefield' %} + {% elseif column_type starts with 'bit' %} + {% set the_class = the_class ~ ' bit' %} + {% endif %} + <input type="text" + name="criteriaValues[{{ column_index }}]" + size="40" + class="{{ the_class }}" + id="{{ column_id }}{{ column_index }}" + {% if criteria_values[column_index] is defined %} + value="{{ criteria_values[column_index] }}" + {%- endif %}> +{% endif %} diff --git a/srcs/phpmyadmin/templates/table/search/replace_preview.twig b/srcs/phpmyadmin/templates/table/search/replace_preview.twig new file mode 100644 index 0000000..e7a2423 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/replace_preview.twig @@ -0,0 +1,39 @@ +<form method="post" + action="tbl_find_replace.php" + name="previewForm" + id="previewForm"> + {{ get_hidden_inputs(db, table) }} + <input type="hidden" name="replace" value="true"> + <input type="hidden" name="columnIndex" value="{{ column_index }}"> + <input type="hidden" name="findString" value="{{ find }}"> + <input type="hidden" name="replaceWith" value="{{ replace_with }}"> + <input type="hidden" name="useRegex" value="{{ use_regex }}"> + + <fieldset id="fieldset_find_replace_preview"> + <legend>{% trans 'Find and replace - preview' %}</legend> + <table id="previewTable"> + <thead> + <tr> + <th>{% trans 'Count' %}</th> + <th>{% trans 'Original string' %}</th> + <th>{% trans 'Replaced string' %}</th> + </tr> + </thead> + <tbody> + {% if result is iterable %} + {% for row in result %} + <tr> + <td class="right">{{ row[2] }}</td>{# count #} + <td>{{ row[0] }}</td>{# original #} + <td>{{ row[1] }}</td>{# replaced #} + </tr> + {% endfor %} + {% endif %} + </tbody> + </table> + </fieldset> + + <fieldset class="tblFooters"> + <input class="btn btn-secondary" type="submit" name="replace" value="{% trans 'Replace' %}"> + </fieldset> +</form> diff --git a/srcs/phpmyadmin/templates/table/search/rows_normal.twig b/srcs/phpmyadmin/templates/table/search/rows_normal.twig new file mode 100644 index 0000000..5e21efa --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/rows_normal.twig @@ -0,0 +1,39 @@ +{% for column_index in 0..column_names|length - 1 %} + <tr class="noclick"> + {# If 'Function' column is present trying to change comment #} + {% if geom_column_flag %} + {% include 'table/search/geom_func.twig' with { + 'column_index': column_index, + 'column_types': column_types + } only %} + {% endif %} + {# Displays column's name, type, collation and value #} + <th> + {{ column_names[column_index] }} + </th> + {% set properties = self.getColumnProperties(column_index, column_index) %} + <td dir="ltr"> + {{ properties['type'] }} + </td> + <td> + {{ properties['collation'] }} + </td> + <td> + {{ properties['func']|raw }} + </td> + {# here, the data-type attribute is needed for a date/time picker #} + <td data-type="{{ properties['type'] }}"> + {{ properties['value']|raw }} + {# Displays hidden fields #} + <input type="hidden" + name="criteriaColumnNames[{{ column_index }}]" + value="{{ column_names[column_index] }}"> + <input type="hidden" + name="criteriaColumnTypes[{{ column_index }}]" + value="{{ column_types[column_index] }}"> + <input type="hidden" + name="criteriaColumnCollations[{{ column_index }}]" + value="{{ column_collations[column_index] }}"> + </td> + </tr> +{% endfor %} diff --git a/srcs/phpmyadmin/templates/table/search/rows_zoom.twig b/srcs/phpmyadmin/templates/table/search/rows_zoom.twig new file mode 100644 index 0000000..dc46f1d --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/rows_zoom.twig @@ -0,0 +1,74 @@ +{# Get already set search criteria (if any) #} +{% set type = [] %} +{% set collation = [] %} +{% set func = [] %} +{% set value = [] %} + +{% for i in 0..3 %} + {# After X-Axis and Y-Axis column rows, display additional criteria option #} + {% if i == 2 %} + <tr> + <td> + {% trans 'Additional search criteria' %} + </td> + </tr> + {% endif %} + <tr class="noclick"> + <th> + <select name="criteriaColumnNames[]" id="tableid_{{ i }}" > + <option value="pma_null"> + {% trans 'None' %} + </option> + {% for j in 0..column_names|length - 1 %} + {% if criteria_column_names[i] is defined + and criteria_column_names[i] == column_names[j] %} + <option value="{{ column_names[j] }}" selected="selected"> + {{ column_names[j] }} + </option> + {% else %} + <option value="{{ column_names[j] }}"> + {{ column_names[j] }} + </option> + {% endif %} + {% endfor %} + </select> + </th> + {% if criteria_column_names[i] is defined + and criteria_column_names[i] != 'pma_null' %} + {% set key = keys[criteria_column_names[i]] %} + {% set properties = self.getColumnProperties(i, key) %} + {% set type = type|merge({i: properties['type']}) %} + {% set collation = collation|merge({i: properties['collation']}) %} + {% set func = func|merge({i: properties['func']}) %} + {% set value = value|merge({i: properties['value']}) %} + {% endif %} + {# Column type #} + <td dir="ltr"> + {{ type[i] is defined ? type[i] }} + </td> + {# Column Collation #} + <td> + {{ collation[i] is defined ? collation[i] }} + </td> + {# Select options for column operators #} + <td> + {{ func[i] is defined ? func[i]|raw }} + </td> + {# Inputbox for search criteria value #} + <td> + </td> + <td> + {{ value[i] is defined ? value[i]|raw }} + {# Displays hidden fields #} + <input type="hidden" + name="criteriaColumnTypes[{{ i }}]" + id="types_{{ i }}" + {%- if criteria_column_types[i] is defined %} + value="{{ criteria_column_types[i] }}" + {%- endif %}> + <input type="hidden" + name="criteriaColumnCollations[{{ i }}]" + id="collations_{{ i }}"> + </td> + </tr> +{% endfor %} diff --git a/srcs/phpmyadmin/templates/table/search/selection_form.twig b/srcs/phpmyadmin/templates/table/search/selection_form.twig new file mode 100644 index 0000000..2ba4d60 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/selection_form.twig @@ -0,0 +1,226 @@ +{% if search_type == 'zoom' %} + {% include 'table/search/form_tag.twig' with { + 'script_name': 'tbl_zoom_select.php', + 'form_id': 'zoom_search_form', + 'db': db, + 'table': table, + 'goto': goto + } only %} + <fieldset id="fieldset_zoom_search"> + <fieldset id="inputSection"> + <legend> + {% trans 'Do a "query by example" (wildcard: "%") for two different columns' %} + </legend> + {% include 'table/search/fields_table.twig' with { + 'self': self, + 'search_type': search_type, + 'geom_column_flag': geom_column_flag, + 'column_names': column_names, + 'column_types': column_types, + 'column_collations': column_collations, + 'keys' : keys, + 'criteria_column_names': criteria_column_names, + 'criteria_column_types': criteria_column_types + } only %}<table class="data"> + {# Select options for data label #} + <tr> + <td> + <label for="dataLabel"> + {% trans 'Use this column to label each point' %} + </label> + </td> + <td> + <select name="dataLabel" id="dataLabel" > + <option value = ""> + {% trans 'None' %} + </option> + {% for i in 0..column_names|length - 1 %} + {% if data_label is defined and data_label == column_names[i]|e %} + <option value="{{ column_names[i] }}" selected="selected"> + {{ column_names[i] }} + </option> + {% else %} + <option value="{{ column_names[i] }}" > + {{ column_names[i] }} + </option> + {% endif %} + {% endfor %} + </select> + </td> + </tr> + {# Inputbox for changing default maximum rows to plot #} + <tr> + <td> + <label for="maxRowPlotLimit"> + {% trans 'Maximum rows to plot' %} + </label> + </td> + <td> + <input type="number" + name="maxPlotLimit" + id="maxRowPlotLimit" + required="required" + value="{{ max_plot_limit }}"> + </td> + </tr> + </table> + </fieldset> + </fieldset> +{% elseif search_type == 'normal' %} + {% include 'table/search/form_tag.twig' with { + 'script_name': 'tbl_select.php', + 'form_id': 'tbl_search_form', + 'db': db, + 'table': table, + 'goto': goto + } only %} + <fieldset id="fieldset_table_search"> + <fieldset id="fieldset_table_qbe"> + <legend> + {% trans 'Do a "query by example" (wildcard: "%")' %} + </legend> + <div class="responsivetable jsresponsive"> + {% include 'table/search/fields_table.twig' with { + 'self': self, + 'search_type': search_type, + 'geom_column_flag': geom_column_flag, + 'column_names': column_names, + 'column_types': column_types, + 'column_collations': column_collations, + 'criteria_column_names': criteria_column_names, + 'criteria_column_types': criteria_column_types + } only %} + </div> + <div id="gis_editor"></div> + <div id="popup_background"></div> + </fieldset> + {% include 'div_for_slider_effect.twig' with { + 'id': 'searchoptions', + 'message': 'Options'|trans, + 'initial_sliders_state': default_sliders_state + } only %} + + {# Displays columns select list for selecting distinct columns in the search #} + <fieldset id="fieldset_select_fields"> + <legend> + {% trans 'Select columns (at least one):' %} + </legend> + <select name="columnsToDisplay[]" + size="{{ min(column_names|length, 10) }}" + multiple="multiple"> + {% for each_field in column_names %} + <option value="{{ each_field }}" + selected="selected"> + {{ each_field }} + </option> + {% endfor %} + </select> + <input type="checkbox" name="distinct" value="DISTINCT" id="oDistinct"> + <label for="oDistinct">DISTINCT</label> + </fieldset> + + {# Displays input box for custom 'Where' clause to be used in the search #} + <fieldset id="fieldset_search_conditions"> + <legend> + <em>{% trans 'Or' %}</em> + {% trans 'Add search conditions (body of the "where" clause):' %} + </legend> + {{ show_mysql_docu('Functions') }} + <input type="text" name="customWhereClause" class="textfield" size="64"> + </fieldset> + + {# Displays option of changing default number of rows displayed per page #} + <fieldset id="fieldset_limit_rows"> + <legend>{% trans 'Number of rows per page' %}</legend> + <input type="number" + name="session_max_rows" + required="required" + min="1" + value="{{ max_rows }}" + class="textfield"> + </fieldset> + + {# Displays option for ordering search results by a column value (Asc or Desc) #} + <fieldset id="fieldset_display_order"> + <legend>{% trans 'Display order:' %}</legend> + <select name="orderByColumn"><option value="--nil--"></option> + {% for each_field in column_names %} + <option value="{{ each_field }}"> + {{ each_field }} + </option> + {% endfor %} + </select> + + {{ get_radio_fields( + 'order', + { + 'ASC': 'Ascending'|trans, + 'DESC': 'Descending'|trans + }, + 'ASC', + false, + true, + 'formelement' + ) }} + + </fieldset> + <div class="clearfloat"></div> + </fieldset> +{% elseif search_type == 'replace' %} + {% include 'table/search/form_tag.twig' with { + 'script_name': 'tbl_find_replace.php', + 'form_id': 'find_replace_form', + 'db': db, + 'table': table, + 'goto': goto + } only %} + <fieldset id="fieldset_find_replace"> + <fieldset id="fieldset_find"> + <legend> + {% trans 'Find and replace' %} + </legend>{% trans 'Find:' %} + <input type="text" value="" name="find" required> + {% trans 'Replace with:' %} + <input type="text" value="" name="replaceWith"> + + {% trans 'Column:' %} + <select name="columnIndex"> + {% for i in 0..column_names|length - 1 %} + {% set type = types[column_names[i]] %} + + {% if sql_types.getTypeClass(type) == 'CHAR' %} + <option value="{{ i }}"> + {{- column_names[i] -}} + </option> + {% endif %} + {% endfor %} + </select> + + {% include 'checkbox.twig' with { + 'html_field_id': 'useRegex', + 'html_field_name': 'useRegex', + 'label': 'Use regular expression'|trans, + 'checked': false, + 'onclick': false + } only %} + </fieldset> + </fieldset> +{% else %} + {% include 'table/search/form_tag.twig' with { + 'script_name': '', + 'form_id': '', + 'db': db, + 'table': table, + 'goto': goto + } only %} +{% endif %} + +{# Displays selection form's footer elements #} + <fieldset class="tblFooters"> + <input class="btn btn-primary" type="submit" + name="{{ search_type == 'zoom' ? 'zoom_submit' : 'submit' }}" + {{ search_type == 'zoom' ? 'id="inputFormSubmitId"' }} + value="{% trans 'Go' %}"> + </fieldset> +</form> +<div id="sqlqueryresultsouter"></div> diff --git a/srcs/phpmyadmin/templates/table/search/zoom_result_form.twig b/srcs/phpmyadmin/templates/table/search/zoom_result_form.twig new file mode 100644 index 0000000..7543f85 --- /dev/null +++ b/srcs/phpmyadmin/templates/table/search/zoom_result_form.twig @@ -0,0 +1,86 @@ +<form method="post" action="tbl_zoom_select.php" name="displayResultForm" id="zoom_display_form" class="ajax"> + {{ get_hidden_inputs(db, table) }} + <input type="hidden" name="goto" value="{{ goto }}"> + <input type="hidden" name="back" value="tbl_zoom_select.php"> + + <fieldset id="displaySection"> + <legend>{% trans 'Browse/Edit the points' %}</legend> + + {# JSON encode the data(query result) #} + <center> + {% if zoom_submit and data is not empty %} + <div id="resizer"> + <center> + <a id="help_dialog" href="#"> + {% trans 'How to use' %} + </a> + </center> + <div id="querydata" class="hide"> + {{ data_json }} + </div> + <div id="querychart"></div> + <button class="button-reset"> + {% trans 'Reset zoom' %} + </button> + </div> + {% endif %} + </center> + + {# Displays rows in point edit form #} + <div id="dataDisplay" class="hide"> + <table> + <thead> + <tr> + <th>{% trans 'Column' %}</th> + <th>{% trans 'Null' %}</th> + <th>{% trans 'Value' %}</th> + </tr> + </thead> + <tbody> + {% for column_index in 0..column_names|length - 1 %} + {% set field_popup = column_names[column_index] %} + {% set foreign_data = get_foreign_data( + foreigners, + field_popup, + false, + '', + '' + ) %} + <tr class="noclick"> + <th>{{ column_names[column_index] }}</th> + {# Null checkbox if column can be null #} + <th> + {% if column_null_flags[column_index] == 'YES' %} + <input type="checkbox" class="checkbox_null" + name="criteriaColumnNullFlags[{{ column_index }}]" + id="edit_fields_null_id_{{ column_index }}"> + {% endif %} + </th> + {# Column's Input box #} + <th> + {% include 'table/search/input_box.twig' with { + 'str': '', + 'column_type': column_types[column_index], + 'column_id': column_types[column_index] ? 'edit_fieldID_' : 'fieldID_', + 'in_zoom_search_edit': true, + 'foreigners': foreigners, + 'column_name': field_popup, + 'column_name_hash': column_name_hashes[field_popup], + 'foreign_data': foreign_data, + 'table': table, + 'column_index': column_index, + 'foreign_max_limit': foreign_max_limit, + 'criteria_values': '', + 'db': db, + 'titles': titles, + 'in_fbs': false + } only %} + </th> + </tr> + {% endfor %} + </tbody> + </table> + </div> + <input type="hidden" id="queryID" name="sql_query"> + </fieldset> +</form> |
