UtilExtension.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * hold PhpMyAdmin\Twig\UtilExtension class
  5. *
  6. * @package PhpMyAdmin\Twig
  7. */
  8. declare(strict_types=1);
  9. namespace PhpMyAdmin\Twig;
  10. use Twig\Extension\AbstractExtension;
  11. use Twig\TwigFilter;
  12. use Twig\TwigFunction;
  13. /**
  14. * Class UtilExtension
  15. *
  16. * @package PhpMyAdmin\Twig
  17. */
  18. class UtilExtension extends AbstractExtension
  19. {
  20. /**
  21. * Returns a list of functions to add to the existing list.
  22. *
  23. * @return TwigFunction[]
  24. */
  25. public function getFunctions()
  26. {
  27. return [
  28. new TwigFunction(
  29. 'backquote',
  30. 'PhpMyAdmin\Util::backquote'
  31. ),
  32. new TwigFunction(
  33. 'get_browse_upload_file_block',
  34. 'PhpMyAdmin\Util::getBrowseUploadFileBlock',
  35. ['is_safe' => ['html']]
  36. ),
  37. new TwigFunction(
  38. 'extract_column_spec',
  39. 'PhpMyAdmin\Util::extractColumnSpec'
  40. ),
  41. new TwigFunction(
  42. 'format_byte_down',
  43. 'PhpMyAdmin\Util::formatByteDown'
  44. ),
  45. new TwigFunction(
  46. 'format_number',
  47. 'PhpMyAdmin\Util::formatNumber'
  48. ),
  49. new TwigFunction(
  50. 'format_sql',
  51. 'PhpMyAdmin\Util::formatSql',
  52. ['is_safe' => ['html']]
  53. ),
  54. new TwigFunction(
  55. 'get_button_or_image',
  56. 'PhpMyAdmin\Util::getButtonOrImage',
  57. ['is_safe' => ['html']]
  58. ),
  59. new TwigFunction(
  60. 'get_docu_link',
  61. 'PhpMyAdmin\Util::getDocuLink',
  62. ['is_safe' => ['html']]
  63. ),
  64. new TwigFunction(
  65. 'get_list_navigator',
  66. 'PhpMyAdmin\Util::getListNavigator',
  67. ['is_safe' => ['html']]
  68. ),
  69. new TwigFunction(
  70. 'show_docu',
  71. 'PhpMyAdmin\Util::showDocu',
  72. ['is_safe' => ['html']]
  73. ),
  74. new TwigFunction(
  75. 'get_dropdown',
  76. 'PhpMyAdmin\Util::getDropdown',
  77. ['is_safe' => ['html']]
  78. ),
  79. new TwigFunction(
  80. 'get_fk_checkbox',
  81. 'PhpMyAdmin\Util::getFKCheckbox',
  82. ['is_safe' => ['html']]
  83. ),
  84. new TwigFunction(
  85. 'get_gis_datatypes',
  86. 'PhpMyAdmin\Util::getGISDatatypes'
  87. ),
  88. new TwigFunction(
  89. 'get_gis_functions',
  90. 'PhpMyAdmin\Util::getGISFunctions'
  91. ),
  92. new TwigFunction(
  93. 'get_html_tab',
  94. 'PhpMyAdmin\Util::getHtmlTab',
  95. ['is_safe' => ['html']]
  96. ),
  97. new TwigFunction(
  98. 'get_icon',
  99. 'PhpMyAdmin\Util::getIcon',
  100. ['is_safe' => ['html']]
  101. ),
  102. new TwigFunction(
  103. 'get_image',
  104. 'PhpMyAdmin\Util::getImage',
  105. ['is_safe' => ['html']]
  106. ),
  107. new TwigFunction(
  108. 'get_radio_fields',
  109. 'PhpMyAdmin\Util::getRadioFields',
  110. ['is_safe' => ['html']]
  111. ),
  112. new TwigFunction(
  113. 'get_select_upload_file_block',
  114. 'PhpMyAdmin\Util::getSelectUploadFileBlock',
  115. ['is_safe' => ['html']]
  116. ),
  117. new TwigFunction(
  118. 'get_script_name_for_option',
  119. 'PhpMyAdmin\Util::getScriptNameForOption',
  120. ['is_safe' => ['html']]
  121. ),
  122. new TwigFunction(
  123. 'get_start_and_number_of_rows_panel',
  124. 'PhpMyAdmin\Util::getStartAndNumberOfRowsPanel',
  125. ['is_safe' => ['html']]
  126. ),
  127. new TwigFunction(
  128. 'get_supported_datatypes',
  129. 'PhpMyAdmin\Util::getSupportedDatatypes',
  130. ['is_safe' => ['html']]
  131. ),
  132. new TwigFunction(
  133. 'is_foreign_key_supported',
  134. 'PhpMyAdmin\Util::isForeignKeySupported'
  135. ),
  136. new TwigFunction(
  137. 'link_or_button',
  138. 'PhpMyAdmin\Util::linkOrButton',
  139. ['is_safe' => ['html']]
  140. ),
  141. new TwigFunction(
  142. 'link_to_var_documentation',
  143. 'PhpMyAdmin\Util::linkToVarDocumentation',
  144. ['is_safe' => ['html']]
  145. ),
  146. new TwigFunction(
  147. 'localised_date',
  148. 'PhpMyAdmin\Util::localisedDate'
  149. ),
  150. new TwigFunction(
  151. 'show_hint',
  152. 'PhpMyAdmin\Util::showHint',
  153. ['is_safe' => ['html']]
  154. ),
  155. new TwigFunction(
  156. 'show_icons',
  157. 'PhpMyAdmin\Util::showIcons'
  158. ),
  159. new TwigFunction(
  160. 'show_mysql_docu',
  161. 'PhpMyAdmin\Util::showMySQLDocu',
  162. ['is_safe' => ['html']]
  163. ),
  164. new TwigFunction(
  165. 'get_mysql_docu_url',
  166. 'PhpMyAdmin\Util::getMySQLDocuURL',
  167. ['is_safe' => ['html']]
  168. ),
  169. new TwigFunction(
  170. 'show_php_docu',
  171. 'PhpMyAdmin\Util::showPHPDocu',
  172. ['is_safe' => ['html']]
  173. ),
  174. new TwigFunction(
  175. 'sortable_table_header',
  176. 'PhpMyAdmin\Util::sortableTableHeader',
  177. ['is_safe' => ['html']]
  178. ),
  179. new TwigFunction(
  180. 'timespan_format',
  181. 'PhpMyAdmin\Util::timespanFormat'
  182. ),
  183. new TwigFunction(
  184. 'generate_hidden_max_file_size',
  185. 'PhpMyAdmin\Util::generateHiddenMaxFileSize',
  186. ['is_safe' => ['html']]
  187. ),
  188. ];
  189. }
  190. /**
  191. * Returns a list of filters to add to the existing list.
  192. *
  193. * @return TwigFilter[]
  194. */
  195. public function getFilters()
  196. {
  197. return [
  198. new TwigFilter(
  199. 'convert_bit_default_value',
  200. 'PhpMyAdmin\Util::convertBitDefaultValue'
  201. ),
  202. new TwigFilter(
  203. 'escape_mysql_wildcards',
  204. 'PhpMyAdmin\Util::convertBitDefaultValue'
  205. ),
  206. ];
  207. }
  208. }