actions_in_table_structure.twig 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <td class="print_ignore"><ul class="table-structure-actions resizable-menu">
  2. {% if hide_structure_actions %}
  3. <li class="submenu shown">
  4. <a href="#" class="tab nowrap">{{ Util_getIcon('b_more', 'More'|trans) }}</a>
  5. <ul>
  6. {% endif %}
  7. {# Add primary #}
  8. {% include 'table/structure/action_row_in_structure_table.twig' with {
  9. 'type': type,
  10. 'tbl_storage_engine': tbl_storage_engine,
  11. 'class': 'primary nowrap',
  12. 'has_field': primary and primary.hasColumn(field_name),
  13. 'has_link_class': true,
  14. 'url_query': url_query,
  15. 'primary': primary,
  16. 'syntax': 'ADD PRIMARY KEY',
  17. 'message': 'A primary key has been added on %s.'|trans,
  18. 'action': 'Primary',
  19. 'titles': titles,
  20. 'row': row,
  21. 'is_primary': true,
  22. 'table': table
  23. } only %}
  24. {# Add unique #}
  25. {% include 'table/structure/action_row_in_structure_table.twig' with {
  26. 'type': type,
  27. 'tbl_storage_engine': tbl_storage_engine,
  28. 'class': 'add_unique unique nowrap',
  29. 'has_field': field_name in columns_with_unique_index,
  30. 'has_link_class': false,
  31. 'url_query': url_query,
  32. 'primary': primary,
  33. 'syntax': 'ADD UNIQUE',
  34. 'message': 'An index has been added on %s.'|trans,
  35. 'action': 'Unique',
  36. 'titles': titles,
  37. 'row': row,
  38. 'is_primary': false,
  39. 'table': table
  40. } only %}
  41. {# Add index #}
  42. {% include 'table/structure/action_row_in_structure_table.twig' with {
  43. 'type': type,
  44. 'tbl_storage_engine': tbl_storage_engine,
  45. 'class': 'add_index nowrap',
  46. 'has_field': false,
  47. 'has_link_class': false,
  48. 'url_query': url_query,
  49. 'primary': primary,
  50. 'syntax': 'ADD INDEX',
  51. 'message': 'An index has been added on %s.'|trans,
  52. 'action': 'Index',
  53. 'titles': titles,
  54. 'row': row,
  55. 'is_primary': false,
  56. 'table': table
  57. } only %}
  58. {# Add spatial #}
  59. {% set spatial_types = [
  60. 'geometry',
  61. 'point',
  62. 'linestring',
  63. 'polygon',
  64. 'multipoint',
  65. 'multilinestring',
  66. 'multipolygon',
  67. 'geomtrycollection'
  68. ] %}
  69. {% include 'table/structure/action_row_in_structure_table.twig' with {
  70. 'type': type,
  71. 'tbl_storage_engine': tbl_storage_engine,
  72. 'class': 'spatial nowrap',
  73. 'has_field': type not in spatial_types and
  74. (tbl_storage_engine == 'MYISAM' or mysql_int_version >= 50705),
  75. 'has_link_class': false,
  76. 'url_query': url_query,
  77. 'primary': primary,
  78. 'syntax': 'ADD SPATIAL',
  79. 'message': 'An index has been added on %s.'|trans,
  80. 'action': 'Spatial',
  81. 'titles': titles,
  82. 'row': row,
  83. 'is_primary': false,
  84. 'table': table
  85. } only %}
  86. {# FULLTEXT is possible on TEXT, CHAR and VARCHAR #}
  87. <li class="fulltext nowrap">
  88. {% if tbl_storage_engine is not empty and (
  89. tbl_storage_engine == 'MYISAM'
  90. or tbl_storage_engine == 'ARIA'
  91. or tbl_storage_engine == 'MARIA'
  92. or (tbl_storage_engine == 'INNODB' and mysql_int_version >= 50604)
  93. ) and ('text' in type or 'char' in type) %}
  94. <a rel="samepage" class="ajax add_key add_fulltext_anchor" href="tbl_structure.php"
  95. data-post="{{- url_query|raw }}&amp;add_key=1&amp;sql_query=
  96. {{- ('ALTER TABLE ' ~ Util_backquote(table)
  97. ~ ' ADD FULLTEXT(' ~ Util_backquote(row['Field'])
  98. ~ ');')|url_encode }}&amp;message_to_show=
  99. {{- ('An index has been added on %s.'|trans|format(row['Field']|e))|url_encode }}">
  100. {{ titles['IdxFulltext']|raw }}
  101. </a>
  102. {% else %}
  103. {{ titles['NoIdxFulltext']|raw }}
  104. {% endif %}
  105. </li>
  106. {# Distinct value action #}
  107. <li class="browse nowrap">
  108. <a href="sql.php" data-post="{{ url_query|raw }}&amp;sql_query=
  109. {{- ('SELECT COUNT(*) AS ' ~ Util_backquote('Rows'|trans)
  110. ~ ', ' ~ Util_backquote(row['Field'])
  111. ~ ' FROM ' ~ Util_backquote(table)
  112. ~ ' GROUP BY ' ~ Util_backquote(row['Field'])
  113. ~ ' ORDER BY ' ~ Util_backquote(row['Field']))|url_encode -}}
  114. &amp;is_browse_distinct=1">
  115. {{ titles['DistinctValues']|raw }}
  116. </a>
  117. </li>
  118. {% if central_columns_work %}
  119. <li class="browse nowrap">
  120. {% if is_in_central_columns %}
  121. <a href="#" class="central_columns remove_button">
  122. {{ Util_getIcon('centralColumns_delete', 'Remove from central columns'|trans) }}
  123. </a>
  124. {% else %}
  125. <a href="#" class="central_columns add_button">
  126. {{ Util_getIcon('centralColumns_add', 'Add to central columns'|trans) }}
  127. </a>
  128. {% endif %}
  129. </li>
  130. {% endif %}
  131. {% if hide_structure_actions %}
  132. </ul>
  133. </li>
  134. {% endif %}
  135. </ul></td>