display_git_revision.lib.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Displays form for password change
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Prints details about the current Git commit revision
  13. *
  14. * @return void
  15. */
  16. function PMA_printGitRevision()
  17. {
  18. if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
  19. $response = PMA_Response::getInstance();
  20. $response->isSuccess(false);
  21. return;
  22. }
  23. // load revision data from repo
  24. $GLOBALS['PMA_Config']->checkGitRevision();
  25. // if using a remote commit fast-forwarded, link to Github
  26. $commit_hash = substr(
  27. $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
  28. 0,
  29. 7
  30. );
  31. $commit_hash = '<strong title="'
  32. . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE'))
  33. . '">' . $commit_hash . '</strong>';
  34. if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
  35. $commit_hash = '<a href="'
  36. . PMA_linkURL(
  37. 'https://github.com/phpmyadmin/phpmyadmin/commit/'
  38. . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')
  39. )
  40. . '" rel="noopener noreferrer" target="_blank">' . $commit_hash . '</a>';
  41. }
  42. $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
  43. if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
  44. $branch = '<a href="'
  45. . PMA_linkURL(
  46. 'https://github.com/phpmyadmin/phpmyadmin/tree/'
  47. . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')
  48. )
  49. . '" rel="noopener noreferrer" target="_blank">' . $branch . '</a>';
  50. }
  51. if ($branch !== false) {
  52. $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
  53. } else {
  54. $branch = $commit_hash . ' (' . __('no branch') . ')';
  55. }
  56. $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
  57. $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
  58. PMA_printListItem(
  59. __('Git revision') . ': '
  60. . $branch . ',<br /> '
  61. . sprintf(
  62. __('committed on %1$s by %2$s'),
  63. PMA_Util::localisedDate(strtotime($committer['date'])),
  64. '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">'
  65. . htmlspecialchars($committer['name']) . '</a>'
  66. )
  67. . ($author != $committer
  68. ? ', <br />'
  69. . sprintf(
  70. __('authored on %1$s by %2$s'),
  71. PMA_Util::localisedDate(strtotime($author['date'])),
  72. '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">'
  73. . htmlspecialchars($author['name']) . '</a>'
  74. )
  75. : ''),
  76. 'li_pma_version_git', null, null, null
  77. );
  78. }