UtilExtension.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. declare(strict_types=1);
  3. namespace PhpMyAdmin\Twig;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFilter;
  6. use Twig\TwigFunction;
  7. class UtilExtension extends AbstractExtension
  8. {
  9. /**
  10. * Returns a list of functions to add to the existing list.
  11. *
  12. * @return TwigFunction[]
  13. */
  14. public function getFunctions()
  15. {
  16. return [
  17. new TwigFunction(
  18. 'backquote',
  19. 'PhpMyAdmin\Util::backquote'
  20. ),
  21. new TwigFunction(
  22. 'extract_column_spec',
  23. 'PhpMyAdmin\Util::extractColumnSpec'
  24. ),
  25. new TwigFunction(
  26. 'format_byte_down',
  27. 'PhpMyAdmin\Util::formatByteDown'
  28. ),
  29. new TwigFunction(
  30. 'get_formatted_maximum_upload_size',
  31. 'PhpMyAdmin\Util::getFormattedMaximumUploadSize'
  32. ),
  33. new TwigFunction(
  34. 'format_number',
  35. 'PhpMyAdmin\Util::formatNumber'
  36. ),
  37. new TwigFunction(
  38. 'format_sql',
  39. '\PhpMyAdmin\Html\Generator::formatSql',
  40. ['is_safe' => ['html']]
  41. ),
  42. new TwigFunction(
  43. 'get_docu_link',
  44. '\PhpMyAdmin\Html\MySQLDocumentation::getDocumentationLink',
  45. ['is_safe' => ['html']]
  46. ),
  47. new TwigFunction(
  48. 'get_list_navigator',
  49. '\PhpMyAdmin\Html\Generator::getListNavigator',
  50. ['is_safe' => ['html']]
  51. ),
  52. new TwigFunction(
  53. 'show_docu',
  54. '\PhpMyAdmin\Html\MySQLDocumentation::showDocumentation',
  55. ['is_safe' => ['html']]
  56. ),
  57. new TwigFunction(
  58. 'get_gis_datatypes',
  59. 'PhpMyAdmin\Util::getGISDatatypes'
  60. ),
  61. new TwigFunction(
  62. 'get_gis_functions',
  63. 'PhpMyAdmin\Util::getGISFunctions'
  64. ),
  65. new TwigFunction(
  66. 'get_icon',
  67. '\PhpMyAdmin\Html\Generator::getIcon',
  68. ['is_safe' => ['html']]
  69. ),
  70. new TwigFunction(
  71. 'get_image',
  72. '\PhpMyAdmin\Html\Generator::getImage',
  73. ['is_safe' => ['html']]
  74. ),
  75. new TwigFunction(
  76. 'get_start_and_number_of_rows_panel',
  77. 'PhpMyAdmin\Html\Generator::getStartAndNumberOfRowsPanel',
  78. ['is_safe' => ['html']]
  79. ),
  80. new TwigFunction(
  81. 'get_supported_datatypes',
  82. 'PhpMyAdmin\Util::getSupportedDatatypes',
  83. ['is_safe' => ['html']]
  84. ),
  85. new TwigFunction(
  86. 'is_foreign_key_supported',
  87. 'PhpMyAdmin\Util::isForeignKeySupported'
  88. ),
  89. new TwigFunction(
  90. 'link_or_button',
  91. 'PhpMyAdmin\Html\Generator::linkOrButton',
  92. ['is_safe' => ['html']]
  93. ),
  94. new TwigFunction(
  95. 'link_to_var_documentation',
  96. 'PhpMyAdmin\Html\Generator::linkToVarDocumentation',
  97. ['is_safe' => ['html']]
  98. ),
  99. new TwigFunction(
  100. 'localised_date',
  101. 'PhpMyAdmin\Util::localisedDate'
  102. ),
  103. new TwigFunction(
  104. 'show_hint',
  105. '\PhpMyAdmin\Html\Generator::showHint',
  106. ['is_safe' => ['html']]
  107. ),
  108. new TwigFunction(
  109. 'show_icons',
  110. 'PhpMyAdmin\Util::showIcons'
  111. ),
  112. new TwigFunction(
  113. 'show_text',
  114. 'PhpMyAdmin\Util::showText'
  115. ),
  116. new TwigFunction(
  117. 'show_mysql_docu',
  118. '\PhpMyAdmin\Html\MySQLDocumentation::show',
  119. ['is_safe' => ['html']]
  120. ),
  121. new TwigFunction(
  122. 'get_mysql_docu_url',
  123. 'PhpMyAdmin\Util::getMySQLDocuURL',
  124. ['is_safe' => ['html']]
  125. ),
  126. new TwigFunction(
  127. 'get_docu_url',
  128. 'PhpMyAdmin\Util::getdocuURL',
  129. ['is_safe' => ['html']]
  130. ),
  131. new TwigFunction(
  132. 'show_php_docu',
  133. '\PhpMyAdmin\Html\Generator::showPHPDocumentation',
  134. ['is_safe' => ['html']]
  135. ),
  136. new TwigFunction(
  137. 'sortable_table_header',
  138. 'PhpMyAdmin\Util::sortableTableHeader',
  139. ['is_safe' => ['html']]
  140. ),
  141. new TwigFunction(
  142. 'timespan_format',
  143. 'PhpMyAdmin\Util::timespanFormat'
  144. ),
  145. ];
  146. }
  147. /**
  148. * Returns a list of filters to add to the existing list.
  149. *
  150. * @return TwigFilter[]
  151. */
  152. public function getFilters()
  153. {
  154. return [
  155. new TwigFilter(
  156. 'convert_bit_default_value',
  157. 'PhpMyAdmin\Util::convertBitDefaultValue'
  158. ),
  159. new TwigFilter(
  160. 'escape_mysql_wildcards',
  161. 'PhpMyAdmin\Util::escapeMysqlWildcards'
  162. ),
  163. ];
  164. }
  165. }