display_structure.twig 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. edit_view_url,
  133. Util_getIcon('b_edit', 'Edit view'|trans, true)
  134. ) }}
  135. {% endif %}
  136. {% include 'table/structure/optional_action_links.twig' with {
  137. 'url_query': url_query,
  138. 'tbl_is_view': tbl_is_view,
  139. 'db_is_system_schema': db_is_system_schema,
  140. 'table': table,
  141. 'is_active': is_active
  142. } only %}
  143. </div>
  144. {% if not tbl_is_view and not db_is_system_schema %}
  145. {% include 'table/structure/add_column.twig' with {
  146. 'columns_list': columns_list,
  147. 'db': db,
  148. 'table': table
  149. } only %}
  150. {% endif %}
  151. {# Displays indexes #}
  152. {% if not tbl_is_view and not db_is_system_schema
  153. and 'ARCHIVE' != tbl_storage_engine %}
  154. {{ Index_getHtmlForDisplayIndexes() }}
  155. {% endif %}
  156. {# Display partition details #}
  157. {% if have_partitioning %}
  158. {# Detect partitioning #}
  159. {% if partition_names is not empty and partition_names[0] is not null %}
  160. {% set partitions = Partition_getPartitions(db, table) %}
  161. {% set first_partition = partitions[0] %}
  162. {% set range_or_list = first_partition.getMethod() == 'RANGE'
  163. or first_partition.getMethod() == 'RANGE COLUMNS'
  164. or first_partition.getMethod() == 'LIST'
  165. or first_partition.getMethod() == 'LIST COLUMNS' %}
  166. {% set sub_partitions = first_partition.getSubPartitions() %}
  167. {% set has_sub_partitions = first_partition.hasSubPartitions() %}
  168. {% if has_sub_partitions %}
  169. {% set first_sub_partition = sub_partitions[0] %}
  170. {% endif %}
  171. {% set action_icons = {
  172. 'ANALYZE': Util_getIcon('b_search', 'Analyze'|trans),
  173. 'CHECK': Util_getIcon('eye', 'Check'|trans),
  174. 'OPTIMIZE': Util_getIcon('normalize', 'Optimize'|trans),
  175. 'REBUILD': Util_getIcon('s_tbl', 'Rebuild'|trans),
  176. 'REPAIR': Util_getIcon('b_tblops', 'Repair'|trans),
  177. 'TRUNCATE': Util_getIcon('b_empty', 'Truncate'|trans),
  178. } %}
  179. {% if range_or_list %}
  180. {% set action_icons = action_icons|merge({'DROP': Util_getIcon('b_drop', 'Drop'|trans)}) %}
  181. {% endif %}
  182. {{ Util_getDivForSliderEffect('partitions', 'Partitions'|trans) }}
  183. {% set remove_sql = 'ALTER TABLE ' ~ Util_backquote(table) ~ ' REMOVE PARTITIONING' %}
  184. {% set remove_url = 'sql.php' ~ url_query ~ '&sql_query=' ~ remove_sql|url_encode %}
  185. {% include 'table/structure/display_partitions.twig' with {
  186. 'db': db,
  187. 'table': table,
  188. 'url_query': url_query,
  189. 'partitions': partitions,
  190. 'partition_method': first_partition.getMethod(),
  191. 'partition_expression': first_partition.getExpression(),
  192. 'has_description': first_partition.getDescription() is not empty,
  193. 'has_sub_partitions': has_sub_partitions,
  194. 'sub_partition_method': has_sub_partitions ? first_sub_partition.getMethod(),
  195. 'sub_partition_expression': has_sub_partitions ? first_sub_partition.getExpression(),
  196. 'action_icons': action_icons,
  197. 'range_or_list': range_or_list,
  198. 'remove_url': remove_url
  199. } only %}
  200. {% else %}
  201. {% include 'table/structure/display_partitions.twig' with {
  202. 'db': db,
  203. 'table': table
  204. } only %}
  205. {% endif %}
  206. {# For closing Slider effect div #}
  207. </div>
  208. {% endif %}
  209. {# Displays Space usage and row statistics #}
  210. {% if show_stats %}
  211. {{ table_stats|raw }}
  212. {% endif %}
  213. <div class="clearfloat"></div>