display_structure.twig 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm"
  2. class="ajax{{ hide_structure_actions ? ' HideStructureActions' }}">
  3. {{ Url_getHiddenInputs(db, table) }}
  4. <input type="hidden" name="table_type" value=
  5. {%- if db_is_system_schema -%}
  6. "information_schema"
  7. {%- elseif tbl_is_view -%}
  8. "view"
  9. {%- else -%}
  10. "table"
  11. {%- endif %} />
  12. <div class="responsivetable">
  13. <table id="tablestructure" class="data topmargin">
  14. {# Table header #}
  15. {% include 'table/structure/table_structure_header.twig' with {
  16. 'db_is_system_schema': db_is_system_schema,
  17. 'tbl_is_view': tbl_is_view,
  18. 'show_column_comments': show_column_comments
  19. } only %}
  20. <tbody>
  21. {# Table body #}
  22. {% set rownum = 0 %}
  23. {% set columns_list = [] %}
  24. {% for row in fields %}
  25. {% set rownum = rownum + 1 %}
  26. {% set columns_list = columns_list|merge([row['Field']]) %}
  27. {% set field_charset = row['Collation'] %}
  28. {% set extracted_columnspec = Util_extractColumnSpec(row['Type']) %}
  29. {% set attribute = extracted_columnspec['attribute'] %}
  30. {% if strpos(row['Extra'], 'on update CURRENT_TIMESTAMP')
  31. is not same as(false) %}
  32. {% set attribute = 'on update CURRENT_TIMESTAMP' %}
  33. {% endif %}
  34. {% if row['Default'] is null %}
  35. {% if row['Null'] == 'YES' %}
  36. {% set row = row|merge({'Default': '<em>NULL</em>'}) %}
  37. {% endif %}
  38. {% else %}
  39. {% set row = row|merge({'Default': row['Default']|e}) %}
  40. {% endif %}
  41. {% set field_name = row['Field']|e %}
  42. {% set displayed_field_name = field_name %}
  43. {# For column comments #}
  44. {% set comments = '' %}
  45. {# Underline commented fields and display a hover-title (CSS only) #}
  46. {% if comments_map[row['Field']] is defined %}
  47. {% set displayed_field_name -%}
  48. <span class="commented_column" title="
  49. {{- comments_map[row['Field']] }}">
  50. {{- field_name|raw -}}
  51. </span>
  52. {%- endset %}
  53. {% set comments = comments_map[row['Field']] %}
  54. {% endif %}
  55. {% if primary and primary.hasColumn(field_name) %}
  56. {% set displayed_field_name = displayed_field_name ~ Util_getImage(
  57. 'b_primary', 'Primary'|trans
  58. ) %}
  59. {% endif %}
  60. {% if field_name in columns_with_index %}
  61. {% set displayed_field_name = displayed_field_name ~ Util_getImage(
  62. 'bd_primary', 'Index'|trans
  63. ) %}
  64. {% endif %}
  65. <tr>
  66. {% include 'table/structure/table_structure_row.twig' with {
  67. 'row': row,
  68. 'rownum': rownum,
  69. 'displayed_field_name': preg_replace(
  70. '/[\\x00-\\x1F]/',
  71. '&#x2051;',
  72. displayed_field_name
  73. ),
  74. 'type_nowrap': Util_getClassForType(extracted_columnspec['type']),
  75. 'extracted_columnspec': extracted_columnspec,
  76. 'attribute': attribute,
  77. 'tbl_is_view': tbl_is_view,
  78. 'db_is_system_schema': db_is_system_schema,
  79. 'url_query': url_query,
  80. 'titles': titles,
  81. 'table': table,
  82. 'tbl_storage_engine': tbl_storage_engine,
  83. 'field_charset': field_charset,
  84. 'comments': comments,
  85. 'show_column_comments': show_column_comments,
  86. 'relation_commwork': relation_commwork,
  87. 'relation_mimework': relation_mimework,
  88. 'browse_mime': browse_mime
  89. } only %}
  90. {% if not tbl_is_view and not db_is_system_schema %}
  91. {% include 'table/structure/actions_in_table_structure.twig' with {
  92. 'row': row,
  93. 'rownum': rownum,
  94. 'extracted_columnspec': extracted_columnspec,
  95. 'type': extracted_columnspec['print_type'] is not empty ? extracted_columnspec['print_type'],
  96. 'tbl_storage_engine': tbl_storage_engine,
  97. 'primary': primary,
  98. 'field_name': field_name,
  99. 'url_query': url_query,
  100. 'titles': titles,
  101. 'columns_with_unique_index': columns_with_unique_index,
  102. 'is_in_central_columns': row['Field'] in central_list ? true : false,
  103. 'central_columns_work': central_columns_work,
  104. 'table': table,
  105. 'hide_structure_actions': hide_structure_actions,
  106. 'mysql_int_version': mysql_int_version
  107. } only %}
  108. {% endif %}
  109. </tr>
  110. {% endfor %}
  111. </tbody>
  112. </table>
  113. </div>
  114. {% include 'table/structure/check_all_table_column.twig' with {
  115. 'pma_theme_image': pma_theme_image,
  116. 'text_dir': text_dir,
  117. 'tbl_is_view': tbl_is_view,
  118. 'db_is_system_schema': db_is_system_schema,
  119. 'tbl_storage_engine': tbl_storage_engine,
  120. 'central_columns_work': central_columns_work
  121. } only %}
  122. </form>
  123. <hr class="print_ignore"/>
  124. {% include 'table/structure/move_columns_dialog.twig' with {
  125. 'db': db,
  126. 'table': table
  127. } only %}
  128. {# Work on the table #}
  129. <div id="structure-action-links">
  130. {% if tbl_is_view and not db_is_system_schema %}
  131. {{ Util_linkOrButton(
  132. 'view_create.php',
  133. {'db': db, 'table': table},
  134. Util_getIcon('b_edit', 'Edit view'|trans, true)
  135. ) }}
  136. {% endif %}
  137. {% include 'table/structure/optional_action_links.twig' with {
  138. 'url_query': url_query,
  139. 'tbl_is_view': tbl_is_view,
  140. 'db_is_system_schema': db_is_system_schema,
  141. 'table': table,
  142. 'is_active': is_active,
  143. 'mysql_int_version': mysql_int_version,
  144. 'is_mariadb': is_mariadb
  145. } only %}
  146. </div>
  147. {% if not tbl_is_view and not db_is_system_schema %}
  148. {% include 'table/structure/add_column.twig' with {
  149. 'columns_list': columns_list,
  150. 'db': db,
  151. 'table': table
  152. } only %}
  153. {% endif %}
  154. {# Displays indexes #}
  155. {% if not tbl_is_view and not db_is_system_schema
  156. and 'ARCHIVE' != tbl_storage_engine %}
  157. {{ Index_getHtmlForDisplayIndexes() }}
  158. {% endif %}
  159. {# Display partition details #}
  160. {% if have_partitioning %}
  161. {# Detect partitioning #}
  162. {% if partition_names is not empty and partition_names[0] is not null %}
  163. {% set partitions = Partition_getPartitions(db, table) %}
  164. {% set first_partition = partitions[0] %}
  165. {% set range_or_list = first_partition.getMethod() == 'RANGE'
  166. or first_partition.getMethod() == 'RANGE COLUMNS'
  167. or first_partition.getMethod() == 'LIST'
  168. or first_partition.getMethod() == 'LIST COLUMNS' %}
  169. {% set sub_partitions = first_partition.getSubPartitions() %}
  170. {% set has_sub_partitions = first_partition.hasSubPartitions() %}
  171. {% if has_sub_partitions %}
  172. {% set first_sub_partition = sub_partitions[0] %}
  173. {% endif %}
  174. {% set action_icons = {
  175. 'ANALYZE': Util_getIcon('b_search', 'Analyze'|trans),
  176. 'CHECK': Util_getIcon('eye', 'Check'|trans),
  177. 'OPTIMIZE': Util_getIcon('normalize', 'Optimize'|trans),
  178. 'REBUILD': Util_getIcon('s_tbl', 'Rebuild'|trans),
  179. 'REPAIR': Util_getIcon('b_tblops', 'Repair'|trans),
  180. 'TRUNCATE': Util_getIcon('b_empty', 'Truncate'|trans),
  181. } %}
  182. {% if range_or_list %}
  183. {% set action_icons = action_icons|merge({'DROP': Util_getIcon('b_drop', 'Drop'|trans)}) %}
  184. {% endif %}
  185. {{ Util_getDivForSliderEffect('partitions', 'Partitions'|trans) }}
  186. {% set remove_sql = 'ALTER TABLE ' ~ Util_backquote(table) ~ ' REMOVE PARTITIONING' %}
  187. {% include 'table/structure/display_partitions.twig' with {
  188. 'db': db,
  189. 'table': table,
  190. 'url_query': url_query,
  191. 'partitions': partitions,
  192. 'partition_method': first_partition.getMethod(),
  193. 'partition_expression': first_partition.getExpression(),
  194. 'has_description': first_partition.getDescription() is not empty,
  195. 'has_sub_partitions': has_sub_partitions,
  196. 'sub_partition_method': has_sub_partitions ? first_sub_partition.getMethod(),
  197. 'sub_partition_expression': has_sub_partitions ? first_sub_partition.getExpression(),
  198. 'action_icons': action_icons,
  199. 'range_or_list': range_or_list,
  200. 'remove_url_params': url_params|merge({'sql_query': remove_sql})
  201. } only %}
  202. {% else %}
  203. {% include 'table/structure/display_partitions.twig' with {
  204. 'db': db,
  205. 'table': table
  206. } only %}
  207. {% endif %}
  208. {# For closing Slider effect div #}
  209. </div>
  210. {% endif %}
  211. {# Displays Space usage and row statistics #}
  212. {% if show_stats %}
  213. {{ table_stats|raw }}
  214. {% endif %}
  215. <div class="clearfloat"></div>